@theia/core 1.42.0 → 1.43.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/i18n/nls.cs.json +29 -0
- package/i18n/nls.de.json +29 -0
- package/i18n/nls.es.json +29 -0
- package/i18n/nls.fr.json +29 -0
- package/i18n/nls.hu.json +29 -0
- package/i18n/nls.it.json +29 -0
- package/i18n/nls.ja.json +29 -0
- package/i18n/nls.json +29 -0
- package/i18n/nls.pl.json +29 -0
- package/i18n/nls.pt-br.json +29 -0
- package/i18n/nls.pt-pt.json +29 -0
- package/i18n/nls.ru.json +29 -0
- package/i18n/nls.zh-cn.json +29 -0
- package/lib/browser/color-application-contribution.d.ts +1 -1
- package/lib/browser/color-application-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.d.ts +6 -3
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +35 -14
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/connection-status-service.d.ts +1 -1
- package/lib/browser/connection-status-service.d.ts.map +1 -1
- package/lib/browser/connection-status-service.js +2 -2
- package/lib/browser/connection-status-service.js.map +1 -1
- package/lib/browser/core-preferences.js +16 -16
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/credentials-service.d.ts +2 -2
- package/lib/browser/credentials-service.d.ts.map +1 -1
- package/lib/browser/credentials-service.js +2 -2
- package/lib/browser/credentials-service.js.map +1 -1
- package/lib/browser/dialogs.d.ts +1 -1
- package/lib/browser/dialogs.d.ts.map +1 -1
- package/lib/browser/frontend-application-contribution.d.ts +76 -0
- package/lib/browser/frontend-application-contribution.d.ts.map +1 -0
- package/lib/browser/frontend-application-contribution.js +51 -0
- package/lib/browser/frontend-application-contribution.js.map +1 -0
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +24 -23
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/frontend-application.d.ts +1 -73
- package/lib/browser/frontend-application.d.ts.map +1 -1
- package/lib/browser/frontend-application.js +3 -26
- package/lib/browser/frontend-application.js.map +1 -1
- package/lib/browser/i18n/language-quick-pick-service.d.ts.map +1 -1
- package/lib/browser/i18n/language-quick-pick-service.js +1 -0
- package/lib/browser/i18n/language-quick-pick-service.js.map +1 -1
- package/lib/browser/icon-registry.d.ts +63 -0
- package/lib/browser/icon-registry.d.ts.map +1 -0
- package/lib/browser/icon-registry.js +25 -0
- package/lib/browser/icon-registry.js.map +1 -0
- package/lib/browser/icon-theme-contribution.d.ts +1 -1
- package/lib/browser/icon-theme-contribution.d.ts.map +1 -1
- package/lib/browser/index.d.ts +1 -0
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +1 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/json-schema-store.d.ts +1 -1
- package/lib/browser/json-schema-store.d.ts.map +1 -1
- package/lib/browser/label-provider.d.ts +1 -1
- package/lib/browser/label-provider.d.ts.map +1 -1
- package/lib/browser/logger-frontend-module.js +2 -2
- package/lib/browser/logger-frontend-module.js.map +1 -1
- package/lib/browser/menu/browser-menu-module.js +2 -2
- package/lib/browser/menu/browser-menu-module.js.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.d.ts +2 -1
- package/lib/browser/menu/browser-menu-plugin.d.ts.map +1 -1
- package/lib/browser/menu/browser-menu-plugin.js.map +1 -1
- package/lib/browser/messaging/messaging-frontend-module.d.ts.map +1 -1
- package/lib/browser/messaging/messaging-frontend-module.js +1 -0
- package/lib/browser/messaging/messaging-frontend-module.js.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.d.ts +5 -0
- package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.js +18 -3
- package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
- package/lib/browser/preload/theme-preload-contribution.js +2 -2
- package/lib/browser/preload/theme-preload-contribution.js.map +1 -1
- package/lib/browser/quick-input/quick-command-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/quick-input/quick-command-frontend-contribution.js +5 -0
- package/lib/browser/quick-input/quick-command-frontend-contribution.js.map +1 -1
- package/lib/browser/quick-input/quick-input-frontend-contribution.d.ts +1 -1
- package/lib/browser/quick-input/quick-input-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/saveable.d.ts +3 -3
- package/lib/browser/saveable.d.ts.map +1 -1
- package/lib/browser/saveable.js +13 -8
- package/lib/browser/saveable.js.map +1 -1
- package/lib/browser/shell/application-shell-mouse-tracker.d.ts +1 -1
- package/lib/browser/shell/application-shell-mouse-tracker.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.d.ts.map +1 -1
- package/lib/browser/shell/application-shell.js +15 -16
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/shell/tab-bar-decorator.d.ts +1 -1
- package/lib/browser/shell/tab-bar-decorator.d.ts.map +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts +1 -1
- package/lib/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.d.ts.map +1 -1
- package/lib/browser/status-bar/status-bar.d.ts.map +1 -1
- package/lib/browser/status-bar/status-bar.js +4 -2
- package/lib/browser/status-bar/status-bar.js.map +1 -1
- package/lib/browser/styling-service.d.ts +1 -1
- package/lib/browser/styling-service.d.ts.map +1 -1
- package/lib/browser/window/browser-window-module.js +2 -2
- package/lib/browser/window/browser-window-module.js.map +1 -1
- package/lib/browser/window/default-window-service.d.ts +2 -1
- package/lib/browser/window/default-window-service.d.ts.map +1 -1
- package/lib/browser/window/default-window-service.js +3 -3
- package/lib/browser/window/default-window-service.js.map +1 -1
- package/lib/browser/window/default-window-service.spec.js +2 -2
- package/lib/browser/window/default-window-service.spec.js.map +1 -1
- package/lib/browser/window/window-service.d.ts +3 -3
- package/lib/browser/window/window-service.d.ts.map +1 -1
- package/lib/browser/window/window-title-updater.d.ts +2 -1
- package/lib/browser/window/window-title-updater.d.ts.map +1 -1
- package/lib/browser/window/window-title-updater.js.map +1 -1
- package/lib/common/cancellation.d.ts +2 -0
- package/lib/common/cancellation.d.ts.map +1 -1
- package/lib/common/cancellation.js +20 -0
- package/lib/common/cancellation.js.map +1 -1
- package/lib/common/collections.d.ts +30 -0
- package/lib/common/collections.d.ts.map +1 -0
- package/lib/common/collections.js +122 -0
- package/lib/common/collections.js.map +1 -0
- package/lib/common/event.d.ts +5 -0
- package/lib/common/event.d.ts.map +1 -1
- package/lib/common/event.js +31 -0
- package/lib/common/event.js.map +1 -1
- package/lib/common/hash.d.ts +8 -0
- package/lib/common/hash.d.ts.map +1 -0
- package/lib/common/hash.js +85 -0
- package/lib/common/hash.js.map +1 -0
- package/lib/common/index.d.ts +1 -0
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +1 -0
- package/lib/common/index.js.map +1 -1
- package/lib/common/{keytar-protocol.d.ts → key-store.d.ts} +4 -4
- package/lib/common/key-store.d.ts.map +1 -0
- package/lib/common/{keytar-protocol.js → key-store.js} +4 -4
- package/lib/common/key-store.js.map +1 -0
- package/lib/common/keybinding.d.ts +2 -0
- package/lib/common/keybinding.d.ts.map +1 -1
- package/lib/common/keybinding.js +28 -0
- package/lib/common/keybinding.js.map +1 -1
- package/lib/common/markdown-rendering/markdown-string.d.ts +4 -0
- package/lib/common/markdown-rendering/markdown-string.d.ts.map +1 -1
- package/lib/common/markdown-rendering/markdown-string.js +24 -1
- package/lib/common/markdown-rendering/markdown-string.js.map +1 -1
- package/lib/common/menu/menu-types.d.ts +1 -1
- package/lib/common/menu/menu-types.d.ts.map +1 -1
- package/lib/common/menu/menu-types.js +2 -2
- package/lib/common/menu/menu-types.js.map +1 -1
- package/lib/common/message-rpc/rpc-protocol.d.ts.map +1 -1
- package/lib/common/message-rpc/rpc-protocol.js +6 -11
- package/lib/common/message-rpc/rpc-protocol.js.map +1 -1
- package/lib/common/objects.d.ts +1 -1
- package/lib/common/objects.d.ts.map +1 -1
- package/lib/common/objects.js +12 -10
- package/lib/common/objects.js.map +1 -1
- package/lib/common/quick-pick-service.d.ts +1 -0
- package/lib/common/quick-pick-service.d.ts.map +1 -1
- package/lib/common/quick-pick-service.js +2 -1
- package/lib/common/quick-pick-service.js.map +1 -1
- package/lib/common/strings.d.ts +1 -0
- package/lib/common/strings.d.ts.map +1 -1
- package/lib/common/strings.js +10 -1
- package/lib/common/strings.js.map +1 -1
- package/lib/common/types.d.ts +8 -0
- package/lib/common/types.d.ts.map +1 -1
- package/lib/common/types.js +21 -1
- package/lib/common/types.js.map +1 -1
- package/lib/common/uri.d.ts +0 -1
- package/lib/common/uri.d.ts.map +1 -1
- package/lib/common/uri.js +0 -3
- package/lib/common/uri.js.map +1 -1
- package/lib/common/uuid.d.ts +3 -0
- package/lib/common/uuid.d.ts.map +1 -0
- package/lib/common/uuid.js +86 -0
- package/lib/common/uuid.js.map +1 -0
- package/lib/common/version.d.ts +2 -0
- package/lib/common/version.d.ts.map +1 -0
- package/lib/common/version.js +20 -0
- package/lib/common/version.js.map +1 -0
- package/lib/common/window.d.ts +3 -0
- package/lib/common/window.d.ts.map +1 -1
- package/lib/electron-browser/keyboard/electron-keyboard-module.js +1 -1
- package/lib/electron-browser/keyboard/electron-keyboard-module.js.map +1 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts +7 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts.map +1 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.js +55 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.js.map +1 -0
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js +16 -2
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-module.js +2 -2
- package/lib/electron-browser/window/electron-window-module.js.map +1 -1
- package/lib/electron-browser/window/electron-window-service.d.ts +3 -3
- package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-service.js +10 -4
- package/lib/electron-browser/window/electron-window-service.js.map +1 -1
- package/lib/electron-common/electron-main-window-service.d.ts +2 -2
- package/lib/electron-common/electron-main-window-service.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts +3 -2
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +8 -4
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/electron-main-window-service-impl.d.ts +2 -2
- package/lib/electron-main/electron-main-window-service-impl.d.ts.map +1 -1
- package/lib/electron-main/electron-main-window-service-impl.js +2 -2
- package/lib/electron-main/electron-main-window-service-impl.js.map +1 -1
- package/lib/electron-node/hosting/electron-ws-origin-validator.d.ts +2 -0
- package/lib/electron-node/hosting/electron-ws-origin-validator.d.ts.map +1 -1
- package/lib/electron-node/hosting/electron-ws-origin-validator.js +12 -0
- package/lib/electron-node/hosting/electron-ws-origin-validator.js.map +1 -1
- package/lib/electron-node/token/electron-token-validator.d.ts +2 -2
- package/lib/electron-node/token/electron-token-validator.d.ts.map +1 -1
- package/lib/electron-node/token/electron-token-validator.js +12 -1
- package/lib/electron-node/token/electron-token-validator.js.map +1 -1
- package/lib/node/backend-application-module.d.ts.map +1 -1
- package/lib/node/backend-application-module.js +7 -4
- package/lib/node/backend-application-module.js.map +1 -1
- package/lib/node/backend-application.d.ts.map +1 -1
- package/lib/node/backend-application.js +4 -0
- package/lib/node/backend-application.js.map +1 -1
- package/lib/node/backend-remote-service.d.ts +4 -0
- package/lib/node/backend-remote-service.d.ts.map +1 -0
- package/lib/node/backend-remote-service.js +35 -0
- package/lib/node/backend-remote-service.js.map +1 -0
- package/lib/node/i18n/localization-contribution.d.ts +4 -4
- package/lib/node/i18n/localization-contribution.d.ts.map +1 -1
- package/lib/node/i18n/localization-contribution.js +11 -7
- package/lib/node/i18n/localization-contribution.js.map +1 -1
- package/lib/node/i18n/localization-provider.d.ts +16 -4
- package/lib/node/i18n/localization-provider.d.ts.map +1 -1
- package/lib/node/i18n/localization-provider.js +42 -10
- package/lib/node/i18n/localization-provider.js.map +1 -1
- package/lib/node/key-store-server.d.ts +28 -0
- package/lib/node/key-store-server.d.ts.map +1 -0
- package/lib/node/{keytar-server.js → key-store-server.js} +76 -17
- package/lib/node/key-store-server.js.map +1 -0
- package/lib/node/messaging/messaging-contribution.d.ts +1 -1
- package/lib/node/messaging/messaging-contribution.d.ts.map +1 -1
- package/lib/node/messaging/messaging-contribution.js +5 -4
- package/lib/node/messaging/messaging-contribution.js.map +1 -1
- package/package.json +6 -6
- package/src/browser/color-application-contribution.ts +1 -1
- package/src/browser/common-frontend-contribution.ts +41 -16
- package/src/browser/connection-status-service.ts +1 -1
- package/src/browser/core-preferences.ts +16 -16
- package/src/browser/credentials-service.ts +3 -3
- package/src/browser/dialogs.ts +1 -1
- package/src/browser/frontend-application-contribution.ts +110 -0
- package/src/browser/frontend-application-module.ts +8 -7
- package/src/browser/frontend-application.ts +2 -92
- package/src/browser/i18n/language-quick-pick-service.ts +1 -0
- package/src/browser/icon-registry.ts +96 -0
- package/src/browser/icon-theme-contribution.ts +1 -1
- package/src/browser/index.ts +1 -0
- package/src/browser/json-schema-store.ts +1 -1
- package/src/browser/label-provider.ts +1 -1
- package/src/browser/logger-frontend-module.ts +1 -1
- package/src/browser/menu/browser-menu-module.ts +1 -1
- package/src/browser/menu/browser-menu-plugin.ts +2 -1
- package/src/browser/messaging/messaging-frontend-module.ts +2 -1
- package/src/browser/messaging/ws-connection-provider.ts +21 -2
- package/src/browser/preload/theme-preload-contribution.ts +1 -1
- package/src/browser/quick-input/quick-command-frontend-contribution.ts +5 -0
- package/src/browser/quick-input/quick-input-frontend-contribution.ts +1 -1
- package/src/browser/saveable.ts +11 -7
- package/src/browser/shell/application-shell-mouse-tracker.ts +1 -1
- package/src/browser/shell/application-shell.ts +16 -15
- package/src/browser/shell/tab-bar-decorator.ts +1 -1
- package/src/browser/shell/tab-bar-toolbar/tab-bar-toolbar-registry.ts +1 -1
- package/src/browser/status-bar/status-bar.tsx +6 -2
- package/src/browser/style/status-bar.css +12 -4
- package/src/browser/styling-service.ts +1 -1
- package/src/browser/window/browser-window-module.ts +1 -1
- package/src/browser/window/default-window-service.spec.ts +1 -1
- package/src/browser/window/default-window-service.ts +2 -1
- package/src/browser/window/window-service.ts +3 -3
- package/src/browser/window/window-title-updater.ts +2 -1
- package/src/common/cancellation.ts +22 -0
- package/src/common/collections.ts +125 -0
- package/src/common/event.ts +32 -0
- package/src/common/hash.ts +85 -0
- package/src/common/i18n/nls.metadata.json +4947 -4690
- package/src/common/index.ts +1 -0
- package/src/common/{keytar-protocol.ts → key-store.ts} +3 -3
- package/src/common/keybinding.ts +26 -0
- package/src/common/markdown-rendering/markdown-string.ts +24 -0
- package/src/common/menu/menu-types.ts +1 -1
- package/src/common/message-rpc/rpc-protocol.ts +6 -10
- package/src/common/objects.ts +14 -10
- package/src/common/quick-pick-service.ts +1 -0
- package/src/common/strings.ts +11 -0
- package/src/common/types.ts +22 -0
- package/src/common/uri.ts +0 -4
- package/src/common/uuid.ts +99 -0
- package/src/common/version.ts +17 -0
- package/src/common/window.ts +4 -0
- package/src/electron-browser/keyboard/electron-keyboard-module.ts +1 -1
- package/src/electron-browser/messaging/electron-local-ws-connection-provider.ts +45 -0
- package/src/electron-browser/messaging/electron-messaging-frontend-module.ts +15 -2
- package/src/electron-browser/messaging/electron-ws-connection-provider.ts +1 -1
- package/src/electron-browser/window/electron-window-module.ts +1 -1
- package/src/electron-browser/window/electron-window-service.ts +10 -5
- package/src/electron-common/electron-main-window-service.ts +2 -2
- package/src/electron-main/electron-main-application.ts +9 -5
- package/src/electron-main/electron-main-window-service-impl.ts +3 -3
- package/src/electron-node/hosting/electron-ws-origin-validator.ts +9 -1
- package/src/electron-node/token/electron-token-validator.ts +13 -3
- package/src/node/backend-application-module.ts +8 -5
- package/src/node/backend-application.ts +4 -0
- package/src/node/backend-remote-service.ts +25 -0
- package/src/node/i18n/localization-contribution.ts +15 -11
- package/src/node/i18n/localization-provider.ts +59 -12
- package/src/node/{keytar-server.ts → key-store-server.ts} +75 -11
- package/src/node/messaging/messaging-contribution.ts +5 -4
- package/lib/common/keytar-protocol.d.ts.map +0 -1
- package/lib/common/keytar-protocol.js.map +0 -1
- package/lib/node/keytar-server.d.ts +0 -14
- package/lib/node/keytar-server.d.ts.map +0 -1
- package/lib/node/keytar-server.js.map +0 -1
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, named } from 'inversify';
|
|
18
|
-
import { FrontendApplicationContribution } from './frontend-application';
|
|
18
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
19
19
|
import { ContributionProvider } from '../common/contribution-provider';
|
|
20
20
|
import { IconThemeService, IconTheme } from './icon-theme-service';
|
|
21
21
|
import { MaybePromise } from '../common/types';
|
package/src/browser/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, named } from 'inversify';
|
|
18
18
|
import { ContributionProvider } from '../common/contribution-provider';
|
|
19
|
-
import { FrontendApplicationContribution } from './frontend-application';
|
|
19
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
20
20
|
import { MaybePromise } from '../common';
|
|
21
21
|
import { Endpoint } from './endpoint';
|
|
22
22
|
import { timeout, Deferred } from '../common/promise-util';
|
|
@@ -19,7 +19,7 @@ import * as fileIcons from 'file-icons-js';
|
|
|
19
19
|
import URI from '../common/uri';
|
|
20
20
|
import { ContributionProvider } from '../common/contribution-provider';
|
|
21
21
|
import { Event, Emitter, Disposable, isObject, Path, Prioritizeable } from '../common';
|
|
22
|
-
import { FrontendApplicationContribution } from './frontend-application';
|
|
22
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
23
23
|
import { EnvVariablesServer } from '../common/env-variables/env-variables-protocol';
|
|
24
24
|
import { ResourceLabelFormatter, ResourceLabelFormatting } from '../common/label-protocol';
|
|
25
25
|
import { codicon } from './widgets';
|
|
@@ -19,7 +19,7 @@ import { ILoggerServer, loggerPath, ConsoleLogger } from '../common/logger-proto
|
|
|
19
19
|
import { ILogger, Logger, LoggerFactory, setRootLogger, LoggerName, rootLoggerName } from '../common/logger';
|
|
20
20
|
import { LoggerWatcher } from '../common/logger-watcher';
|
|
21
21
|
import { WebSocketConnectionProvider } from './messaging';
|
|
22
|
-
import { FrontendApplicationContribution } from './frontend-application';
|
|
22
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
23
23
|
import { EncodingError } from '../common/message-rpc/rpc-message-encoder';
|
|
24
24
|
|
|
25
25
|
export const loggerFrontendModule = new ContainerModule(bind => {
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import { FrontendApplicationContribution } from '../frontend-application';
|
|
18
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
19
19
|
import { ContextMenuRenderer } from '../context-menu-renderer';
|
|
20
20
|
import { BrowserMenuBarContribution, BrowserMainMenuFactory } from './browser-menu-plugin';
|
|
21
21
|
import { BrowserContextMenuRenderer } from './browser-context-menu-renderer';
|
|
@@ -22,7 +22,8 @@ import {
|
|
|
22
22
|
MenuModelRegistry, MAIN_MENU_BAR, MenuPath, MenuNode, MenuCommandExecutor, CompoundMenuNode, CompoundMenuNodeRole, CommandMenuNode
|
|
23
23
|
} from '../../common';
|
|
24
24
|
import { KeybindingRegistry } from '../keybinding';
|
|
25
|
-
import {
|
|
25
|
+
import { FrontendApplication } from '../frontend-application';
|
|
26
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
26
27
|
import { ContextKeyService, ContextMatcher } from '../context-key-service';
|
|
27
28
|
import { ContextMenuContext } from './context-menu-context';
|
|
28
29
|
import { waitForRevealed } from '../widgets';
|
|
@@ -15,8 +15,9 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import { WebSocketConnectionProvider } from './ws-connection-provider';
|
|
18
|
+
import { LocalWebSocketConnectionProvider, WebSocketConnectionProvider } from './ws-connection-provider';
|
|
19
19
|
|
|
20
20
|
export const messagingFrontendModule = new ContainerModule(bind => {
|
|
21
21
|
bind(WebSocketConnectionProvider).toSelf().inSingletonScope();
|
|
22
|
+
bind(LocalWebSocketConnectionProvider).toService(WebSocketConnectionProvider);
|
|
22
23
|
});
|
|
@@ -24,6 +24,8 @@ import { IWebSocket, WebSocketChannel } from '../../common/messaging/web-socket-
|
|
|
24
24
|
decorate(injectable(), RpcProxyFactory);
|
|
25
25
|
decorate(unmanaged(), RpcProxyFactory, 0);
|
|
26
26
|
|
|
27
|
+
export const LocalWebSocketConnectionProvider = Symbol('LocalWebSocketConnectionProvider');
|
|
28
|
+
|
|
27
29
|
export interface WebSocketOptions {
|
|
28
30
|
/**
|
|
29
31
|
* True by default.
|
|
@@ -48,6 +50,19 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
|
|
|
48
50
|
return container.get(WebSocketConnectionProvider).createProxy<T>(path, arg);
|
|
49
51
|
}
|
|
50
52
|
|
|
53
|
+
static createLocalProxy<T extends object>(container: interfaces.Container, path: string, arg?: object): RpcProxy<T> {
|
|
54
|
+
return container.get<WebSocketConnectionProvider>(LocalWebSocketConnectionProvider).createProxy<T>(path, arg);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static createHandler(container: interfaces.Container, path: string, arg?: object): void {
|
|
58
|
+
const remote = container.get(WebSocketConnectionProvider);
|
|
59
|
+
const local = container.get<WebSocketConnectionProvider>(LocalWebSocketConnectionProvider);
|
|
60
|
+
remote.createProxy(path, arg);
|
|
61
|
+
if (remote !== local) {
|
|
62
|
+
local.createProxy(path, arg);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
51
66
|
protected readonly socket: Socket;
|
|
52
67
|
|
|
53
68
|
constructor() {
|
|
@@ -104,11 +119,15 @@ export class WebSocketConnectionProvider extends AbstractConnectionProvider<WebS
|
|
|
104
119
|
protected createWebSocketUrl(path: string): string {
|
|
105
120
|
// Since we are using Socket.io, the path should look like the following:
|
|
106
121
|
// proto://domain.com/{path}
|
|
107
|
-
return
|
|
122
|
+
return this.createEndpoint(path).getWebSocketUrl().toString();
|
|
108
123
|
}
|
|
109
124
|
|
|
110
125
|
protected createHttpWebSocketUrl(path: string): string {
|
|
111
|
-
return
|
|
126
|
+
return this.createEndpoint(path).getRestUrl().toString();
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
protected createEndpoint(path: string): Endpoint {
|
|
130
|
+
return new Endpoint({ path });
|
|
112
131
|
}
|
|
113
132
|
|
|
114
133
|
/**
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { PreloadContribution } from './preloader';
|
|
18
18
|
import { DEFAULT_BACKGROUND_COLOR_STORAGE_KEY } from '../frontend-application-config-provider';
|
|
19
19
|
import { injectable } from 'inversify';
|
|
20
|
-
import { DefaultTheme } from '@theia/application-package';
|
|
20
|
+
import { DefaultTheme } from '@theia/application-package/lib/application-props';
|
|
21
21
|
|
|
22
22
|
@injectable()
|
|
23
23
|
export class ThemePreloadContribution implements PreloadContribution {
|
|
@@ -59,6 +59,11 @@ export class QuickCommandFrontendContribution implements CommandContribution, Ke
|
|
|
59
59
|
commandId: quickCommand.id,
|
|
60
60
|
label: nls.localizeByDefault('Command Palette...')
|
|
61
61
|
});
|
|
62
|
+
menus.registerMenuAction(CommonMenus.MANAGE_GENERAL, {
|
|
63
|
+
commandId: quickCommand.id,
|
|
64
|
+
label: nls.localizeByDefault('Command Palette...'),
|
|
65
|
+
order: '0'
|
|
66
|
+
});
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
registerKeybindings(keybindings: KeybindingRegistry): void {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, named } from 'inversify';
|
|
18
18
|
import { ContributionProvider } from '../../common';
|
|
19
|
-
import { FrontendApplicationContribution } from '../frontend-application';
|
|
19
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
20
20
|
import { QuickAccessContribution } from './quick-access';
|
|
21
21
|
|
|
22
22
|
@injectable()
|
package/src/browser/saveable.ts
CHANGED
|
@@ -50,7 +50,7 @@ export interface SaveableSource {
|
|
|
50
50
|
readonly saveable: Saveable;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
export class
|
|
53
|
+
export class DelegatingSaveable implements Saveable {
|
|
54
54
|
dirty = false;
|
|
55
55
|
protected readonly onDirtyChangedEmitter = new Emitter<void>();
|
|
56
56
|
|
|
@@ -60,20 +60,20 @@ export class SaveableDelegate implements Saveable {
|
|
|
60
60
|
autoSave: 'off' | 'afterDelay' | 'onFocusChange' | 'onWindowChange' = 'off';
|
|
61
61
|
|
|
62
62
|
async save(options?: SaveOptions): Promise<void> {
|
|
63
|
-
await this.
|
|
63
|
+
await this._delegate?.save(options);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
66
|
revert?(options?: Saveable.RevertOptions): Promise<void>;
|
|
67
67
|
createSnapshot?(): Saveable.Snapshot;
|
|
68
68
|
applySnapshot?(snapshot: object): void;
|
|
69
69
|
|
|
70
|
-
protected
|
|
70
|
+
protected _delegate?: Saveable;
|
|
71
71
|
protected toDispose?: Disposable;
|
|
72
72
|
|
|
73
|
-
set(delegate: Saveable)
|
|
73
|
+
set delegate(delegate: Saveable) {
|
|
74
74
|
this.toDispose?.dispose();
|
|
75
|
-
this.
|
|
76
|
-
this.toDispose =
|
|
75
|
+
this._delegate = delegate;
|
|
76
|
+
this.toDispose = delegate.onDirtyChanged(() => {
|
|
77
77
|
this.dirty = delegate.dirty;
|
|
78
78
|
this.onDirtyChangedEmitter.fire();
|
|
79
79
|
});
|
|
@@ -164,8 +164,12 @@ export namespace Saveable {
|
|
|
164
164
|
if (typeof result === 'boolean') {
|
|
165
165
|
if (result) {
|
|
166
166
|
await (doSave?.(this) ?? Saveable.save(this));
|
|
167
|
+
if (!isDirty(this)) {
|
|
168
|
+
await this.closeWithoutSaving();
|
|
169
|
+
}
|
|
170
|
+
} else {
|
|
171
|
+
await this.closeWithoutSaving();
|
|
167
172
|
}
|
|
168
|
-
await this.closeWithoutSaving();
|
|
169
173
|
}
|
|
170
174
|
} finally {
|
|
171
175
|
closing = false;
|
|
@@ -14,7 +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 { FrontendApplicationContribution } from '../frontend-application';
|
|
17
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
18
18
|
import { ApplicationShell } from './application-shell';
|
|
19
19
|
import { injectable, inject } from 'inversify';
|
|
20
20
|
import { DisposableCollection, Disposable } from '../../common/disposable';
|
|
@@ -272,6 +272,22 @@ export class ApplicationShell extends Widget {
|
|
|
272
272
|
@inject(SecondaryWindowHandler) protected readonly secondaryWindowHandler: SecondaryWindowHandler,
|
|
273
273
|
) {
|
|
274
274
|
super(options as Widget.IOptions);
|
|
275
|
+
|
|
276
|
+
// Merge the user-defined application options with the default options
|
|
277
|
+
this.options = {
|
|
278
|
+
bottomPanel: {
|
|
279
|
+
...ApplicationShell.DEFAULT_OPTIONS.bottomPanel,
|
|
280
|
+
...options?.bottomPanel || {}
|
|
281
|
+
},
|
|
282
|
+
leftPanel: {
|
|
283
|
+
...ApplicationShell.DEFAULT_OPTIONS.leftPanel,
|
|
284
|
+
...options?.leftPanel || {}
|
|
285
|
+
},
|
|
286
|
+
rightPanel: {
|
|
287
|
+
...ApplicationShell.DEFAULT_OPTIONS.rightPanel,
|
|
288
|
+
...options?.rightPanel || {}
|
|
289
|
+
}
|
|
290
|
+
};
|
|
275
291
|
}
|
|
276
292
|
|
|
277
293
|
@postConstruct()
|
|
@@ -303,21 +319,6 @@ export class ApplicationShell extends Widget {
|
|
|
303
319
|
protected initializeShell(): void {
|
|
304
320
|
this.addClass(APPLICATION_SHELL_CLASS);
|
|
305
321
|
this.id = 'theia-app-shell';
|
|
306
|
-
// Merge the user-defined application options with the default options
|
|
307
|
-
this.options = {
|
|
308
|
-
bottomPanel: {
|
|
309
|
-
...ApplicationShell.DEFAULT_OPTIONS.bottomPanel,
|
|
310
|
-
...this.options?.bottomPanel || {}
|
|
311
|
-
},
|
|
312
|
-
leftPanel: {
|
|
313
|
-
...ApplicationShell.DEFAULT_OPTIONS.leftPanel,
|
|
314
|
-
...this.options?.leftPanel || {}
|
|
315
|
-
},
|
|
316
|
-
rightPanel: {
|
|
317
|
-
...ApplicationShell.DEFAULT_OPTIONS.rightPanel,
|
|
318
|
-
...this.options?.rightPanel || {}
|
|
319
|
-
}
|
|
320
|
-
};
|
|
321
322
|
|
|
322
323
|
this.mainPanel = this.createMainPanel();
|
|
323
324
|
this.topPanel = this.createTopPanel();
|
|
@@ -19,7 +19,7 @@ import { Title, Widget } from '@phosphor/widgets';
|
|
|
19
19
|
import { inject, injectable, named } from 'inversify';
|
|
20
20
|
import { Event, Emitter, ContributionProvider } from '../../common';
|
|
21
21
|
import { WidgetDecoration } from '../widget-decoration';
|
|
22
|
-
import { FrontendApplicationContribution } from '../frontend-application';
|
|
22
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
23
23
|
|
|
24
24
|
export const TabBarDecorator = Symbol('TabBarDecorator');
|
|
25
25
|
|
|
@@ -19,7 +19,7 @@ import { inject, injectable, named } from 'inversify';
|
|
|
19
19
|
// eslint-disable-next-line max-len
|
|
20
20
|
import { CommandMenuNode, CommandRegistry, CompoundMenuNode, ContributionProvider, Disposable, DisposableCollection, Emitter, Event, MenuModelRegistry, MenuNode, MenuPath } from '../../../common';
|
|
21
21
|
import { ContextKeyService } from '../../context-key-service';
|
|
22
|
-
import { FrontendApplicationContribution } from '../../frontend-application';
|
|
22
|
+
import { FrontendApplicationContribution } from '../../frontend-application-contribution';
|
|
23
23
|
import { Widget } from '../../widgets';
|
|
24
24
|
import { AnyToolbarItem, ConditionalToolbarItem, MenuDelegate, MenuToolbarItem, ReactTabBarToolbarItem, TabBarToolbarItem } from './tab-bar-toolbar-types';
|
|
25
25
|
import { ToolbarMenuNodeWrapper } from './tab-bar-toolbar-menu-adapters';
|
|
@@ -151,6 +151,9 @@ export class StatusBarImpl extends ReactWidget implements StatusBar {
|
|
|
151
151
|
} else {
|
|
152
152
|
attrs['aria-label'] = [entry.text, entry.tooltip].join(', ');
|
|
153
153
|
}
|
|
154
|
+
if (entry.backgroundColor) {
|
|
155
|
+
attrs.className += ' has-background';
|
|
156
|
+
}
|
|
154
157
|
|
|
155
158
|
attrs.style = {
|
|
156
159
|
color: entry.color || this.color,
|
|
@@ -178,8 +181,9 @@ export class StatusBarImpl extends ReactWidget implements StatusBar {
|
|
|
178
181
|
children.push(<span key={key}>{val}</span>);
|
|
179
182
|
}
|
|
180
183
|
});
|
|
181
|
-
|
|
182
|
-
|
|
184
|
+
return <div key={entry.id} {...this.createAttributes(entry)}>
|
|
185
|
+
{children}
|
|
186
|
+
</div>;
|
|
183
187
|
}
|
|
184
188
|
|
|
185
189
|
}
|
|
@@ -30,7 +30,7 @@ body.theia-no-open-workspace #theia-statusBar {
|
|
|
30
30
|
background: var(--theia-statusBar-noFolderBackground);
|
|
31
31
|
color: var(--theia-statusBar-noFolderForeground);
|
|
32
32
|
border-top: var(--theia-border-width) solid
|
|
33
|
-
|
|
33
|
+
var(--theia-statusBar-noFolderBorder);
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
#theia-statusBar .area {
|
|
@@ -41,7 +41,6 @@ body.theia-no-open-workspace #theia-statusBar {
|
|
|
41
41
|
|
|
42
42
|
#theia-statusBar .area.left {
|
|
43
43
|
justify-content: flex-start;
|
|
44
|
-
padding-left: calc(var(--theia-ui-padding) * 2);
|
|
45
44
|
}
|
|
46
45
|
|
|
47
46
|
#theia-statusBar .area.right {
|
|
@@ -56,8 +55,14 @@ body.theia-no-open-workspace #theia-statusBar {
|
|
|
56
55
|
font-size: var(--theia-statusBar-font-size);
|
|
57
56
|
}
|
|
58
57
|
|
|
59
|
-
#theia-statusBar .area .element
|
|
60
|
-
margin-left:
|
|
58
|
+
#theia-statusBar .area.left .element.has-background {
|
|
59
|
+
margin-left: 0px;
|
|
60
|
+
margin-right: 3px;
|
|
61
|
+
padding-left: 7px;
|
|
62
|
+
padding-right: 7px;
|
|
63
|
+
}
|
|
64
|
+
#theia-statusBar .area .element>* {
|
|
65
|
+
margin-left: calc(var(--theia-ui-padding)/2);
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
#theia-statusBar .area .element .codicon {
|
|
@@ -77,6 +82,9 @@ body.theia-no-open-workspace #theia-statusBar {
|
|
|
77
82
|
color: var(--theia-statusBar-offlineForeground) !important;
|
|
78
83
|
}
|
|
79
84
|
|
|
85
|
+
#theia-statusBar .area.left .element:first-child:not(.has-background) {
|
|
86
|
+
margin-left: calc(var(--theia-ui-padding) * 3);
|
|
87
|
+
}
|
|
80
88
|
#theia-statusBar .area.left .element {
|
|
81
89
|
margin-right: var(--theia-ui-padding);
|
|
82
90
|
}
|
|
@@ -19,7 +19,7 @@ import { ContributionProvider } from '../common/contribution-provider';
|
|
|
19
19
|
import { Theme, ThemeType } from '../common/theme';
|
|
20
20
|
import { ColorRegistry } from './color-registry';
|
|
21
21
|
import { DecorationStyle } from './decoration-style';
|
|
22
|
-
import { FrontendApplicationContribution } from './frontend-application';
|
|
22
|
+
import { FrontendApplicationContribution } from './frontend-application-contribution';
|
|
23
23
|
import { ThemeService } from './theming';
|
|
24
24
|
import { Disposable } from '../common';
|
|
25
25
|
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
18
|
import { WindowService } from '../../browser/window/window-service';
|
|
19
19
|
import { DefaultWindowService } from '../../browser/window/default-window-service';
|
|
20
|
-
import { FrontendApplicationContribution } from '../frontend-application';
|
|
20
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
21
21
|
import { ClipboardService } from '../clipboard-service';
|
|
22
22
|
import { BrowserClipboardService } from '../browser-clipboard-service';
|
|
23
23
|
import { SecondaryWindowService } from './secondary-window-service';
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { Container } from 'inversify';
|
|
18
18
|
import { ContributionProvider } from '../../common';
|
|
19
19
|
import { CorePreferences } from '../core-preferences';
|
|
20
|
-
import { FrontendApplicationContribution } from '../frontend-application';
|
|
20
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
21
21
|
import { DefaultWindowService } from './default-window-service';
|
|
22
22
|
import assert = require('assert');
|
|
23
23
|
|
|
@@ -18,11 +18,12 @@ import { inject, injectable, named } from 'inversify';
|
|
|
18
18
|
import { Event, Emitter } from '../../common';
|
|
19
19
|
import { CorePreferences } from '../core-preferences';
|
|
20
20
|
import { ContributionProvider } from '../../common/contribution-provider';
|
|
21
|
-
import { FrontendApplicationContribution,
|
|
21
|
+
import { FrontendApplicationContribution, OnWillStopAction } from '../frontend-application-contribution';
|
|
22
22
|
import { WindowService } from './window-service';
|
|
23
23
|
import { DEFAULT_WINDOW_HASH } from '../../common/window';
|
|
24
24
|
import { confirmExit } from '../dialogs';
|
|
25
25
|
import { StopReason } from '../../common/frontend-application-state';
|
|
26
|
+
import { FrontendApplication } from '../frontend-application';
|
|
26
27
|
|
|
27
28
|
@injectable()
|
|
28
29
|
export class DefaultWindowService implements WindowService, FrontendApplicationContribution {
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { StopReason } from '../../common/frontend-application-state';
|
|
18
18
|
import { Event } from '../../common/event';
|
|
19
|
-
import { NewWindowOptions } from '../../common/window';
|
|
19
|
+
import { NewWindowOptions, WindowSearchParams } from '../../common/window';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* Service for opening new browser windows.
|
|
@@ -35,7 +35,7 @@ export interface WindowService {
|
|
|
35
35
|
* Opens a new default window.
|
|
36
36
|
* - In electron and in the browser it will open the default window without a pre-defined content.
|
|
37
37
|
*/
|
|
38
|
-
openNewDefaultWindow(): void;
|
|
38
|
+
openNewDefaultWindow(params?: WindowSearchParams): void;
|
|
39
39
|
|
|
40
40
|
/**
|
|
41
41
|
* Fires when the `window` unloads. The unload event is inevitable. On this event, the frontend application can save its state and release resource.
|
|
@@ -64,5 +64,5 @@ export interface WindowService {
|
|
|
64
64
|
/**
|
|
65
65
|
* Reloads the window according to platform.
|
|
66
66
|
*/
|
|
67
|
-
reload(): void;
|
|
67
|
+
reload(params?: WindowSearchParams): void;
|
|
68
68
|
}
|
|
@@ -15,7 +15,8 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { Widget } from '../widgets';
|
|
18
|
-
import { FrontendApplication
|
|
18
|
+
import { FrontendApplication } from '../frontend-application';
|
|
19
|
+
import { FrontendApplicationContribution } from '../frontend-application-contribution';
|
|
19
20
|
import { NavigatableWidget } from '../navigatable-types';
|
|
20
21
|
import { inject, injectable } from 'inversify';
|
|
21
22
|
import { WindowTitleService } from './window-title-service';
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
import { Event, Emitter } from './event';
|
|
22
22
|
import { isBoolean, isObject } from './types';
|
|
23
|
+
import { Disposable } from './disposable';
|
|
23
24
|
|
|
24
25
|
export interface CancellationToken {
|
|
25
26
|
readonly isCancellationRequested: boolean;
|
|
@@ -93,11 +94,23 @@ class MutableToken implements CancellationToken {
|
|
|
93
94
|
}
|
|
94
95
|
return this._emitter.event;
|
|
95
96
|
}
|
|
97
|
+
|
|
98
|
+
public dispose(): void {
|
|
99
|
+
if (this._emitter) {
|
|
100
|
+
this._emitter.dispose();
|
|
101
|
+
this._emitter = undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
export class CancellationTokenSource {
|
|
99
107
|
|
|
100
108
|
private _token: CancellationToken;
|
|
109
|
+
private _parentListener?: Disposable = undefined;
|
|
110
|
+
|
|
111
|
+
constructor(parent?: CancellationToken) {
|
|
112
|
+
this._parentListener = parent && parent.onCancellationRequested(this.cancel, this);
|
|
113
|
+
}
|
|
101
114
|
|
|
102
115
|
get token(): CancellationToken {
|
|
103
116
|
if (!this._token) {
|
|
@@ -121,6 +134,15 @@ export class CancellationTokenSource {
|
|
|
121
134
|
|
|
122
135
|
dispose(): void {
|
|
123
136
|
this.cancel();
|
|
137
|
+
this._parentListener?.dispose();
|
|
138
|
+
if (!this._token) {
|
|
139
|
+
// ensure to initialize with an empty token if we had none
|
|
140
|
+
this._token = CancellationToken.None;
|
|
141
|
+
|
|
142
|
+
} else if (this._token instanceof MutableToken) {
|
|
143
|
+
// actually dispose
|
|
144
|
+
this._token.dispose();
|
|
145
|
+
}
|
|
124
146
|
}
|
|
125
147
|
}
|
|
126
148
|
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 STMicroelectronics and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* A convenience class for managing a "map of maps" of arbitrary depth
|
|
19
|
+
*/
|
|
20
|
+
export class MultiKeyMap<K, V> {
|
|
21
|
+
private rootMap = new Map();
|
|
22
|
+
|
|
23
|
+
constructor(private readonly keyLength: number) {
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static create<S, T>(keyLength: number, data: [S[], T][]): MultiKeyMap<S, T> {
|
|
27
|
+
const result = new MultiKeyMap<S, T>(keyLength);
|
|
28
|
+
for (const entry of data) {
|
|
29
|
+
result.set(entry[0], entry[1]);
|
|
30
|
+
}
|
|
31
|
+
return result;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
set(key: readonly K[], value: V): V | undefined {
|
|
35
|
+
if (this.keyLength !== key.length) {
|
|
36
|
+
throw new Error(`inappropriate key length: ${key.length}, should be ${this.keyLength}`);
|
|
37
|
+
}
|
|
38
|
+
let map = this.rootMap;
|
|
39
|
+
for (let i = 0; i < this.keyLength - 1; i++) {
|
|
40
|
+
let existing = map.get(key[i]);
|
|
41
|
+
if (!existing) {
|
|
42
|
+
existing = new Map();
|
|
43
|
+
map.set(key[i], existing);
|
|
44
|
+
}
|
|
45
|
+
map = existing;
|
|
46
|
+
}
|
|
47
|
+
const oldValue = map.get(key[this.keyLength - 1]);
|
|
48
|
+
map.set(key[this.keyLength - 1], value);
|
|
49
|
+
return oldValue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
get(key: readonly K[]): V | undefined {
|
|
53
|
+
if (this.keyLength !== key.length) {
|
|
54
|
+
throw new Error(`inappropriate key length: ${key.length}, should be ${this.keyLength}`);
|
|
55
|
+
}
|
|
56
|
+
let map = this.rootMap;
|
|
57
|
+
for (let i = 0; i < this.keyLength - 1; i++) {
|
|
58
|
+
map = map.get(key[i]);
|
|
59
|
+
if (!map) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return map.get(key[this.keyLength - 1]);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Checks whether the given key is present in the map
|
|
68
|
+
* @param key the key to test. It can have a length < the key length
|
|
69
|
+
* @returns whether the key exists
|
|
70
|
+
*/
|
|
71
|
+
has(key: readonly K[]): boolean {
|
|
72
|
+
if (this.keyLength < key.length) {
|
|
73
|
+
throw new Error(`inappropriate key length: ${key.length}, should <= ${this.keyLength}`);
|
|
74
|
+
}
|
|
75
|
+
let map = this.rootMap;
|
|
76
|
+
for (let i = 0; i < key.length - 1; i++) {
|
|
77
|
+
map = map.get(key[i]);
|
|
78
|
+
if (!map) {
|
|
79
|
+
return false;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return map.has(key[key.length - 1]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Deletes the value with the given key from the map
|
|
87
|
+
* @param key the key to remove. It can have a length < the key length
|
|
88
|
+
* @returns whether the key was present in the map
|
|
89
|
+
*/
|
|
90
|
+
delete(key: readonly K[]): boolean {
|
|
91
|
+
if (this.keyLength < key.length) {
|
|
92
|
+
throw new Error(`inappropriate key length: ${key.length}, should <= ${this.keyLength}`);
|
|
93
|
+
}
|
|
94
|
+
let map = this.rootMap;
|
|
95
|
+
for (let i = 0; i < this.keyLength - 1; i++) {
|
|
96
|
+
map = map.get(key[i]);
|
|
97
|
+
if (!map) {
|
|
98
|
+
return false;
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return map.delete(key[key.length - 1]);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* Iterates over all entries in the map. The ordering semantics are like iterating over a map of maps.
|
|
106
|
+
* @param handler Handler for each entry
|
|
107
|
+
*/
|
|
108
|
+
forEach(handler: (value: V, key: K[]) => void): void {
|
|
109
|
+
this.doForeach(handler, this.rootMap, []);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
113
|
+
private doForeach(handler: (value: V, key: K[]) => void, currentMap: Map<any, any>, keys: K[]): void {
|
|
114
|
+
if (keys.length === this.keyLength - 1) {
|
|
115
|
+
currentMap.forEach((v, k) => {
|
|
116
|
+
handler(v, [...keys, k]);
|
|
117
|
+
});
|
|
118
|
+
} else {
|
|
119
|
+
currentMap.forEach((v, k) => {
|
|
120
|
+
this.doForeach(handler, v, [...keys, k]);
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
package/src/common/event.ts
CHANGED
|
@@ -57,6 +57,38 @@ export namespace Event {
|
|
|
57
57
|
set maxListeners(maxListeners: number) { }
|
|
58
58
|
});
|
|
59
59
|
|
|
60
|
+
/**
|
|
61
|
+
* Given an event, returns another event which only fires once.
|
|
62
|
+
*/
|
|
63
|
+
export function once<T>(event: Event<T>): Event<T> {
|
|
64
|
+
return (listener, thisArgs = undefined, disposables?) => {
|
|
65
|
+
// we need this, in case the event fires during the listener call
|
|
66
|
+
let didFire = false;
|
|
67
|
+
let result: Disposable | undefined = undefined;
|
|
68
|
+
result = event(e => {
|
|
69
|
+
if (didFire) {
|
|
70
|
+
return;
|
|
71
|
+
} else if (result) {
|
|
72
|
+
result.dispose();
|
|
73
|
+
} else {
|
|
74
|
+
didFire = true;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return listener.call(thisArgs, e);
|
|
78
|
+
}, undefined, disposables);
|
|
79
|
+
|
|
80
|
+
if (didFire) {
|
|
81
|
+
result.dispose();
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
return result;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function toPromise<T>(event: Event<T>): Promise<T> {
|
|
89
|
+
return new Promise(resolve => once(event)(resolve));
|
|
90
|
+
}
|
|
91
|
+
|
|
60
92
|
/**
|
|
61
93
|
* Given an event and a `map` function, returns another event which maps each element
|
|
62
94
|
* through the mapping function.
|