extensionManagement.ts 5.5 KB
Newer Older
E
Erich Gamma 已提交
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';

8
import nls = require('vs/nls');
9
import { TPromise } from 'vs/base/common/winjs.base';
E
Erich Gamma 已提交
10
import Event from 'vs/base/common/event';
J
Joao Moreno 已提交
11
import { IPager } from 'vs/base/common/paging';
12
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
J
Joao Moreno 已提交
13
import { IRequestContext } from 'vs/base/node/request';
E
Erich Gamma 已提交
14

15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
export interface ICommand {
	command: string;
	title: string;
	category?: string;
}

export interface IConfigurationProperty {
	description: string;
	type: string | string[];
}

export interface IConfiguration {
	properties: { [key: string]: IConfigurationProperty; };
}

export interface IDebugger {
J
Joao Moreno 已提交
31 32
	label?: string;
	type: string;
33 34 35 36 37 38 39 40 41 42 43
	runtime: string;
}

export interface IGrammar {
	language: string;
}

export interface IJSONValidation {
	fileMatch: string;
}

44
export interface IKeyBinding {
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
	command: string;
	key: string;
	when?: string;
	mac?: string;
	linux?: string;
	win?: string;
}

export interface ILanguage {
	id: string;
	extensions: string[];
	aliases: string[];
}

export interface IMenu {
	command: string;
	alt?: string;
	when?: string;
	group?: string;
}

export interface ISnippet {
	language: string;
}

J
Joao Moreno 已提交
70 71 72 73
export interface ITheme {
	label: string;
}

74 75 76 77 78 79
export interface IExtensionContributions {
	commands?: ICommand[];
	configuration?: IConfiguration;
	debuggers?: IDebugger[];
	grammars?: IGrammar[];
	jsonValidation?: IJSONValidation[];
80
	keybindings?: IKeyBinding[];
81 82 83
	languages?: ILanguage[];
	menus?: { [context: string]: IMenu[] };
	snippets?: ISnippet[];
J
Joao Moreno 已提交
84
	themes?: ITheme[];
85 86
}

E
Erich Gamma 已提交
87 88 89 90
export interface IExtensionManifest {
	name: string;
	publisher: string;
	version: string;
91
	engines: { vscode: string };
E
Erich Gamma 已提交
92 93
	displayName?: string;
	description?: string;
J
Joao Moreno 已提交
94
	main?: string;
J
Joao Moreno 已提交
95
	icon?: string;
96 97 98
	categories?: string[];
	activationEvents?: string[];
	contributes?: IExtensionContributions;
E
Erich Gamma 已提交
99 100
}

J
Joao Moreno 已提交
101 102 103 104 105
export interface IExtensionIdentity {
	name: string;
	publisher: string;
}

106 107
export interface IGalleryExtensionProperties {
	dependencies?: string[];
108
	engine?: string;
109 110
}

111 112 113
export interface IGalleryExtensionAssets {
	manifest: string;
	readme: string;
114
	changelog: string;
115 116
	download: string;
	icon: string;
117
	iconFallback: string;
118 119 120
	license: string;
}

J
Joao Moreno 已提交
121 122 123
export interface IGalleryExtension {
	id: string;
	name: string;
124 125
	version: string;
	date: string;
J
Joao Moreno 已提交
126
	displayName: string;
E
Erich Gamma 已提交
127
	publisherId: string;
J
Joao Moreno 已提交
128
	publisher: string;
E
Erich Gamma 已提交
129
	publisherDisplayName: string;
J
Joao Moreno 已提交
130
	description: string;
J
Joao Moreno 已提交
131
	installCount: number;
J
Joao Moreno 已提交
132 133
	rating: number;
	ratingCount: number;
134
	assets: IGalleryExtensionAssets;
135
	properties: IGalleryExtensionProperties;
136
	downloadHeaders: { [key: string]: string; };
137 138
	/** We need this check until all extension in the market place contain engine property */
	compatibilityChecked: boolean;
139
	isCompatible: boolean;
E
Erich Gamma 已提交
140 141
}

J
Joao Moreno 已提交
142
export interface IGalleryMetadata {
143 144 145
	id: string;
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
146 147
}

J
Joao Moreno 已提交
148 149 150 151 152
export enum LocalExtensionType {
	System,
	User
}

J
Joao Moreno 已提交
153
export interface ILocalExtension {
J
Joao Moreno 已提交
154
	type: LocalExtensionType;
J
Joao Moreno 已提交
155
	id: string;
J
Joao Moreno 已提交
156
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
157
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
158
	path: string;
J
Joao Moreno 已提交
159
	readmeUrl: string;
160
	changelogUrl: string;
J
Joao Moreno 已提交
161 162
}

J
Joao Moreno 已提交
163 164
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
165

J
Joao Moreno 已提交
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181
export enum SortBy {
	NoneOrRelevance = 0,
	LastUpdatedDate = 1,
	Title = 2,
	PublisherName = 3,
	InstallCount = 4,
	PublishedDate = 5,
	AverageRating = 6
}

export enum SortOrder {
	Default = 0,
	Ascending = 1,
	Descending = 2
}

J
Joao Moreno 已提交
182 183
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
184
	ids?: string[];
185
	names?: string[];
J
Joao Moreno 已提交
186
	pageSize?: number;
J
Joao Moreno 已提交
187 188
	sortBy?: SortBy;
	sortOrder?: SortOrder;
J
Joao Moreno 已提交
189 190
}

J
Joao Moreno 已提交
191
export interface IExtensionGalleryService {
192
	_serviceBrand: any;
E
Erich Gamma 已提交
193
	isEnabled(): boolean;
J
Joao Moreno 已提交
194
	query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
195
	download(extension: IGalleryExtension): TPromise<string>;
J
Joao Moreno 已提交
196
	getAsset(url: string): TPromise<IRequestContext>;
197 198
	loadCompatibleVersion(extension: IGalleryExtension): TPromise<IGalleryExtension>;
	getAllDependencies(extension: IGalleryExtension): TPromise<IGalleryExtension[]>;
E
Erich Gamma 已提交
199 200
}

201 202 203 204 205 206 207 208 209 210 211 212 213
export interface InstallExtensionEvent {
	id: string;
	zipPath?: string;
	gallery?: IGalleryExtension;
}

export interface DidInstallExtensionEvent {
	id: string;
	zipPath?: string;
	gallery?: IGalleryExtension;
	local?: ILocalExtension;
	error?: Error;
}
J
Joao Moreno 已提交
214

J
Joao Moreno 已提交
215
export interface IExtensionManagementService {
216
	_serviceBrand: any;
E
Erich Gamma 已提交
217

J
Joao Moreno 已提交
218
	onInstallExtension: Event<InstallExtensionEvent>;
J
Joao Moreno 已提交
219 220 221 222 223
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

	install(zipPath: string): TPromise<void>;
224
	installFromGallery(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
225
	uninstall(extension: ILocalExtension): TPromise<void>;
J
Joao Moreno 已提交
226
	getInstalled(type?: LocalExtensionType): TPromise<ILocalExtension[]>;
E
Erich Gamma 已提交
227
}
228

J
Joao Moreno 已提交
229
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
230 231

export interface IExtensionTipsService {
232
	_serviceBrand: any;
233
	getRecommendations(): string[];
S
Sandeep Somavarapu 已提交
234
	getWorkspaceRecommendations(): string[];
235 236
}

I
isidor 已提交
237 238
export const ExtensionsLabel = nls.localize('extensions', "Extensions");
export const ExtensionsChannelId = 'extensions';