1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { createDecorator, refineServiceDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtension, ExtensionType, IExtensionManifest } from 'vs/platform/extensions/common/extensions';
import { IExtensionManagementService, IGalleryExtension, IExtensionIdentifier, ILocalExtension, InstallOptions, InstallExtensionEvent, DidUninstallExtensionEvent, InstallExtensionResult, Metadata } from 'vs/platform/extensionManagement/common/extensionManagement';
import { URI } from 'vs/base/common/uri';
import { FileAccess } from 'vs/base/common/network';
export interface IExtensionManagementServer {
readonly id: string;
readonly label: string;
readonly extensionManagementService: IExtensionManagementService;
}
export const enum ExtensionInstallLocation {
Local = 1,
Remote,
Web
}
export const IExtensionManagementServerService = createDecorator<IExtensionManagementServerService>('extensionManagementServerService');
export interface IExtensionManagementServerService {
readonly _serviceBrand: undefined;
readonly localExtensionManagementServer: IExtensionManagementServer | null;
readonly remoteExtensionManagementServer: IExtensionManagementServer | null;
readonly webExtensionManagementServer: IExtensionManagementServer | null;
getExtensionManagementServer(extension: IExtension): IExtensionManagementServer | null;
getExtensionInstallLocation(extension: IExtension): ExtensionInstallLocation | null;
}
export const DefaultIconPath = FileAccess.asBrowserUri('./media/defaultIcon.png', require).toString(true);
export type InstallExtensionOnServerEvent = InstallExtensionEvent & { server: IExtensionManagementServer };
export type UninstallExtensionOnServerEvent = IExtensionIdentifier & { server: IExtensionManagementServer };
export type DidUninstallExtensionOnServerEvent = DidUninstallExtensionEvent & { server: IExtensionManagementServer };
export const IWorkbenchExtensionManagementService = refineServiceDecorator<IExtensionManagementService, IWorkbenchExtensionManagementService>(IExtensionManagementService);
export interface IWorkbenchExtensionManagementService extends IExtensionManagementService {
readonly _serviceBrand: undefined;
onInstallExtension: Event<InstallExtensionOnServerEvent>;
onDidInstallExtensions: Event<readonly InstallExtensionResult[]>;
onUninstallExtension: Event<UninstallExtensionOnServerEvent>;
onDidUninstallExtension: Event<DidUninstallExtensionOnServerEvent>;
installWebExtension(location: URI): Promise<ILocalExtension>;
installExtensions(extensions: IGalleryExtension[], installOptions?: InstallOptions): Promise<ILocalExtension[]>;
updateFromGallery(gallery: IGalleryExtension, extension: ILocalExtension, installOptions?: InstallOptions): Promise<ILocalExtension>;
getExtensionManagementServerToInstall(manifest: IExtensionManifest): IExtensionManagementServer | null;
}
export const enum EnablementState {
DisabledByTrustRequirement,
DisabledByExtensionKind,
DisabledByEnvironment,
EnabledByEnvironment,
DisabledByVirtualWorkspace,
DisabledByExtensionDependency,
DisabledGlobally,
DisabledWorkspace,
EnabledGlobally,
EnabledWorkspace
}
export const IWorkbenchExtensionEnablementService = createDecorator<IWorkbenchExtensionEnablementService>('extensionEnablementService');
export interface IWorkbenchExtensionEnablementService {
readonly _serviceBrand: undefined;
/**
* Event to listen on for extension enablement changes
*/
readonly onEnablementChanged: Event<readonly IExtension[]>;
/**
* Returns the enablement state for the given extension
*/
getEnablementState(extension: IExtension): EnablementState;
/**
* Returns the enablement states for the given extensions
* @param extensions list of extensions
* @param workspaceTypeOverrides Workspace type overrides
*/
getEnablementStates(extensions: IExtension[], workspaceTypeOverrides?: { trusted?: boolean }): EnablementState[];
/**
* Returns the enablement states for the dependencies of the given extension
*/
getDependenciesEnablementStates(extension: IExtension): [IExtension, EnablementState][];
/**
* Returns `true` if the enablement can be changed.
*/
canChangeEnablement(extension: IExtension): boolean;
/**
* Returns `true` if the enablement can be changed.
*/
canChangeWorkspaceEnablement(extension: IExtension): boolean;
/**
* Returns `true` if the given extension is enabled.
*/
isEnabled(extension: IExtension): boolean;
/**
* Returns `true` if the given enablement state is enabled enablement state.
*/
isEnabledEnablementState(enablementState: EnablementState): boolean;
/**
* Returns `true` if the given extension identifier is disabled globally.
* Extensions can be disabled globally or in workspace or both.
* If an extension is disabled in both then enablement state shows only workspace.
* This will
*/
isDisabledGlobally(extension: IExtension): boolean;
/**
* Enable or disable the given extension.
* if `workspace` is `true` then enablement is done for workspace, otherwise globally.
*
* Returns a promise that resolves to boolean value.
* if resolves to `true` then requires restart for the change to take effect.
*
* Throws error if enablement is requested for workspace and there is no workspace
*/
setEnablement(extensions: IExtension[], state: EnablementState): Promise<boolean[]>;
/**
* Updates the enablement state of the extensions when workspace trust changes.
*/
updateExtensionsEnablementsWhenWorkspaceTrustChanges(): Promise<void>;
}
export interface IScannedExtension extends IExtension {
readonly metadata?: Metadata;
readonly isValid: boolean;
readonly validationMessages: readonly string[];
}
export type ScanOptions = { readonly bailOut?: boolean; readonly skipInvalidExtensions?: boolean };
export const IWebExtensionsScannerService = createDecorator<IWebExtensionsScannerService>('IWebExtensionsScannerService');
export interface IWebExtensionsScannerService {
readonly _serviceBrand: undefined;
scanSystemExtensions(): Promise<IExtension[]>;
scanUserExtensions(options?: ScanOptions): Promise<IScannedExtension[]>;
scanExtensionsUnderDevelopment(): Promise<IExtension[]>;
scanExistingExtension(extensionLocation: URI, extensionType: ExtensionType): Promise<IExtension | null>;
addExtension(location: URI, metadata?: Metadata): Promise<IExtension>;
addExtensionFromGallery(galleryExtension: IGalleryExtension, metadata?: Metadata): Promise<IExtension>;
removeExtension(identifier: IExtensionIdentifier, version?: string): Promise<void>;
scanExtensionManifest(extensionLocation: URI): Promise<IExtensionManifest | null>;
}
|