extensionManagement.ts 4.8 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 108 109 110
export interface IGalleryExtensionAssets {
	manifest: string;
	readme: string;
	download: string;
	icon: string;
111
	iconFallback: string;
112 113 114
	license: string;
}

J
Joao Moreno 已提交
115 116 117
export interface IGalleryExtension {
	id: string;
	name: string;
118 119
	version: string;
	date: string;
J
Joao Moreno 已提交
120
	displayName: string;
E
Erich Gamma 已提交
121
	publisherId: string;
J
Joao Moreno 已提交
122
	publisher: string;
E
Erich Gamma 已提交
123
	publisherDisplayName: string;
J
Joao Moreno 已提交
124
	description: string;
J
Joao Moreno 已提交
125
	installCount: number;
J
Joao Moreno 已提交
126 127
	rating: number;
	ratingCount: number;
128 129
	assets: IGalleryExtensionAssets;
	downloadHeaders: { [key: string]: string; };
E
Erich Gamma 已提交
130 131
}

J
Joao Moreno 已提交
132
export interface IGalleryMetadata {
133 134 135
	id: string;
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
136 137
}

J
Joao Moreno 已提交
138
export interface ILocalExtension {
J
Joao Moreno 已提交
139
	id: string;
J
Joao Moreno 已提交
140
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
141
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
142
	path: string;
J
Joao Moreno 已提交
143
	readmeUrl: string;
144
	changelogUrl: string;
J
Joao Moreno 已提交
145 146
}

J
Joao Moreno 已提交
147 148
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
149

J
Joao Moreno 已提交
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165
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 已提交
166 167
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
168
	ids?: string[];
169
	names?: string[];
J
Joao Moreno 已提交
170
	pageSize?: number;
J
Joao Moreno 已提交
171 172
	sortBy?: SortBy;
	sortOrder?: SortOrder;
J
Joao Moreno 已提交
173 174
}

J
Joao Moreno 已提交
175
export interface IExtensionGalleryService {
176
	_serviceBrand: any;
E
Erich Gamma 已提交
177
	isEnabled(): boolean;
J
Joao Moreno 已提交
178
	query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
179
	download(extension: IGalleryExtension): TPromise<string>;
J
Joao Moreno 已提交
180
	getAsset(url: string): TPromise<IRequestContext>;
E
Erich Gamma 已提交
181 182
}

J
Joao Moreno 已提交
183 184
export type InstallExtensionEvent = { id: string; gallery?: IGalleryExtension; };
export type DidInstallExtensionEvent = { id: string; local?: ILocalExtension; error?: Error; };
J
Joao Moreno 已提交
185

J
Joao Moreno 已提交
186
export interface IExtensionManagementService {
187
	_serviceBrand: any;
E
Erich Gamma 已提交
188

J
Joao Moreno 已提交
189
	onInstallExtension: Event<InstallExtensionEvent>;
J
Joao Moreno 已提交
190 191 192 193 194
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

	install(zipPath: string): TPromise<void>;
195
	installFromGallery(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
196
	uninstall(extension: ILocalExtension): TPromise<void>;
J
Joao Moreno 已提交
197
	getInstalled(): TPromise<ILocalExtension[]>;
E
Erich Gamma 已提交
198
}
199

J
Joao Moreno 已提交
200
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
201 202

export interface IExtensionTipsService {
203
	_serviceBrand: any;
204
	getRecommendations(): string[];
S
Sandeep Somavarapu 已提交
205
	getWorkspaceRecommendations(): string[];
206 207
}

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