@theia/core 1.19.0 → 1.20.0

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 (130) hide show
  1. package/lib/browser/color-registry.d.ts +3 -69
  2. package/lib/browser/color-registry.d.ts.map +1 -1
  3. package/lib/browser/color-registry.js +13 -27
  4. package/lib/browser/color-registry.js.map +1 -1
  5. package/lib/browser/common-frontend-contribution.d.ts +3 -3
  6. package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
  7. package/lib/browser/common-frontend-contribution.js +64 -64
  8. package/lib/browser/common-frontend-contribution.js.map +1 -1
  9. package/lib/browser/core-preferences.d.ts.map +1 -1
  10. package/lib/browser/core-preferences.js +23 -20
  11. package/lib/browser/core-preferences.js.map +1 -1
  12. package/lib/browser/dialogs.d.ts.map +1 -1
  13. package/lib/browser/dialogs.js +4 -4
  14. package/lib/browser/dialogs.js.map +1 -1
  15. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js +2 -2
  16. package/lib/browser/keyboard/browser-keyboard-frontend-contribution.js.map +1 -1
  17. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts +1 -1
  18. package/lib/browser/keyboard/browser-keyboard-layout-provider.d.ts.map +1 -1
  19. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js +6 -4
  20. package/lib/browser/keyboard/browser-keyboard-layout-provider.spec.js.map +1 -1
  21. package/lib/browser/keyboard/keys.d.ts +2 -251
  22. package/lib/browser/keyboard/keys.d.ts.map +1 -1
  23. package/lib/browser/keyboard/keys.js +12 -614
  24. package/lib/browser/keyboard/keys.js.map +1 -1
  25. package/lib/browser/messaging/ws-connection-provider.d.ts +3 -3
  26. package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
  27. package/lib/browser/messaging/ws-connection-provider.js +14 -4
  28. package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
  29. package/lib/browser/quick-input/quick-command-frontend-contribution.js +1 -1
  30. package/lib/browser/quick-input/quick-command-frontend-contribution.js.map +1 -1
  31. package/lib/browser/quick-input/quick-command-service.d.ts.map +1 -1
  32. package/lib/browser/quick-input/quick-command-service.js +2 -2
  33. package/lib/browser/quick-input/quick-command-service.js.map +1 -1
  34. package/lib/browser/quick-input/quick-input-service.d.ts +1 -201
  35. package/lib/browser/quick-input/quick-input-service.d.ts.map +1 -1
  36. package/lib/browser/quick-input/quick-input-service.js +11 -93
  37. package/lib/browser/quick-input/quick-input-service.js.map +1 -1
  38. package/lib/browser/shell/tab-bar-toolbar.js +1 -1
  39. package/lib/browser/shell/tab-bar-toolbar.js.map +1 -1
  40. package/lib/browser/storage-service.spec.js +1 -1
  41. package/lib/browser/storage-service.spec.js.map +1 -1
  42. package/lib/browser/theming.d.ts +5 -14
  43. package/lib/browser/theming.d.ts.map +1 -1
  44. package/lib/browser/theming.js +14 -0
  45. package/lib/browser/theming.js.map +1 -1
  46. package/lib/browser/window/default-window-service.js +1 -1
  47. package/lib/browser/window/default-window-service.js.map +1 -1
  48. package/lib/browser/window-contribution.d.ts.map +1 -1
  49. package/lib/browser/window-contribution.js +2 -2
  50. package/lib/browser/window-contribution.js.map +1 -1
  51. package/lib/common/color.d.ts +84 -0
  52. package/lib/common/color.d.ts.map +1 -0
  53. package/lib/common/color.js +44 -0
  54. package/lib/common/color.js.map +1 -0
  55. package/lib/common/command.d.ts +1 -0
  56. package/lib/common/command.d.ts.map +1 -1
  57. package/lib/common/command.js +4 -0
  58. package/lib/common/command.js.map +1 -1
  59. package/lib/common/i18n/localization.d.ts +9 -0
  60. package/lib/common/i18n/localization.d.ts.map +1 -1
  61. package/lib/common/i18n/localization.js +13 -2
  62. package/lib/common/i18n/localization.js.map +1 -1
  63. package/lib/common/keys.d.ts +269 -0
  64. package/lib/common/keys.d.ts.map +1 -0
  65. package/lib/common/keys.js +634 -0
  66. package/lib/common/keys.js.map +1 -0
  67. package/lib/common/messaging/abstract-connection-provider.d.ts +1 -1
  68. package/lib/common/messaging/abstract-connection-provider.d.ts.map +1 -1
  69. package/lib/common/messaging/abstract-connection-provider.js +3 -1
  70. package/lib/common/messaging/abstract-connection-provider.js.map +1 -1
  71. package/lib/common/messaging/proxy-factory.js +1 -1
  72. package/lib/common/messaging/proxy-factory.js.map +1 -1
  73. package/lib/common/nls.d.ts +5 -0
  74. package/lib/common/nls.d.ts.map +1 -1
  75. package/lib/common/nls.js +62 -0
  76. package/lib/common/nls.js.map +1 -1
  77. package/lib/common/path.d.ts +6 -0
  78. package/lib/common/path.d.ts.map +1 -1
  79. package/lib/common/path.js +16 -4
  80. package/lib/common/path.js.map +1 -1
  81. package/lib/common/path.spec.js +12 -0
  82. package/lib/common/path.spec.js.map +1 -1
  83. package/lib/common/promise-util.d.ts +2 -2
  84. package/lib/common/promise-util.d.ts.map +1 -1
  85. package/lib/common/promise-util.js.map +1 -1
  86. package/lib/common/quick-pick-service.d.ts +219 -1
  87. package/lib/common/quick-pick-service.d.ts.map +1 -1
  88. package/lib/common/quick-pick-service.js +108 -1
  89. package/lib/common/quick-pick-service.js.map +1 -1
  90. package/lib/common/theme.d.ts +30 -0
  91. package/lib/common/theme.d.ts.map +1 -0
  92. package/lib/common/theme.js +18 -0
  93. package/lib/common/theme.js.map +1 -0
  94. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  95. package/lib/electron-browser/menu/electron-menu-contribution.js +17 -17
  96. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  97. package/lib/electron-browser/window/electron-window-preferences.js +2 -2
  98. package/lib/electron-browser/window/electron-window-preferences.js.map +1 -1
  99. package/package.json +5 -5
  100. package/src/browser/color-registry.ts +3 -85
  101. package/src/browser/common-frontend-contribution.ts +64 -64
  102. package/src/browser/core-preferences.ts +24 -21
  103. package/src/browser/dialogs.ts +4 -4
  104. package/src/browser/keyboard/browser-keyboard-frontend-contribution.ts +2 -2
  105. package/src/browser/keyboard/browser-keyboard-layout-provider.spec.ts +10 -4
  106. package/src/browser/keyboard/keys.ts +2 -675
  107. package/src/browser/messaging/ws-connection-provider.ts +13 -4
  108. package/src/browser/quick-input/quick-command-frontend-contribution.ts +1 -1
  109. package/src/browser/quick-input/quick-command-service.ts +2 -2
  110. package/src/browser/quick-input/quick-input-service.ts +1 -278
  111. package/src/browser/shell/tab-bar-toolbar.tsx +1 -1
  112. package/src/browser/storage-service.spec.ts +1 -1
  113. package/src/browser/theming.ts +6 -17
  114. package/src/browser/window/default-window-service.ts +1 -1
  115. package/src/browser/window-contribution.ts +2 -2
  116. package/src/common/color.ts +100 -0
  117. package/src/common/command.ts +10 -0
  118. package/src/common/i18n/localization.ts +13 -3
  119. package/src/common/i18n/nls.metadata.json +20421 -0
  120. package/src/common/keys.ts +693 -0
  121. package/src/common/messaging/abstract-connection-provider.ts +3 -1
  122. package/src/common/messaging/proxy-factory.ts +1 -1
  123. package/src/common/nls.ts +74 -0
  124. package/src/common/path.spec.ts +15 -0
  125. package/src/common/path.ts +16 -4
  126. package/src/common/promise-util.ts +3 -3
  127. package/src/common/quick-pick-service.ts +299 -4
  128. package/src/common/theme.ts +32 -0
  129. package/src/electron-browser/menu/electron-menu-contribution.ts +17 -17
  130. package/src/electron-browser/window/electron-window-preferences.ts +2 -2
@@ -59,13 +59,19 @@ export const DEFAULT_HTTP_FALLBACK_OPTIONS: HttpFallbackOptions = {
59
59
  export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebSocketOptions> {
60
60
 
61
61
  protected readonly onSocketDidOpenEmitter: Emitter<void> = new Emitter();
62
- readonly onSocketDidOpen: Event<void> = this.onSocketDidOpenEmitter.event;
62
+ get onSocketDidOpen(): Event<void> {
63
+ return this.onSocketDidOpenEmitter.event;
64
+ }
63
65
 
64
66
  protected readonly onSocketDidCloseEmitter: Emitter<void> = new Emitter();
65
- readonly onSocketDidClose: Event<void> = this.onSocketDidCloseEmitter.event;
67
+ get onSocketDidClose(): Event<void> {
68
+ return this.onSocketDidCloseEmitter.event;
69
+ }
66
70
 
67
71
  protected readonly onHttpFallbackDidActivateEmitter: Emitter<void> = new Emitter();
68
- readonly onHttpFallbackDidActivate: Event<void> = this.onHttpFallbackDidActivateEmitter.event;
72
+ get onHttpFallbackDidActivate(): Event<void> {
73
+ return this.onHttpFallbackDidActivateEmitter.event;
74
+ }
69
75
 
70
76
  static createProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): JsonRpcProxy<T> {
71
77
  return container.get(WebSocketConnectionProvider).createProxy<T>(path, arg);
@@ -98,7 +104,6 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
98
104
  this.fireSocketDidClose();
99
105
  };
100
106
  socket.onmessage = ({ data }) => {
101
- this.websocketErrorCounter = 0;
102
107
  this.handleIncomingRawMessage(data);
103
108
  };
104
109
  this.socket = socket;
@@ -218,6 +223,10 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
218
223
  }
219
224
 
220
225
  protected fireSocketDidOpen(): void {
226
+ // Once a websocket connection has opened, disable the http fallback
227
+ if (this.httpFallbackOptions?.allowed) {
228
+ this.httpFallbackOptions.allowed = false;
229
+ }
221
230
  this.onSocketDidOpenEmitter.fire(undefined);
222
231
  }
223
232
 
@@ -43,7 +43,7 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
43
43
  registerMenus(menus: MenuModelRegistry): void {
44
44
  menus.registerMenuAction(CommonMenus.VIEW_PRIMARY, {
45
45
  commandId: quickCommand.id,
46
- label: nls.localize('vscode/quickAccess.contribution/commandsQuickAccess', 'Find Command...')
46
+ label: nls.localizeByDefault('Command Palette...')
47
47
  });
48
48
  }
49
49
 
@@ -28,10 +28,10 @@ export const quickCommand: Command = {
28
28
  id: 'workbench.action.showCommands'
29
29
  };
30
30
 
31
- export const CLEAR_COMMAND_HISTORY = Command.toLocalizedCommand({
31
+ export const CLEAR_COMMAND_HISTORY = Command.toDefaultLocalizedCommand({
32
32
  id: 'clear.command.history',
33
33
  label: 'Clear Command History'
34
- }, 'vscode/commandsQuickAccess/clearCommandHistory');
34
+ });
35
35
 
36
36
  @injectable()
37
37
  export class QuickCommandService implements QuickAccessContribution, QuickAccessProvider {
@@ -14,281 +14,4 @@
14
14
  * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  ********************************************************************************/
16
16
 
17
- import { CancellationToken, Event } from '../../common';
18
- import URI from '../../common/uri';
19
- import { KeySequence } from '../keyboard';
20
- import * as fuzzy from 'fuzzy';
21
-
22
- export interface Match {
23
- start: number;
24
- end: number;
25
- }
26
- export interface QuickPickItemHighlights {
27
- label?: Match[];
28
- description?: Match[];
29
- detail?: Match[];
30
- }
31
-
32
- export interface QuickPickItem {
33
- type?: 'item' | 'separator';
34
- id?: string;
35
- label: string;
36
- meta?: string;
37
- ariaLabel?: string;
38
- description?: string;
39
- detail?: string;
40
- keySequence?: KeySequence;
41
- iconClasses?: string[];
42
- alwaysShow?: boolean;
43
- highlights?: QuickPickItemHighlights;
44
- buttons?: QuickInputButton[];
45
- execute?: () => void;
46
- }
47
-
48
- export namespace QuickPickItem {
49
- export function is(item: QuickPickSeparator | QuickPickItem): item is QuickPickItem {
50
- // if it's not a separator, it's an item
51
- return item.type !== 'separator';
52
- }
53
- }
54
-
55
- export interface QuickPickSeparator {
56
- type: 'separator';
57
- label?: string;
58
- }
59
-
60
- export namespace QuickPickSeparator {
61
- export function is(item: QuickPickSeparator | QuickPickItem): item is QuickPickSeparator {
62
- return item.type === 'separator';
63
- }
64
- }
65
-
66
- export type QuickPicks = (QuickPickSeparator | QuickPickItem)[];
67
-
68
- export interface QuickPickValue<V> extends QuickPickItem {
69
- value: V
70
- }
71
-
72
- export interface QuickInputButton {
73
- iconPath?: URI | { light: URI; dark: URI } | { id: string };
74
- iconClass?: string;
75
- tooltip?: string;
76
- }
77
-
78
- export interface QuickInputButtonHandle extends QuickInputButton {
79
- index: number; // index of where they are in buttons array if QuickInputButton or -1 if QuickInputButtons.Back
80
- }
81
-
82
- export interface QuickInput {
83
- readonly onDidHide: Event<void>;
84
- readonly onDispose: Event<void>;
85
- title: string | undefined;
86
- description: string | undefined;
87
- step: number | undefined;
88
- totalSteps: number | undefined;
89
- enabled: boolean;
90
- contextKey: string | undefined;
91
- busy: boolean;
92
- ignoreFocusOut: boolean;
93
- show(): void;
94
- hide(): void;
95
- dispose(): void;
96
- }
97
-
98
- export interface InputBox extends QuickInput {
99
- value: string | undefined;
100
- valueSelection: Readonly<[number, number]> | undefined;
101
- placeholder: string | undefined;
102
- password: boolean;
103
- readonly onDidChangeValue: Event<string>;
104
- readonly onDidAccept: Event<void>;
105
- buttons: ReadonlyArray<QuickInputButton>;
106
- readonly onDidTriggerButton: Event<QuickInputButton>;
107
- prompt: string | undefined;
108
- validationMessage: string | undefined;
109
- }
110
-
111
- export interface QuickPick<T extends QuickPickItem> extends QuickInput {
112
- value: string;
113
- placeholder: string | undefined;
114
- items: ReadonlyArray<T | QuickPickSeparator>;
115
- activeItems: ReadonlyArray<T>;
116
- selectedItems: ReadonlyArray<T>;
117
- canSelectMany: boolean;
118
- matchOnDescription: boolean;
119
- matchOnDetail: boolean;
120
- readonly onDidAccept: Event<void>;
121
- readonly onDidChangeValue: Event<string>;
122
- readonly onDidTriggerButton: Event<QuickInputButton>;
123
- readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
124
- readonly onDidChangeActive: Event<T[]>;
125
- readonly onDidChangeSelection: Event<T[]>;
126
- }
127
-
128
- export interface PickOptions<T extends QuickPickItem> {
129
- placeHolder?: string;
130
- matchOnDescription?: boolean;
131
- matchOnDetail?: boolean;
132
- matchOnLabel?: boolean;
133
- autoFocusOnList?: boolean;
134
- ignoreFocusLost?: boolean;
135
- canPickMany?: boolean;
136
- contextKey?: string;
137
- activeItem?: Promise<T> | T;
138
- onDidFocus?: (entry: T) => void;
139
- }
140
-
141
- export interface InputOptions {
142
- value?: string;
143
- valueSelection?: [number, number];
144
- prompt?: string;
145
- placeHolder?: string;
146
- password?: boolean;
147
- ignoreFocusLost?: boolean;
148
- validateInput?(input: string): Promise<string | null | undefined> | undefined;
149
- }
150
-
151
- export interface QuickPickItemButtonEvent<T extends QuickPickItem> {
152
- button: QuickInputButton;
153
- item: T;
154
- }
155
-
156
- export interface QuickPickOptions<T extends QuickPickItem> {
157
- busy?: boolean;
158
- enabled?: boolean;
159
- title?: string;
160
- description?: string;
161
- value?: string;
162
- filterValue?: (value: string) => string;
163
- ariaLabel?: string;
164
- buttons?: Array<QuickInputButton>;
165
- placeholder?: string;
166
- canAcceptInBackground?: boolean;
167
- customButton?: boolean;
168
- customLabel?: string;
169
- customHover?: string;
170
- canSelectMany?: boolean;
171
- matchOnDescription?: boolean;
172
- matchOnDetail?: boolean;
173
- matchOnLabel?: boolean;
174
- sortByLabel?: boolean;
175
- autoFocusOnList?: boolean;
176
- ignoreFocusOut?: boolean;
177
- valueSelection?: Readonly<[number, number]>;
178
- validationMessage?: string;
179
- hideInput?: boolean;
180
- hideCheckAll?: boolean;
181
- runIfSingle?: boolean
182
- contextKey?: string;
183
- activeItem?: T,
184
- step?: number;
185
- totalSteps?: number;
186
-
187
- onDidAccept?: () => void,
188
- onDidChangeActive?: (quickPick: QuickPick<T>, activeItems: Array<T>) => void,
189
- onDidChangeSelection?: (quickPick: QuickPick<T>, selectedItems: Array<T>) => void,
190
- onDidChangeValue?: (quickPick: QuickPick<T>, filter: string) => void,
191
- onDidCustom?: () => void,
192
- onDidHide?: () => void;
193
- onDidTriggerButton?: (button: QuickInputButton) => void,
194
- onDidTriggerItemButton?: (ItemButtonEvent: QuickPickItemButtonEvent<T>) => void
195
- }
196
-
197
- export const QuickInputService = Symbol('QuickInputService');
198
- export interface QuickInputService {
199
- readonly backButton: QuickInputButton;
200
- readonly onShow: Event<void>;
201
- readonly onHide: Event<void>;
202
- open(filter: string): void;
203
- createInputBox(): InputBox;
204
- input(options?: InputOptions, token?: CancellationToken): Promise<string | undefined>;
205
- pick<T extends QuickPickItem, O extends PickOptions<T>>(picks: Promise<T[]> | T[], options?: O, token?: CancellationToken):
206
- Promise<(O extends { canPickMany: true } ? T[] : T) | undefined>;
207
- showQuickPick<T extends QuickPickItem>(items: Array<T>, options?: QuickPickOptions<T>): Promise<T>;
208
- hide(): void;
209
- /**
210
- * Provides raw access to the quick pick controller.
211
- */
212
- createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
213
- }
214
-
215
- /**
216
- * Filter the list of quick pick items based on the provided filter.
217
- * Items are filtered based on if:
218
- * - their `label` satisfies the filter using `fuzzy`.
219
- * - their `description` satisfies the filter using `fuzzy`.
220
- * - their `detail` satisfies the filter using `fuzzy`.
221
- * Filtered items are also updated to display proper highlights based on how they were filtered.
222
- * @param items the list of quick pick items.
223
- * @param filter the filter to search for.
224
- * @returns the list of quick pick items that satisfy the filter.
225
- */
226
- export function filterItems(items: QuickPickItem[], filter: string): QuickPickItem[] {
227
- filter = filter.trim().toLowerCase();
228
-
229
- if (filter.length === 0) {
230
- for (const item of items) {
231
- item.highlights = undefined; // reset highlights from previous filtering.
232
- }
233
- return items;
234
- }
235
-
236
- const filteredItems: QuickPickItem[] = [];
237
- for (const item of items) {
238
- if (
239
- fuzzy.test(filter, item.label) ||
240
- (item.description && fuzzy.test(filter, item.description)) ||
241
- (item.detail && fuzzy.test(filter, item.detail))
242
- ) {
243
- item.highlights = {
244
- label: findMatches(item.label, filter),
245
- description: item.description ? findMatches(item.description, filter) : undefined,
246
- detail: item.detail ? findMatches(item.detail, filter) : undefined
247
- };
248
- filteredItems.push(item);
249
- }
250
- }
251
- return filteredItems;
252
- }
253
-
254
- /**
255
- * Find match highlights when testing a word against a pattern.
256
- * @param word the word to test.
257
- * @param pattern the word to match against.
258
- * @returns the list of highlights if present.
259
- */
260
- export function findMatches(word: string, pattern: string): Array<{ start: number, end: number }> | undefined {
261
- word = word.toLocaleLowerCase();
262
- pattern = pattern.toLocaleLowerCase();
263
-
264
- if (pattern.trim().length === 0) {
265
- return undefined;
266
- }
267
-
268
- const delimiter = '\u0000'; // null byte that shouldn't appear in the input and is used to denote matches.
269
- const matchResult = fuzzy.match(pattern.replace(/\u0000/gu, ''), word, { pre: delimiter, post: delimiter });
270
- if (!matchResult) {
271
- return undefined;
272
- }
273
-
274
- const match = matchResult.rendered;
275
- const highlights: { start: number, end: number }[] = [];
276
-
277
- let lastIndex = 0;
278
- /** We need to account for the extra markers by removing them from the range */
279
- let offset = 0;
280
-
281
- while (true) {
282
- const start = match.indexOf(delimiter, lastIndex);
283
- if (start === -1) { break; }
284
- const end = match.indexOf(delimiter, start + 1);
285
- if (end === -1) { break; }
286
- highlights.push({
287
- start: start - offset++,
288
- end: end - offset++
289
- });
290
- lastIndex = end + 1;
291
- }
292
-
293
- return highlights.length > 0 ? highlights : undefined;
294
- }
17
+ export * from '../../common/quick-pick-service';
@@ -405,7 +405,7 @@ export class TabBarToolbar extends ReactWidget {
405
405
  protected renderMore(): React.ReactNode {
406
406
  return !!this.more.size && <div key='__more__' className={TabBarToolbar.Styles.TAB_BAR_TOOLBAR_ITEM + ' enabled'}>
407
407
  <div id='__more__' className={codicon('ellipsis', true)} onClick={this.showMoreContextMenu}
408
- title={nls.localize('vscode/compositePart/viewsAndMoreActions', 'More Actions...')} />
408
+ title={nls.localizeByDefault('More Actions...')} />
409
409
  </div>;
410
410
  }
411
411
 
@@ -34,7 +34,7 @@ before(() => {
34
34
  MockLogger since it does what we need but this is there as a demo of
35
35
  sinon for other uses-cases. We can remove this once this technique is
36
36
  more generally used. */
37
- sinon.stub(logger, 'warn').callsFake(() => { });
37
+ sinon.stub(logger, 'warn').callsFake(async () => { });
38
38
  return logger;
39
39
  });
40
40
  testContainer.bind(StorageService).to(LocalStorageService).inSingletonScope();
@@ -18,25 +18,14 @@ import { Emitter, Event } from '../common/event';
18
18
  import { Disposable } from '../common/disposable';
19
19
  import { FrontendApplicationConfigProvider } from './frontend-application-config-provider';
20
20
  import { ApplicationProps } from '@theia/application-package/lib/application-props';
21
+ import { Theme, ThemeChangeEvent } from '../common/theme';
21
22
 
22
- export const ThemeServiceSymbol = Symbol('ThemeService');
23
-
24
- export type ThemeType = 'light' | 'dark' | 'hc';
25
-
26
- export interface Theme {
27
- readonly id: string;
28
- readonly type: ThemeType;
29
- readonly label: string;
30
- readonly description?: string;
31
- readonly editorTheme?: string;
32
- activate(): void;
33
- deactivate(): void;
34
- }
23
+ /**
24
+ * @deprecated since 1.20.0. Import from `@theia/core/lib/common/theme` instead.
25
+ */
26
+ export * from '../common/theme';
35
27
 
36
- export interface ThemeChangeEvent {
37
- readonly newTheme: Theme;
38
- readonly oldTheme?: Theme;
39
- }
28
+ export const ThemeServiceSymbol = Symbol('ThemeService');
40
29
 
41
30
  export class ThemeService {
42
31
 
@@ -50,7 +50,7 @@ export class DefaultWindowService implements WindowService, FrontendApplicationC
50
50
  }
51
51
 
52
52
  openNewDefaultWindow(): void {
53
- this.openNewWindow(DEFAULT_WINDOW_HASH);
53
+ this.openNewWindow(`#${DEFAULT_WINDOW_HASH}`);
54
54
  }
55
55
 
56
56
  canUnload(): boolean {
@@ -23,10 +23,10 @@ import { CommonMenus } from '../browser/common-frontend-contribution';
23
23
 
24
24
  export namespace WindowCommands {
25
25
 
26
- export const NEW_WINDOW = Command.toLocalizedCommand({
26
+ export const NEW_WINDOW = Command.toDefaultLocalizedCommand({
27
27
  id: 'workbench.action.newWindow',
28
28
  label: 'New Window'
29
- }, 'vscode/windowActions/newWindow');
29
+ });
30
30
  }
31
31
 
32
32
  @injectable()
@@ -0,0 +1,100 @@
1
+ /********************************************************************************
2
+ * Copyright (C) 2019 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
+ /**
18
+ * Either be a reference to an existing color or a color value as a hex string, rgba, or hsla.
19
+ */
20
+ export type Color = string | RGBA | HSLA | ColorTransformation;
21
+ export namespace Color {
22
+ export function rgba(r: number, g: number, b: number, a: number = 1): Color {
23
+ return { r, g, b, a };
24
+ }
25
+ export function hsla(h: number, s: number, l: number, a: number = 1): Color {
26
+ return { h, s, l, a };
27
+ }
28
+ export const white = rgba(255, 255, 255, 1);
29
+ export const black = rgba(0, 0, 0, 1);
30
+ export function transparent(v: string, f: number): ColorTransformation {
31
+ return { v, f, kind: 'transparent' };
32
+ }
33
+ export function lighten(v: string, f: number): ColorTransformation {
34
+ return { v, f, kind: 'lighten' };
35
+ }
36
+ export function darken(v: string, f: number): ColorTransformation {
37
+ return { v, f, kind: 'darken' };
38
+ }
39
+ }
40
+ export interface ColorTransformation {
41
+ kind: 'transparent' | 'lighten' | 'darken'
42
+ v: string
43
+ f: number
44
+ }
45
+ export interface RGBA {
46
+ /**
47
+ * Red: integer in [0-255]
48
+ */
49
+ readonly r: number;
50
+
51
+ /**
52
+ * Green: integer in [0-255]
53
+ */
54
+ readonly g: number;
55
+
56
+ /**
57
+ * Blue: integer in [0-255]
58
+ */
59
+ readonly b: number;
60
+
61
+ /**
62
+ * Alpha: float in [0-1]
63
+ */
64
+ readonly a: number;
65
+ }
66
+ export interface HSLA {
67
+ /**
68
+ * Hue: integer in [0, 360]
69
+ */
70
+ readonly h: number;
71
+ /**
72
+ * Saturation: float in [0, 1]
73
+ */
74
+ readonly s: number;
75
+ /**
76
+ * Luminosity: float in [0, 1]
77
+ */
78
+ readonly l: number;
79
+ /**
80
+ * Alpha: float in [0, 1]
81
+ */
82
+ readonly a: number;
83
+ }
84
+
85
+ export interface ColorDefaults {
86
+ light?: Color
87
+ dark?: Color
88
+ hc?: Color
89
+ }
90
+
91
+ export interface ColorDefinition {
92
+ id: string
93
+ defaults?: ColorDefaults
94
+ description: string
95
+ }
96
+
97
+ export interface ColorCssVariable {
98
+ name: string
99
+ value: string
100
+ }
@@ -64,6 +64,16 @@ export namespace Command {
64
64
  };
65
65
  }
66
66
 
67
+ export function toDefaultLocalizedCommand(command: Command): Command {
68
+ return {
69
+ ...command,
70
+ label: command.label && nls.localizeByDefault(command.label),
71
+ originalLabel: command.label,
72
+ category: command.category && nls.localizeByDefault(command.category),
73
+ originalCategory: command.category,
74
+ };
75
+ }
76
+
67
77
  /** Comparator function for when sorting commands */
68
78
  export function compareCommands(a: Command, b: Command): number {
69
79
  if (a.label && b.label) {
@@ -36,7 +36,7 @@ export type FormatType = string | number | boolean | undefined;
36
36
 
37
37
  export namespace Localization {
38
38
 
39
- function format(message: string, args: FormatType[]): string {
39
+ export function format(message: string, args: FormatType[]): string {
40
40
  let result = message;
41
41
  if (args.length > 0) {
42
42
  result = message.replace(/\{(\d+)\}/g, (match, rest) => {
@@ -59,13 +59,23 @@ export namespace Localization {
59
59
  if (localization) {
60
60
  const translation = localization.translations[key];
61
61
  if (translation) {
62
- // vscode's localizations often contain additional '&&' symbols, which we simply ignore
63
- value = translation.replace(/&&/g, '');
62
+ value = normalize(translation);
64
63
  }
65
64
  }
66
65
  return format(value, args);
67
66
  }
68
67
 
68
+ /**
69
+ * This function normalizes values from VSCode's localizations, which often contain additional mnemonics (`&&`).
70
+ * The normalization removes the mnemonics from the input string.
71
+ *
72
+ * @param value Localization value coming from VSCode
73
+ * @returns A normalized localized value
74
+ */
75
+ export function normalize(value: string): string {
76
+ return value.replace(/&&/g, '');
77
+ }
78
+
69
79
  export function transformKey(key: string): string {
70
80
  let nlsKey = key;
71
81
  const keySlashIndex = key.lastIndexOf('/');