@theia/core 1.55.0-next.4 → 1.55.0-next.67

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 (89) hide show
  1. package/README.md +11 -11
  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 +147 -52
  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/tree/tree-view-welcome-widget.d.ts +17 -11
  37. package/lib/browser/tree/tree-view-welcome-widget.d.ts.map +1 -1
  38. package/lib/browser/tree/tree-view-welcome-widget.js +65 -34
  39. package/lib/browser/tree/tree-view-welcome-widget.js.map +1 -1
  40. package/lib/browser/widget-status-bar-service.d.ts +29 -0
  41. package/lib/browser/widget-status-bar-service.d.ts.map +1 -0
  42. package/lib/browser/widget-status-bar-service.js +81 -0
  43. package/lib/browser/widget-status-bar-service.js.map +1 -0
  44. package/lib/browser/widgets/react-widget.d.ts.map +1 -1
  45. package/lib/browser/widgets/react-widget.js +3 -1
  46. package/lib/browser/widgets/react-widget.js.map +1 -1
  47. package/lib/browser/widgets/widget.d.ts +1 -1
  48. package/lib/browser/widgets/widget.d.ts.map +1 -1
  49. package/lib/browser/widgets/widget.js +20 -6
  50. package/lib/browser/widgets/widget.js.map +1 -1
  51. package/lib/electron-browser/menu/electron-context-menu-renderer.d.ts.map +1 -1
  52. package/lib/electron-browser/menu/electron-context-menu-renderer.js +10 -2
  53. package/lib/electron-browser/menu/electron-context-menu-renderer.js.map +1 -1
  54. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts +5 -3
  55. package/lib/electron-browser/menu/electron-main-menu-factory.d.ts.map +1 -1
  56. package/lib/electron-browser/menu/electron-main-menu-factory.js +28 -28
  57. package/lib/electron-browser/menu/electron-main-menu-factory.js.map +1 -1
  58. package/lib/electron-browser/menu/electron-menu-contribution.d.ts +1 -2
  59. package/lib/electron-browser/menu/electron-menu-contribution.d.ts.map +1 -1
  60. package/lib/electron-browser/menu/electron-menu-contribution.js +2 -2
  61. package/lib/electron-browser/menu/electron-menu-contribution.js.map +1 -1
  62. package/lib/electron-browser/preload.js +2 -2
  63. package/lib/node/env-variables/env-variables-server.d.ts.map +1 -1
  64. package/lib/node/env-variables/env-variables-server.js +2 -1
  65. package/lib/node/env-variables/env-variables-server.js.map +1 -1
  66. package/lib/node/logger-cli-contribution.d.ts.map +1 -1
  67. package/lib/node/logger-cli-contribution.js +10 -8
  68. package/lib/node/logger-cli-contribution.js.map +1 -1
  69. package/package.json +10 -10
  70. package/shared/@parcel/watcher/index.d.ts +2 -0
  71. package/shared/@parcel/watcher/index.js +1 -0
  72. package/src/browser/core-preferences.ts +3 -1
  73. package/src/browser/dialogs/react-dialog.spec.tsx +47 -0
  74. package/src/browser/dialogs.ts +1 -1
  75. package/src/browser/frontend-application-module.ts +5 -0
  76. package/src/browser/index.ts +1 -0
  77. package/src/browser/style/tabs.css +55 -138
  78. package/src/browser/tree/tree-view-welcome-widget.tsx +82 -46
  79. package/src/browser/widget-status-bar-service.ts +84 -0
  80. package/src/browser/widgets/react-widget.tsx +3 -1
  81. package/src/browser/widgets/widget.ts +20 -5
  82. package/src/electron-browser/menu/electron-context-menu-renderer.ts +10 -2
  83. package/src/electron-browser/menu/electron-main-menu-factory.ts +32 -31
  84. package/src/electron-browser/menu/electron-menu-contribution.ts +2 -3
  85. package/src/electron-browser/preload.ts +2 -2
  86. package/src/node/env-variables/env-variables-server.ts +2 -1
  87. package/src/node/logger-cli-contribution.ts +10 -8
  88. package/shared/nsfw/index.d.ts +0 -2
  89. package/shared/nsfw/index.js +0 -1
@@ -19,28 +19,35 @@
19
19
  * Licensed under the MIT License. See License.txt in the project root for license information.
20
20
  *--------------------------------------------------------------------------------------------*/
21
21
  // some code is copied and modified from: https://github.com/microsoft/vscode/blob/573e5145ae3b50523925a6f6315d373e649d1b06/src/vs/base/common/linkedText.ts
22
+ // aligned the API and enablement behavior to https://github.com/microsoft/vscode/blob/c711bc9333ba339fde1a530de0094b3fa32f09de/src/vs/base/common/linkedText.ts
22
23
 
23
24
  import React = require('react');
24
25
  import { inject, injectable } from 'inversify';
25
- import { CommandRegistry } from '../../common';
26
+ import { URI as CodeUri } from 'vscode-uri';
27
+ import { CommandRegistry, DisposableCollection } from '../../common';
28
+ import URI from '../../common/uri';
26
29
  import { ContextKeyService } from '../context-key-service';
30
+ import { LabelIcon, LabelParser } from '../label-parser';
31
+ import { OpenerService, open } from '../opener-service';
32
+ import { codicon } from '../widgets';
33
+ import { WindowService } from '../window/window-service';
27
34
  import { TreeModel } from './tree-model';
28
35
  import { TreeWidget } from './tree-widget';
29
- import { WindowService } from '../window/window-service';
30
36
 
31
- interface ViewWelcome {
37
+ export interface ViewWelcome {
32
38
  readonly view: string;
33
39
  readonly content: string;
34
40
  readonly when?: string;
41
+ readonly enablement?: string;
35
42
  readonly order: number;
36
43
  }
37
44
 
38
- interface IItem {
45
+ export interface IItem {
39
46
  readonly welcomeInfo: ViewWelcome;
40
47
  visible: boolean;
41
48
  }
42
49
 
43
- interface ILink {
50
+ export interface ILink {
44
51
  readonly label: string;
45
52
  readonly href: string;
46
53
  readonly title?: string;
@@ -60,6 +67,14 @@ export class TreeViewWelcomeWidget extends TreeWidget {
60
67
  @inject(WindowService)
61
68
  protected readonly windowService: WindowService;
62
69
 
70
+ @inject(LabelParser)
71
+ protected readonly labelParser: LabelParser;
72
+
73
+ @inject(OpenerService)
74
+ protected readonly openerService: OpenerService;
75
+
76
+ protected readonly toDisposeBeforeUpdateViewWelcomeNodes = new DisposableCollection();
77
+
63
78
  protected viewWelcomeNodes: React.ReactNode[] = [];
64
79
  protected defaultItem: IItem | undefined;
65
80
  protected items: IItem[] = [];
@@ -130,13 +145,31 @@ export class TreeViewWelcomeWidget extends TreeWidget {
130
145
 
131
146
  protected updateViewWelcomeNodes(): void {
132
147
  this.viewWelcomeNodes = [];
148
+ this.toDisposeBeforeUpdateViewWelcomeNodes.dispose();
133
149
  const items = this.visibleItems.sort((a, b) => a.order - b.order);
134
150
 
135
- for (const [iIndex, { content }] of items.entries()) {
151
+ const enablementKeys: Set<string>[] = [];
152
+ // the plugin-view-registry will push the changes when there is a change in the `when` prop which controls the visibility
153
+ // this listener is to update the enablement of the components in the view welcome
154
+ this.toDisposeBeforeUpdateViewWelcomeNodes.push(
155
+ this.contextService.onDidChange(event => {
156
+ if (enablementKeys.some(keys => event.affects(keys))) {
157
+ this.updateViewWelcomeNodes();
158
+ this.update();
159
+ }
160
+ })
161
+ );
162
+ // Note: VS Code does not support the `renderSecondaryButtons` prop in welcome content either.
163
+ for (const { content, enablement } of items) {
164
+ const itemEnablementKeys = enablement
165
+ ? this.contextService.parseKeys(enablement)
166
+ : undefined;
167
+ if (itemEnablementKeys) {
168
+ enablementKeys.push(itemEnablementKeys);
169
+ }
136
170
  const lines = content.split('\n');
137
171
 
138
- for (let [lIndex, line] of lines.entries()) {
139
- const lineKey = `${iIndex}-${lIndex}`;
172
+ for (let line of lines) {
140
173
  line = line.trim();
141
174
 
142
175
  if (!line) {
@@ -146,42 +179,35 @@ export class TreeViewWelcomeWidget extends TreeWidget {
146
179
  const linkedTextItems = this.parseLinkedText(line);
147
180
 
148
181
  if (linkedTextItems.length === 1 && typeof linkedTextItems[0] !== 'string') {
182
+ const node = linkedTextItems[0];
149
183
  this.viewWelcomeNodes.push(
150
- this.renderButtonNode(linkedTextItems[0], lineKey)
184
+ this.renderButtonNode(
185
+ node,
186
+ this.viewWelcomeNodes.length,
187
+ enablement
188
+ )
151
189
  );
152
190
  } else {
153
- const linkedTextNodes: React.ReactNode[] = [];
154
-
155
- for (const [nIndex, node] of linkedTextItems.entries()) {
156
- const linkedTextKey = `${lineKey}-${nIndex}`;
157
-
158
- if (typeof node === 'string') {
159
- linkedTextNodes.push(
160
- this.renderTextNode(node, linkedTextKey)
161
- );
162
- } else {
163
- linkedTextNodes.push(
164
- this.renderCommandLinkNode(node, linkedTextKey)
165
- );
166
- }
167
- }
191
+ const renderNode = (item: LinkedTextItem, index: number) => typeof item == 'string'
192
+ ? this.renderTextNode(item, index)
193
+ : this.renderLinkNode(item, index, enablement);
168
194
 
169
195
  this.viewWelcomeNodes.push(
170
- <div key={`line-${lineKey}`}>
171
- {...linkedTextNodes}
172
- </div>
196
+ <p key={`p-${this.viewWelcomeNodes.length}`}>
197
+ {...linkedTextItems.flatMap(renderNode)}
198
+ </p>
173
199
  );
174
200
  }
175
201
  }
176
202
  }
177
203
  }
178
204
 
179
- protected renderButtonNode(node: ILink, lineKey: string): React.ReactNode {
205
+ protected renderButtonNode(node: ILink, lineKey: string | number, enablement: string | undefined): React.ReactNode {
180
206
  return (
181
207
  <div key={`line-${lineKey}`} className='theia-WelcomeViewButtonWrapper'>
182
208
  <button title={node.title}
183
209
  className='theia-button theia-WelcomeViewButton'
184
- disabled={!this.isEnabledClick(node.href)}
210
+ disabled={!this.isEnabledClick(enablement)}
185
211
  onClick={e => this.openLinkOrCommand(e, node.href)}>
186
212
  {node.label}
187
213
  </button>
@@ -189,14 +215,22 @@ export class TreeViewWelcomeWidget extends TreeWidget {
189
215
  );
190
216
  }
191
217
 
192
- protected renderTextNode(node: string, textKey: string): React.ReactNode {
193
- return <span key={`text-${textKey}`}>{node}</span>;
218
+ protected renderTextNode(node: string, textKey: string | number): React.ReactNode {
219
+ return <span key={`text-${textKey}`}>
220
+ {this.labelParser.parse(node)
221
+ .map((segment, index) =>
222
+ LabelIcon.is(segment)
223
+ ? <span
224
+ key={index}
225
+ className={codicon(segment.name)}
226
+ />
227
+ : <span key={index}>{segment}</span>)}</span>;
194
228
  }
195
229
 
196
- protected renderCommandLinkNode(node: ILink, linkKey: string): React.ReactNode {
230
+ protected renderLinkNode(node: ILink, linkKey: string | number, enablement: string | undefined): React.ReactNode {
197
231
  return (
198
232
  <a key={`link-${linkKey}`}
199
- className={this.getLinkClassName(node.href)}
233
+ className={this.getLinkClassName(node.href, enablement)}
200
234
  title={node.title || ''}
201
235
  onClick={e => this.openLinkOrCommand(e, node.href)}>
202
236
  {node.label}
@@ -204,37 +238,39 @@ export class TreeViewWelcomeWidget extends TreeWidget {
204
238
  );
205
239
  }
206
240
 
207
- protected getLinkClassName(href: string): string {
241
+ protected getLinkClassName(href: string, enablement: string | undefined): string {
208
242
  const classNames = ['theia-WelcomeViewCommandLink'];
209
- if (!this.isEnabledClick(href)) {
243
+ // Only command-backed links can be disabled. All other, https:, file: remain enabled
244
+ if (href.startsWith('command:') && !this.isEnabledClick(enablement)) {
210
245
  classNames.push('disabled');
211
246
  }
212
247
  return classNames.join(' ');
213
248
  }
214
249
 
215
- protected isEnabledClick(href: string): boolean {
216
- if (href.startsWith('command:')) {
217
- const command = href.replace('command:', '');
218
- return this.commands.isEnabled(command);
219
- }
220
- return true;
250
+ protected isEnabledClick(enablement: string | undefined): boolean {
251
+ return typeof enablement === 'string'
252
+ ? this.contextService.match(enablement)
253
+ : true;
221
254
  }
222
255
 
223
- protected openLinkOrCommand = (event: React.MouseEvent, href: string): void => {
256
+ protected openLinkOrCommand = (event: React.MouseEvent, value: string): void => {
224
257
  event.stopPropagation();
225
258
 
226
- if (href.startsWith('command:')) {
227
- const command = href.replace('command:', '');
259
+ if (value.startsWith('command:')) {
260
+ const command = value.replace('command:', '');
228
261
  this.commands.executeCommand(command);
262
+ } else if (value.startsWith('file:')) {
263
+ const uri = value.replace('file:', '');
264
+ open(this.openerService, new URI(CodeUri.file(uri).toString()));
229
265
  } else {
230
- this.windowService.openNewWindow(href, { external: true });
266
+ this.windowService.openNewWindow(value, { external: true });
231
267
  }
232
268
  };
233
269
 
234
270
  protected parseLinkedText(text: string): LinkedTextItem[] {
235
271
  const result: LinkedTextItem[] = [];
236
272
 
237
- const linkRegex = /\[([^\]]+)\]\(((?:https?:\/\/|command:)[^\)\s]+)(?: ("|')([^\3]+)(\3))?\)/gi;
273
+ const linkRegex = /\[([^\]]+)\]\(((?:https?:\/\/|command:|file:)[^\)\s]+)(?: (["'])(.+?)(\3))?\)/gi;
238
274
  let index = 0;
239
275
  let match: RegExpExecArray | null;
240
276
 
@@ -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
  /**
@@ -24,6 +24,7 @@ import { KeyCode, KeysOrKeyCodes } from '../keyboard/keys';
24
24
 
25
25
  import PerfectScrollbar from 'perfect-scrollbar';
26
26
  import { PreviewableWidget } from '../widgets/previewable-widget';
27
+ import { Slot } from '@phosphor/signaling';
27
28
 
28
29
  decorate(injectable(), Widget);
29
30
  decorate(unmanaged(), Widget, 0);
@@ -364,23 +365,37 @@ function waitForVisible(widget: Widget, visible: boolean, attached?: boolean): P
364
365
  });
365
366
  }
366
367
 
368
+ const pinnedTitles = new Map<Title<Widget>, [boolean, Slot<Widget, void>]>();
369
+
367
370
  export function isPinned(title: Title<Widget>): boolean {
368
371
  const pinnedState = !title.closable && title.className.includes(PINNED_CLASS);
369
372
  return pinnedState;
370
373
  }
371
374
 
372
- export function unpin(title: Title<Widget>): void {
373
- title.closable = true;
374
- title.className = title.className.replace(PINNED_CLASS, '').trim();
375
- }
376
-
377
375
  export function pin(title: Title<Widget>): void {
376
+ const l = () => {
377
+ pinnedTitles.delete(title);
378
+ };
379
+ pinnedTitles.set(title, [title.closable, l]);
380
+ title.owner.disposed.connect(l);
378
381
  title.closable = false;
379
382
  if (!title.className.includes(PINNED_CLASS)) {
380
383
  title.className += ` ${PINNED_CLASS}`;
381
384
  }
382
385
  }
383
386
 
387
+ export function unpin(title: Title<Widget>): void {
388
+ const entry = pinnedTitles.get(title);
389
+ if (entry) {
390
+ title.owner.disposed.disconnect(entry[1]);
391
+ title.closable = entry[0];
392
+ pinnedTitles.delete(title);
393
+ } else {
394
+ title.closable = true;
395
+ }
396
+ title.className = title.className.replace(PINNED_CLASS, '').trim();
397
+ }
398
+
384
399
  export function isLocked(title: Title<Widget>): boolean {
385
400
  return title.className.includes(LOCKED_CLASS);
386
401
  }
@@ -23,7 +23,7 @@ import {
23
23
  import { ElectronMainMenuFactory } from './electron-main-menu-factory';
24
24
  import { ContextMenuContext } from '../../browser/menu/context-menu-context';
25
25
  import { MenuPath, MenuContribution, MenuModelRegistry } from '../../common';
26
- import { BrowserContextMenuRenderer } from '../../browser/menu/browser-context-menu-renderer';
26
+ import { BrowserContextMenuAccess, BrowserContextMenuRenderer } from '../../browser/menu/browser-context-menu-renderer';
27
27
 
28
28
  export class ElectronContextMenuAccess extends ContextMenuAccess {
29
29
  constructor(readonly menuHandle: Promise<number>) {
@@ -115,7 +115,15 @@ export class ElectronContextMenuRenderer extends BrowserContextMenuRenderer {
115
115
  this.context.resetAltPressed();
116
116
  return new ElectronContextMenuAccess(menuHandle);
117
117
  } else {
118
- return super.doRender(options);
118
+ const menuAccess = super.doRender(options);
119
+ const node = (menuAccess as BrowserContextMenuAccess).menu.node;
120
+ const topPanelHeight = document.getElementById('theia-top-panel')?.clientHeight ?? 0;
121
+ // ensure the context menu is not displayed outside of the main area
122
+ if (node.style.top && parseInt(node.style.top.substring(0, node.style.top.length - 2)) < topPanelHeight) {
123
+ node.style.top = `${topPanelHeight}px`;
124
+ node.style.maxHeight = `calc(${node.style.maxHeight} - ${topPanelHeight}px)`;
125
+ }
126
+ return menuAccess;
119
127
  }
120
128
  }
121
129
 
@@ -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');