@theia/core 1.42.1 → 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/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/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
package/src/common/index.ts
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
export const
|
|
17
|
+
export const keyStoreServicePath = '/services/keyStore';
|
|
18
18
|
|
|
19
|
-
export const
|
|
20
|
-
export interface
|
|
19
|
+
export const KeyStoreService = Symbol('KeyStoreService');
|
|
20
|
+
export interface KeyStoreService {
|
|
21
21
|
setPassword(service: string, account: string, password: string): Promise<void>;
|
|
22
22
|
getPassword(service: string, account: string): Promise<string | undefined>;
|
|
23
23
|
deletePassword(service: string, account: string): Promise<boolean>;
|
package/src/common/keybinding.ts
CHANGED
|
@@ -107,6 +107,32 @@ export namespace Keybinding {
|
|
|
107
107
|
export function is(arg: unknown): arg is Keybinding {
|
|
108
108
|
return isObject(arg) && 'command' in arg && 'keybinding' in arg;
|
|
109
109
|
}
|
|
110
|
+
|
|
111
|
+
export function replaceKeybinding(keybindings: Keybinding[], oldKeybinding: Keybinding, newKeybinding: Keybinding): boolean {
|
|
112
|
+
const indexOld = keybindings.findIndex(keybinding => Keybinding.equals(keybinding, oldKeybinding, false, true));
|
|
113
|
+
if (indexOld >= 0) {
|
|
114
|
+
const indexNew = keybindings.findIndex(keybinding => Keybinding.equals(keybinding, newKeybinding, false, true));
|
|
115
|
+
if (indexNew >= 0 && indexNew !== indexOld) {
|
|
116
|
+
// if keybindings already contain the new keybinding, remove the old keybinding and update the new one
|
|
117
|
+
keybindings.splice(indexOld, 1);
|
|
118
|
+
keybindings[indexNew] = newKeybinding;
|
|
119
|
+
} else {
|
|
120
|
+
keybindings[indexOld] = newKeybinding;
|
|
121
|
+
}
|
|
122
|
+
return true;
|
|
123
|
+
}
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function addKeybinding(keybindings: Keybinding[], newKeybinding: Keybinding): void {
|
|
128
|
+
const index = keybindings.findIndex(keybinding => Keybinding.equals(keybinding, newKeybinding, false, true));
|
|
129
|
+
if (index >= 0) {
|
|
130
|
+
// if keybindings already contain the new keybinding, update it
|
|
131
|
+
keybindings[index] = newKeybinding;
|
|
132
|
+
} else {
|
|
133
|
+
keybindings.push(newKeybinding);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
110
136
|
}
|
|
111
137
|
|
|
112
138
|
/**
|
|
@@ -123,3 +123,27 @@ export function escapeMarkdownSyntaxTokens(text: string): string {
|
|
|
123
123
|
// escape markdown syntax tokens: http://daringfireball.net/projects/markdown/syntax#backslash
|
|
124
124
|
return text.replace(/[\\`*_{}[\]()#+\-!]/g, '\\$&');
|
|
125
125
|
}
|
|
126
|
+
|
|
127
|
+
// Copied from https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/htmlContent.ts
|
|
128
|
+
|
|
129
|
+
export function parseHrefAndDimensions(href: string): { href: string; dimensions: string[] } {
|
|
130
|
+
const dimensions: string[] = [];
|
|
131
|
+
const splitted = href.split('|').map(s => s.trim());
|
|
132
|
+
href = splitted[0];
|
|
133
|
+
const parameters = splitted[1];
|
|
134
|
+
if (parameters) {
|
|
135
|
+
const heightFromParams = /height=(\d+)/.exec(parameters);
|
|
136
|
+
const widthFromParams = /width=(\d+)/.exec(parameters);
|
|
137
|
+
const height = heightFromParams ? heightFromParams[1] : '';
|
|
138
|
+
const width = widthFromParams ? widthFromParams[1] : '';
|
|
139
|
+
const widthIsFinite = isFinite(parseInt(width));
|
|
140
|
+
const heightIsFinite = isFinite(parseInt(height));
|
|
141
|
+
if (widthIsFinite) {
|
|
142
|
+
dimensions.push(`width="${width}"`);
|
|
143
|
+
}
|
|
144
|
+
if (heightIsFinite) {
|
|
145
|
+
dimensions.push(`height="${height}"`);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
return { href, dimensions };
|
|
149
|
+
}
|
|
@@ -19,7 +19,7 @@ import { isObject } from '../types';
|
|
|
19
19
|
|
|
20
20
|
export type MenuPath = string[];
|
|
21
21
|
export const MAIN_MENU_BAR: MenuPath = ['menubar'];
|
|
22
|
-
export const
|
|
22
|
+
export const MANAGE_MENU: MenuPath = ['manage_menu'];
|
|
23
23
|
export const ACCOUNTS_MENU: MenuPath = ['accounts_menu'];
|
|
24
24
|
export const ACCOUNTS_SUBMENU = [...ACCOUNTS_MENU, '1_accounts_submenu'];
|
|
25
25
|
|
|
@@ -134,16 +134,12 @@ export class RpcProtocol {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
protected handleReplyErr(id: number, error: any): void {
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
throw new Error(`No reply handler for error reply with id: ${id}`);
|
|
144
|
-
}
|
|
145
|
-
} catch (err) {
|
|
146
|
-
throw err;
|
|
137
|
+
const replyHandler = this.pendingRequests.get(id);
|
|
138
|
+
if (replyHandler) {
|
|
139
|
+
this.pendingRequests.delete(id);
|
|
140
|
+
replyHandler.reject(error);
|
|
141
|
+
} else {
|
|
142
|
+
throw new Error(`No reply handler for error reply with id: ${id}`);
|
|
147
143
|
}
|
|
148
144
|
}
|
|
149
145
|
|
package/src/common/objects.ts
CHANGED
|
@@ -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 { isObject, isUndefined } from './types';
|
|
17
|
+
import { isObject, isUndefined, isUndefinedOrNull } from './types';
|
|
18
18
|
|
|
19
19
|
export function deepClone<T>(obj: T): T {
|
|
20
20
|
if (!isObject(obj)) {
|
|
@@ -71,17 +71,21 @@ export function isEmpty(arg: Object): boolean {
|
|
|
71
71
|
return Object.keys(arg).length === 0 && arg.constructor === Object;
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
-
// copied and modified from https://github.com/microsoft/vscode/blob/1.76.0/src/vs/base/common/objects.ts#L45-L83
|
|
75
74
|
/*---------------------------------------------------------------------------------------------
|
|
76
|
-
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
77
|
-
* Licensed under the MIT License. See
|
|
75
|
+
* Copyright (c) Microsoft Corporation and others. All rights reserved.
|
|
76
|
+
* Licensed under the MIT License. See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.
|
|
78
77
|
*--------------------------------------------------------------------------------------------*/
|
|
79
78
|
|
|
79
|
+
// Copied from https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/objects.ts
|
|
80
|
+
|
|
80
81
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
81
|
-
export function cloneAndChange(obj: any, changer: (orig: any) => any
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
export function cloneAndChange(obj: any, changer: (orig: any) => any): any {
|
|
83
|
+
return _cloneAndChange(obj, changer, new Set());
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
87
|
+
function _cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>): any {
|
|
88
|
+
if (isUndefinedOrNull(obj)) {
|
|
85
89
|
return obj;
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -94,7 +98,7 @@ export function cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<
|
|
|
94
98
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
95
99
|
const r1: any[] = [];
|
|
96
100
|
for (const e of obj) {
|
|
97
|
-
r1.push(
|
|
101
|
+
r1.push(_cloneAndChange(e, changer, seen));
|
|
98
102
|
}
|
|
99
103
|
return r1;
|
|
100
104
|
}
|
|
@@ -108,7 +112,7 @@ export function cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<
|
|
|
108
112
|
for (const i2 in obj) {
|
|
109
113
|
if (_hasOwnProperty.call(obj, i2)) {
|
|
110
114
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
111
|
-
(r2 as any)[i2] =
|
|
115
|
+
(r2 as any)[i2] = _cloneAndChange(obj[i2], changer, seen);
|
|
112
116
|
}
|
|
113
117
|
}
|
|
114
118
|
seen.delete(obj);
|
|
@@ -272,6 +272,7 @@ export interface QuickPickOptions<T extends QuickPickItemOrSeparator> {
|
|
|
272
272
|
onDidTriggerItemButton?: (ItemButtonEvent: QuickPickItemButtonContext<T>) => void
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
+
export const quickInputServicePath = '/services/quickInput';
|
|
275
276
|
export const QuickInputService = Symbol('QuickInputService');
|
|
276
277
|
export interface QuickInputService {
|
|
277
278
|
readonly backButton: QuickInputButton;
|
package/src/common/strings.ts
CHANGED
|
@@ -218,3 +218,14 @@ export function compareSubstringIgnoreCase(a: string, b: string, aStart: number
|
|
|
218
218
|
|
|
219
219
|
return 0;
|
|
220
220
|
}
|
|
221
|
+
|
|
222
|
+
// Copied from https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/strings.ts
|
|
223
|
+
|
|
224
|
+
export function regExpFlags(regexp: RegExp): string {
|
|
225
|
+
return (regexp.global ? 'g' : '')
|
|
226
|
+
+ (regexp.ignoreCase ? 'i' : '')
|
|
227
|
+
+ (regexp.multiline ? 'm' : '')
|
|
228
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
229
|
+
+ ((regexp as any /* standalone editor compilation */).unicode ? 'u' : '');
|
|
230
|
+
}
|
|
231
|
+
|
package/src/common/types.ts
CHANGED
|
@@ -116,3 +116,25 @@ export function nullToUndefined<T>(nullable: MaybeNull<T>): MaybeUndefined<T> {
|
|
|
116
116
|
export function unreachable(_never: never, message: string = 'unhandled case'): never {
|
|
117
117
|
throw new Error(message);
|
|
118
118
|
}
|
|
119
|
+
|
|
120
|
+
/*---------------------------------------------------------------------------------------------
|
|
121
|
+
* Copyright (c) Microsoft Corporation and others. All rights reserved.
|
|
122
|
+
* Licensed under the MIT License. See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.
|
|
123
|
+
*--------------------------------------------------------------------------------------------*/
|
|
124
|
+
|
|
125
|
+
// Copied from https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/types.ts
|
|
126
|
+
|
|
127
|
+
/**
|
|
128
|
+
* @returns whether the provided parameter is defined.
|
|
129
|
+
*/
|
|
130
|
+
export function isDefined<T>(arg: T | null | undefined): arg is T {
|
|
131
|
+
return !isUndefinedOrNull(arg);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* @returns whether the provided parameter is undefined or null.
|
|
136
|
+
*/
|
|
137
|
+
export function isUndefinedOrNull(obj: unknown): obj is undefined | null {
|
|
138
|
+
// eslint-disable-next-line no-null/no-null
|
|
139
|
+
return (isUndefined(obj) || obj === null);
|
|
140
|
+
}
|
package/src/common/uri.ts
CHANGED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 Mathieu Bussieres 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
|
+
* Copyright (c) Microsoft Corporation and others. All rights reserved.
|
|
19
|
+
* Licensed under the MIT License. See https://github.com/Microsoft/vscode/blob/master/LICENSE.txt for license information.
|
|
20
|
+
*--------------------------------------------------------------------------------------------*/
|
|
21
|
+
|
|
22
|
+
// based on https://github.com/microsoft/vscode/blob/1.72.2/src/vs/base/common/uuid.ts
|
|
23
|
+
|
|
24
|
+
const _UUIDPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
25
|
+
|
|
26
|
+
export function isUUID(value: string): boolean {
|
|
27
|
+
return _UUIDPattern.test(value);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
declare const crypto: undefined | {
|
|
31
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues#browser_compatibility
|
|
32
|
+
getRandomValues?(data: Uint8Array): Uint8Array;
|
|
33
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/Crypto/randomUUID#browser_compatibility
|
|
34
|
+
randomUUID?(): string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export const generateUuid = (function (): () => string {
|
|
38
|
+
|
|
39
|
+
// use `randomUUID` if possible
|
|
40
|
+
if (typeof crypto === 'object' && typeof crypto.randomUUID === 'function') {
|
|
41
|
+
return crypto.randomUUID.bind(crypto);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// use `randomValues` if possible
|
|
45
|
+
let getRandomValues: (bucket: Uint8Array) => Uint8Array;
|
|
46
|
+
if (typeof crypto === 'object' && typeof crypto.getRandomValues === 'function') {
|
|
47
|
+
getRandomValues = crypto.getRandomValues.bind(crypto);
|
|
48
|
+
|
|
49
|
+
} else {
|
|
50
|
+
getRandomValues = function (bucket: Uint8Array): Uint8Array {
|
|
51
|
+
for (let i = 0; i < bucket.length; i++) {
|
|
52
|
+
bucket[i] = Math.floor(Math.random() * 256);
|
|
53
|
+
}
|
|
54
|
+
return bucket;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// prep-work
|
|
59
|
+
const _data = new Uint8Array(16);
|
|
60
|
+
const _hex: string[] = [];
|
|
61
|
+
for (let i = 0; i < 256; i++) {
|
|
62
|
+
_hex.push(i.toString(16).padStart(2, '0'));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-shadow
|
|
66
|
+
return function generateUuid(): string {
|
|
67
|
+
// get data
|
|
68
|
+
getRandomValues(_data);
|
|
69
|
+
|
|
70
|
+
// set version bits
|
|
71
|
+
_data[6] = (_data[6] & 0x0f) | 0x40;
|
|
72
|
+
_data[8] = (_data[8] & 0x3f) | 0x80;
|
|
73
|
+
|
|
74
|
+
// print as string
|
|
75
|
+
let i = 0;
|
|
76
|
+
let result = '';
|
|
77
|
+
result += _hex[_data[i++]];
|
|
78
|
+
result += _hex[_data[i++]];
|
|
79
|
+
result += _hex[_data[i++]];
|
|
80
|
+
result += _hex[_data[i++]];
|
|
81
|
+
result += '-';
|
|
82
|
+
result += _hex[_data[i++]];
|
|
83
|
+
result += _hex[_data[i++]];
|
|
84
|
+
result += '-';
|
|
85
|
+
result += _hex[_data[i++]];
|
|
86
|
+
result += _hex[_data[i++]];
|
|
87
|
+
result += '-';
|
|
88
|
+
result += _hex[_data[i++]];
|
|
89
|
+
result += _hex[_data[i++]];
|
|
90
|
+
result += '-';
|
|
91
|
+
result += _hex[_data[i++]];
|
|
92
|
+
result += _hex[_data[i++]];
|
|
93
|
+
result += _hex[_data[i++]];
|
|
94
|
+
result += _hex[_data[i++]];
|
|
95
|
+
result += _hex[_data[i++]];
|
|
96
|
+
result += _hex[_data[i++]];
|
|
97
|
+
return result;
|
|
98
|
+
};
|
|
99
|
+
})();
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2017 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
|
+
export const THEIA_VERSION: string = require('../../package.json').version;
|
package/src/common/window.ts
CHANGED
|
@@ -21,7 +21,7 @@ import { ElectronKeyboardLayoutChangeNotifier } from './electron-keyboard-layout
|
|
|
21
21
|
|
|
22
22
|
export default new ContainerModule((bind, unbind, isBound, rebind) => {
|
|
23
23
|
bind(KeyboardLayoutProvider).toDynamicValue(ctx =>
|
|
24
|
-
WebSocketConnectionProvider.
|
|
24
|
+
WebSocketConnectionProvider.createLocalProxy<KeyboardLayoutProvider>(ctx.container, keyboardPath)
|
|
25
25
|
).inSingletonScope();
|
|
26
26
|
bind(ElectronKeyboardLayoutChangeNotifier).toSelf().inSingletonScope();
|
|
27
27
|
bind(KeyboardLayoutChangeNotifier).toService(ElectronKeyboardLayoutChangeNotifier);
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2023 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 { injectable } from 'inversify';
|
|
18
|
+
import { WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider';
|
|
19
|
+
import { Endpoint } from '../../browser/endpoint';
|
|
20
|
+
|
|
21
|
+
export function getLocalPort(): string | undefined {
|
|
22
|
+
const params = new URLSearchParams(location.search);
|
|
23
|
+
return params.get('localPort') ?? undefined;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@injectable()
|
|
27
|
+
export class ElectronLocalWebSocketConnectionProvider extends WebSocketConnectionProvider {
|
|
28
|
+
|
|
29
|
+
protected override createEndpoint(path: string): Endpoint {
|
|
30
|
+
const localPort = getLocalPort();
|
|
31
|
+
if (!localPort) {
|
|
32
|
+
throw new Error('This should only be called in case there is a local port specified!');
|
|
33
|
+
}
|
|
34
|
+
const endpoint = new Endpoint({
|
|
35
|
+
path
|
|
36
|
+
}, {
|
|
37
|
+
host: `localhost:${localPort}`,
|
|
38
|
+
pathname: '/',
|
|
39
|
+
protocol: 'http',
|
|
40
|
+
search: ''
|
|
41
|
+
});
|
|
42
|
+
return endpoint;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
@@ -15,14 +15,27 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
|
-
import { FrontendApplicationContribution } from '../../browser/frontend-application';
|
|
19
|
-
import { WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider';
|
|
18
|
+
import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution';
|
|
19
|
+
import { LocalWebSocketConnectionProvider, WebSocketConnectionProvider } from '../../browser/messaging/ws-connection-provider';
|
|
20
20
|
import { ElectronWebSocketConnectionProvider } from './electron-ws-connection-provider';
|
|
21
21
|
import { ElectronIpcConnectionProvider } from './electron-ipc-connection-provider';
|
|
22
|
+
import { ElectronLocalWebSocketConnectionProvider, getLocalPort } from './electron-local-ws-connection-provider';
|
|
22
23
|
|
|
23
24
|
export const messagingFrontendModule = new ContainerModule(bind => {
|
|
24
25
|
bind(ElectronWebSocketConnectionProvider).toSelf().inSingletonScope();
|
|
25
26
|
bind(FrontendApplicationContribution).toService(ElectronWebSocketConnectionProvider);
|
|
26
27
|
bind(WebSocketConnectionProvider).toService(ElectronWebSocketConnectionProvider);
|
|
28
|
+
bind(ElectronLocalWebSocketConnectionProvider).toSelf().inSingletonScope();
|
|
29
|
+
bind(LocalWebSocketConnectionProvider).toDynamicValue(ctx => {
|
|
30
|
+
const localPort = getLocalPort();
|
|
31
|
+
if (localPort) {
|
|
32
|
+
// Return new web socket provider that connects to local app
|
|
33
|
+
return ctx.container.get(ElectronLocalWebSocketConnectionProvider);
|
|
34
|
+
} else {
|
|
35
|
+
// Return the usual web socket provider that already established its connection
|
|
36
|
+
// That way we don't create a second socket connection
|
|
37
|
+
return ctx.container.get(WebSocketConnectionProvider);
|
|
38
|
+
}
|
|
39
|
+
}).inSingletonScope();
|
|
27
40
|
bind(ElectronIpcConnectionProvider).toSelf().inSingletonScope();
|
|
28
41
|
});
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
import { injectable } from 'inversify';
|
|
18
18
|
import { WebSocketConnectionProvider, WebSocketOptions } from '../../browser/messaging/ws-connection-provider';
|
|
19
|
-
import { FrontendApplicationContribution } from '../../browser/frontend-application';
|
|
19
|
+
import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution';
|
|
20
20
|
import { Channel } from '../../common';
|
|
21
21
|
|
|
22
22
|
/**
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
import { ContainerModule } from 'inversify';
|
|
18
18
|
import { WindowService } from '../../browser/window/window-service';
|
|
19
19
|
import { ElectronWindowService } from './electron-window-service';
|
|
20
|
-
import { FrontendApplicationContribution } from '../../browser/frontend-application';
|
|
20
|
+
import { FrontendApplicationContribution } from '../../browser/frontend-application-contribution';
|
|
21
21
|
import { ElectronClipboardService } from '../electron-clipboard-service';
|
|
22
22
|
import { ClipboardService } from '../../browser/clipboard-service';
|
|
23
23
|
import { ElectronMainWindowService, electronMainWindowServicePath } from '../../electron-common/electron-main-window-service';
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import { injectable, inject, postConstruct } from 'inversify';
|
|
18
|
-
import { NewWindowOptions } from '../../common/window';
|
|
18
|
+
import { NewWindowOptions, WindowSearchParams } from '../../common/window';
|
|
19
19
|
import { DefaultWindowService } from '../../browser/window/default-window-service';
|
|
20
20
|
import { ElectronMainWindowService } from '../../electron-common/electron-main-window-service';
|
|
21
21
|
import { ElectronWindowPreferences } from './electron-window-preferences';
|
|
@@ -44,8 +44,8 @@ export class ElectronWindowService extends DefaultWindowService {
|
|
|
44
44
|
return undefined;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
override openNewDefaultWindow(): void {
|
|
48
|
-
this.delegate.openNewDefaultWindow();
|
|
47
|
+
override openNewDefaultWindow(params?: WindowSearchParams): void {
|
|
48
|
+
this.delegate.openNewDefaultWindow(params);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
@postConstruct()
|
|
@@ -75,7 +75,12 @@ export class ElectronWindowService extends DefaultWindowService {
|
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
override reload(): void {
|
|
79
|
-
|
|
78
|
+
override reload(params?: WindowSearchParams): void {
|
|
79
|
+
if (params) {
|
|
80
|
+
const query = Object.entries(params).map(([name, value]) => `${name}=${value}`).join('&');
|
|
81
|
+
location.search = query;
|
|
82
|
+
} else {
|
|
83
|
+
window.electronTheiaCore.requestReload();
|
|
84
|
+
}
|
|
80
85
|
}
|
|
81
86
|
}
|
|
@@ -14,11 +14,11 @@
|
|
|
14
14
|
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
|
-
import { NewWindowOptions } from '../common/window';
|
|
17
|
+
import { NewWindowOptions, WindowSearchParams } from '../common/window';
|
|
18
18
|
|
|
19
19
|
export const electronMainWindowServicePath = '/services/electron-window';
|
|
20
20
|
export const ElectronMainWindowService = Symbol('ElectronMainWindowService');
|
|
21
21
|
export interface ElectronMainWindowService {
|
|
22
22
|
openNewWindow(url: string, options?: NewWindowOptions): undefined;
|
|
23
|
-
openNewDefaultWindow(): void;
|
|
23
|
+
openNewDefaultWindow(params?: WindowSearchParams): void;
|
|
24
24
|
}
|
|
@@ -31,7 +31,7 @@ import { ElectronSecurityTokenService } from './electron-security-token-service'
|
|
|
31
31
|
import { ElectronSecurityToken } from '../electron-common/electron-token';
|
|
32
32
|
import Storage = require('electron-store');
|
|
33
33
|
import { Disposable, DisposableCollection, isOSX, isWindows } from '../common';
|
|
34
|
-
import { DEFAULT_WINDOW_HASH } from '../common/window';
|
|
34
|
+
import { DEFAULT_WINDOW_HASH, WindowSearchParams } from '../common/window';
|
|
35
35
|
import { TheiaBrowserWindowOptions, TheiaElectronWindow, TheiaElectronWindowFactory } from './theia-electron-window';
|
|
36
36
|
import { ElectronMainApplicationGlobals } from './electron-main-constants';
|
|
37
37
|
import { createDisposableListener } from './event-utils';
|
|
@@ -343,9 +343,9 @@ export class ElectronMainApplication {
|
|
|
343
343
|
};
|
|
344
344
|
}
|
|
345
345
|
|
|
346
|
-
async openDefaultWindow(): Promise<BrowserWindow> {
|
|
346
|
+
async openDefaultWindow(params?: WindowSearchParams): Promise<BrowserWindow> {
|
|
347
347
|
const options = this.getDefaultTheiaWindowOptions();
|
|
348
|
-
const [uri, electronWindow] = await Promise.all([this.createWindowUri(), this.reuseOrCreateWindow(options)]);
|
|
348
|
+
const [uri, electronWindow] = await Promise.all([this.createWindowUri(params), this.reuseOrCreateWindow(options)]);
|
|
349
349
|
electronWindow.loadURL(uri.withFragment(DEFAULT_WINDOW_HASH).toString(true));
|
|
350
350
|
return electronWindow;
|
|
351
351
|
}
|
|
@@ -419,9 +419,13 @@ export class ElectronMainApplication {
|
|
|
419
419
|
}
|
|
420
420
|
}
|
|
421
421
|
|
|
422
|
-
protected async createWindowUri(): Promise<URI> {
|
|
422
|
+
protected async createWindowUri(params: WindowSearchParams = {}): Promise<URI> {
|
|
423
|
+
if (!('port' in params)) {
|
|
424
|
+
params.port = (await this.backendPort).toString();
|
|
425
|
+
}
|
|
426
|
+
const query = Object.entries(params).map(([name, value]) => `${name}=${value}`).join('&');
|
|
423
427
|
return FileUri.create(this.globals.THEIA_FRONTEND_HTML_PATH)
|
|
424
|
-
.withQuery(
|
|
428
|
+
.withQuery(query);
|
|
425
429
|
}
|
|
426
430
|
|
|
427
431
|
protected getDefaultTheiaWindowOptions(): TheiaBrowserWindowOptions {
|
|
@@ -18,7 +18,7 @@ import { shell } from '@theia/electron/shared/electron';
|
|
|
18
18
|
import { injectable, inject } from 'inversify';
|
|
19
19
|
import { ElectronMainWindowService } from '../electron-common/electron-main-window-service';
|
|
20
20
|
import { ElectronMainApplication } from './electron-main-application';
|
|
21
|
-
import { NewWindowOptions } from '../common/window';
|
|
21
|
+
import { NewWindowOptions, WindowSearchParams } from '../common/window';
|
|
22
22
|
|
|
23
23
|
@injectable()
|
|
24
24
|
export class ElectronMainWindowServiceImpl implements ElectronMainWindowService {
|
|
@@ -37,8 +37,8 @@ export class ElectronMainWindowServiceImpl implements ElectronMainWindowService
|
|
|
37
37
|
return undefined;
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
openNewDefaultWindow(): void {
|
|
41
|
-
this.app.openDefaultWindow();
|
|
40
|
+
openNewDefaultWindow(params?: WindowSearchParams): void {
|
|
41
|
+
this.app.openDefaultWindow(params);
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
}
|
|
@@ -15,13 +15,21 @@
|
|
|
15
15
|
// *****************************************************************************
|
|
16
16
|
|
|
17
17
|
import * as http from 'http';
|
|
18
|
-
import { injectable } from 'inversify';
|
|
18
|
+
import { inject, injectable } from 'inversify';
|
|
19
|
+
import { BackendRemoteService } from '../../node/backend-remote-service';
|
|
19
20
|
import { WsRequestValidatorContribution } from '../../node/ws-request-validators';
|
|
20
21
|
|
|
21
22
|
@injectable()
|
|
22
23
|
export class ElectronWsOriginValidator implements WsRequestValidatorContribution {
|
|
23
24
|
|
|
25
|
+
@inject(BackendRemoteService)
|
|
26
|
+
protected readonly backendRemoteService: BackendRemoteService;
|
|
27
|
+
|
|
24
28
|
allowWsUpgrade(request: http.IncomingMessage): boolean {
|
|
29
|
+
// If we are running as a remote server, requests will come from an http endpoint
|
|
30
|
+
if (this.backendRemoteService.isRemoteServer()) {
|
|
31
|
+
return true;
|
|
32
|
+
}
|
|
25
33
|
// On Electron the main page is served from the `file` protocol.
|
|
26
34
|
// We don't expect the requests to come from anywhere else.
|
|
27
35
|
return request.headers.origin === 'file://';
|
|
@@ -28,7 +28,7 @@ import { WsRequestValidatorContribution } from '../../node/ws-request-validators
|
|
|
28
28
|
@injectable()
|
|
29
29
|
export class ElectronTokenValidator implements WsRequestValidatorContribution {
|
|
30
30
|
|
|
31
|
-
protected electronSecurityToken
|
|
31
|
+
protected electronSecurityToken?: ElectronSecurityToken;
|
|
32
32
|
|
|
33
33
|
@postConstruct()
|
|
34
34
|
protected init(): void {
|
|
@@ -43,6 +43,9 @@ export class ElectronTokenValidator implements WsRequestValidatorContribution {
|
|
|
43
43
|
* Expects the token to be passed via cookies by default.
|
|
44
44
|
*/
|
|
45
45
|
allowRequest(request: http.IncomingMessage): boolean {
|
|
46
|
+
if (!this.electronSecurityToken) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
46
49
|
const cookieHeader = request.headers.cookie;
|
|
47
50
|
if (isString(cookieHeader)) {
|
|
48
51
|
const token = cookie.parse(cookieHeader)[ElectronSecurityToken];
|
|
@@ -76,8 +79,15 @@ export class ElectronTokenValidator implements WsRequestValidatorContribution {
|
|
|
76
79
|
/**
|
|
77
80
|
* Returns the token to compare to when authorizing requests.
|
|
78
81
|
*/
|
|
79
|
-
protected getToken(): ElectronSecurityToken {
|
|
80
|
-
|
|
82
|
+
protected getToken(): ElectronSecurityToken | undefined {
|
|
83
|
+
const token = process.env[ElectronSecurityToken];
|
|
84
|
+
if (token) {
|
|
85
|
+
return JSON.parse(token);
|
|
86
|
+
} else {
|
|
87
|
+
// No token has been passed to the backend server
|
|
88
|
+
// That indicates we're running without a local frontend
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
81
91
|
}
|
|
82
92
|
|
|
83
93
|
}
|