@theia/core 1.55.0-next.4 → 1.55.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 (75) hide show
  1. package/README.md +10 -10
  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.ko.json +4 -0
  11. package/i18n/nls.pl.json +4 -0
  12. package/i18n/nls.pt-br.json +4 -0
  13. package/i18n/nls.ru.json +4 -0
  14. package/i18n/nls.tr.json +4 -0
  15. package/i18n/nls.zh-cn.json +4 -0
  16. package/i18n/nls.zh-tw.json +4 -0
  17. package/lib/browser/catalog.json +112 -47
  18. package/lib/browser/core-preferences.d.ts.map +1 -1
  19. package/lib/browser/core-preferences.js +3 -1
  20. package/lib/browser/core-preferences.js.map +1 -1
  21. package/lib/browser/dialogs/react-dialog.spec.d.ts +2 -0
  22. package/lib/browser/dialogs/react-dialog.spec.d.ts.map +1 -0
  23. package/lib/browser/dialogs/react-dialog.spec.js +42 -0
  24. package/lib/browser/dialogs/react-dialog.spec.js.map +1 -0
  25. package/lib/browser/dialogs.d.ts +1 -1
  26. package/lib/browser/dialogs.d.ts.map +1 -1
  27. package/lib/browser/dialogs.js +8 -8
  28. package/lib/browser/dialogs.js.map +1 -1
  29. package/lib/browser/frontend-application-module.d.ts.map +1 -1
  30. package/lib/browser/frontend-application-module.js +4 -0
  31. package/lib/browser/frontend-application-module.js.map +1 -1
  32. package/lib/browser/index.d.ts +1 -0
  33. package/lib/browser/index.d.ts.map +1 -1
  34. package/lib/browser/index.js +1 -0
  35. package/lib/browser/index.js.map +1 -1
  36. package/lib/browser/widget-status-bar-service.d.ts +29 -0
  37. package/lib/browser/widget-status-bar-service.d.ts.map +1 -0
  38. package/lib/browser/widget-status-bar-service.js +81 -0
  39. package/lib/browser/widget-status-bar-service.js.map +1 -0
  40. package/lib/browser/widgets/react-widget.d.ts.map +1 -1
  41. package/lib/browser/widgets/react-widget.js +3 -1
  42. package/lib/browser/widgets/react-widget.js.map +1 -1
  43. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +5 -3
  44. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  45. package/lib/electron-browser/menu/electron-main-menu-factory.js +28 -28
  46. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  47. package/lib/electron-browser/menu/electron-menu-contribution.d.ts +1 -2
  48. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  49. package/lib/electron-browser/menu/electron-menu-contribution.js +2 -2
  50. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  51. package/lib/electron-browser/preload.js +2 -2
  52. package/lib/node/env-variables/env-variables-server.d.ts.map +1 -1
  53. package/lib/node/env-variables/env-variables-server.js +2 -1
  54. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  55. package/lib/node/logger-cli-contribution.d.ts.map +1 -1
  56. package/lib/node/logger-cli-contribution.js +10 -8
  57. package/lib/node/logger-cli-contribution.js.map +1 -1
  58. package/package.json +10 -10
  59. package/shared/@parcel/watcher/index.d.ts +2 -0
  60. package/shared/@parcel/watcher/index.js +1 -0
  61. package/src/browser/core-preferences.ts +3 -1
  62. package/src/browser/dialogs/react-dialog.spec.tsx +47 -0
  63. package/src/browser/dialogs.ts +1 -1
  64. package/src/browser/frontend-application-module.ts +5 -0
  65. package/src/browser/index.ts +1 -0
  66. package/src/browser/style/tabs.css +55 -138
  67. package/src/browser/widget-status-bar-service.ts +84 -0
  68. package/src/browser/widgets/react-widget.tsx +3 -1
  69. package/src/electron-browser/menu/electron-main-menu-factory.ts +32 -31
  70. package/src/electron-browser/menu/electron-menu-contribution.ts +2 -3
  71. package/src/electron-browser/preload.ts +2 -2
  72. package/src/node/env-variables/env-variables-server.ts +2 -1
  73. package/src/node/logger-cli-contribution.ts +10 -8
  74. package/shared/nsfw/index.d.ts +0 -2
  75. package/shared/nsfw/index.js +0 -1
@@ -0,0 +1,84 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2024 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 { inject, injectable, named } from 'inversify';
18
+ import { Widget } from './widgets';
19
+ import { StatusBar } from './status-bar';
20
+ import { FrontendApplicationContribution } from './frontend-application-contribution';
21
+ import { ContributionProvider } from '../common';
22
+ import { FrontendApplication } from './frontend-application';
23
+
24
+ export const WidgetStatusBarContribution = Symbol('WidgetStatusBarContribution');
25
+
26
+ export interface WidgetStatusBarContribution<T extends Widget> {
27
+ canHandle(widget: Widget): widget is T;
28
+ activate(statusBar: StatusBar, widget: T): void;
29
+ deactivate(statusBar: StatusBar): void;
30
+ }
31
+
32
+ /**
33
+ * Creates an empty {@link WidgetStatusBarContribution} that does nothing.
34
+ * Useful for widgets that are not handled by any other contribution, for example:
35
+ * * Settings widget
36
+ * * Welcome widget
37
+ * * Webview widget
38
+ *
39
+ * @param prototype Prototype to identify the kind of the widget.
40
+ * @returns An empty {@link WidgetStatusBarContribution}.
41
+ */
42
+ export function noopWidgetStatusBarContribution(prototype: Function): WidgetStatusBarContribution<Widget> {
43
+ return {
44
+ canHandle(widget: Widget): widget is Widget {
45
+ return widget instanceof prototype;
46
+ },
47
+ activate: () => { },
48
+ deactivate: () => { }
49
+ };
50
+ }
51
+
52
+ @injectable()
53
+ export class WidgetStatusBarService implements FrontendApplicationContribution {
54
+
55
+ @inject(ContributionProvider) @named(WidgetStatusBarContribution)
56
+ protected readonly contributionProvider: ContributionProvider<WidgetStatusBarContribution<Widget>>;
57
+
58
+ @inject(StatusBar)
59
+ protected readonly statusBar: StatusBar;
60
+
61
+ onStart(app: FrontendApplication): void {
62
+ app.shell.onDidChangeCurrentWidget(event => {
63
+ if (event.newValue) {
64
+ this.show(event.newValue);
65
+ }
66
+ });
67
+ }
68
+
69
+ protected show(widget: Widget): void {
70
+ const contributions = this.contributionProvider.getContributions();
71
+ // If any contribution can handle the widget, activate it
72
+ // If none can, keep everything as is
73
+ if (contributions.some(contribution => contribution.canHandle(widget))) {
74
+ for (const contribution of contributions) {
75
+ // Deactivate all contributions
76
+ contribution.deactivate(this.statusBar);
77
+ if (contribution.canHandle(widget)) {
78
+ // Selectively re-activate them
79
+ contribution.activate(this.statusBar, widget);
80
+ }
81
+ }
82
+ }
83
+ }
84
+ }
@@ -38,7 +38,9 @@ export abstract class ReactWidget extends BaseWidget {
38
38
 
39
39
  protected override onUpdateRequest(msg: Message): void {
40
40
  super.onUpdateRequest(msg);
41
- this.nodeRoot.render(<React.Fragment>{this.render()}</React.Fragment>);
41
+ if (!this.isDisposed) {
42
+ this.nodeRoot.render(<React.Fragment>{this.render()}</React.Fragment>);
43
+ }
42
44
  }
43
45
 
44
46
  /**
@@ -74,42 +74,45 @@ export type ElectronMenuItemRole = ('undo' | 'redo' | 'cut' | 'copy' | 'paste' |
74
74
  @injectable()
75
75
  export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
76
76
 
77
- protected _menu?: MenuDto[];
78
- protected _toggledCommands: Set<string> = new Set();
77
+ protected menu?: MenuDto[];
78
+ protected toggledCommands: Set<string> = new Set();
79
79
 
80
80
  @inject(PreferenceService)
81
81
  protected preferencesService: PreferenceService;
82
82
 
83
+ setMenuBar = debounce(() => this.doSetMenuBar(), 100);
84
+
83
85
  @postConstruct()
84
86
  postConstruct(): void {
85
- this.preferencesService.onPreferenceChanged(
86
- debounce(e => {
87
- if (e.preferenceName === 'window.menuBarVisibility') {
88
- this.setMenuBar();
89
- }
90
- if (this._menu) {
91
- for (const cmd of this._toggledCommands) {
92
- const menuItem = this.findMenuById(this._menu, cmd);
93
- if (menuItem) {
94
- menuItem.checked = this.commandRegistry.isToggled(cmd);
95
- }
96
- }
97
- window.electronTheiaCore.setMenu(this._menu);
98
- }
99
- }, 10)
100
- );
101
87
  this.keybindingRegistry.onKeybindingsChanged(() => {
102
88
  this.setMenuBar();
103
89
  });
104
90
  this.menuProvider.onDidChange(() => {
105
91
  this.setMenuBar();
106
92
  });
93
+ this.preferencesService.ready.then(() => {
94
+ this.preferencesService.onPreferenceChanged(
95
+ debounce(e => {
96
+ if (e.preferenceName === 'window.menuBarVisibility') {
97
+ this.doSetMenuBar();
98
+ }
99
+ if (this.menu) {
100
+ for (const cmd of this.toggledCommands) {
101
+ const menuItem = this.findMenuById(this.menu, cmd);
102
+ if (menuItem && (!!menuItem.checked !== this.commandRegistry.isToggled(cmd))) {
103
+ menuItem.checked = !menuItem.checked;
104
+ }
105
+ }
106
+ window.electronTheiaCore.setMenu(this.menu);
107
+ }
108
+ }, 10)
109
+ );
110
+ });
107
111
  }
108
112
 
109
- async setMenuBar(): Promise<void> {
110
- await this.preferencesService.ready;
111
- const createdMenuBar = this.createElectronMenuBar();
112
- window.electronTheiaCore.setMenu(createdMenuBar);
113
+ doSetMenuBar(): void {
114
+ this.menu = this.createElectronMenuBar();
115
+ window.electronTheiaCore.setMenu(this.menu);
113
116
  }
114
117
 
115
118
  createElectronMenuBar(): MenuDto[] | undefined {
@@ -117,14 +120,12 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
117
120
  const maxWidget = document.getElementsByClassName(MAXIMIZED_CLASS);
118
121
  if (preference === 'visible' || (preference === 'classic' && maxWidget.length === 0)) {
119
122
  const menuModel = this.menuProvider.getMenu(MAIN_MENU_BAR);
120
- this._menu = this.fillMenuTemplate([], menuModel, [], { honorDisabled: false, rootMenuPath: MAIN_MENU_BAR }, false);
123
+ const menu = this.fillMenuTemplate([], menuModel, [], { honorDisabled: false, rootMenuPath: MAIN_MENU_BAR }, false);
121
124
  if (isOSX) {
122
- this._menu.unshift(this.createOSXMenu());
125
+ menu.unshift(this.createOSXMenu());
123
126
  }
124
- return this._menu;
127
+ return menu;
125
128
  }
126
- this._menu = undefined;
127
- // eslint-disable-next-line no-null/no-null
128
129
  return undefined;
129
130
  }
130
131
 
@@ -208,7 +209,7 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
208
209
  parentItems.push(menuItem);
209
210
 
210
211
  if (this.commandRegistry.getToggledHandler(commandId, ...args)) {
211
- this._toggledCommands.add(commandId);
212
+ this.toggledCommands.add(commandId);
212
213
  }
213
214
  }
214
215
  return parentItems;
@@ -273,11 +274,11 @@ export class ElectronMainMenuFactory extends BrowserMainMenuFactory {
273
274
  // We need to check if we can execute it.
274
275
  if (this.menuCommandExecutor.isEnabled(menuPath, cmd, ...args)) {
275
276
  await this.menuCommandExecutor.executeCommand(menuPath, cmd, ...args);
276
- if (this._menu && this.menuCommandExecutor.isVisible(menuPath, cmd, ...args)) {
277
- const item = this.findMenuById(this._menu, cmd);
277
+ if (this.menu && this.menuCommandExecutor.isVisible(menuPath, cmd, ...args)) {
278
+ const item = this.findMenuById(this.menu, cmd);
278
279
  if (item) {
279
280
  item.checked = this.menuCommandExecutor.isToggled(menuPath, cmd, ...args);
280
- window.electronTheiaCore.setMenu(this._menu);
281
+ window.electronTheiaCore.setMenu(this.menu);
281
282
  }
282
283
  }
283
284
  }
@@ -29,7 +29,6 @@ import { WindowService } from '../../browser/window/window-service';
29
29
  import { WindowTitleService } from '../../browser/window/window-title-service';
30
30
 
31
31
  import '../../../src/electron-browser/menu/electron-menu-style.css';
32
- import { MenuDto } from '../../electron-common/electron-api';
33
32
  import { ThemeService } from '../../browser/theming';
34
33
  import { ThemeChangeEvent } from '../../common/theme';
35
34
 
@@ -203,7 +202,7 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
203
202
  }
204
203
  }
205
204
 
206
- protected setMenu(app: FrontendApplication, electronMenu: MenuDto[] | undefined = this.factory.createElectronMenuBar()): void {
205
+ protected setMenu(app: FrontendApplication): void {
207
206
  if (!isOSX) {
208
207
  this.hideTopPanel(app);
209
208
  if (this.titleBarStyle === 'custom' && !this.menuBar) {
@@ -211,7 +210,7 @@ export class ElectronMenuContribution extends BrowserMenuBarContribution impleme
211
210
  return;
212
211
  }
213
212
  }
214
- window.electronTheiaCore.setMenu(electronMenu);
213
+ this.factory.setMenuBar();
215
214
  }
216
215
 
217
216
  protected createCustomTitleBar(app: FrontendApplication): void {
@@ -35,8 +35,8 @@ const { ipcRenderer, contextBridge } = require('electron');
35
35
 
36
36
  // a map of menuId => map<handler id => handler>
37
37
  const commandHandlers = new Map<number, Map<number, () => void>>();
38
- let nextHandlerId = 0;
39
- const mainMenuId = 0;
38
+ let nextHandlerId = 1;
39
+ const mainMenuId = 1;
40
40
  let nextMenuId = mainMenuId + 1;
41
41
 
42
42
  let openUrlHandler: ((url: string) => Promise<boolean>) | undefined;
@@ -23,6 +23,7 @@ import { EnvVariable, EnvVariablesServer } from '../../common/env-variables';
23
23
  import { isWindows } from '../../common/os';
24
24
  import { FileUri } from '../../common/file-uri';
25
25
  import { BackendApplicationPath } from '../backend-application';
26
+ import { BackendApplicationConfigProvider } from '../backend-application-config-provider';
26
27
 
27
28
  @injectable()
28
29
  export class EnvVariablesServerImpl implements EnvVariablesServer {
@@ -64,7 +65,7 @@ export class EnvVariablesServerImpl implements EnvVariablesServer {
64
65
  this.pathExistenceCache[userDataPath] = true;
65
66
  }
66
67
  } else {
67
- process.env.THEIA_CONFIG_DIR = join(homedir(), '.theia');
68
+ process.env.THEIA_CONFIG_DIR = join(homedir(), BackendApplicationConfigProvider.get().configurationFolder);
68
69
  }
69
70
  return FileUri.create(process.env.THEIA_CONFIG_DIR).toString();
70
71
  }
@@ -19,7 +19,7 @@ import { injectable } from 'inversify';
19
19
  import { LogLevel } from '../common/logger';
20
20
  import { CliContribution } from './cli';
21
21
  import * as fs from 'fs-extra';
22
- import * as nsfw from 'nsfw';
22
+ import { subscribe } from '@parcel/watcher';
23
23
  import { Event, Emitter } from '../common/event';
24
24
  import * as path from 'path';
25
25
 
@@ -89,13 +89,17 @@ export class LogLevelCliContribution implements CliContribution {
89
89
  }
90
90
  }
91
91
 
92
- protected watchLogConfigFile(filename: string): Promise<void> {
93
- return nsfw(filename, async (events: nsfw.FileChangeEvent[]) => {
92
+ protected async watchLogConfigFile(filename: string): Promise<void> {
93
+ await subscribe(filename, async (err, events) => {
94
+ if (err) {
95
+ console.log(`Error during log file watching ${filename}: ${err}`);
96
+ return;
97
+ }
94
98
  try {
95
99
  for (const event of events) {
96
- switch (event.action) {
97
- case nsfw.actions.CREATED:
98
- case nsfw.actions.MODIFIED:
100
+ switch (event.type) {
101
+ case 'create':
102
+ case 'update':
99
103
  await this.slurpLogConfigFile(filename);
100
104
  this.logConfigChangedEvent.fire(undefined);
101
105
  break;
@@ -104,8 +108,6 @@ export class LogLevelCliContribution implements CliContribution {
104
108
  } catch (e) {
105
109
  console.error(`Error reading log config file ${filename}: ${e}`);
106
110
  }
107
- }).then((watcher: nsfw.NSFW) => {
108
- watcher.start();
109
111
  });
110
112
  }
111
113
 
@@ -1,2 +0,0 @@
1
- import nsfw = require('nsfw');
2
- export = nsfw;
@@ -1 +0,0 @@
1
- module.exports = require('nsfw');