@theia/core 1.56.0 → 1.57.0-next.136
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.
- package/README.md +43 -39
- package/i18n/nls.cs.json +23 -17
- package/i18n/nls.de.json +23 -17
- package/i18n/nls.es.json +23 -17
- package/i18n/nls.fr.json +23 -17
- package/i18n/nls.hu.json +23 -17
- package/i18n/nls.it.json +23 -17
- package/i18n/nls.ja.json +23 -17
- package/i18n/nls.json +24 -18
- package/i18n/nls.ko.json +23 -17
- package/i18n/nls.pl.json +23 -17
- package/i18n/nls.pt-br.json +23 -17
- package/i18n/nls.ru.json +23 -17
- package/i18n/nls.tr.json +23 -17
- package/i18n/nls.zh-cn.json +23 -17
- package/i18n/nls.zh-tw.json +23 -17
- package/lib/browser/catalog.json +367 -50
- package/lib/browser/common-frontend-contribution.d.ts +1 -1
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +23 -8
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/dialogs.d.ts +1 -0
- package/lib/browser/dialogs.d.ts.map +1 -1
- package/lib/browser/dialogs.js +6 -0
- package/lib/browser/dialogs.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +1 -0
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/hover-service.d.ts.map +1 -1
- package/lib/browser/hover-service.js +12 -4
- package/lib/browser/hover-service.js.map +1 -1
- package/lib/browser/json-schema-store.d.ts +12 -1
- package/lib/browser/json-schema-store.d.ts.map +1 -1
- package/lib/browser/json-schema-store.js +31 -1
- package/lib/browser/json-schema-store.js.map +1 -1
- package/lib/browser/keybinding.js +3 -3
- package/lib/browser/keybinding.js.map +1 -1
- package/lib/browser/logger-frontend-module.d.ts.map +1 -1
- package/lib/browser/logger-frontend-module.js +2 -3
- package/lib/browser/logger-frontend-module.js.map +1 -1
- package/lib/browser/progress-status-bar-item.d.ts +1 -1
- package/lib/browser/progress-status-bar-item.d.ts.map +1 -1
- package/lib/browser/saveable.d.ts +1 -0
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +3 -0
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/secondary-window-handler.d.ts.map +1 -1
- package/lib/browser/secondary-window-handler.js +1 -0
- package/lib/browser/secondary-window-handler.js.map +1 -1
- package/lib/browser/shell/application-shell.d.ts +2 -1
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +24 -10
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/test/jsdom.d.ts.map +1 -1
- package/lib/browser/test/jsdom.js +6 -1
- package/lib/browser/test/jsdom.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +6 -2
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +4 -4
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/window/browser-window-module.d.ts.map +1 -1
- package/lib/browser/window/browser-window-module.js +3 -0
- package/lib/browser/window/browser-window-module.js.map +1 -1
- package/lib/browser/window/default-secondary-window-service.d.ts +5 -0
- package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
- package/lib/browser/window/default-secondary-window-service.js +6 -0
- package/lib/browser/window/default-secondary-window-service.js.map +1 -1
- package/lib/browser/window/secondary-window-service.d.ts +3 -0
- package/lib/browser/window/secondary-window-service.d.ts.map +1 -1
- package/lib/browser/window/secondary-window-service.js.map +1 -1
- package/lib/browser/window/window-title-service.d.ts +6 -0
- package/lib/browser/window/window-title-service.d.ts.map +1 -1
- package/lib/browser/window/window-title-service.js +12 -1
- package/lib/browser/window/window-title-service.js.map +1 -1
- package/lib/common/encoding-service.d.ts +1 -0
- package/lib/common/encoding-service.d.ts.map +1 -1
- package/lib/common/logger-binding.d.ts +3 -0
- package/lib/common/logger-binding.d.ts.map +1 -0
- package/lib/common/logger-binding.js +36 -0
- package/lib/common/logger-binding.js.map +1 -0
- package/lib/common/logger-protocol.d.ts +1 -1
- package/lib/common/logger-protocol.d.ts.map +1 -1
- package/lib/common/logger-protocol.js +3 -1
- package/lib/common/logger-protocol.js.map +1 -1
- package/lib/common/logger.d.ts +1 -0
- package/lib/common/logger.d.ts.map +1 -1
- package/lib/common/logger.js +12 -1
- package/lib/common/logger.js.map +1 -1
- package/lib/common/resource.d.ts +2 -0
- package/lib/common/resource.d.ts.map +1 -1
- package/lib/common/resource.js +1 -0
- package/lib/common/resource.js.map +1 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +1 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js +7 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js.map +1 -1
- package/lib/electron-browser/window/electron-window-module.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-module.js +3 -0
- package/lib/electron-browser/window/electron-window-module.js.map +1 -1
- package/lib/electron-main/electron-main-application.js +12 -13
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +11 -3
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/lib/node/console-logger-server.d.ts +5 -1
- package/lib/node/console-logger-server.d.ts.map +1 -1
- package/lib/node/console-logger-server.js +18 -4
- package/lib/node/console-logger-server.js.map +1 -1
- package/lib/node/logger-backend-module.d.ts.map +1 -1
- package/lib/node/logger-backend-module.js +2 -3
- package/lib/node/logger-backend-module.js.map +1 -1
- package/lib/node/logger-cli-contribution.d.ts +2 -0
- package/lib/node/logger-cli-contribution.d.ts.map +1 -1
- package/lib/node/logger-cli-contribution.js +40 -7
- package/lib/node/logger-cli-contribution.js.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.js +7 -1
- package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
- package/lib/node/messaging/websocket-endpoint.d.ts +1 -1
- package/lib/node/messaging/websocket-endpoint.d.ts.map +1 -1
- package/package.json +12 -12
- package/src/browser/common-frontend-contribution.ts +23 -8
- package/src/browser/dialogs.ts +7 -0
- package/src/browser/frontend-application-module.ts +2 -1
- package/src/browser/hover-service.ts +12 -5
- package/src/browser/json-schema-store.ts +35 -1
- package/src/browser/keybinding.ts +3 -3
- package/src/browser/logger-frontend-module.ts +3 -4
- package/src/browser/saveable.ts +3 -0
- package/src/browser/secondary-window-handler.ts +1 -0
- package/src/browser/shell/application-shell.ts +27 -11
- package/src/browser/style/dockpanel.css +10 -0
- package/src/browser/test/jsdom.ts +6 -1
- package/src/browser/tree/tree-widget.tsx +10 -4
- package/src/browser/window/browser-window-module.ts +3 -0
- package/src/browser/window/default-secondary-window-service.ts +7 -1
- package/src/browser/window/secondary-window-service.ts +3 -0
- package/src/browser/window/window-title-service.ts +14 -1
- package/src/common/logger-binding.ts +34 -0
- package/src/common/logger-protocol.ts +4 -2
- package/src/common/logger.ts +10 -1
- package/src/common/resource.ts +4 -0
- package/src/electron-browser/messaging/electron-local-ws-connection-source.ts +5 -0
- package/src/electron-browser/window/electron-window-module.ts +3 -0
- package/src/electron-main/electron-main-application.ts +10 -10
- package/src/electron-main/theia-electron-window.ts +11 -3
- package/src/node/console-logger-server.ts +22 -2
- package/src/node/logger-backend-module.ts +3 -4
- package/src/node/logger-cli-contribution.ts +43 -7
- package/src/node/messaging/test/test-web-socket-channel.ts +6 -1
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
} from '@phosphor/widgets';
|
|
23
23
|
import { Message } from '@phosphor/messaging';
|
|
24
24
|
import { IDragEvent } from '@phosphor/dragdrop';
|
|
25
|
-
import { RecursivePartial, Event as CommonEvent, DisposableCollection, Disposable, environment, isObject } from '../../common';
|
|
25
|
+
import { RecursivePartial, Event as CommonEvent, DisposableCollection, Disposable, environment, isObject, UntitledResourceResolver, UNTITLED_SCHEME } from '../../common';
|
|
26
26
|
import { animationFrame } from '../browser';
|
|
27
27
|
import { Saveable, SaveableWidget, SaveOptions } from '../saveable';
|
|
28
28
|
import { StatusBarImpl, StatusBarEntry, StatusBarAlignment } from '../status-bar/status-bar';
|
|
@@ -232,6 +232,9 @@ export class ApplicationShell extends Widget {
|
|
|
232
232
|
@inject(OpenerService)
|
|
233
233
|
protected readonly openerService: OpenerService;
|
|
234
234
|
|
|
235
|
+
@inject(UntitledResourceResolver)
|
|
236
|
+
protected readonly untitledResourceResolver: UntitledResourceResolver;
|
|
237
|
+
|
|
235
238
|
protected readonly onDidAddWidgetEmitter = new Emitter<Widget>();
|
|
236
239
|
readonly onDidAddWidget = this.onDidAddWidgetEmitter.event;
|
|
237
240
|
protected fireDidAddWidget(widget: Widget): void {
|
|
@@ -323,6 +326,7 @@ export class ApplicationShell extends Widget {
|
|
|
323
326
|
|
|
324
327
|
protected initializeShell(): void {
|
|
325
328
|
this.addClass(APPLICATION_SHELL_CLASS);
|
|
329
|
+
this.addClass('monaco-workbench'); // needed for compatility with VSCode styles
|
|
326
330
|
this.id = 'theia-app-shell';
|
|
327
331
|
|
|
328
332
|
this.mainPanel = this.createMainPanel();
|
|
@@ -572,16 +576,28 @@ export class ApplicationShell extends Widget {
|
|
|
572
576
|
uris.forEach(openUri);
|
|
573
577
|
} else if (event.dataTransfer.files?.length > 0) {
|
|
574
578
|
// the files were dragged from the outside the workspace
|
|
575
|
-
Array.from(event.dataTransfer.files).forEach(file => {
|
|
576
|
-
if (
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
579
|
+
Array.from(event.dataTransfer.files).forEach(async file => {
|
|
580
|
+
if (environment.electron.is()) {
|
|
581
|
+
if (file.path) {
|
|
582
|
+
const fileUri = URI.fromFilePath(file.path);
|
|
583
|
+
openUri(fileUri);
|
|
584
|
+
}
|
|
585
|
+
} else {
|
|
586
|
+
const fileContent = await file.text();
|
|
587
|
+
const fileName = file.name;
|
|
588
|
+
const uri = new URI(`${UNTITLED_SCHEME}:/${fileName}`);
|
|
589
|
+
// Only create a new untitled resource if it doesn't already exist.
|
|
590
|
+
// VS Code does the same thing, and there's not really a better solution,
|
|
591
|
+
// since we want to keep the original name of the file,
|
|
592
|
+
// but also to prevent duplicates of the same file.
|
|
593
|
+
if (!this.untitledResourceResolver.has(uri)) {
|
|
594
|
+
const untitledResource = await this.untitledResourceResolver.createUntitledResource(
|
|
595
|
+
fileContent,
|
|
596
|
+
undefined,
|
|
597
|
+
new URI(`${UNTITLED_SCHEME}:/${fileName}`)
|
|
598
|
+
);
|
|
599
|
+
openUri(untitledResource.uri);
|
|
600
|
+
}
|
|
585
601
|
}
|
|
586
602
|
});
|
|
587
603
|
}
|
|
@@ -14,6 +14,16 @@
|
|
|
14
14
|
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
********************************************************************************/
|
|
16
16
|
|
|
17
|
+
/*
|
|
18
|
+
* phosphor.js sets the z-index of its panels to 0, which causes overlay issues
|
|
19
|
+
* See also https://github.com/eclipse-theia/theia/issues/14290
|
|
20
|
+
*/
|
|
21
|
+
.p-SplitPanel-child,
|
|
22
|
+
.p-DockPanel,
|
|
23
|
+
.p-DockPanel-widget {
|
|
24
|
+
z-index: initial;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
.p-DockPanel.p-SplitPanel-child {
|
|
18
28
|
padding: 0px;
|
|
19
29
|
}
|
|
@@ -43,7 +43,12 @@ export function enableJSDOM(): () => void {
|
|
|
43
43
|
});
|
|
44
44
|
(global as any)['document'] = dom.window.document;
|
|
45
45
|
(global as any)['window'] = dom.window;
|
|
46
|
-
|
|
46
|
+
try {
|
|
47
|
+
(global as any)['navigator'] = { userAgent: 'node.js', platform: 'Mac' };
|
|
48
|
+
|
|
49
|
+
} catch (e) {
|
|
50
|
+
// node 21+ already has a navigator object
|
|
51
|
+
}
|
|
47
52
|
|
|
48
53
|
const toCleanup: string[] = [];
|
|
49
54
|
Object.getOwnPropertyNames((dom.window as any)).forEach(property => {
|
|
@@ -32,7 +32,7 @@ import { notEmpty } from '../../common/objects';
|
|
|
32
32
|
import { isOSX } from '../../common/os';
|
|
33
33
|
import { ReactWidget } from '../widgets/react-widget';
|
|
34
34
|
import * as React from 'react';
|
|
35
|
-
import { Virtuoso, VirtuosoHandle } from 'react-virtuoso';
|
|
35
|
+
import { Virtuoso, VirtuosoHandle, VirtuosoProps } from 'react-virtuoso';
|
|
36
36
|
import { TopDownTreeIterator } from './tree-iterator';
|
|
37
37
|
import { SearchBox, SearchBoxFactory, SearchBoxProps } from './search-box';
|
|
38
38
|
import { TreeSearch } from './tree-search';
|
|
@@ -111,6 +111,10 @@ export interface TreeProps {
|
|
|
111
111
|
*/
|
|
112
112
|
readonly expandOnlyOnExpansionToggleClick?: boolean;
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* Props that are forwarded to the virtuoso list rendered. Defaults to `{}`.
|
|
116
|
+
*/
|
|
117
|
+
readonly viewProps?: VirtuosoProps<unknown, unknown>;
|
|
114
118
|
}
|
|
115
119
|
|
|
116
120
|
/**
|
|
@@ -498,6 +502,7 @@ export class TreeWidget extends ReactWidget implements StatefulWidget {
|
|
|
498
502
|
rows={rows}
|
|
499
503
|
renderNodeRow={this.renderNodeRow}
|
|
500
504
|
scrollToRow={this.scrollToRow}
|
|
505
|
+
{...this.props.viewProps}
|
|
501
506
|
/>;
|
|
502
507
|
}
|
|
503
508
|
// eslint-disable-next-line no-null/no-null
|
|
@@ -1546,7 +1551,7 @@ export namespace TreeWidget {
|
|
|
1546
1551
|
/**
|
|
1547
1552
|
* Representation of the tree view properties.
|
|
1548
1553
|
*/
|
|
1549
|
-
export interface ViewProps {
|
|
1554
|
+
export interface ViewProps extends VirtuosoProps<unknown, unknown> {
|
|
1550
1555
|
/**
|
|
1551
1556
|
* The width property.
|
|
1552
1557
|
*/
|
|
@@ -1568,7 +1573,7 @@ export namespace TreeWidget {
|
|
|
1568
1573
|
export class View extends React.Component<ViewProps> {
|
|
1569
1574
|
list: VirtuosoHandle | undefined;
|
|
1570
1575
|
override render(): React.ReactNode {
|
|
1571
|
-
const { rows, width, height, scrollToRow } = this.props;
|
|
1576
|
+
const { rows, width, height, scrollToRow, renderNodeRow, ...other } = this.props;
|
|
1572
1577
|
return <Virtuoso
|
|
1573
1578
|
ref={list => {
|
|
1574
1579
|
this.list = (list || undefined);
|
|
@@ -1580,11 +1585,12 @@ export namespace TreeWidget {
|
|
|
1580
1585
|
}
|
|
1581
1586
|
}}
|
|
1582
1587
|
totalCount={rows.length}
|
|
1583
|
-
itemContent={index =>
|
|
1588
|
+
itemContent={index => renderNodeRow(rows[index])}
|
|
1584
1589
|
width={width}
|
|
1585
1590
|
height={height}
|
|
1586
1591
|
// This is a pixel value, it will scan 200px to the top and bottom of the current view
|
|
1587
1592
|
overscan={500}
|
|
1593
|
+
{...other}
|
|
1588
1594
|
/>;
|
|
1589
1595
|
}
|
|
1590
1596
|
}
|
|
@@ -22,6 +22,8 @@ import { ClipboardService } from '../clipboard-service';
|
|
|
22
22
|
import { BrowserClipboardService } from '../browser-clipboard-service';
|
|
23
23
|
import { SecondaryWindowService } from './secondary-window-service';
|
|
24
24
|
import { DefaultSecondaryWindowService } from './default-secondary-window-service';
|
|
25
|
+
import { bindContributionProvider } from '../../common';
|
|
26
|
+
import { WindowTitleContribution } from './window-title-service';
|
|
25
27
|
|
|
26
28
|
export default new ContainerModule(bind => {
|
|
27
29
|
bind(DefaultWindowService).toSelf().inSingletonScope();
|
|
@@ -29,4 +31,5 @@ export default new ContainerModule(bind => {
|
|
|
29
31
|
bind(FrontendApplicationContribution).toService(DefaultWindowService);
|
|
30
32
|
bind(ClipboardService).to(BrowserClipboardService).inSingletonScope();
|
|
31
33
|
bind(SecondaryWindowService).to(DefaultSecondaryWindowService).inSingletonScope();
|
|
34
|
+
bindContributionProvider(bind, WindowTitleContribution);
|
|
32
35
|
});
|
|
@@ -20,11 +20,15 @@ import { ExtractableWidget } from '../widgets';
|
|
|
20
20
|
import { ApplicationShell } from '../shell';
|
|
21
21
|
import { Saveable } from '../saveable';
|
|
22
22
|
import { PreferenceService } from '../preferences';
|
|
23
|
-
import { environment } from '../../common';
|
|
23
|
+
import { Emitter, environment, Event } from '../../common';
|
|
24
24
|
import { SaveableService } from '../saveable-service';
|
|
25
25
|
|
|
26
26
|
@injectable()
|
|
27
27
|
export class DefaultSecondaryWindowService implements SecondaryWindowService {
|
|
28
|
+
protected readonly onWindowOpenedEmitter = new Emitter<Window>;
|
|
29
|
+
readonly onWindowOpened: Event<Window> = this.onWindowOpenedEmitter.event;
|
|
30
|
+
protected readonly onWindowClosedEmitter = new Emitter<Window>;
|
|
31
|
+
readonly onWindowClosed: Event<Window> = this.onWindowClosedEmitter.event;
|
|
28
32
|
// secondary-window.html is part of Theia's generated code. It is generated by dev-packages/application-manager/src/generator/frontend-generator.ts
|
|
29
33
|
protected static SECONDARY_WINDOW_URL = 'secondary-window.html';
|
|
30
34
|
|
|
@@ -94,6 +98,7 @@ export class DefaultSecondaryWindowService implements SecondaryWindowService {
|
|
|
94
98
|
const newWindow = window.open(DefaultSecondaryWindowService.SECONDARY_WINDOW_URL, this.nextWindowId(), options) ?? undefined;
|
|
95
99
|
if (newWindow) {
|
|
96
100
|
this.secondaryWindows.push(newWindow);
|
|
101
|
+
this.onWindowOpenedEmitter.fire(newWindow);
|
|
97
102
|
newWindow.addEventListener('DOMContentLoaded', () => {
|
|
98
103
|
newWindow.addEventListener('beforeunload', evt => {
|
|
99
104
|
const saveable = Saveable.get(widget);
|
|
@@ -113,6 +118,7 @@ export class DefaultSecondaryWindowService implements SecondaryWindowService {
|
|
|
113
118
|
|
|
114
119
|
const extIndex = this.secondaryWindows.indexOf(newWindow);
|
|
115
120
|
if (extIndex > -1) {
|
|
121
|
+
this.onWindowClosedEmitter.fire(newWindow);
|
|
116
122
|
this.secondaryWindows.splice(extIndex, 1);
|
|
117
123
|
};
|
|
118
124
|
});
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
+
import { Event } from '../../common';
|
|
17
18
|
import { ApplicationShell } from '../shell';
|
|
18
19
|
import { ExtractableWidget } from '../widgets';
|
|
19
20
|
|
|
@@ -33,6 +34,8 @@ export interface SecondaryWindowService {
|
|
|
33
34
|
* @returns the created window or `undefined` if it could not be created
|
|
34
35
|
*/
|
|
35
36
|
createSecondaryWindow(widget: ExtractableWidget, shell: ApplicationShell): Window | undefined;
|
|
37
|
+
readonly onWindowOpened: Event<Window>;
|
|
38
|
+
readonly onWindowClosed: Event<Window>;
|
|
36
39
|
|
|
37
40
|
/** Handles focussing the given secondary window in the browser and on Electron. */
|
|
38
41
|
focus(win: Window): void;
|
|
@@ -14,11 +14,17 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { inject, injectable, postConstruct } from 'inversify';
|
|
17
|
+
import { inject, injectable, named, postConstruct } from 'inversify';
|
|
18
18
|
import { escapeRegExpCharacters } from '../../common/strings';
|
|
19
19
|
import { Emitter, Event } from '../../common/event';
|
|
20
20
|
import { CorePreferences } from '../core-preferences';
|
|
21
21
|
import { FrontendApplicationConfigProvider } from '../frontend-application-config-provider';
|
|
22
|
+
import { ContributionProvider } from '../../common';
|
|
23
|
+
|
|
24
|
+
export const WindowTitleContribution = Symbol('WindowTitleAddOnContribution');
|
|
25
|
+
export interface WindowTitleContribution {
|
|
26
|
+
enhanceTitle(title: string, parts: Map<string, string | undefined>): string;
|
|
27
|
+
}
|
|
22
28
|
|
|
23
29
|
export const InitialWindowTitleParts = {
|
|
24
30
|
activeEditorShort: undefined,
|
|
@@ -43,6 +49,9 @@ export class WindowTitleService {
|
|
|
43
49
|
@inject(CorePreferences)
|
|
44
50
|
protected readonly preferences: CorePreferences;
|
|
45
51
|
|
|
52
|
+
@inject(ContributionProvider) @named(WindowTitleContribution)
|
|
53
|
+
protected readonly titleContributions: ContributionProvider<WindowTitleContribution>;
|
|
54
|
+
|
|
46
55
|
protected _title = '';
|
|
47
56
|
protected titleTemplate?: string;
|
|
48
57
|
|
|
@@ -95,6 +104,10 @@ export class WindowTitleService {
|
|
|
95
104
|
}
|
|
96
105
|
const separatedTitle = title.split('${separator}').filter(e => e.trim().length > 0);
|
|
97
106
|
this._title = separatedTitle.join(this.separator);
|
|
107
|
+
const contributions = this.titleContributions.getContributions();
|
|
108
|
+
for (const contribution of contributions) {
|
|
109
|
+
this._title = contribution.enhanceTitle(this.title, this.titleParts);
|
|
110
|
+
}
|
|
98
111
|
}
|
|
99
112
|
const developmentHost = this.titleParts.get('developmentHost');
|
|
100
113
|
if (developmentHost) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2025 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 { interfaces } from 'inversify';
|
|
18
|
+
import { ILogger, Logger, LoggerName, rootLoggerName } from './logger';
|
|
19
|
+
import { LoggerWatcher } from './logger-watcher';
|
|
20
|
+
|
|
21
|
+
export function bindCommonLogger(bind: interfaces.Bind): void {
|
|
22
|
+
bind(LoggerName).toConstantValue(rootLoggerName);
|
|
23
|
+
bind(ILogger).to(Logger).inSingletonScope().when(request => getName(request) === undefined);
|
|
24
|
+
bind(ILogger).toDynamicValue(ctx => {
|
|
25
|
+
const logger = ctx.container.get<ILogger>(ILogger);
|
|
26
|
+
return logger.child(getName(ctx.currentRequest)!);
|
|
27
|
+
}).when(request => getName(request) !== undefined);
|
|
28
|
+
bind(LoggerWatcher).toSelf().inSingletonScope();
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function getName(request: interfaces.Request): string | undefined {
|
|
32
|
+
const named = request.target.metadata.find(e => e.key === 'named');
|
|
33
|
+
return named ? named.value?.toString() : undefined;
|
|
34
|
+
}
|
|
@@ -110,10 +110,12 @@ export namespace ConsoleLogger {
|
|
|
110
110
|
console.trace = consoles.get(LogLevel.TRACE)!;
|
|
111
111
|
console.log = originalConsoleLog;
|
|
112
112
|
}
|
|
113
|
-
export function log(name: string, logLevel: number, message: string, params: any[]):
|
|
113
|
+
export function log(name: string, logLevel: number, message: string, params: any[]): string {
|
|
114
114
|
const console = consoles.get(logLevel) || originalConsoleLog;
|
|
115
115
|
const severity = (LogLevel.strings.get(logLevel) || 'unknown').toUpperCase();
|
|
116
116
|
const now = new Date();
|
|
117
|
-
|
|
117
|
+
const formattedMessage = `${now.toISOString()} ${name} ${severity} ${message}`;
|
|
118
|
+
console(formattedMessage, ...params);
|
|
119
|
+
return formattedMessage;
|
|
118
120
|
}
|
|
119
121
|
}
|
package/src/common/logger.ts
CHANGED
|
@@ -240,6 +240,8 @@ export class Logger implements ILogger {
|
|
|
240
240
|
@inject(LoggerFactory) protected readonly factory: LoggerFactory;
|
|
241
241
|
@inject(LoggerName) protected name: string;
|
|
242
242
|
|
|
243
|
+
protected cache = new Map<string, ILogger>();
|
|
244
|
+
|
|
243
245
|
@postConstruct()
|
|
244
246
|
protected init(): void {
|
|
245
247
|
if (this.name !== rootLoggerName) {
|
|
@@ -384,6 +386,13 @@ export class Logger implements ILogger {
|
|
|
384
386
|
}
|
|
385
387
|
|
|
386
388
|
child(name: string): ILogger {
|
|
387
|
-
|
|
389
|
+
const existing = this.cache.get(name);
|
|
390
|
+
if (existing) {
|
|
391
|
+
return existing;
|
|
392
|
+
} else {
|
|
393
|
+
const child = this.factory(name);
|
|
394
|
+
this.cache.set(name, child);
|
|
395
|
+
return child;
|
|
396
|
+
}
|
|
388
397
|
}
|
|
389
398
|
}
|
package/src/common/resource.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface Resource extends Disposable {
|
|
|
60
60
|
readonly onDidChangeReadOnly?: Event<boolean | MarkdownString>;
|
|
61
61
|
|
|
62
62
|
readonly readOnly?: boolean | MarkdownString;
|
|
63
|
+
|
|
64
|
+
readonly initiallyDirty?: boolean;
|
|
63
65
|
/**
|
|
64
66
|
* Reads latest content of this resource.
|
|
65
67
|
*
|
|
@@ -378,11 +380,13 @@ export class UntitledResourceResolver implements ResourceResolver {
|
|
|
378
380
|
export class UntitledResource implements Resource {
|
|
379
381
|
|
|
380
382
|
protected readonly onDidChangeContentsEmitter = new Emitter<void>();
|
|
383
|
+
initiallyDirty: boolean;
|
|
381
384
|
get onDidChangeContents(): Event<void> {
|
|
382
385
|
return this.onDidChangeContentsEmitter.event;
|
|
383
386
|
}
|
|
384
387
|
|
|
385
388
|
constructor(private resources: Map<string, UntitledResource>, public uri: URI, private content?: string) {
|
|
389
|
+
this.initiallyDirty = (content !== undefined && content.length > 0);
|
|
386
390
|
this.resources.set(this.uri.toString(), this);
|
|
387
391
|
}
|
|
388
392
|
|
|
@@ -23,6 +23,11 @@ export function getLocalPort(): string | undefined {
|
|
|
23
23
|
return params.get('localPort') ?? undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
+
export function getCurrentPort(): string | undefined {
|
|
27
|
+
const params = new URLSearchParams(location.search);
|
|
28
|
+
return params.get('port') ?? undefined;
|
|
29
|
+
}
|
|
30
|
+
|
|
26
31
|
@injectable()
|
|
27
32
|
export class ElectronLocalWebSocketConnectionSource extends WebSocketConnectionSource {
|
|
28
33
|
|
|
@@ -30,6 +30,8 @@ import { bindWindowPreferences } from './electron-window-preferences';
|
|
|
30
30
|
import { ElectronWindowService } from './electron-window-service';
|
|
31
31
|
import { ExternalAppOpenHandler } from './external-app-open-handler';
|
|
32
32
|
import { ElectronUriHandlerContribution } from '../electron-uri-handler';
|
|
33
|
+
import { bindContributionProvider } from '../../common';
|
|
34
|
+
import { WindowTitleContribution } from '../../browser/window/window-title-service';
|
|
33
35
|
|
|
34
36
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
35
37
|
bind(ElectronMainWindowService).toDynamicValue(context =>
|
|
@@ -45,4 +47,5 @@ export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
|
45
47
|
bind(SecondaryWindowService).to(ElectronSecondaryWindowService).inSingletonScope();
|
|
46
48
|
bind(ExternalAppOpenHandler).toSelf().inSingletonScope();
|
|
47
49
|
bind(OpenHandler).toService(ExternalAppOpenHandler);
|
|
50
|
+
bindContributionProvider(bind, WindowTitleContribution);
|
|
48
51
|
});
|
|
@@ -396,7 +396,7 @@ export class ElectronMainApplication {
|
|
|
396
396
|
}
|
|
397
397
|
|
|
398
398
|
protected isShowSplashScreen(): boolean {
|
|
399
|
-
return typeof this.config.electron.splashScreenOptions === 'object' && !!this.config.electron.splashScreenOptions.content;
|
|
399
|
+
return !process.env.THEIA_NO_SPLASH && typeof this.config.electron.splashScreenOptions === 'object' && !!this.config.electron.splashScreenOptions.content;
|
|
400
400
|
}
|
|
401
401
|
|
|
402
402
|
protected getSplashScreenOptions(): ElectronFrontendApplicationConfig.SplashScreenOptions | undefined {
|
|
@@ -522,21 +522,21 @@ export class ElectronMainApplication {
|
|
|
522
522
|
}
|
|
523
523
|
|
|
524
524
|
protected async handleMainCommand(options: ElectronMainCommandOptions): Promise<void> {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
} else if (options.file === undefined) {
|
|
528
|
-
await this.openDefaultWindow();
|
|
529
|
-
} else {
|
|
530
|
-
let workspacePath: string | undefined;
|
|
525
|
+
let workspacePath: string | undefined;
|
|
526
|
+
if (options.file) {
|
|
531
527
|
try {
|
|
532
528
|
workspacePath = await fs.realpath(path.resolve(options.cwd, options.file));
|
|
533
529
|
} catch {
|
|
534
530
|
console.error(`Could not resolve the workspace path. "${options.file}" is not a valid 'file' option. Falling back to the default workspace location.`);
|
|
535
531
|
}
|
|
536
|
-
|
|
532
|
+
}
|
|
533
|
+
if (workspacePath !== undefined) {
|
|
534
|
+
await this.openWindowWithWorkspace(workspacePath);
|
|
535
|
+
} else {
|
|
536
|
+
if (options.secondInstance === false) {
|
|
537
|
+
await this.openWindowWithWorkspace(''); // restore previous workspace.
|
|
538
|
+
} else if (options.file === undefined) {
|
|
537
539
|
await this.openDefaultWindow();
|
|
538
|
-
} else {
|
|
539
|
-
await this.openWindowWithWorkspace(workspacePath);
|
|
540
540
|
}
|
|
541
541
|
}
|
|
542
542
|
}
|
|
@@ -186,10 +186,18 @@ export class TheiaElectronWindow {
|
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
protected restoreMaximizedState(): void {
|
|
189
|
-
|
|
190
|
-
this.
|
|
189
|
+
const restore = () => {
|
|
190
|
+
if (this.options.isMaximized) {
|
|
191
|
+
this._window.maximize();
|
|
192
|
+
} else {
|
|
193
|
+
this._window.unmaximize();
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
if (this._window.isVisible()) {
|
|
198
|
+
restore();
|
|
191
199
|
} else {
|
|
192
|
-
this._window.
|
|
200
|
+
this._window.once('show', () => restore());
|
|
193
201
|
}
|
|
194
202
|
}
|
|
195
203
|
|
|
@@ -18,11 +18,14 @@ import { inject, injectable, postConstruct } from 'inversify';
|
|
|
18
18
|
import { LoggerWatcher } from '../common/logger-watcher';
|
|
19
19
|
import { LogLevelCliContribution } from './logger-cli-contribution';
|
|
20
20
|
import { ILoggerServer, ILoggerClient, ConsoleLogger, rootLoggerName } from '../common/logger-protocol';
|
|
21
|
+
import { format } from 'util';
|
|
22
|
+
import { EOL } from 'os';
|
|
23
|
+
import * as fs from 'fs';
|
|
21
24
|
|
|
22
25
|
@injectable()
|
|
23
26
|
export class ConsoleLoggerServer implements ILoggerServer {
|
|
24
27
|
|
|
25
|
-
protected client
|
|
28
|
+
protected client?: ILoggerClient;
|
|
26
29
|
|
|
27
30
|
@inject(LoggerWatcher)
|
|
28
31
|
protected watcher: LoggerWatcher;
|
|
@@ -30,6 +33,8 @@ export class ConsoleLoggerServer implements ILoggerServer {
|
|
|
30
33
|
@inject(LogLevelCliContribution)
|
|
31
34
|
protected cli: LogLevelCliContribution;
|
|
32
35
|
|
|
36
|
+
protected logFileStream?: fs.WriteStream;
|
|
37
|
+
|
|
33
38
|
@postConstruct()
|
|
34
39
|
protected init(): void {
|
|
35
40
|
this.setLogLevel(rootLoggerName, this.cli.defaultLogLevel);
|
|
@@ -59,7 +64,22 @@ export class ConsoleLoggerServer implements ILoggerServer {
|
|
|
59
64
|
async log(name: string, logLevel: number, message: string, params: any[]): Promise<void> {
|
|
60
65
|
const configuredLogLevel = await this.getLogLevel(name);
|
|
61
66
|
if (logLevel >= configuredLogLevel) {
|
|
62
|
-
ConsoleLogger.log(name, logLevel, message, params);
|
|
67
|
+
const fullMessage = ConsoleLogger.log(name, logLevel, message, params);
|
|
68
|
+
this.logToFile(fullMessage, params);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
protected logToFile(message: string, params: any[]): void {
|
|
73
|
+
if (this.cli.logFile && !this.logFileStream) {
|
|
74
|
+
this.logFileStream = fs.createWriteStream(this.cli.logFile, { flags: 'a' });
|
|
75
|
+
// Only log errors once to avoid spamming the console
|
|
76
|
+
this.logFileStream.once('error', error => {
|
|
77
|
+
console.error(`Error writing to log file ${this.cli.logFile}`, error);
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (this.logFileStream) {
|
|
81
|
+
const formatted = format(message, ...params) + EOL;
|
|
82
|
+
this.logFileStream.write(formatted);
|
|
63
83
|
}
|
|
64
84
|
}
|
|
65
85
|
|
|
@@ -16,20 +16,19 @@
|
|
|
16
16
|
|
|
17
17
|
import { ContainerModule, Container, interfaces } from 'inversify';
|
|
18
18
|
import { ConnectionHandler, RpcConnectionHandler } from '../common/messaging';
|
|
19
|
-
import { ILogger, LoggerFactory, Logger, setRootLogger, LoggerName
|
|
19
|
+
import { ILogger, LoggerFactory, Logger, setRootLogger, LoggerName } from '../common/logger';
|
|
20
20
|
import { ILoggerServer, ILoggerClient, loggerPath, DispatchingLoggerClient } from '../common/logger-protocol';
|
|
21
21
|
import { ConsoleLoggerServer } from './console-logger-server';
|
|
22
22
|
import { LoggerWatcher } from '../common/logger-watcher';
|
|
23
23
|
import { BackendApplicationContribution } from './backend-application';
|
|
24
24
|
import { CliContribution } from './cli';
|
|
25
25
|
import { LogLevelCliContribution } from './logger-cli-contribution';
|
|
26
|
+
import { bindCommonLogger } from '../common/logger-binding';
|
|
26
27
|
|
|
27
28
|
export function bindLogger(bind: interfaces.Bind, props?: {
|
|
28
29
|
onLoggerServerActivation?: (context: interfaces.Context, server: ILoggerServer) => void
|
|
29
30
|
}): void {
|
|
30
|
-
bind
|
|
31
|
-
bind(ILogger).to(Logger).inSingletonScope().whenTargetIsDefault();
|
|
32
|
-
bind(LoggerWatcher).toSelf().inSingletonScope();
|
|
31
|
+
bindCommonLogger(bind);
|
|
33
32
|
bind<ILoggerServer>(ILoggerServer).to(ConsoleLoggerServer).inSingletonScope().onActivation((context, server) => {
|
|
34
33
|
if (props && props.onLoggerServerActivation) {
|
|
35
34
|
props.onLoggerServerActivation(context, server);
|
|
@@ -43,6 +43,8 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
43
43
|
*/
|
|
44
44
|
protected _defaultLogLevel: LogLevel = LogLevel.INFO;
|
|
45
45
|
|
|
46
|
+
protected _logFile?: string;
|
|
47
|
+
|
|
46
48
|
protected logConfigChangedEvent: Emitter<void> = new Emitter<void>();
|
|
47
49
|
|
|
48
50
|
get defaultLogLevel(): LogLevel {
|
|
@@ -53,6 +55,10 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
53
55
|
return this._logLevels;
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
get logFile(): string | undefined {
|
|
59
|
+
return this._logFile;
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
configure(conf: yargs.Argv): void {
|
|
57
63
|
conf.option('log-level', {
|
|
58
64
|
description: 'Sets the default log level',
|
|
@@ -65,6 +71,12 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
65
71
|
type: 'string',
|
|
66
72
|
nargs: 1,
|
|
67
73
|
});
|
|
74
|
+
|
|
75
|
+
conf.option('log-file', {
|
|
76
|
+
description: 'Path to the log file',
|
|
77
|
+
type: 'string',
|
|
78
|
+
nargs: 1
|
|
79
|
+
});
|
|
68
80
|
}
|
|
69
81
|
|
|
70
82
|
async setArguments(args: yargs.Arguments): Promise<void> {
|
|
@@ -87,22 +99,46 @@ export class LogLevelCliContribution implements CliContribution {
|
|
|
87
99
|
console.error(`Error reading log config file ${filename}: ${e}`);
|
|
88
100
|
}
|
|
89
101
|
}
|
|
102
|
+
|
|
103
|
+
if (args['log-file'] !== undefined) {
|
|
104
|
+
let filename = args['log-file'] as string;
|
|
105
|
+
try {
|
|
106
|
+
filename = path.resolve(filename);
|
|
107
|
+
try {
|
|
108
|
+
const stat = await fs.stat(filename);
|
|
109
|
+
if (stat && stat.isFile()) {
|
|
110
|
+
// Rename the previous log file to avoid overwriting it
|
|
111
|
+
const oldFilename = `${filename}.${stat.ctime.toISOString().replace(/:/g, '-')}.old`;
|
|
112
|
+
await fs.rename(filename, oldFilename);
|
|
113
|
+
}
|
|
114
|
+
} catch {
|
|
115
|
+
// File does not exist, just continue to create it
|
|
116
|
+
}
|
|
117
|
+
await fs.writeFile(filename, '');
|
|
118
|
+
this._logFile = filename;
|
|
119
|
+
} catch (e) {
|
|
120
|
+
console.error(`Error creating log file ${filename}: ${e}`);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
90
123
|
}
|
|
91
124
|
|
|
92
125
|
protected async watchLogConfigFile(filename: string): Promise<void> {
|
|
93
|
-
|
|
126
|
+
const dir = path.dirname(filename);
|
|
127
|
+
await subscribe(dir, async (err, events) => {
|
|
94
128
|
if (err) {
|
|
95
129
|
console.log(`Error during log file watching ${filename}: ${err}`);
|
|
96
130
|
return;
|
|
97
131
|
}
|
|
98
132
|
try {
|
|
99
133
|
for (const event of events) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
134
|
+
if (event.path === filename) {
|
|
135
|
+
switch (event.type) {
|
|
136
|
+
case 'create':
|
|
137
|
+
case 'update':
|
|
138
|
+
await this.slurpLogConfigFile(filename);
|
|
139
|
+
this.logConfigChangedEvent.fire(undefined);
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
106
142
|
}
|
|
107
143
|
}
|
|
108
144
|
} catch (e) {
|
|
@@ -47,7 +47,12 @@ export class TestWebSocketChannelSetup {
|
|
|
47
47
|
path: string
|
|
48
48
|
}) {
|
|
49
49
|
const address = (server.address() as AddressInfo);
|
|
50
|
-
|
|
50
|
+
let url;
|
|
51
|
+
if (address.family === 'IPv6') {
|
|
52
|
+
url = `ws://[${address.address}]:${address.port}${servicesPath}`;
|
|
53
|
+
} else {
|
|
54
|
+
url = `ws://${address.address}:${address.port}${servicesPath}`;
|
|
55
|
+
}
|
|
51
56
|
this.connectionProvider = this.createConnectionProvider(url);
|
|
52
57
|
}
|
|
53
58
|
|