extensionManagement.ts 2.9 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 11 12 13 14 15 16
import Event from 'vs/base/common/event';
import { createDecorator, ServiceIdentifier } from 'vs/platform/instantiation/common/instantiation';

export interface IExtensionManifest {
	name: string;
	publisher: string;
	version: string;
17
	engines: { vscode: string };
E
Erich Gamma 已提交
18 19
	displayName?: string;
	description?: string;
J
Joao Moreno 已提交
20
	main?: string;
E
Erich Gamma 已提交
21 22
}

23 24 25 26
export interface IGalleryVersion {
	version: string;
	date: string;
	manifestUrl: string;
J
Joao Moreno 已提交
27
	readmeUrl: string;
28
	downloadUrl: string;
J
Joao Moreno 已提交
29
	iconUrl: string;
30
	downloadHeaders: { [key: string]: string; };
31 32
}

J
Joao Moreno 已提交
33
export interface IGalleryMetadata {
E
Erich Gamma 已提交
34 35
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
36
	installCount: number;
37
	versions: IGalleryVersion[];
E
Erich Gamma 已提交
38 39
}

J
Joao Moreno 已提交
40 41 42 43 44 45
export interface IGalleryExtension {
	id: string;
	manifest: IExtensionManifest;
	metadata: IGalleryMetadata;
}

J
Joao Moreno 已提交
46
export interface IExtension {
J
Joao Moreno 已提交
47
	id: string;
J
Joao Moreno 已提交
48
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
49
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
50
	path: string;
J
Joao Moreno 已提交
51 52
}

J
Joao Moreno 已提交
53 54
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
55

J
Joao Moreno 已提交
56 57
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
58
	ids?: string[];
J
Joao Moreno 已提交
59 60 61 62
	pageSize?: number;
}

export interface IQueryResult {
J
Joao Moreno 已提交
63
	firstPage: IGalleryExtension[];
J
Joao Moreno 已提交
64
	total: number;
J
Joao Moreno 已提交
65
	pageSize: number;
J
Joao Moreno 已提交
66
	getPage(pageNumber: number): TPromise<IGalleryExtension[]>;
J
Joao Moreno 已提交
67 68
}

J
Joao Moreno 已提交
69
export interface IExtensionGalleryService {
E
Erich Gamma 已提交
70 71
	serviceId: ServiceIdentifier<any>;
	isEnabled(): boolean;
J
Joao Moreno 已提交
72
	query(options?: IQueryOptions): TPromise<IQueryResult>;
E
Erich Gamma 已提交
73 74
}

J
Joao Moreno 已提交
75 76
export type DidInstallExtensionEvent = { id: string; error?: Error; };

J
Joao Moreno 已提交
77
export interface IExtensionManagementService {
E
Erich Gamma 已提交
78 79
	serviceId: ServiceIdentifier<any>;

J
Joao Moreno 已提交
80 81 82 83 84
	onInstallExtension: Event<string>;
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

J
Joao Moreno 已提交
85
	install(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
86
	install(zipPath: string): TPromise<void>;
E
Erich Gamma 已提交
87
	uninstall(extension: IExtension): TPromise<void>;
J
Joao Moreno 已提交
88
	getInstalled(includeDuplicateVersions?: boolean): TPromise<IExtension[]>;
E
Erich Gamma 已提交
89
}
90

J
Joao Moreno 已提交
91
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
92 93

export interface IExtensionTipsService {
J
Johannes Rieken 已提交
94
	serviceId: ServiceIdentifier<IExtensionTipsService>;
J
Joao Moreno 已提交
95
	getRecommendations(): TPromise<IExtension[]>;
96 97
}

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