extensionManagement.ts 4.7 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 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
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 {
	label: string;
	runtime: string;
}

export interface IGrammar {
	language: string;
}

export interface IJSONValidation {
	fileMatch: string;
}

export interface IKeyBindings {
	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;
}

export interface IExtensionContributions {
	commands?: ICommand[];
	configuration?: IConfiguration;
	debuggers?: IDebugger[];
	grammars?: IGrammar[];
	jsonValidation?: IJSONValidation[];
	keybindings?: IKeyBindings[];
	languages?: ILanguage[];
	menus?: { [context: string]: IMenu[] };
	snippets?: ISnippet[];
}

E
Erich Gamma 已提交
81 82 83 84
export interface IExtensionManifest {
	name: string;
	publisher: string;
	version: string;
85
	engines: { vscode: string };
E
Erich Gamma 已提交
86 87
	displayName?: string;
	description?: string;
J
Joao Moreno 已提交
88
	main?: string;
J
Joao Moreno 已提交
89
	icon?: string;
90 91 92
	categories?: string[];
	activationEvents?: string[];
	contributes?: IExtensionContributions;
E
Erich Gamma 已提交
93 94
}

J
Joao Moreno 已提交
95 96 97 98 99
export interface IExtensionIdentity {
	name: string;
	publisher: string;
}

100 101 102 103 104
export interface IGalleryExtensionAssets {
	manifest: string;
	readme: string;
	download: string;
	icon: string;
105
	iconFallback: string;
106 107 108
	license: string;
}

J
Joao Moreno 已提交
109 110 111
export interface IGalleryExtension {
	id: string;
	name: string;
112 113
	version: string;
	date: string;
J
Joao Moreno 已提交
114
	displayName: string;
E
Erich Gamma 已提交
115
	publisherId: string;
J
Joao Moreno 已提交
116
	publisher: string;
E
Erich Gamma 已提交
117
	publisherDisplayName: string;
J
Joao Moreno 已提交
118
	description: string;
J
Joao Moreno 已提交
119
	installCount: number;
J
Joao Moreno 已提交
120 121
	rating: number;
	ratingCount: number;
122 123
	assets: IGalleryExtensionAssets;
	downloadHeaders: { [key: string]: string; };
E
Erich Gamma 已提交
124 125
}

J
Joao Moreno 已提交
126
export interface IGalleryMetadata {
127 128 129
	id: string;
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
130 131
}

J
Joao Moreno 已提交
132
export interface ILocalExtension {
J
Joao Moreno 已提交
133
	id: string;
J
Joao Moreno 已提交
134
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
135
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
136
	path: string;
J
Joao Moreno 已提交
137
	readmeUrl: string;
J
Joao Moreno 已提交
138 139
}

J
Joao Moreno 已提交
140 141
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
142

J
Joao Moreno 已提交
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158
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 已提交
159 160
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
161
	ids?: string[];
162
	names?: string[];
J
Joao Moreno 已提交
163
	pageSize?: number;
J
Joao Moreno 已提交
164 165
	sortBy?: SortBy;
	sortOrder?: SortOrder;
J
Joao Moreno 已提交
166 167
}

J
Joao Moreno 已提交
168
export interface IExtensionGalleryService {
169
	_serviceBrand: any;
E
Erich Gamma 已提交
170
	isEnabled(): boolean;
J
Joao Moreno 已提交
171
	query(options?: IQueryOptions): TPromise<IPager<IGalleryExtension>>;
172
	download(extension: IGalleryExtension): TPromise<string>;
J
Joao Moreno 已提交
173
	getAsset(url: string): TPromise<IRequestContext>;
E
Erich Gamma 已提交
174 175
}

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

J
Joao Moreno 已提交
179
export interface IExtensionManagementService {
180
	_serviceBrand: any;
E
Erich Gamma 已提交
181

J
Joao Moreno 已提交
182
	onInstallExtension: Event<InstallExtensionEvent>;
J
Joao Moreno 已提交
183 184 185 186 187
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

	install(zipPath: string): TPromise<void>;
188
	installFromGallery(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
189
	uninstall(extension: ILocalExtension): TPromise<void>;
J
Joao Moreno 已提交
190
	getInstalled(): TPromise<ILocalExtension[]>;
E
Erich Gamma 已提交
191
}
192

J
Joao Moreno 已提交
193
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
194 195

export interface IExtensionTipsService {
196
	_serviceBrand: any;
J
Joao Moreno 已提交
197
	getRecommendations(): TPromise<IGalleryExtension[]>;
198 199
}

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