diff --git a/CHANGELOG.md b/CHANGELOG.md index 0476d4bd1bdff..e0ae3e080451c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ [Breaking Changes:](#breaking_changes_1.43.0) +- [core] moved `FrontendApplicationContribution` from `@theia/core/lib/browser/frontend-application` to `@theia/core/lib/browser/frontend-application-contribution` [#12993](https://github.com/eclipse-theia/theia/pull/12993) - [core] removed `SETTINGS_OPEN` menupath constant - replaced by `MANAGE_GENERAL` [#12803](https://github.com/eclipse-theia/theia/pull/12803) - [core] removed `SETTINGS__THEME` menupath constant - replaced by `MANAGE_SETTINGS` [#12803](https://github.com/eclipse-theia/theia/pull/12803) diff --git a/packages/core/src/browser/color-application-contribution.ts b/packages/core/src/browser/color-application-contribution.ts index 73b3d8b70f919..4ad35b3de44b5 100644 --- a/packages/core/src/browser/color-application-contribution.ts +++ b/packages/core/src/browser/color-application-contribution.ts @@ -18,7 +18,7 @@ import { injectable, inject, named } from 'inversify'; import { ColorRegistry } from './color-registry'; import { Emitter } from '../common/event'; import { ThemeService } from './theming'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { ContributionProvider } from '../common/contribution-provider'; import { Disposable, DisposableCollection } from '../common/disposable'; import { DEFAULT_BACKGROUND_COLOR_STORAGE_KEY } from './frontend-application-config-provider'; diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index c3e13398731cd..f4a7db93778d4 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -20,7 +20,8 @@ import debounce = require('lodash.debounce'); import { injectable, inject, optional } from 'inversify'; import { MAIN_MENU_BAR, MANAGE_MENU, MenuContribution, MenuModelRegistry, ACCOUNTS_MENU } from '../common/menu'; import { KeybindingContribution, KeybindingRegistry } from './keybinding'; -import { FrontendApplication, FrontendApplicationContribution, OnWillStopAction } from './frontend-application'; +import { FrontendApplication } from './frontend-application'; +import { FrontendApplicationContribution, OnWillStopAction } from './frontend-application-contribution'; import { CommandContribution, CommandRegistry, Command } from '../common/command'; import { UriAwareCommandHandler } from '../common/uri-command-handler'; import { SelectionService } from '../common/selection-service'; diff --git a/packages/core/src/browser/connection-status-service.ts b/packages/core/src/browser/connection-status-service.ts index 55794d9936241..790a702480f00 100644 --- a/packages/core/src/browser/connection-status-service.ts +++ b/packages/core/src/browser/connection-status-service.ts @@ -17,7 +17,7 @@ import { inject, injectable, optional, postConstruct } from 'inversify'; import { ILogger } from '../common/logger'; import { Event, Emitter } from '../common/event'; -import { DefaultFrontendApplicationContribution } from './frontend-application'; +import { DefaultFrontendApplicationContribution } from './frontend-application-contribution'; import { StatusBar, StatusBarAlignment } from './status-bar/status-bar'; import { WebSocketConnectionProvider } from './messaging/ws-connection-provider'; import { Disposable, DisposableCollection, nls } from '../common'; diff --git a/packages/core/src/browser/dialogs.ts b/packages/core/src/browser/dialogs.ts index f9752a2c09a2f..2ab0a1203e976 100644 --- a/packages/core/src/browser/dialogs.ts +++ b/packages/core/src/browser/dialogs.ts @@ -18,7 +18,7 @@ import { injectable, inject } from 'inversify'; import { Disposable, MaybePromise, CancellationTokenSource, nls } from '../common'; import { Key } from './keyboard/keys'; import { Widget, BaseWidget, Message, addKeyListener, codiconArray } from './widgets'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; @injectable() export class DialogProps { diff --git a/packages/core/src/browser/frontend-application-contribution.ts b/packages/core/src/browser/frontend-application-contribution.ts new file mode 100644 index 0000000000000..d6b40ba982391 --- /dev/null +++ b/packages/core/src/browser/frontend-application-contribution.ts @@ -0,0 +1,110 @@ +// ***************************************************************************** +// Copyright (C) 2023 TypeFox and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// http://www.eclipse.org/legal/epl-2.0. +// +// This Source Code may also be made available under the following Secondary +// Licenses when the conditions for such availability set forth in the Eclipse +// Public License v. 2.0 are satisfied: GNU General Public License, version 2 +// with the GNU Classpath Exception which is available at +// https://www.gnu.org/software/classpath/license.html. +// +// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 +// ***************************************************************************** + +import type { FrontendApplication } from './frontend-application'; +import { MaybePromise, isObject } from '../common/types'; +import { StopReason } from '../common/frontend-application-state'; +import { injectable } from 'inversify'; + +/** + * Clients can implement to get a callback for contributing widgets to a shell on start. + */ +export const FrontendApplicationContribution = Symbol('FrontendApplicationContribution'); +export interface FrontendApplicationContribution { + + /** + * Called on application startup before configure is called. + */ + initialize?(): void; + + /** + * Called before commands, key bindings and menus are initialized. + * Should return a promise if it runs asynchronously. + */ + configure?(app: FrontendApplication): MaybePromise; + + /** + * Called when the application is started. The application shell is not attached yet when this method runs. + * Should return a promise if it runs asynchronously. + */ + onStart?(app: FrontendApplication): MaybePromise; + + /** + * Called on `beforeunload` event, right before the window closes. + * Return `true` or an OnWillStopAction in order to prevent exit. + * Note: No async code allowed, this function has to run on one tick. + */ + onWillStop?(app: FrontendApplication): boolean | undefined | OnWillStopAction; + + /** + * Called when an application is stopped or unloaded. + * + * Note that this is implemented using `window.beforeunload` which doesn't allow any asynchronous code anymore. + * I.e. this is the last tick. + */ + onStop?(app: FrontendApplication): void; + + /** + * Called after the application shell has been attached in case there is no previous workbench layout state. + * Should return a promise if it runs asynchronously. + */ + initializeLayout?(app: FrontendApplication): MaybePromise; + + /** + * An event is emitted when a layout is initialized, but before the shell is attached. + */ + onDidInitializeLayout?(app: FrontendApplication): MaybePromise; +} + +export interface OnWillStopAction { + /** + * @resolves to a prepared value to be passed into the `action` function. + */ + prepare?: (stopReason?: StopReason) => MaybePromise; + /** + * @resolves to `true` if it is safe to close the application; `false` otherwise. + */ + action: (prepared: T, stopReason?: StopReason) => MaybePromise; + /** + * A descriptive string for the reason preventing close. + */ + reason: string; + /** + * A number representing priority. Higher priority items are run later. + * High priority implies that some options of this check will have negative impacts if + * the user subsequently cancels the shutdown. + */ + priority?: number; +} + +export namespace OnWillStopAction { + export function is(candidate: unknown): candidate is OnWillStopAction { + return isObject(candidate) && 'action' in candidate && 'reason' in candidate; + } +} + +/** + * Default frontend contribution that can be extended by clients if they do not want to implement any of the + * methods from the interface but still want to contribute to the frontend application. + */ +@injectable() +export abstract class DefaultFrontendApplicationContribution implements FrontendApplicationContribution { + + initialize(): void { + // NOOP + } + +} diff --git a/packages/core/src/browser/frontend-application-module.ts b/packages/core/src/browser/frontend-application-module.ts index 871f03815d654..9b2531485382a 100644 --- a/packages/core/src/browser/frontend-application-module.ts +++ b/packages/core/src/browser/frontend-application-module.ts @@ -38,7 +38,8 @@ import { MenuCommandExecutorImpl } from '../common'; import { KeybindingRegistry, KeybindingContext, KeybindingContribution } from './keybinding'; -import { FrontendApplication, FrontendApplicationContribution, DefaultFrontendApplicationContribution } from './frontend-application'; +import { FrontendApplication } from './frontend-application'; +import { FrontendApplicationContribution, DefaultFrontendApplicationContribution } from './frontend-application-contribution'; import { DefaultOpenerService, OpenerService, OpenHandler } from './opener-service'; import { HttpOpenHandler } from './http-open-handler'; import { CommonFrontendContribution } from './common-frontend-contribution'; diff --git a/packages/core/src/browser/frontend-application.ts b/packages/core/src/browser/frontend-application.ts index 791bc6d501a0e..448520a497034 100644 --- a/packages/core/src/browser/frontend-application.ts +++ b/packages/core/src/browser/frontend-application.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { inject, injectable, named } from 'inversify'; -import { ContributionProvider, CommandRegistry, MenuModelRegistry, isOSX, BackendStopwatch, LogLevel, Stopwatch, isObject } from '../common'; +import { ContributionProvider, CommandRegistry, MenuModelRegistry, isOSX, BackendStopwatch, LogLevel, Stopwatch } from '../common'; import { MaybePromise } from '../common/types'; import { KeybindingRegistry } from './keybinding'; import { Widget } from './widgets'; @@ -26,100 +26,10 @@ import { preventNavigation, parseCssTime, animationFrame } from './browser'; import { CorePreferences } from './core-preferences'; import { WindowService } from './window/window-service'; import { TooltipService } from './tooltip-service'; -import { StopReason } from '../common/frontend-application-state'; - -/** - * Clients can implement to get a callback for contributing widgets to a shell on start. - */ -export const FrontendApplicationContribution = Symbol('FrontendApplicationContribution'); -export interface FrontendApplicationContribution { - - /** - * Called on application startup before configure is called. - */ - initialize?(): void; - - /** - * Called before commands, key bindings and menus are initialized. - * Should return a promise if it runs asynchronously. - */ - configure?(app: FrontendApplication): MaybePromise; - - /** - * Called when the application is started. The application shell is not attached yet when this method runs. - * Should return a promise if it runs asynchronously. - */ - onStart?(app: FrontendApplication): MaybePromise; - - /** - * Called on `beforeunload` event, right before the window closes. - * Return `true` or an OnWillStopAction in order to prevent exit. - * Note: No async code allowed, this function has to run on one tick. - */ - onWillStop?(app: FrontendApplication): boolean | undefined | OnWillStopAction; - - /** - * Called when an application is stopped or unloaded. - * - * Note that this is implemented using `window.beforeunload` which doesn't allow any asynchronous code anymore. - * I.e. this is the last tick. - */ - onStop?(app: FrontendApplication): void; - - /** - * Called after the application shell has been attached in case there is no previous workbench layout state. - * Should return a promise if it runs asynchronously. - */ - initializeLayout?(app: FrontendApplication): MaybePromise; - - /** - * An event is emitted when a layout is initialized, but before the shell is attached. - */ - onDidInitializeLayout?(app: FrontendApplication): MaybePromise; -} - -export interface OnWillStopAction { - /** - * @resolves to a prepared value to be passed into the `action` function. - */ - prepare?: (stopReason?: StopReason) => MaybePromise; - /** - * @resolves to `true` if it is safe to close the application; `false` otherwise. - */ - action: (prepared: T, stopReason?: StopReason) => MaybePromise; - /** - * A descriptive string for the reason preventing close. - */ - reason: string; - /** - * A number representing priority. Higher priority items are run later. - * High priority implies that some options of this check will have negative impacts if - * the user subsequently cancels the shutdown. - */ - priority?: number; -} - -export namespace OnWillStopAction { - export function is(candidate: unknown): candidate is OnWillStopAction { - return isObject(candidate) && 'action' in candidate && 'reason' in candidate; - } -} +import { FrontendApplicationContribution } from './frontend-application-contribution'; const TIMER_WARNING_THRESHOLD = 100; -/** - * Default frontend contribution that can be extended by clients if they do not want to implement any of the - * methods from the interface but still want to contribute to the frontend application. - */ -@injectable() -export abstract class DefaultFrontendApplicationContribution implements FrontendApplicationContribution { - - initialize(): void { - // NOOP - } - -} - @injectable() export class FrontendApplication { diff --git a/packages/core/src/browser/icon-theme-contribution.ts b/packages/core/src/browser/icon-theme-contribution.ts index 3c1dda5465f30..b192588a69547 100644 --- a/packages/core/src/browser/icon-theme-contribution.ts +++ b/packages/core/src/browser/icon-theme-contribution.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { injectable, inject, named } from 'inversify'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { ContributionProvider } from '../common/contribution-provider'; import { IconThemeService, IconTheme } from './icon-theme-service'; import { MaybePromise } from '../common/types'; diff --git a/packages/core/src/browser/index.ts b/packages/core/src/browser/index.ts index d2a119ea80da9..eecaa565401dc 100644 --- a/packages/core/src/browser/index.ts +++ b/packages/core/src/browser/index.ts @@ -16,6 +16,7 @@ export * from './shell'; export * from './frontend-application'; +export * from './frontend-application-contribution'; export * from './keyboard'; export * from './opener-service'; export * from './browser'; diff --git a/packages/core/src/browser/json-schema-store.ts b/packages/core/src/browser/json-schema-store.ts index 40e929b3fe294..729d14bfa1c45 100644 --- a/packages/core/src/browser/json-schema-store.ts +++ b/packages/core/src/browser/json-schema-store.ts @@ -16,7 +16,7 @@ import { injectable, inject, named } from 'inversify'; import { ContributionProvider } from '../common/contribution-provider'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { MaybePromise } from '../common'; import { Endpoint } from './endpoint'; import { timeout, Deferred } from '../common/promise-util'; diff --git a/packages/core/src/browser/label-provider.ts b/packages/core/src/browser/label-provider.ts index 35cf6860cced9..037cf50a3a6d9 100644 --- a/packages/core/src/browser/label-provider.ts +++ b/packages/core/src/browser/label-provider.ts @@ -19,7 +19,7 @@ import * as fileIcons from 'file-icons-js'; import URI from '../common/uri'; import { ContributionProvider } from '../common/contribution-provider'; import { Event, Emitter, Disposable, isObject, Path, Prioritizeable } from '../common'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { EnvVariablesServer } from '../common/env-variables/env-variables-protocol'; import { ResourceLabelFormatter, ResourceLabelFormatting } from '../common/label-protocol'; import { codicon } from './widgets'; diff --git a/packages/core/src/browser/logger-frontend-module.ts b/packages/core/src/browser/logger-frontend-module.ts index c7fa9f0feb7e8..0f5ecb771fc30 100644 --- a/packages/core/src/browser/logger-frontend-module.ts +++ b/packages/core/src/browser/logger-frontend-module.ts @@ -19,7 +19,7 @@ import { ILoggerServer, loggerPath, ConsoleLogger } from '../common/logger-proto import { ILogger, Logger, LoggerFactory, setRootLogger, LoggerName, rootLoggerName } from '../common/logger'; import { LoggerWatcher } from '../common/logger-watcher'; import { WebSocketConnectionProvider } from './messaging'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { EncodingError } from '../common/message-rpc/rpc-message-encoder'; export const loggerFrontendModule = new ContainerModule(bind => { diff --git a/packages/core/src/browser/menu/browser-menu-module.ts b/packages/core/src/browser/menu/browser-menu-module.ts index eaea9ee2a1b6a..f30a7f53dde69 100644 --- a/packages/core/src/browser/menu/browser-menu-module.ts +++ b/packages/core/src/browser/menu/browser-menu-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from 'inversify'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { ContextMenuRenderer } from '../context-menu-renderer'; import { BrowserMenuBarContribution, BrowserMainMenuFactory } from './browser-menu-plugin'; import { BrowserContextMenuRenderer } from './browser-context-menu-renderer'; diff --git a/packages/core/src/browser/menu/browser-menu-plugin.ts b/packages/core/src/browser/menu/browser-menu-plugin.ts index 81b85487c9bec..8145d9d58e84f 100644 --- a/packages/core/src/browser/menu/browser-menu-plugin.ts +++ b/packages/core/src/browser/menu/browser-menu-plugin.ts @@ -22,7 +22,8 @@ import { MenuModelRegistry, MAIN_MENU_BAR, MenuPath, MenuNode, MenuCommandExecutor, CompoundMenuNode, CompoundMenuNodeRole, CommandMenuNode } from '../../common'; import { KeybindingRegistry } from '../keybinding'; -import { FrontendApplicationContribution, FrontendApplication } from '../frontend-application'; +import { FrontendApplication } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { ContextKeyService, ContextMatcher } from '../context-key-service'; import { ContextMenuContext } from './context-menu-context'; import { waitForRevealed } from '../widgets'; diff --git a/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts b/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts index e8ed78fbce102..b9ac60a45c6d8 100644 --- a/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts +++ b/packages/core/src/browser/quick-input/quick-input-frontend-contribution.ts @@ -16,7 +16,7 @@ import { injectable, inject, named } from 'inversify'; import { ContributionProvider } from '../../common'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { QuickAccessContribution } from './quick-access'; @injectable() diff --git a/packages/core/src/browser/shell/application-shell-mouse-tracker.ts b/packages/core/src/browser/shell/application-shell-mouse-tracker.ts index 8a65dd5bc41a6..0dfd317cdf4d6 100644 --- a/packages/core/src/browser/shell/application-shell-mouse-tracker.ts +++ b/packages/core/src/browser/shell/application-shell-mouse-tracker.ts @@ -14,7 +14,7 @@ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 // ***************************************************************************** -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { ApplicationShell } from './application-shell'; import { injectable, inject } from 'inversify'; import { DisposableCollection, Disposable } from '../../common/disposable'; diff --git a/packages/core/src/browser/shell/tab-bar-decorator.ts b/packages/core/src/browser/shell/tab-bar-decorator.ts index 2959337452db1..4b48d848876b1 100644 --- a/packages/core/src/browser/shell/tab-bar-decorator.ts +++ b/packages/core/src/browser/shell/tab-bar-decorator.ts @@ -19,7 +19,7 @@ import { Title, Widget } from '@phosphor/widgets'; import { inject, injectable, named } from 'inversify'; import { Event, Emitter, ContributionProvider } from '../../common'; import { WidgetDecoration } from '../widget-decoration'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; export const TabBarDecorator = Symbol('TabBarDecorator'); diff --git a/packages/core/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts b/packages/core/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts index 92b3c5f219955..e3946be66d197 100644 --- a/packages/core/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +++ b/packages/core/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts @@ -19,7 +19,7 @@ import { inject, injectable, named } from 'inversify'; // eslint-disable-next-line max-len import { CommandMenuNode, CommandRegistry, CompoundMenuNode, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuNode, MenuPath } from '../../../common'; import { ContextKeyService } from '../../context-key-service'; -import { FrontendApplicationContribution } from '../../frontend-application'; +import { FrontendApplicationContribution } from '../../frontend-application-contribution'; import { Widget } from '../../widgets'; import { AnyToolbarItem, ConditionalToolbarItem, MenuDelegate, MenuToolbarItem, ReactTabBarToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types'; import { ToolbarMenuNodeWrapper } from './tab-bar-toolbar-menu-adapters'; diff --git a/packages/core/src/browser/styling-service.ts b/packages/core/src/browser/styling-service.ts index fbed8e2cab9ce..8acac1b1372be 100644 --- a/packages/core/src/browser/styling-service.ts +++ b/packages/core/src/browser/styling-service.ts @@ -19,7 +19,7 @@ import { ContributionProvider } from '../common/contribution-provider'; import { Theme, ThemeType } from '../common/theme'; import { ColorRegistry } from './color-registry'; import { DecorationStyle } from './decoration-style'; -import { FrontendApplicationContribution } from './frontend-application'; +import { FrontendApplicationContribution } from './frontend-application-contribution'; import { ThemeService } from './theming'; import { Disposable } from '../common'; diff --git a/packages/core/src/browser/window/browser-window-module.ts b/packages/core/src/browser/window/browser-window-module.ts index aa53023b6e778..e181616b266d8 100644 --- a/packages/core/src/browser/window/browser-window-module.ts +++ b/packages/core/src/browser/window/browser-window-module.ts @@ -17,7 +17,7 @@ import { ContainerModule } from 'inversify'; import { WindowService } from '../../browser/window/window-service'; import { DefaultWindowService } from '../../browser/window/default-window-service'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { ClipboardService } from '../clipboard-service'; import { BrowserClipboardService } from '../browser-clipboard-service'; import { SecondaryWindowService } from './secondary-window-service'; diff --git a/packages/core/src/browser/window/default-window-service.spec.ts b/packages/core/src/browser/window/default-window-service.spec.ts index 937f2edb85243..d69dc1f1c319b 100644 --- a/packages/core/src/browser/window/default-window-service.spec.ts +++ b/packages/core/src/browser/window/default-window-service.spec.ts @@ -17,7 +17,7 @@ import { Container } from 'inversify'; import { ContributionProvider } from '../../common'; import { CorePreferences } from '../core-preferences'; -import { FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { DefaultWindowService } from './default-window-service'; import assert = require('assert'); diff --git a/packages/core/src/browser/window/default-window-service.ts b/packages/core/src/browser/window/default-window-service.ts index 7626a28261d07..bee19fa4a0408 100644 --- a/packages/core/src/browser/window/default-window-service.ts +++ b/packages/core/src/browser/window/default-window-service.ts @@ -18,11 +18,12 @@ import { inject, injectable, named } from 'inversify'; import { Event, Emitter } from '../../common'; import { CorePreferences } from '../core-preferences'; import { ContributionProvider } from '../../common/contribution-provider'; -import { FrontendApplicationContribution, FrontendApplication, OnWillStopAction } from '../frontend-application'; +import { FrontendApplicationContribution, OnWillStopAction } from '../frontend-application-contribution'; import { WindowService } from './window-service'; import { DEFAULT_WINDOW_HASH } from '../../common/window'; import { confirmExit } from '../dialogs'; import { StopReason } from '../../common/frontend-application-state'; +import { FrontendApplication } from '../frontend-application'; @injectable() export class DefaultWindowService implements WindowService, FrontendApplicationContribution { diff --git a/packages/core/src/browser/window/window-title-updater.ts b/packages/core/src/browser/window/window-title-updater.ts index baa288632458e..65d172574f1e2 100644 --- a/packages/core/src/browser/window/window-title-updater.ts +++ b/packages/core/src/browser/window/window-title-updater.ts @@ -15,7 +15,8 @@ // ***************************************************************************** import { Widget } from '../widgets'; -import { FrontendApplication, FrontendApplicationContribution } from '../frontend-application'; +import { FrontendApplication } from '../frontend-application'; +import { FrontendApplicationContribution } from '../frontend-application-contribution'; import { NavigatableWidget } from '../navigatable-types'; import { inject, injectable } from 'inversify'; import { WindowTitleService } from './window-title-service'; diff --git a/packages/core/src/electron-browser/messaging/electron-messaging-frontend-module.ts b/packages/core/src/electron-browser/messaging/electron-messaging-frontend-module.ts index ed7432d2eddcd..253e0d6946127 100644 --- a/packages/core/src/electron-browser/messaging/electron-messaging-frontend-module.ts +++ b/packages/core/src/electron-browser/messaging/electron-messaging-frontend-module.ts @@ -15,7 +15,7 @@ // ***************************************************************************** import { ContainerModule } from 'inversify'; -import { FrontendApplicationContribution } from '../../browser/frontend-application'; +import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution'; import { WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider'; import { ElectronWebSocketConnectionProvider } from './electron-ws-connection-provider'; import { ElectronIpcConnectionProvider } from './electron-ipc-connection-provider'; diff --git a/packages/core/src/electron-browser/messaging/electron-ws-connection-provider.ts b/packages/core/src/electron-browser/messaging/electron-ws-connection-provider.ts index c83858d905005..a9d0f161ab0df 100644 --- a/packages/core/src/electron-browser/messaging/electron-ws-connection-provider.ts +++ b/packages/core/src/electron-browser/messaging/electron-ws-connection-provider.ts @@ -16,7 +16,7 @@ import { injectable } from 'inversify'; import { WebSocketConnectionProvider, WebSocketOptions } from '../../browser/messaging/ws-connection-provider'; -import { FrontendApplicationContribution } from '../../browser/frontend-application'; +import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution'; import { Channel } from '../../common'; /** diff --git a/packages/core/src/electron-browser/window/electron-window-module.ts b/packages/core/src/electron-browser/window/electron-window-module.ts index 3c88d122b2bd4..360ba55aa36e4 100644 --- a/packages/core/src/electron-browser/window/electron-window-module.ts +++ b/packages/core/src/electron-browser/window/electron-window-module.ts @@ -17,7 +17,7 @@ import { ContainerModule } from 'inversify'; import { WindowService } from '../../browser/window/window-service'; import { ElectronWindowService } from './electron-window-service'; -import { FrontendApplicationContribution } from '../../browser/frontend-application'; +import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution'; import { ElectronClipboardService } from '../electron-clipboard-service'; import { ClipboardService } from '../../browser/clipboard-service'; import { ElectronMainWindowService, electronMainWindowServicePath } from '../../electron-common/electron-main-window-service'; diff --git a/packages/debug/src/browser/editor/debug-inline-value-decorator.ts b/packages/debug/src/browser/editor/debug-inline-value-decorator.ts index bb55a7097605d..92c7a77ca58fa 100644 --- a/packages/debug/src/browser/editor/debug-inline-value-decorator.ts +++ b/packages/debug/src/browser/editor/debug-inline-value-decorator.ts @@ -20,7 +20,7 @@ *--------------------------------------------------------------------------------------------*/ // Based on https://github.com/theia-ide/vscode/blob/standalone/0.19.x/src/vs/workbench/contrib/debug/browser/debugEditorContribution.ts -import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { inject, injectable } from '@theia/core/shared/inversify'; import * as monaco from '@theia/monaco-editor-core'; import { CancellationTokenSource } from '@theia/monaco-editor-core/esm/vs/base/common/cancellation'; diff --git a/packages/editor/src/browser/editor-navigation-contribution.ts b/packages/editor/src/browser/editor-navigation-contribution.ts index 36c5ed2ad6d50..bf4b5f38e7006 100644 --- a/packages/editor/src/browser/editor-navigation-contribution.ts +++ b/packages/editor/src/browser/editor-navigation-contribution.ts @@ -18,7 +18,7 @@ import { inject, injectable, postConstruct } from '@theia/core/shared/inversify' import { ILogger } from '@theia/core/lib/common/logger'; import { StorageService } from '@theia/core/lib/browser/storage-service'; import { Disposable, DisposableCollection } from '@theia/core/lib/common/disposable'; -import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { CommandRegistry } from '@theia/core/lib/common/command'; import { EditorCommands } from './editor-command'; import { EditorWidget } from './editor-widget'; diff --git a/packages/mini-browser/src/browser/mini-browser-frontend-module.ts b/packages/mini-browser/src/browser/mini-browser-frontend-module.ts index 5fd900e4f90e4..0019914ea231a 100644 --- a/packages/mini-browser/src/browser/mini-browser-frontend-module.ts +++ b/packages/mini-browser/src/browser/mini-browser-frontend-module.ts @@ -22,7 +22,7 @@ import { OpenHandler } from '@theia/core/lib/browser/opener-service'; import { WidgetFactory } from '@theia/core/lib/browser/widget-manager'; import { bindContributionProvider } from '@theia/core/lib/common/contribution-provider'; import { WebSocketConnectionProvider } from '@theia/core/lib/browser/messaging/ws-connection-provider'; -import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { TabBarToolbarContribution } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; import { CommandContribution } from '@theia/core/lib/common/command'; import { MenuContribution } from '@theia/core/lib/common/menu'; diff --git a/packages/mini-browser/src/browser/mini-browser-open-handler.ts b/packages/mini-browser/src/browser/mini-browser-open-handler.ts index 269e15243178e..969a78b24a589 100644 --- a/packages/mini-browser/src/browser/mini-browser-open-handler.ts +++ b/packages/mini-browser/src/browser/mini-browser-open-handler.ts @@ -26,7 +26,7 @@ import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/li import { NavigatableWidget, NavigatableWidgetOpenHandler } from '@theia/core/lib/browser/navigatable'; import { open, OpenerService } from '@theia/core/lib/browser/opener-service'; import { LabelProvider } from '@theia/core/lib/browser/label-provider'; -import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { WidgetOpenerOptions } from '@theia/core/lib/browser/widget-open-handler'; import { MiniBrowserService } from '../common/mini-browser-service'; import { MiniBrowser, MiniBrowserProps } from './mini-browser'; diff --git a/packages/monaco/package.json b/packages/monaco/package.json index 2b95858769917..828a1dd0cf287 100644 --- a/packages/monaco/package.json +++ b/packages/monaco/package.json @@ -9,6 +9,7 @@ "@theia/markers": "1.42.0", "@theia/monaco-editor-core": "1.72.3", "@theia/outline-view": "1.42.0", + "@theia/workspace": "1.42.0", "fast-plist": "^0.1.2", "idb": "^4.0.5", "jsonc-parser": "^2.2.0", diff --git a/packages/monaco/src/browser/monaco-frontend-application-contribution.ts b/packages/monaco/src/browser/monaco-frontend-application-contribution.ts index 7e62ccf7157f8..4d8ccb9511129 100644 --- a/packages/monaco/src/browser/monaco-frontend-application-contribution.ts +++ b/packages/monaco/src/browser/monaco-frontend-application-contribution.ts @@ -34,6 +34,7 @@ import { isHighContrast } from '@theia/core/lib/common/theme'; import { editorOptionsRegistry, IEditorOption } from '@theia/monaco-editor-core/esm/vs/editor/common/config/editorOptions'; import { MAX_SAFE_INTEGER } from '@theia/core'; import { editorGeneratedPreferenceProperties } from '@theia/editor/lib/browser/editor-generated-preference-schema'; +import { WorkspaceFileService } from '@theia/workspace/lib/common/workspace-file-service'; let theiaDidInitialize = false; const originalInitialize = StandaloneServices.initialize; @@ -71,6 +72,8 @@ export class MonacoFrontendApplicationContribution implements FrontendApplicatio @inject(MonacoThemingService) protected readonly monacoThemingService: MonacoThemingService; + @inject(WorkspaceFileService) protected readonly workspaceFileService: WorkspaceFileService; + @postConstruct() protected init(): void { this.addAdditionalPreferenceValidations(); @@ -104,7 +107,16 @@ export class MonacoFrontendApplicationContribution implements FrontendApplicatio this.monacoThemingService.initialize(); } - initialize(): void { } + initialize(): void { + const workspaceExtensions = this.workspaceFileService.getWorkspaceFileExtensions(); + monaco.languages.register({ + id: 'jsonc', + 'aliases': [ + 'JSON with Comments' + ], + 'extensions': workspaceExtensions.map(ext => `.${ext}`) + }); + } registerThemeStyle(theme: ColorTheme, collector: CssStyleCollector): void { if (isHighContrast(theme.type)) { diff --git a/packages/monaco/tsconfig.json b/packages/monaco/tsconfig.json index 85d090101540c..0123614ccd2c0 100644 --- a/packages/monaco/tsconfig.json +++ b/packages/monaco/tsconfig.json @@ -23,6 +23,9 @@ }, { "path": "../outline-view" + }, + { + "path": "../workspace" } ] } diff --git a/packages/outline-view/src/browser/outline-view-contribution.ts b/packages/outline-view/src/browser/outline-view-contribution.ts index 8d8577ba6faeb..e3ccc095cce94 100644 --- a/packages/outline-view/src/browser/outline-view-contribution.ts +++ b/packages/outline-view/src/browser/outline-view-contribution.ts @@ -16,7 +16,8 @@ import { injectable } from '@theia/core/shared/inversify'; import { AbstractViewContribution } from '@theia/core/lib/browser/shell/view-contribution'; -import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { Command, CommandRegistry } from '@theia/core/lib/common/command'; import { TabBarToolbarContribution, TabBarToolbarRegistry } from '@theia/core/lib/browser/shell/tab-bar-toolbar'; import { codicon, Widget } from '@theia/core/lib/browser/widgets'; diff --git a/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts b/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts index b2883dd62f4b0..9de6fe277faea 100644 --- a/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts +++ b/packages/vsx-registry/src/browser/vsx-extensions-contribution.ts @@ -24,7 +24,8 @@ import { VSXExtensionsModel } from './vsx-extensions-model'; import { ColorContribution } from '@theia/core/lib/browser/color-application-contribution'; import { ColorRegistry } from '@theia/core/lib/browser/color-registry'; import { Color } from '@theia/core/lib/common/color'; -import { FrontendApplicationContribution, FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplication } from '@theia/core/lib/browser/frontend-application'; +import { FrontendApplicationContribution } from '@theia/core/lib/browser/frontend-application-contribution'; import { MenuModelRegistry, MessageService, nls } from '@theia/core/lib/common'; import { FileDialogService, OpenFileDialogProps } from '@theia/filesystem/lib/browser'; import { LabelProvider, PreferenceService, QuickPickItem, QuickInputService, CommonMenus } from '@theia/core/lib/browser'; diff --git a/packages/workspace/package.json b/packages/workspace/package.json index 07f33666f7135..ffcd60f3f366d 100644 --- a/packages/workspace/package.json +++ b/packages/workspace/package.json @@ -5,7 +5,6 @@ "dependencies": { "@theia/core": "1.42.0", "@theia/filesystem": "1.42.0", - "@theia/monaco-editor-core": "1.72.3", "@theia/variable-resolver": "1.42.0", "jsonc-parser": "^2.2.0", "valid-filename": "^2.0.1" diff --git a/packages/workspace/src/browser/workspace-frontend-contribution.ts b/packages/workspace/src/browser/workspace-frontend-contribution.ts index 43e652511044a..6a5fb2060cf95 100644 --- a/packages/workspace/src/browser/workspace-frontend-contribution.ts +++ b/packages/workspace/src/browser/workspace-frontend-contribution.ts @@ -39,7 +39,6 @@ import { FileStat } from '@theia/filesystem/lib/common/files'; import { UntitledWorkspaceExitDialog } from './untitled-workspace-exit-dialog'; import { FilesystemSaveResourceService } from '@theia/filesystem/lib/browser/filesystem-save-resource-service'; import { StopReason } from '@theia/core/lib/common/frontend-application-state'; -import * as monaco from '@theia/monaco-editor-core'; export enum WorkspaceStates { /** @@ -78,13 +77,6 @@ export class WorkspaceFrontendContribution implements CommandContribution, Keybi configure(): void { const workspaceExtensions = this.workspaceFileService.getWorkspaceFileExtensions(); - monaco.languages.register({ - id: 'jsonc', - 'aliases': [ - 'JSON with Comments' - ], - 'extensions': workspaceExtensions.map(ext => `.${ext}`) - }); for (const extension of workspaceExtensions) { this.encodingRegistry.registerOverride({ encoding: UTF8, extension }); }