@opensumi/ide-core-browser 2.21.8-rc-1670567192.0 → 2.21.8
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/lib/components/actions/index.d.ts.map +1 -1
- package/lib/components/actions/index.js +22 -2
- package/lib/components/actions/index.js.map +1 -1
- package/lib/components/tree/tree.module.less +0 -1
- package/lib/contextkey/testing.d.ts +0 -1
- package/lib/contextkey/testing.d.ts.map +1 -1
- package/lib/contextkey/testing.js +1 -2
- package/lib/contextkey/testing.js.map +1 -1
- package/lib/menu/next/menu.contrib.interface.d.ts +2 -3
- package/lib/menu/next/menu.contrib.interface.d.ts.map +1 -1
- package/lib/menu/next/menu.contrib.interface.js.map +1 -1
- package/lib/preferences/preference-configurations.js +1 -1
- package/lib/preferences/preference-configurations.js.map +1 -1
- package/lib/react-providers/config-provider.d.ts +0 -4
- package/lib/react-providers/config-provider.d.ts.map +1 -1
- package/lib/react-providers/config-provider.js.map +1 -1
- package/lib/services/storage-service.d.ts.map +1 -1
- package/lib/services/storage-service.js +1 -7
- package/lib/services/storage-service.js.map +1 -1
- package/lib/utils/label.d.ts.map +1 -1
- package/lib/utils/label.js +9 -16
- package/lib/utils/label.js.map +1 -1
- package/package.json +6 -7
- package/src/application/application-state-service.ts +0 -54
- package/src/application/application.service.ts +0 -51
- package/src/application/index.ts +0 -2
- package/src/authentication/authentication.contribution.ts +0 -35
- package/src/authentication/authentication.service.ts +0 -517
- package/src/bootstrap/app.ts +0 -745
- package/src/bootstrap/app.view.tsx +0 -88
- package/src/bootstrap/connection.ts +0 -116
- package/src/bootstrap/index.ts +0 -3
- package/src/bootstrap/inner-providers.ts +0 -297
- package/src/bootstrap/lifecycle.service.ts +0 -19
- package/src/browser-module.ts +0 -24
- package/src/common/common.command.ts +0 -977
- package/src/common/common.contribution.ts +0 -343
- package/src/common/common.define.ts +0 -55
- package/src/common/common.module.ts +0 -33
- package/src/common/common.storage.ts +0 -22
- package/src/common/container-id.ts +0 -12
- package/src/common/index.ts +0 -4
- package/src/components/actions/index.tsx +0 -486
- package/src/components/actions/placements.ts +0 -47
- package/src/components/actions/styles.module.less +0 -144
- package/src/components/badge/index.tsx +0 -1
- package/src/components/index.ts +0 -26
- package/src/components/layout/box-panel.tsx +0 -88
- package/src/components/layout/default-layout.tsx +0 -61
- package/src/components/layout/index.ts +0 -4
- package/src/components/layout/layout.ts +0 -80
- package/src/components/layout/split-panel.service.ts +0 -56
- package/src/components/layout/split-panel.tsx +0 -296
- package/src/components/layout/styles.module.less +0 -21
- package/src/components/loading/index.ts +0 -1
- package/src/components/loading/loading.less +0 -14
- package/src/components/loading/loading.view.tsx +0 -7
- package/src/components/loading/media/loading-dark.svg +0 -52
- package/src/components/loading/media/loading-hc.svg +0 -52
- package/src/components/loading/media/loading.svg +0 -52
- package/src/components/popover/styles.module.less +0 -81
- package/src/components/portal/index.tsx +0 -13
- package/src/components/progressbar/index.tsx +0 -16
- package/src/components/progressbar/styles.module.less +0 -31
- package/src/components/recycle-tree/index.ts +0 -1
- package/src/components/recycle-tree/recycle-tree.view.tsx +0 -368
- package/src/components/resize/resize.module.less +0 -78
- package/src/components/resize/resize.tsx +0 -663
- package/src/components/scroll/index.tsx +0 -386
- package/src/components/scroll/scroll.module.less +0 -108
- package/src/components/scrollbar/index.ts +0 -1
- package/src/components/scrollbar/scrollbar.less +0 -36
- package/src/components/scrollbar/scrollbar.view.ts +0 -8
- package/src/components/select/index.tsx +0 -12
- package/src/components/select/styles.less +0 -6
- package/src/components/tree/index.ts +0 -3
- package/src/components/tree/tree-node.view.tsx +0 -546
- package/src/components/tree/tree.module.less +0 -297
- package/src/components/tree/tree.view.tsx +0 -486
- package/src/context-key.ts +0 -48
- package/src/contextkey/dialog.ts +0 -3
- package/src/contextkey/explorer.ts +0 -26
- package/src/contextkey/index.ts +0 -6
- package/src/contextkey/outline.ts +0 -4
- package/src/contextkey/resource.ts +0 -61
- package/src/contextkey/terminal.ts +0 -7
- package/src/contextkey/testing.ts +0 -9
- package/src/contextkey/workspace.ts +0 -7
- package/src/core-preferences.ts +0 -318
- package/src/dom/index.ts +0 -176
- package/src/encoding-registry.ts +0 -83
- package/src/extensions/extensions-point.service.ts +0 -78
- package/src/extensions/index.ts +0 -3
- package/src/extensions/schema/browserViews.ts +0 -96
- package/src/extensions/schema/menu.ts +0 -245
- package/src/extensions/schema/opensumiExtensionPackageSchema.ts +0 -12
- package/src/extensions/schema/toolbar.ts +0 -338
- package/src/extensions/schema/vscodeExtensionPackageSchema.ts +0 -330
- package/src/fs/index.ts +0 -12
- package/src/hash-calculate/hash-calculate.contribution.ts +0 -19
- package/src/index.ts +0 -42
- package/src/keybinding/index.ts +0 -1
- package/src/keybinding/keybinding.ts +0 -908
- package/src/keyboard/index.ts +0 -3
- package/src/keyboard/keyboard-layout-provider.ts +0 -412
- package/src/keyboard/keyboard-layout-service.ts +0 -449
- package/src/keyboard/keys.ts +0 -748
- package/src/keyboard/layouts/_.contribution.ts +0 -24
- package/src/keyboard/layouts/cz.win.ts +0 -168
- package/src/keyboard/layouts/de-swiss.win.ts +0 -168
- package/src/keyboard/layouts/de.darwin.ts +0 -131
- package/src/keyboard/layouts/de.linux.ts +0 -186
- package/src/keyboard/layouts/de.win.ts +0 -168
- package/src/keyboard/layouts/dk.win.ts +0 -168
- package/src/keyboard/layouts/dvorak.darwin.ts +0 -131
- package/src/keyboard/layouts/en-belgian.win.ts +0 -168
- package/src/keyboard/layouts/en-ext.darwin.ts +0 -131
- package/src/keyboard/layouts/en-in.win.ts +0 -168
- package/src/keyboard/layouts/en-intl.darwin.ts +0 -131
- package/src/keyboard/layouts/en-intl.win.ts +0 -168
- package/src/keyboard/layouts/en-uk.darwin.ts +0 -131
- package/src/keyboard/layouts/en-uk.win.ts +0 -168
- package/src/keyboard/layouts/en.darwin.ts +0 -139
- package/src/keyboard/layouts/en.linux.ts +0 -186
- package/src/keyboard/layouts/en.win.ts +0 -173
- package/src/keyboard/layouts/es-latin.win.ts +0 -168
- package/src/keyboard/layouts/es.darwin.ts +0 -131
- package/src/keyboard/layouts/es.linux.ts +0 -186
- package/src/keyboard/layouts/es.win.ts +0 -168
- package/src/keyboard/layouts/fr.darwin.ts +0 -131
- package/src/keyboard/layouts/fr.linux.ts +0 -186
- package/src/keyboard/layouts/fr.win.ts +0 -168
- package/src/keyboard/layouts/hu.win.ts +0 -168
- package/src/keyboard/layouts/it.darwin.ts +0 -131
- package/src/keyboard/layouts/it.win.ts +0 -168
- package/src/keyboard/layouts/jp-roman.darwin.ts +0 -131
- package/src/keyboard/layouts/jp.darwin.ts +0 -131
- package/src/keyboard/layouts/ko.darwin.ts +0 -131
- package/src/keyboard/layouts/layout.contribution.darwin.ts +0 -23
- package/src/keyboard/layouts/layout.contribution.linux.ts +0 -12
- package/src/keyboard/layouts/layout.contribution.ts +0 -9
- package/src/keyboard/layouts/layout.contribution.win.ts +0 -29
- package/src/keyboard/layouts/no.win.ts +0 -168
- package/src/keyboard/layouts/pl.darwin.ts +0 -131
- package/src/keyboard/layouts/pl.win.ts +0 -168
- package/src/keyboard/layouts/pt-br.win.ts +0 -169
- package/src/keyboard/layouts/pt.darwin.ts +0 -131
- package/src/keyboard/layouts/pt.win.ts +0 -168
- package/src/keyboard/layouts/ru.darwin.ts +0 -131
- package/src/keyboard/layouts/ru.linux.ts +0 -186
- package/src/keyboard/layouts/ru.win.ts +0 -168
- package/src/keyboard/layouts/sv.darwin.ts +0 -131
- package/src/keyboard/layouts/sv.win.ts +0 -168
- package/src/keyboard/layouts/thai.win.ts +0 -168
- package/src/keyboard/layouts/tr.win.ts +0 -168
- package/src/keyboard/layouts/zh-hans.darwin.ts +0 -131
- package/src/layout/accordion/tab-bar-toolbar.tsx +0 -59
- package/src/layout/accordion/view-context-key.registry.ts +0 -34
- package/src/layout/constants.ts +0 -7
- package/src/layout/index.ts +0 -5
- package/src/layout/layout-hooks.ts +0 -68
- package/src/layout/layout-state.ts +0 -107
- package/src/layout/layout.interface.ts +0 -101
- package/src/layout/layout.ts +0 -80
- package/src/layout/view-id.ts +0 -18
- package/src/logger/browser-logger.ts +0 -51
- package/src/logger/index.ts +0 -1
- package/src/markdown/index.tsx +0 -62
- package/src/menu/next/base.ts +0 -513
- package/src/menu/next/ctxmenu-service.ts +0 -188
- package/src/menu/next/index.ts +0 -10
- package/src/menu/next/menu-id.ts +0 -86
- package/src/menu/next/menu-service.ts +0 -252
- package/src/menu/next/menu-util.ts +0 -77
- package/src/menu/next/menu.contrib.interface.ts +0 -79
- package/src/menu/next/menu.interface.ts +0 -253
- package/src/menu/next/menubar-service.ts +0 -211
- package/src/menu/next/renderer/ctxmenu/base.ts +0 -18
- package/src/menu/next/renderer/ctxmenu/browser.ts +0 -45
- package/src/menu/next/renderer/ctxmenu/electron.ts +0 -207
- package/src/menu/next/toolbar-action.service.ts +0 -132
- package/src/monaco/index.ts +0 -128
- package/src/opener/command-opener.ts +0 -42
- package/src/opener/default-opener.ts +0 -31
- package/src/opener/http-opener.ts +0 -25
- package/src/opener/index.ts +0 -19
- package/src/opener/opener.contribution.ts +0 -57
- package/src/opener/opener.service.ts +0 -66
- package/src/preferences/early-preferences.ts +0 -117
- package/src/preferences/index.ts +0 -9
- package/src/preferences/preference-configurations.ts +0 -77
- package/src/preferences/preference-contribution.ts +0 -401
- package/src/preferences/preference-provider.ts +0 -414
- package/src/preferences/preference-proxy.ts +0 -292
- package/src/preferences/preference-scope.ts +0 -3
- package/src/preferences/preference-service.ts +0 -571
- package/src/preferences/settings.ts +0 -53
- package/src/preferences/types.ts +0 -111
- package/src/progress/index.ts +0 -58
- package/src/progress/progress-bar.tsx +0 -22
- package/src/progress/progress-indicator.ts +0 -90
- package/src/progress/progress.module.less +0 -46
- package/src/progress/progress.service.tsx +0 -429
- package/src/quick-open/index.ts +0 -655
- package/src/quick-open/recent-files.ts +0 -68
- package/src/raw-context-key.ts +0 -116
- package/src/react-hooks/event.tsx +0 -80
- package/src/react-hooks/hot-key.tsx +0 -58
- package/src/react-hooks/index.ts +0 -3
- package/src/react-hooks/injectable-hooks.tsx +0 -35
- package/src/react-hooks/portal-hooks.tsx +0 -38
- package/src/react-providers/config-provider.tsx +0 -263
- package/src/react-providers/index.tsx +0 -2
- package/src/react-providers/slot.module.less +0 -19
- package/src/react-providers/slot.tsx +0 -242
- package/src/services/clipboard.service.ts +0 -97
- package/src/services/credentials-service.ts +0 -91
- package/src/services/crypto-service.ts +0 -23
- package/src/services/external-uri.service.ts +0 -68
- package/src/services/index.ts +0 -7
- package/src/services/label-service.ts +0 -386
- package/src/services/status-bar-service.ts +0 -108
- package/src/services/storage-service.ts +0 -197
- package/src/style/codicons/README.md +0 -22
- package/src/style/codicons/codicon-animations.css +0 -15
- package/src/style/codicons/generator.js +0 -15
- package/src/style/entry.less +0 -25
- package/src/style/icon/fileicons/file-default.svg +0 -1
- package/src/style/icon/fileicons/folder-default.svg +0 -1
- package/src/style/icon/fileicons.less +0 -20
- package/src/style/icon/icon.ts +0 -543
- package/src/style/icon/ide-iconfont.ts +0 -13
- package/src/style/icon/index.less +0 -54
- package/src/style/icon/seti.woff +0 -0
- package/src/style/icon/symbol-icons/boolean-dark.svg +0 -3
- package/src/style/icon/symbol-icons/boolean-light.svg +0 -3
- package/src/style/icon/symbol-icons/class-dark.svg +0 -3
- package/src/style/icon/symbol-icons/class-light.svg +0 -3
- package/src/style/icon/symbol-icons/constant-dark.svg +0 -4
- package/src/style/icon/symbol-icons/constant-light.svg +0 -4
- package/src/style/icon/symbol-icons/enumerator-dark.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-item-dark.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-item-light.svg +0 -3
- package/src/style/icon/symbol-icons/enumerator-light.svg +0 -3
- package/src/style/icon/symbol-icons/event-dark.svg +0 -3
- package/src/style/icon/symbol-icons/event-light.svg +0 -3
- package/src/style/icon/symbol-icons/field-dark.svg +0 -3
- package/src/style/icon/symbol-icons/field-light.svg +0 -3
- package/src/style/icon/symbol-icons/file-dark.svg +0 -3
- package/src/style/icon/symbol-icons/file-light.svg +0 -3
- package/src/style/icon/symbol-icons/indexer-dark.svg +0 -3
- package/src/style/icon/symbol-icons/indexer-light.svg +0 -3
- package/src/style/icon/symbol-icons/interface-dark.svg +0 -3
- package/src/style/icon/symbol-icons/interface-light.svg +0 -3
- package/src/style/icon/symbol-icons/keyword-dark.svg +0 -3
- package/src/style/icon/symbol-icons/keyword-light.svg +0 -3
- package/src/style/icon/symbol-icons/method-dark.svg +0 -3
- package/src/style/icon/symbol-icons/method-light.svg +0 -3
- package/src/style/icon/symbol-icons/namespace-dark.svg +0 -3
- package/src/style/icon/symbol-icons/namespace-light.svg +0 -3
- package/src/style/icon/symbol-icons/numeric-dark.svg +0 -3
- package/src/style/icon/symbol-icons/numeric-light.svg +0 -3
- package/src/style/icon/symbol-icons/operator-dark.svg +0 -3
- package/src/style/icon/symbol-icons/operator-light.svg +0 -3
- package/src/style/icon/symbol-icons/property-dark.svg +0 -3
- package/src/style/icon/symbol-icons/property-light.svg +0 -3
- package/src/style/icon/symbol-icons/snippet-dark.svg +0 -3
- package/src/style/icon/symbol-icons/snippet-light.svg +0 -3
- package/src/style/icon/symbol-icons/string-dark.svg +0 -3
- package/src/style/icon/symbol-icons/string-light.svg +0 -3
- package/src/style/icon/symbol-icons/structure-dark.svg +0 -3
- package/src/style/icon/symbol-icons/structure-light.svg +0 -3
- package/src/style/icon/symbol-icons/symbol-icons.css +0 -284
- package/src/style/icon/symbol-icons/template-dark.svg +0 -3
- package/src/style/icon/symbol-icons/template-light.svg +0 -3
- package/src/style/icon/symbol-icons/variable-dark.svg +0 -3
- package/src/style/icon/symbol-icons/variable-light.svg +0 -3
- package/src/style/icon.less +0 -8
- package/src/style/index.less +0 -14
- package/src/style/monaco-override.less +0 -116
- package/src/style/normalize.less +0 -92
- package/src/style/octicons/octicons-cdn.css +0 -720
- package/src/style/octicons/octicons.css +0 -714
- package/src/style/octicons/octicons.html +0 -1882
- package/src/style/octicons/octicons.svg +0 -582
- package/src/style/octicons/octicons.ttf +0 -0
- package/src/style/override.less +0 -97
- package/src/style/toolbar.less +0 -199
- package/src/style/utilities.less +0 -8
- package/src/style/variable.less +0 -8
- package/src/terminal/index.ts +0 -7
- package/src/toolbar/components/auto-complete.tsx +0 -0
- package/src/toolbar/components/button.tsx +0 -440
- package/src/toolbar/components/index.ts +0 -2
- package/src/toolbar/components/select.tsx +0 -189
- package/src/toolbar/index.ts +0 -3
- package/src/toolbar/toolbar.popover.registry.ts +0 -32
- package/src/toolbar/toolbar.registry.ts +0 -352
- package/src/toolbar/toolbar.tsx +0 -710
- package/src/toolbar/types.ts +0 -383
- package/src/tree/index.ts +0 -3
- package/src/tree/tree-expansion.ts +0 -25
- package/src/tree/tree-selection.ts +0 -89
- package/src/tree/tree.ts +0 -294
- package/src/utils/create-overlay.tsx +0 -53
- package/src/utils/electron.ts +0 -92
- package/src/utils/env.ts +0 -26
- package/src/utils/icon.ts +0 -13
- package/src/utils/index.ts +0 -7
- package/src/utils/json.ts +0 -251
- package/src/utils/label.tsx +0 -36
- package/src/utils/parse.ts +0 -72
- package/src/utils/react-hooks.ts +0 -118
- package/src/variable/index.ts +0 -1
- package/src/variable/variable.ts +0 -84
- package/src/window/index.ts +0 -34
- package/src/window/window.service.ts +0 -100
package/src/bootstrap/app.ts
DELETED
|
@@ -1,745 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* editor.main 包含了所有 monaco 自带的编辑器相关核心功能以及 contributes
|
|
3
|
-
* 并且 editor.main 也包含对 editor.all 的导入
|
|
4
|
-
*/
|
|
5
|
-
import '@opensumi/monaco-editor-core/esm/vs/editor/editor.main';
|
|
6
|
-
import ResizeObserver from 'resize-observer-polyfill';
|
|
7
|
-
|
|
8
|
-
import { Injector, ConstructorOf } from '@opensumi/di';
|
|
9
|
-
import { RPCMessageConnection } from '@opensumi/ide-connection';
|
|
10
|
-
import { WSChannelHandler } from '@opensumi/ide-connection/lib/browser';
|
|
11
|
-
import {
|
|
12
|
-
CommandRegistry,
|
|
13
|
-
isOSX,
|
|
14
|
-
ContributionProvider,
|
|
15
|
-
MaybePromise,
|
|
16
|
-
createContributionProvider,
|
|
17
|
-
StorageProvider,
|
|
18
|
-
DefaultStorageProvider,
|
|
19
|
-
StorageResolverContribution,
|
|
20
|
-
ILoggerManagerClient,
|
|
21
|
-
SupportLogNamespace,
|
|
22
|
-
ILogServiceClient,
|
|
23
|
-
getDebugLogger,
|
|
24
|
-
isElectronRenderer,
|
|
25
|
-
setLanguageId,
|
|
26
|
-
IReporterService,
|
|
27
|
-
REPORT_NAME,
|
|
28
|
-
IEventBus,
|
|
29
|
-
asExtensionCandidate,
|
|
30
|
-
IApplicationService,
|
|
31
|
-
IDisposable,
|
|
32
|
-
Deferred,
|
|
33
|
-
isUndefined,
|
|
34
|
-
GeneralSettingsId,
|
|
35
|
-
UrlProvider,
|
|
36
|
-
LifeCyclePhase,
|
|
37
|
-
AppLifeCycleServiceToken,
|
|
38
|
-
IAppLifeCycleService,
|
|
39
|
-
} from '@opensumi/ide-core-common';
|
|
40
|
-
import {
|
|
41
|
-
DEFAULT_APPLICATION_DESKTOP_HOST,
|
|
42
|
-
DEFAULT_APPLICATION_NAME,
|
|
43
|
-
DEFAULT_APPLICATION_WEB_HOST,
|
|
44
|
-
DEFAULT_URI_SCHEME,
|
|
45
|
-
} from '@opensumi/ide-core-common/lib/const/application';
|
|
46
|
-
import { IElectronMainLifeCycleService } from '@opensumi/ide-core-common/lib/electron';
|
|
47
|
-
|
|
48
|
-
import { createElectronClientConnection } from '..';
|
|
49
|
-
import { ClientAppStateService } from '../application';
|
|
50
|
-
import { BrowserModule, IClientApp } from '../browser-module';
|
|
51
|
-
import { ClientAppContribution } from '../common';
|
|
52
|
-
import { CorePreferences } from '../core-preferences';
|
|
53
|
-
import { injectCorePreferences } from '../core-preferences';
|
|
54
|
-
import { KeybindingRegistry, KeybindingService, NO_KEYBINDING_NAME } from '../keybinding';
|
|
55
|
-
import { RenderedEvent } from '../layout/layout.interface';
|
|
56
|
-
import { MenuRegistryImpl, IMenuRegistry } from '../menu/next/base';
|
|
57
|
-
import {
|
|
58
|
-
PreferenceProviderProvider,
|
|
59
|
-
injectPreferenceSchemaProvider,
|
|
60
|
-
injectPreferenceConfigurations,
|
|
61
|
-
PreferenceScope,
|
|
62
|
-
PreferenceProvider,
|
|
63
|
-
PreferenceService,
|
|
64
|
-
PreferenceServiceImpl,
|
|
65
|
-
getPreferenceLanguageId,
|
|
66
|
-
registerLocalStorageProvider,
|
|
67
|
-
} from '../preferences';
|
|
68
|
-
import { AppConfig } from '../react-providers/config-provider';
|
|
69
|
-
import { DEFAULT_CDN_ICON, IDE_OCTICONS_CN_CSS, IDE_CODICONS_CN_CSS, updateIconMap } from '../style/icon/icon';
|
|
70
|
-
import { electronEnv } from '../utils';
|
|
71
|
-
|
|
72
|
-
import { renderClientApp, IAppRenderer } from './app.view';
|
|
73
|
-
import { createClientConnection2, bindConnectionService } from './connection';
|
|
74
|
-
import { injectInnerProviders } from './inner-providers';
|
|
75
|
-
import { AppLifeCycleService } from './lifecycle.service';
|
|
76
|
-
|
|
77
|
-
export type ModuleConstructor = ConstructorOf<BrowserModule>;
|
|
78
|
-
export type ContributionConstructor = ConstructorOf<ClientAppContribution>;
|
|
79
|
-
export type Direction = 'left-to-right' | 'right-to-left' | 'top-to-bottom' | 'bottom-to-top';
|
|
80
|
-
export interface IconMap {
|
|
81
|
-
[iconKey: string]: string;
|
|
82
|
-
}
|
|
83
|
-
export interface IPreferences {
|
|
84
|
-
[key: string]: any;
|
|
85
|
-
}
|
|
86
|
-
export interface IconInfo {
|
|
87
|
-
cssPath: string;
|
|
88
|
-
prefix: string;
|
|
89
|
-
iconMap: IconMap;
|
|
90
|
-
}
|
|
91
|
-
export interface IClientAppOpts extends Partial<AppConfig> {
|
|
92
|
-
modules: ModuleConstructor[];
|
|
93
|
-
contributions?: ContributionConstructor[];
|
|
94
|
-
modulesInstances?: BrowserModule[];
|
|
95
|
-
connectionPath?: UrlProvider;
|
|
96
|
-
connectionProtocols?: string[];
|
|
97
|
-
iconStyleSheets?: IconInfo[];
|
|
98
|
-
useCdnIcon?: boolean;
|
|
99
|
-
editorBackgroundImage?: string;
|
|
100
|
-
/**
|
|
101
|
-
* 插件开发模式下指定的插件路径
|
|
102
|
-
*/
|
|
103
|
-
extensionDevelopmentPath?: string | string[];
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export interface LayoutConfig {
|
|
107
|
-
[area: string]: {
|
|
108
|
-
modules: Array<string>;
|
|
109
|
-
// @deprecated
|
|
110
|
-
size?: number;
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
// 添加resize observer polyfill
|
|
115
|
-
if (typeof (window as any).ResizeObserver === 'undefined') {
|
|
116
|
-
(window as any).ResizeObserver = ResizeObserver;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export class ClientApp implements IClientApp, IDisposable {
|
|
120
|
-
/**
|
|
121
|
-
* 应用是否完成初始化
|
|
122
|
-
*/
|
|
123
|
-
appInitialized: Deferred<void> = new Deferred();
|
|
124
|
-
|
|
125
|
-
browserModules: BrowserModule[] = [];
|
|
126
|
-
|
|
127
|
-
modules: ModuleConstructor[];
|
|
128
|
-
|
|
129
|
-
injector: Injector;
|
|
130
|
-
|
|
131
|
-
logger: ILogServiceClient;
|
|
132
|
-
|
|
133
|
-
connectionPath: UrlProvider;
|
|
134
|
-
|
|
135
|
-
connectionProtocols?: string[];
|
|
136
|
-
|
|
137
|
-
keybindingRegistry: KeybindingRegistry;
|
|
138
|
-
|
|
139
|
-
keybindingService: KeybindingService;
|
|
140
|
-
|
|
141
|
-
config: AppConfig;
|
|
142
|
-
|
|
143
|
-
contributionsProvider: ContributionProvider<ClientAppContribution>;
|
|
144
|
-
|
|
145
|
-
commandRegistry: CommandRegistry;
|
|
146
|
-
|
|
147
|
-
// 这里将 onStart contribution 方法放到 MenuRegistryImpl 上了
|
|
148
|
-
nextMenuRegistry: MenuRegistryImpl;
|
|
149
|
-
|
|
150
|
-
stateService: ClientAppStateService;
|
|
151
|
-
|
|
152
|
-
constructor(opts: IClientAppOpts) {
|
|
153
|
-
const {
|
|
154
|
-
modules,
|
|
155
|
-
contributions,
|
|
156
|
-
modulesInstances,
|
|
157
|
-
connectionPath,
|
|
158
|
-
connectionProtocols,
|
|
159
|
-
iconStyleSheets,
|
|
160
|
-
useCdnIcon,
|
|
161
|
-
editorBackgroundImage,
|
|
162
|
-
defaultPreferences,
|
|
163
|
-
allowSetDocumentTitleFollowWorkspaceDir = true,
|
|
164
|
-
devtools = false, // if not set, disable devtools support as default
|
|
165
|
-
...restOpts // rest part 为 AppConfig
|
|
166
|
-
} = opts;
|
|
167
|
-
|
|
168
|
-
this.initEarlyPreference(opts.workspaceDir || '');
|
|
169
|
-
setLanguageId(getPreferenceLanguageId(defaultPreferences));
|
|
170
|
-
this.injector = opts.injector || new Injector();
|
|
171
|
-
this.modules = modules;
|
|
172
|
-
this.modules.forEach((m) => this.resolveModuleDeps(m));
|
|
173
|
-
// moduleInstance必须第一个是layout模块
|
|
174
|
-
this.browserModules = opts.modulesInstances || [];
|
|
175
|
-
const isDesktop = opts.isElectronRenderer || isElectronRenderer();
|
|
176
|
-
this.config = {
|
|
177
|
-
appName: DEFAULT_APPLICATION_NAME,
|
|
178
|
-
appHost: isDesktop ? DEFAULT_APPLICATION_DESKTOP_HOST : DEFAULT_APPLICATION_WEB_HOST,
|
|
179
|
-
appRoot: isUndefined(opts.appRoot) ? (isDesktop ? electronEnv.appPath : '') : opts.appRoot,
|
|
180
|
-
uriScheme: DEFAULT_URI_SCHEME,
|
|
181
|
-
// 如果通过 config 传入了 appName 及 uriScheme,则优先使用
|
|
182
|
-
...restOpts,
|
|
183
|
-
// 一些转换和 typo 修复
|
|
184
|
-
isElectronRenderer: isDesktop,
|
|
185
|
-
workspaceDir: opts.workspaceDir || '',
|
|
186
|
-
extensionDir:
|
|
187
|
-
opts.extensionDir || (opts.isElectronRenderer || isDesktop ? electronEnv.metadata?.extensionDir : ''),
|
|
188
|
-
injector: this.injector,
|
|
189
|
-
wsPath: opts.wsPath || `ws://${window.location.hostname}:8000`,
|
|
190
|
-
layoutConfig: opts.layoutConfig as LayoutConfig,
|
|
191
|
-
editorBackgroundImage: opts.editorBackgroundImage || editorBackgroundImage,
|
|
192
|
-
allowSetDocumentTitleFollowWorkspaceDir,
|
|
193
|
-
devtools,
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
if (devtools) {
|
|
197
|
-
// set a global so the opensumi devtools can identify that
|
|
198
|
-
// the current page is powered by opensumi core
|
|
199
|
-
window.__OPENSUMI_DEVTOOLS_GLOBAL_HOOK__ = {};
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
if (this.config.isElectronRenderer && electronEnv.metadata?.extensionDevelopmentHost) {
|
|
203
|
-
this.config.extensionDevelopmentHost = electronEnv.metadata.extensionDevelopmentHost;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
if (opts.extensionDevelopmentPath) {
|
|
207
|
-
this.config.extensionCandidate = (this.config.extensionCandidate || []).concat(
|
|
208
|
-
Array.isArray(opts.extensionDevelopmentPath)
|
|
209
|
-
? opts.extensionDevelopmentPath.map((e) => asExtensionCandidate(e, true))
|
|
210
|
-
: [asExtensionCandidate(opts.extensionDevelopmentPath, true)],
|
|
211
|
-
);
|
|
212
|
-
|
|
213
|
-
this.config.extensionDevelopmentHost = !!opts.extensionDevelopmentPath;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// 旧方案兼容, 把electron.metadata.extensionCandidate提前注入appConfig的对应配置中
|
|
217
|
-
if (this.config.isElectronRenderer && electronEnv.metadata?.extensionCandidate) {
|
|
218
|
-
this.config.extensionCandidate = (this.config.extensionCandidate || []).concat(
|
|
219
|
-
electronEnv.metadata.extensionCandidate || [],
|
|
220
|
-
);
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
this.connectionPath = connectionPath || `${this.config.wsPath}/service`;
|
|
224
|
-
this.connectionProtocols = connectionProtocols;
|
|
225
|
-
this.initBaseProvider();
|
|
226
|
-
this.initFields();
|
|
227
|
-
this.appendIconStyleSheets(iconStyleSheets, useCdnIcon);
|
|
228
|
-
this.createBrowserModules(defaultPreferences);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
private _inComposition = false;
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* 将被依赖但未被加入modules的模块加入到待加载模块最后
|
|
235
|
-
*/
|
|
236
|
-
public resolveModuleDeps(moduleConstructor: ModuleConstructor) {
|
|
237
|
-
const dependencies = Reflect.getMetadata('dependencies', moduleConstructor) as [];
|
|
238
|
-
if (dependencies) {
|
|
239
|
-
dependencies.forEach((dep) => {
|
|
240
|
-
if (this.modules.indexOf(dep) === -1) {
|
|
241
|
-
this.modules.push(dep);
|
|
242
|
-
}
|
|
243
|
-
});
|
|
244
|
-
}
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
get lifeCycleService(): IAppLifeCycleService {
|
|
248
|
-
return this.injector.get(AppLifeCycleServiceToken);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
/**
|
|
252
|
-
* LifeCycle
|
|
253
|
-
* 1. Prepare
|
|
254
|
-
* 2. Initialize
|
|
255
|
-
* 3. Starting
|
|
256
|
-
* 4. Ready
|
|
257
|
-
*/
|
|
258
|
-
public async start(
|
|
259
|
-
container: HTMLElement | IAppRenderer,
|
|
260
|
-
type?: 'electron' | 'web',
|
|
261
|
-
connection?: RPCMessageConnection,
|
|
262
|
-
): Promise<void> {
|
|
263
|
-
const reporterService: IReporterService = this.injector.get(IReporterService);
|
|
264
|
-
const measureReporter = reporterService.time(REPORT_NAME.MEASURE);
|
|
265
|
-
|
|
266
|
-
this.lifeCycleService.phase = LifeCyclePhase.Prepare;
|
|
267
|
-
|
|
268
|
-
if (connection) {
|
|
269
|
-
await bindConnectionService(this.injector, this.modules, connection);
|
|
270
|
-
} else {
|
|
271
|
-
if (type === 'electron') {
|
|
272
|
-
await bindConnectionService(this.injector, this.modules, createElectronClientConnection());
|
|
273
|
-
} else if (type === 'web') {
|
|
274
|
-
await createClientConnection2(
|
|
275
|
-
this.injector,
|
|
276
|
-
this.modules,
|
|
277
|
-
this.connectionPath,
|
|
278
|
-
() => {
|
|
279
|
-
this.onReconnectContributions();
|
|
280
|
-
},
|
|
281
|
-
this.connectionProtocols,
|
|
282
|
-
this.config.clientId,
|
|
283
|
-
);
|
|
284
|
-
|
|
285
|
-
this.logger = this.getLogger();
|
|
286
|
-
// 回写需要用到打点的 Logger 的地方
|
|
287
|
-
this.injector.get(WSChannelHandler).replaceLogger(this.logger);
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
measureReporter.timeEnd('ClientApp.createConnection');
|
|
291
|
-
|
|
292
|
-
this.logger = this.getLogger();
|
|
293
|
-
this.stateService.state = 'client_connected';
|
|
294
|
-
this.registerEventListeners();
|
|
295
|
-
// 在 connect 之后立即初始化数据,保证其它 module 能同步获取数据
|
|
296
|
-
await this.injector.get(IApplicationService).initializeData();
|
|
297
|
-
|
|
298
|
-
// 在 contributions 执行完 onStart 上报一次耗时
|
|
299
|
-
await this.measure('Contributions.start', () => this.startContributions(container));
|
|
300
|
-
this.stateService.state = 'started_contributions';
|
|
301
|
-
this.stateService.state = 'ready';
|
|
302
|
-
|
|
303
|
-
this.lifeCycleService.phase = LifeCyclePhase.Ready;
|
|
304
|
-
measureReporter.timeEnd('Framework.ready');
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
private getLogger() {
|
|
308
|
-
if (this.logger) {
|
|
309
|
-
return this.logger;
|
|
310
|
-
}
|
|
311
|
-
this.logger = this.injector.get(ILoggerManagerClient).getLogger(SupportLogNamespace.Browser);
|
|
312
|
-
return this.logger;
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
private onReconnectContributions() {
|
|
316
|
-
const contributions = this.contributions;
|
|
317
|
-
|
|
318
|
-
for (const contribution of contributions) {
|
|
319
|
-
if (contribution.onReconnect) {
|
|
320
|
-
contribution.onReconnect(this);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* 给 injector 初始化默认的 Providers
|
|
327
|
-
*/
|
|
328
|
-
private initBaseProvider() {
|
|
329
|
-
this.injector.addProviders({ token: IClientApp, useValue: this });
|
|
330
|
-
this.injector.addProviders({ token: AppConfig, useValue: this.config });
|
|
331
|
-
injectInnerProviders(this.injector);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
/**
|
|
335
|
-
* 从 injector 里获得实例
|
|
336
|
-
*/
|
|
337
|
-
private initFields() {
|
|
338
|
-
this.contributionsProvider = this.injector.get(ClientAppContribution);
|
|
339
|
-
this.commandRegistry = this.injector.get(CommandRegistry);
|
|
340
|
-
this.keybindingRegistry = this.injector.get(KeybindingRegistry);
|
|
341
|
-
this.keybindingService = this.injector.get(KeybindingService);
|
|
342
|
-
this.stateService = this.injector.get(ClientAppStateService);
|
|
343
|
-
this.nextMenuRegistry = this.injector.get(IMenuRegistry);
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
private createBrowserModules(defaultPreferences?: IPreferences) {
|
|
347
|
-
const injector = this.injector;
|
|
348
|
-
|
|
349
|
-
for (const Constructor of this.modules) {
|
|
350
|
-
const instance = injector.get(Constructor);
|
|
351
|
-
this.browserModules.push(instance);
|
|
352
|
-
|
|
353
|
-
if (instance.providers) {
|
|
354
|
-
this.injector.addProviders(...instance.providers);
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
if (instance.preferences) {
|
|
358
|
-
instance.preferences(this.injector);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
injectCorePreferences(this.injector);
|
|
363
|
-
|
|
364
|
-
// 注册PreferenceService
|
|
365
|
-
this.injectPreferenceService(this.injector, defaultPreferences);
|
|
366
|
-
|
|
367
|
-
// 注册存储服务
|
|
368
|
-
this.injectStorageProvider(this.injector);
|
|
369
|
-
|
|
370
|
-
for (const instance of this.browserModules) {
|
|
371
|
-
if (instance.contributionProvider) {
|
|
372
|
-
if (Array.isArray(instance.contributionProvider)) {
|
|
373
|
-
for (const contributionProvider of instance.contributionProvider) {
|
|
374
|
-
createContributionProvider(this.injector, contributionProvider);
|
|
375
|
-
}
|
|
376
|
-
} else {
|
|
377
|
-
createContributionProvider(this.injector, instance.contributionProvider);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
get contributions(): ClientAppContribution[] {
|
|
384
|
-
return this.contributionsProvider.getContributions();
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
protected async startContributions(container) {
|
|
388
|
-
// 先渲染 layout,模块视图的时序由layout控制
|
|
389
|
-
await this.measure('RenderApp.render', () => this.renderApp(container));
|
|
390
|
-
|
|
391
|
-
this.lifeCycleService.phase = LifeCyclePhase.Initialize;
|
|
392
|
-
await this.measure('Contributions.initialize', () => this.initializeContributions());
|
|
393
|
-
|
|
394
|
-
// 初始化命令、快捷键与菜单
|
|
395
|
-
await this.initializeCoreRegistry();
|
|
396
|
-
|
|
397
|
-
// 核心模块初始化完毕
|
|
398
|
-
this.stateService.state = 'core_module_initialized';
|
|
399
|
-
|
|
400
|
-
this.lifeCycleService.phase = LifeCyclePhase.Starting;
|
|
401
|
-
await this.measure('Contributions.onStart', () => this.onStartContributions());
|
|
402
|
-
|
|
403
|
-
await this.runContributionsPhase(this.contributions, 'onDidStart');
|
|
404
|
-
}
|
|
405
|
-
|
|
406
|
-
/**
|
|
407
|
-
* 初始化核心模板
|
|
408
|
-
*/
|
|
409
|
-
private async initializeCoreRegistry() {
|
|
410
|
-
this.commandRegistry.initialize();
|
|
411
|
-
await this.keybindingRegistry.initialize();
|
|
412
|
-
this.nextMenuRegistry.initialize();
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
/**
|
|
416
|
-
* run contribution#initialize
|
|
417
|
-
*/
|
|
418
|
-
private async initializeContributions() {
|
|
419
|
-
await this.runContributionsPhase(this.contributions, 'initialize');
|
|
420
|
-
this.appInitialized.resolve();
|
|
421
|
-
|
|
422
|
-
this.logger.verbose('contributions.initialize done');
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* run contribution#onStart
|
|
427
|
-
*/
|
|
428
|
-
private async onStartContributions() {
|
|
429
|
-
await this.runContributionsPhase(this.contributions, 'onStart');
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
private async runContributionsPhase(contributions: ClientAppContribution[], phaseName: keyof ClientAppContribution) {
|
|
433
|
-
return await Promise.all(
|
|
434
|
-
contributions.map((contribution) => this.contributionPhaseRunner(contribution, phaseName)),
|
|
435
|
-
);
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
private async contributionPhaseRunner(contribution: ClientAppContribution, phaseName: keyof ClientAppContribution) {
|
|
439
|
-
const phase = contribution[phaseName];
|
|
440
|
-
if (typeof phase === 'function') {
|
|
441
|
-
try {
|
|
442
|
-
const uid = contribution.constructor.name + '.' + phaseName;
|
|
443
|
-
return await this.measure(uid, () => phase.call(contribution, this));
|
|
444
|
-
} catch (error) {
|
|
445
|
-
this.logger.error(`Could not run contribution#${phaseName}`, error);
|
|
446
|
-
}
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
private async renderApp(container: HTMLElement | IAppRenderer) {
|
|
451
|
-
await renderClientApp(this, container);
|
|
452
|
-
|
|
453
|
-
const eventBus = this.injector.get(IEventBus);
|
|
454
|
-
eventBus.fire(new RenderedEvent());
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
protected async measure<T>(name: string, fn: () => MaybePromise<T>): Promise<T> {
|
|
458
|
-
const reporterService: IReporterService = this.injector.get(IReporterService);
|
|
459
|
-
const measureReporter = reporterService.time(REPORT_NAME.MEASURE);
|
|
460
|
-
const result = await fn();
|
|
461
|
-
measureReporter.timeEnd(name);
|
|
462
|
-
return result;
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* `beforeunload` listener implementation
|
|
467
|
-
*/
|
|
468
|
-
protected preventStop(): boolean {
|
|
469
|
-
// 获取corePreferences配置判断是否弹出确认框
|
|
470
|
-
const corePreferences = this.injector.get(CorePreferences);
|
|
471
|
-
const confirmExit = corePreferences['application.confirmExit'];
|
|
472
|
-
if (confirmExit === 'never') {
|
|
473
|
-
return false;
|
|
474
|
-
}
|
|
475
|
-
for (const contribution of this.contributions) {
|
|
476
|
-
if (contribution.onWillStop) {
|
|
477
|
-
try {
|
|
478
|
-
const res = contribution.onWillStop(this);
|
|
479
|
-
if (res) {
|
|
480
|
-
return true;
|
|
481
|
-
}
|
|
482
|
-
} catch (e) {
|
|
483
|
-
getDebugLogger().error(e);
|
|
484
|
-
}
|
|
485
|
-
}
|
|
486
|
-
}
|
|
487
|
-
return confirmExit === 'always';
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
/**
|
|
491
|
-
* electron 退出询问
|
|
492
|
-
*/
|
|
493
|
-
protected async preventStopElectron(): Promise<boolean> {
|
|
494
|
-
// 获取corePreferences配置判断是否弹出确认框
|
|
495
|
-
const corePreferences = this.injector.get(CorePreferences);
|
|
496
|
-
const confirmExit = corePreferences['application.confirmExit'];
|
|
497
|
-
if (confirmExit === 'never') {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
for (const contribution of this.contributions) {
|
|
501
|
-
if (contribution.onWillStop) {
|
|
502
|
-
try {
|
|
503
|
-
const res = await contribution.onWillStop(this);
|
|
504
|
-
if (res) {
|
|
505
|
-
return true;
|
|
506
|
-
}
|
|
507
|
-
} catch (e) {
|
|
508
|
-
getDebugLogger().error(e);
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
}
|
|
512
|
-
return false;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
/**
|
|
516
|
-
* Stop the frontend application contributions. This is called when the window is unloaded.
|
|
517
|
-
*/
|
|
518
|
-
protected stopContributions(): void {
|
|
519
|
-
for (const contribution of this.contributions) {
|
|
520
|
-
if (contribution.onStop) {
|
|
521
|
-
try {
|
|
522
|
-
contribution.onStop(this);
|
|
523
|
-
} catch (error) {
|
|
524
|
-
this.logger.error('Could not stop contribution', error);
|
|
525
|
-
}
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
protected async stopContributionsElectron(): Promise<void> {
|
|
531
|
-
const promises: Array<Promise<void>> = [];
|
|
532
|
-
for (const contribution of this.contributions) {
|
|
533
|
-
if (contribution.onStop) {
|
|
534
|
-
promises.push(
|
|
535
|
-
(async () => {
|
|
536
|
-
try {
|
|
537
|
-
await contribution.onStop!(this);
|
|
538
|
-
} catch (error) {
|
|
539
|
-
this.logger.error('Could not stop contribution', error);
|
|
540
|
-
}
|
|
541
|
-
})(),
|
|
542
|
-
);
|
|
543
|
-
}
|
|
544
|
-
}
|
|
545
|
-
await Promise.all(promises);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
/**
|
|
549
|
-
* 注册全局事件监听
|
|
550
|
-
*/
|
|
551
|
-
protected registerEventListeners(): void {
|
|
552
|
-
window.addEventListener('beforeunload', this._handleBeforeUpload);
|
|
553
|
-
window.addEventListener('unload', this._handleUnload);
|
|
554
|
-
|
|
555
|
-
window.addEventListener('resize', this._handleResize);
|
|
556
|
-
// 处理中文输入回退时可能出现多个光标问题
|
|
557
|
-
// https://github.com/eclipse-theia/theia/pull/6673
|
|
558
|
-
window.addEventListener('compositionstart', this._handleCompositionstart);
|
|
559
|
-
window.addEventListener('compositionend', this._handleCompositionend);
|
|
560
|
-
window.addEventListener('keydown', this._handleKeydown, true);
|
|
561
|
-
window.addEventListener('keyup', this._handleKeyup, true);
|
|
562
|
-
|
|
563
|
-
if (isOSX) {
|
|
564
|
-
document.body.addEventListener('wheel', this._handleWheel, { passive: false });
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
|
|
568
|
-
injectPreferenceService(injector: Injector, defaultPreferences?: IPreferences): void {
|
|
569
|
-
const preferencesProviderFactory = () => (scope: PreferenceScope) => {
|
|
570
|
-
const provider: PreferenceProvider = injector.get(PreferenceProvider, { tag: scope });
|
|
571
|
-
provider.asScope(scope);
|
|
572
|
-
return provider;
|
|
573
|
-
};
|
|
574
|
-
injectPreferenceConfigurations(injector);
|
|
575
|
-
|
|
576
|
-
injectPreferenceSchemaProvider(injector);
|
|
577
|
-
|
|
578
|
-
// 用于获取不同scope下的PreferenceProvider
|
|
579
|
-
injector.addProviders(
|
|
580
|
-
{
|
|
581
|
-
token: PreferenceProviderProvider,
|
|
582
|
-
useFactory: preferencesProviderFactory,
|
|
583
|
-
},
|
|
584
|
-
{
|
|
585
|
-
token: PreferenceService,
|
|
586
|
-
useClass: PreferenceServiceImpl,
|
|
587
|
-
},
|
|
588
|
-
);
|
|
589
|
-
// 设置默认配置
|
|
590
|
-
if (defaultPreferences) {
|
|
591
|
-
const providerFactory: PreferenceProviderProvider = injector.get(PreferenceProviderProvider);
|
|
592
|
-
const defaultPreference: PreferenceProvider = providerFactory(PreferenceScope.Default);
|
|
593
|
-
for (const key of Object.keys(defaultPreferences)) {
|
|
594
|
-
defaultPreference.setPreference(key, defaultPreferences[key]);
|
|
595
|
-
}
|
|
596
|
-
}
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
injectStorageProvider(injector: Injector) {
|
|
600
|
-
injector.addProviders({
|
|
601
|
-
token: DefaultStorageProvider,
|
|
602
|
-
useClass: DefaultStorageProvider,
|
|
603
|
-
});
|
|
604
|
-
injector.addProviders({
|
|
605
|
-
token: StorageProvider,
|
|
606
|
-
useFactory: () => (storageId) => injector.get(DefaultStorageProvider).get(storageId),
|
|
607
|
-
});
|
|
608
|
-
createContributionProvider(injector, StorageResolverContribution);
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
/**
|
|
612
|
-
* 通知上层需要刷新浏览器
|
|
613
|
-
* @param forcedReload 当取值为 true 时,将强制浏览器从服务器重新获取当前页面资源,而不是从浏览器的缓存中读取,如果取值为 false 或不传该参数时,浏览器则可能会从缓存中读取当前页面。
|
|
614
|
-
*/
|
|
615
|
-
fireOnReload(forcedReload = false) {
|
|
616
|
-
// 默认调用 location reload
|
|
617
|
-
// @ts-ignore
|
|
618
|
-
window.location.reload(forcedReload);
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
protected appendIconStyleSheets(iconInfos?: IconInfo[], useCdnIcon?: boolean) {
|
|
622
|
-
const iconPaths: string[] = useCdnIcon ? [DEFAULT_CDN_ICON, IDE_OCTICONS_CN_CSS, IDE_CODICONS_CN_CSS] : [];
|
|
623
|
-
if (iconInfos && iconInfos.length) {
|
|
624
|
-
iconInfos.forEach((info) => {
|
|
625
|
-
this.updateIconMap(info.prefix, info.iconMap);
|
|
626
|
-
iconPaths.push(info.cssPath);
|
|
627
|
-
});
|
|
628
|
-
}
|
|
629
|
-
for (const path of iconPaths) {
|
|
630
|
-
const link = document.createElement('link');
|
|
631
|
-
link.setAttribute('rel', 'stylesheet');
|
|
632
|
-
link.setAttribute('href', path);
|
|
633
|
-
document.getElementsByTagName('head')[0].appendChild(link);
|
|
634
|
-
}
|
|
635
|
-
}
|
|
636
|
-
|
|
637
|
-
protected updateIconMap(prefix: string, iconMap: IconMap) {
|
|
638
|
-
if (prefix === 'kaitian-icon kticon-') {
|
|
639
|
-
this.logger.error('icon prefix与内置图标冲突,请检查图标配置!');
|
|
640
|
-
}
|
|
641
|
-
updateIconMap(prefix, iconMap);
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
protected initEarlyPreference(workspaceDir: string) {
|
|
645
|
-
registerLocalStorageProvider(GeneralSettingsId.Theme, workspaceDir);
|
|
646
|
-
registerLocalStorageProvider(GeneralSettingsId.Icon, workspaceDir);
|
|
647
|
-
registerLocalStorageProvider(GeneralSettingsId.Language, workspaceDir);
|
|
648
|
-
}
|
|
649
|
-
|
|
650
|
-
public async dispose() {
|
|
651
|
-
window.removeEventListener('beforeunload', this._handleBeforeUpload);
|
|
652
|
-
window.removeEventListener('unload', this._handleUnload);
|
|
653
|
-
window.removeEventListener('resize', this._handleResize);
|
|
654
|
-
window.removeEventListener('compositionstart', this._handleCompositionstart);
|
|
655
|
-
window.removeEventListener('compositionend', this._handleCompositionend);
|
|
656
|
-
window.removeEventListener('keydown', this._handleKeydown, true);
|
|
657
|
-
if (isOSX) {
|
|
658
|
-
document.body.removeEventListener('wheel', this._handleWheel);
|
|
659
|
-
}
|
|
660
|
-
|
|
661
|
-
this.disposeSideEffect();
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
private disposeSideEffect() {
|
|
665
|
-
for (const contribution of this.contributions) {
|
|
666
|
-
if (contribution.onDisposeSideEffects) {
|
|
667
|
-
try {
|
|
668
|
-
contribution.onDisposeSideEffects(this);
|
|
669
|
-
} catch (error) {
|
|
670
|
-
this.logger.error('Could not dispose contribution', error);
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
private _handleBeforeUpload = (event: BeforeUnloadEvent) => {
|
|
677
|
-
// 浏览器关闭事件前
|
|
678
|
-
if (this.config.isElectronRenderer) {
|
|
679
|
-
if (this.stateService.state === 'electron_confirmed_close') {
|
|
680
|
-
return;
|
|
681
|
-
}
|
|
682
|
-
// 在electron上,先直接prevent, 然后进入ask环节
|
|
683
|
-
event.returnValue = '';
|
|
684
|
-
event.preventDefault();
|
|
685
|
-
if (this.stateService.state !== 'electron_asking_close') {
|
|
686
|
-
this.stateService.state = 'electron_asking_close';
|
|
687
|
-
this.preventStopElectron().then((res) => {
|
|
688
|
-
if (res) {
|
|
689
|
-
this.stateService.state = 'ready';
|
|
690
|
-
} else {
|
|
691
|
-
return this.stopContributionsElectron().then(() => {
|
|
692
|
-
this.stateService.state = 'electron_confirmed_close';
|
|
693
|
-
const electronLifeCycle: IElectronMainLifeCycleService = this.injector.get(IElectronMainLifeCycleService);
|
|
694
|
-
// 在下一个 event loop 执行,否则可能导致第一次无法关闭。
|
|
695
|
-
setTimeout(() => {
|
|
696
|
-
electronLifeCycle.closeWindow(electronEnv.currentWindowId);
|
|
697
|
-
}, 0);
|
|
698
|
-
});
|
|
699
|
-
}
|
|
700
|
-
});
|
|
701
|
-
}
|
|
702
|
-
} else {
|
|
703
|
-
// 为了避免不必要的弹窗,如果页面并没有发生交互浏览器可能不会展示在 beforeunload 事件中引发的弹框,甚至可能即使发生交互了也直接不显示。
|
|
704
|
-
if (this.preventStop()) {
|
|
705
|
-
(event || window.event).returnValue = true;
|
|
706
|
-
return true;
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
};
|
|
710
|
-
|
|
711
|
-
private _handleUnload = () => {
|
|
712
|
-
// 浏览器关闭事件
|
|
713
|
-
this.stateService.state = 'closing_window';
|
|
714
|
-
if (!this.config.isElectronRenderer) {
|
|
715
|
-
this.disposeSideEffect();
|
|
716
|
-
this.stopContributions();
|
|
717
|
-
}
|
|
718
|
-
};
|
|
719
|
-
|
|
720
|
-
private _handleResize = () => {
|
|
721
|
-
// 浏览器resize事件
|
|
722
|
-
};
|
|
723
|
-
|
|
724
|
-
private _handleKeydown = (event: any) => {
|
|
725
|
-
if (event && event.target!.name !== NO_KEYBINDING_NAME && !this._inComposition) {
|
|
726
|
-
this.keybindingService.run(event);
|
|
727
|
-
}
|
|
728
|
-
};
|
|
729
|
-
|
|
730
|
-
private _handleKeyup = (event: any) => {
|
|
731
|
-
this.keybindingService.resolveModifierKey(event);
|
|
732
|
-
};
|
|
733
|
-
|
|
734
|
-
private _handleCompositionstart = () => {
|
|
735
|
-
this._inComposition = true;
|
|
736
|
-
};
|
|
737
|
-
|
|
738
|
-
private _handleCompositionend = () => {
|
|
739
|
-
this._inComposition = false;
|
|
740
|
-
};
|
|
741
|
-
|
|
742
|
-
private _handleWheel = () => {
|
|
743
|
-
// 屏蔽在OSX系统浏览器中由于滚动导致的前进后退事件
|
|
744
|
-
};
|
|
745
|
-
}
|