@theia/core 1.37.1 → 1.37.2

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 (57) hide show
  1. package/README.md +6 -6
  2. package/lib/browser/common-frontend-contribution.js +3 -3
  3. package/lib/browser/common-frontend-contribution.js.map +1 -1
  4. package/lib/browser/core-preferences.js +1 -1
  5. package/lib/browser/core-preferences.js.map +1 -1
  6. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts +2 -0
  7. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.d.ts.map +1 -1
  8. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js +23 -8
  9. package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar.js.map +1 -1
  10. package/lib/browser/shell/tab-bars.d.ts +33 -24
  11. package/lib/browser/shell/tab-bars.d.ts.map +1 -1
  12. package/lib/browser/shell/tab-bars.js +90 -45
  13. package/lib/browser/shell/tab-bars.js.map +1 -1
  14. package/lib/browser/view-container.d.ts +10 -0
  15. package/lib/browser/view-container.d.ts.map +1 -1
  16. package/lib/browser/view-container.js +15 -1
  17. package/lib/browser/view-container.js.map +1 -1
  18. package/lib/browser/widgets/select-component.d.ts +4 -2
  19. package/lib/browser/widgets/select-component.d.ts.map +1 -1
  20. package/lib/browser/widgets/select-component.js +14 -11
  21. package/lib/browser/widgets/select-component.js.map +1 -1
  22. package/lib/common/command.d.ts +1 -0
  23. package/lib/common/command.d.ts.map +1 -1
  24. package/lib/common/command.js.map +1 -1
  25. package/lib/common/index.d.ts +1 -0
  26. package/lib/common/index.d.ts.map +1 -1
  27. package/lib/common/index.js +1 -0
  28. package/lib/common/index.js.map +1 -1
  29. package/lib/common/objects.d.ts +1 -0
  30. package/lib/common/objects.d.ts.map +1 -1
  31. package/lib/common/objects.js +43 -1
  32. package/lib/common/objects.js.map +1 -1
  33. package/lib/common/severity.js +1 -1
  34. package/lib/common/severity.js.map +1 -1
  35. package/lib/common/telemetry.d.ts +20 -0
  36. package/lib/common/telemetry.d.ts.map +1 -0
  37. package/lib/common/telemetry.js +25 -0
  38. package/lib/common/telemetry.js.map +1 -0
  39. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +5 -0
  40. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  41. package/lib/electron-browser/menu/electron-main-menu-factory.js +4 -3
  42. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  43. package/package.json +6 -6
  44. package/src/browser/common-frontend-contribution.ts +3 -3
  45. package/src/browser/core-preferences.ts +1 -1
  46. package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar.tsx +23 -6
  47. package/src/browser/shell/tab-bars.ts +107 -63
  48. package/src/browser/style/tabs.css +67 -7
  49. package/src/browser/view-container.ts +21 -0
  50. package/src/browser/widgets/select-component.tsx +21 -13
  51. package/src/common/command.ts +1 -0
  52. package/src/common/i18n/nls.metadata.json +16592 -14032
  53. package/src/common/index.ts +1 -0
  54. package/src/common/objects.ts +48 -1
  55. package/src/common/severity.ts +1 -1
  56. package/src/common/telemetry.ts +45 -0
  57. package/src/electron-browser/menu/electron-main-menu-factory.ts +10 -3
@@ -46,4 +46,5 @@ export * from './strings';
46
46
  export * from './types';
47
47
  export { default as URI } from './uri';
48
48
  export * from './view-column';
49
+ export * from './telemetry';
49
50
 
@@ -14,7 +14,7 @@
14
14
  // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
15
  // *****************************************************************************
16
16
 
17
- import { isObject } from './types';
17
+ import { isObject, isUndefined } from './types';
18
18
 
19
19
  export function deepClone<T>(obj: T): T {
20
20
  if (!isObject(obj)) {
@@ -70,3 +70,50 @@ export function notEmpty<T>(arg: T | undefined | null): arg is T {
70
70
  export function isEmpty(arg: Object): boolean {
71
71
  return Object.keys(arg).length === 0 && arg.constructor === Object;
72
72
  }
73
+
74
+ // copied and modified from https://github.com/microsoft/vscode/blob/1.76.0/src/vs/base/common/objects.ts#L45-L83
75
+ /*---------------------------------------------------------------------------------------------
76
+ * Copyright (c) Microsoft Corporation. All rights reserved.
77
+ * Licensed under the MIT License. See License.txt in the project root for license information.
78
+ *--------------------------------------------------------------------------------------------*/
79
+
80
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
81
+ export function cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>): any {
82
+ // impossible to clone an undefined or null object
83
+ // eslint-disable-next-line no-null/no-null
84
+ if (isUndefined(obj) || obj === null) {
85
+ return obj;
86
+ }
87
+
88
+ const changed = changer(obj);
89
+ if (!isUndefined(changed)) {
90
+ return changed;
91
+ }
92
+
93
+ if (Array.isArray(obj)) {
94
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
95
+ const r1: any[] = [];
96
+ for (const e of obj) {
97
+ r1.push(cloneAndChange(e, changer, seen));
98
+ }
99
+ return r1;
100
+ }
101
+
102
+ if (isObject(obj)) {
103
+ if (seen.has(obj)) {
104
+ throw new Error('Cannot clone recursive data-structure');
105
+ }
106
+ seen.add(obj);
107
+ const r2 = {};
108
+ for (const i2 in obj) {
109
+ if (_hasOwnProperty.call(obj, i2)) {
110
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
111
+ (r2 as any)[i2] = cloneAndChange(obj[i2], changer, seen);
112
+ }
113
+ }
114
+ seen.delete(obj);
115
+ return r2;
116
+ }
117
+
118
+ return obj;
119
+ }
@@ -101,7 +101,7 @@ export namespace Severity {
101
101
  } else if (severity === Severity.Log || severity === log) {
102
102
  return nls.localize('theia/core/severity/log', 'Log');
103
103
  } else {
104
- return nls.localize('theia/core/severity/all', 'All');
104
+ return nls.localizeByDefault('All');
105
105
  }
106
106
  }
107
107
 
@@ -0,0 +1,45 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 STMicroelectronics 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 class TelemetryTrustedValue<T> {
18
+ readonly value: T;
19
+
20
+ constructor(value: T) {
21
+ this.value = value;
22
+ }
23
+ }
24
+
25
+ export interface TelemetryLogger {
26
+ readonly sender: TelemetrySender;
27
+ readonly options: TelemetryLoggerOptions | undefined;
28
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
+ logUsage(eventName: string, data?: Record<string, any | TelemetryTrustedValue<any>>): void;
30
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
31
+ logError(eventNameOrException: string | Error, data?: Record<string, any | TelemetryTrustedValue<any>>): void;
32
+
33
+ dispose(): void;
34
+ }
35
+
36
+ interface TelemetrySender {
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ sendEventData(eventName: string, data?: Record<string, any>): void;
39
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
+ sendErrorData(error: Error, data?: Record<string, any>): void;
41
+ flush?(): void | Thenable<void>;
42
+ }
43
+
44
+ interface TelemetryLoggerOptions {
45
+ }
@@ -35,6 +35,12 @@ export interface ElectronMenuOptions {
35
35
  * Defaults to `true`.
36
36
  */
37
37
  readonly showDisabled?: boolean;
38
+
39
+ /**
40
+ * Controls whether to render disabled items as disabled
41
+ * Defaults to `true`
42
+ */
43
+ readonly honorDisabled?: boolean;
38
44
  /**
39
45
  * A DOM context to use when evaluating any `when` clauses
40
46
  * of menu items registered for this item.
@@ -108,7 +114,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
108
114
  const maxWidget = document.getElementsByClassName(MAXIMIZED_CLASS);
109
115
  if (preference === 'visible' || (preference === 'classic' && maxWidget.length === 0)) {
110
116
  const menuModel = this.menuProvider.getMenu(MAIN_MENU_BAR);
111
- this._menu = this.fillMenuTemplate([], menuModel, [], { rootMenuPath: MAIN_MENU_BAR });
117
+ this._menu = this.fillMenuTemplate([], menuModel, [], { honorDisabled: false, rootMenuPath: MAIN_MENU_BAR });
112
118
  if (isOSX) {
113
119
  this._menu.unshift(this.createOSXMenu());
114
120
  }
@@ -121,7 +127,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
121
127
 
122
128
  createElectronContextMenu(menuPath: MenuPath, args?: any[], context?: HTMLElement, contextKeyService?: ContextMatcher): MenuDto[] {
123
129
  const menuModel = this.menuProvider.getMenu(menuPath);
124
- return this.fillMenuTemplate([], menuModel, args, { showDisabled: false, context, rootMenuPath: menuPath, contextKeyService });
130
+ return this.fillMenuTemplate([], menuModel, args, { showDisabled: true, context, rootMenuPath: menuPath, contextKeyService });
125
131
  }
126
132
 
127
133
  protected fillMenuTemplate(parentItems: MenuDto[],
@@ -130,6 +136,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
130
136
  options: ElectronMenuOptions
131
137
  ): MenuDto[] {
132
138
  const showDisabled = options?.showDisabled !== false;
139
+ const honorDisabled = options?.honorDisabled !== false;
133
140
 
134
141
  if (CompoundMenuNode.is(menu) && menu.children.length && this.undefinedOrMatch(options.contextKeyService ?? this.contextKeyService, menu.when, options.context)) {
135
142
  const role = CompoundMenuNode.getRole(menu);
@@ -181,7 +188,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
181
188
  label: node.label,
182
189
  type: this.commandRegistry.getToggledHandler(commandId, ...args) ? 'checkbox' : 'normal',
183
190
  checked: this.commandRegistry.isToggled(commandId, ...args),
184
- enabled: true, // https://github.com/eclipse-theia/theia/issues/446
191
+ enabled: !honorDisabled || this.commandRegistry.isEnabled(commandId, ...args), // see https://github.com/eclipse-theia/theia/issues/446
185
192
  visible: true,
186
193
  accelerator,
187
194
  execute: () => this.execute(commandId, args, options.rootMenuPath)