extensionManagement.ts 3.0 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;
J
Joao Moreno 已提交
21
	icon?: string;
E
Erich Gamma 已提交
22 23
}

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

J
Joao Moreno 已提交
34 35 36 37 38 39 40 41 42
export interface IExtensionIdentity {
	name: string;
	publisher: string;
}

export interface IGalleryExtension {
	id: string;
	name: string;
	displayName: string;
E
Erich Gamma 已提交
43
	publisherId: string;
J
Joao Moreno 已提交
44
	publisher: string;
E
Erich Gamma 已提交
45
	publisherDisplayName: string;
J
Joao Moreno 已提交
46
	description: string;
J
Joao Moreno 已提交
47
	installCount: number;
48
	versions: IGalleryVersion[];
E
Erich Gamma 已提交
49 50
}

J
Joao Moreno 已提交
51
export interface IGalleryMetadata {
52 53 54
	id: string;
	publisherId: string;
	publisherDisplayName: string;
J
Joao Moreno 已提交
55 56
}

J
Joao Moreno 已提交
57
export interface IExtension {
J
Joao Moreno 已提交
58
	id: string;
J
Joao Moreno 已提交
59
	manifest: IExtensionManifest;
J
Joao Moreno 已提交
60
	metadata: IGalleryMetadata;
J
Joao Moreno 已提交
61
	path: string;
J
Joao Moreno 已提交
62 63
}

J
Joao Moreno 已提交
64 65
export const IExtensionManagementService = createDecorator<IExtensionManagementService>('extensionManagementService');
export const IExtensionGalleryService = createDecorator<IExtensionGalleryService>('extensionGalleryService');
E
Erich Gamma 已提交
66

J
Joao Moreno 已提交
67 68
export interface IQueryOptions {
	text?: string;
J
Joao Moreno 已提交
69
	ids?: string[];
J
Joao Moreno 已提交
70 71 72 73
	pageSize?: number;
}

export interface IQueryResult {
J
Joao Moreno 已提交
74
	firstPage: IGalleryExtension[];
J
Joao Moreno 已提交
75
	total: number;
J
Joao Moreno 已提交
76
	pageSize: number;
J
Joao Moreno 已提交
77
	getPage(pageNumber: number): TPromise<IGalleryExtension[]>;
J
Joao Moreno 已提交
78 79
}

J
Joao Moreno 已提交
80
export interface IExtensionGalleryService {
E
Erich Gamma 已提交
81 82
	serviceId: ServiceIdentifier<any>;
	isEnabled(): boolean;
J
Joao Moreno 已提交
83
	query(options?: IQueryOptions): TPromise<IQueryResult>;
E
Erich Gamma 已提交
84 85
}

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

J
Joao Moreno 已提交
88
export interface IExtensionManagementService {
E
Erich Gamma 已提交
89 90
	serviceId: ServiceIdentifier<any>;

J
Joao Moreno 已提交
91 92 93 94 95
	onInstallExtension: Event<string>;
	onDidInstallExtension: Event<DidInstallExtensionEvent>;
	onUninstallExtension: Event<string>;
	onDidUninstallExtension: Event<string>;

J
Joao Moreno 已提交
96
	install(extension: IGalleryExtension): TPromise<void>;
J
Joao Moreno 已提交
97
	install(zipPath: string): TPromise<void>;
E
Erich Gamma 已提交
98
	uninstall(extension: IExtension): TPromise<void>;
J
Joao Moreno 已提交
99
	getInstalled(includeDuplicateVersions?: boolean): TPromise<IExtension[]>;
E
Erich Gamma 已提交
100
}
101

J
Joao Moreno 已提交
102
export const IExtensionTipsService = createDecorator<IExtensionTipsService>('extensionTipsService');
103 104

export interface IExtensionTipsService {
J
Johannes Rieken 已提交
105
	serviceId: ServiceIdentifier<IExtensionTipsService>;
J
Joao Moreno 已提交
106
	getRecommendations(): TPromise<IExtension[]>;
107 108
}

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