|
| 1 | +/*--------------------------------------------------------------------------------------------- |
| 2 | + * Copyright (c) Microsoft Corporation. All rights reserved. |
| 3 | + * Licensed under the MIT License. See License.txt in the project root for license information. |
| 4 | + *--------------------------------------------------------------------------------------------*/ |
| 5 | + |
| 6 | +declare module 'vscode' { |
| 7 | + // https://github.com/microsoft/vscode/issues/84297 |
| 8 | + |
| 9 | + export class TimelineItem { |
| 10 | + /** |
| 11 | + * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred. |
| 12 | + */ |
| 13 | + timestamp: number; |
| 14 | + |
| 15 | + /** |
| 16 | + * A human-readable string describing the timeline item. |
| 17 | + */ |
| 18 | + label: string; |
| 19 | + |
| 20 | + /** |
| 21 | + * Optional id for the timeline item. It must be unique across all the timeline items provided by this source. |
| 22 | + * |
| 23 | + * If not provided, an id is generated using the timeline item's timestamp. |
| 24 | + */ |
| 25 | + id?: string; |
| 26 | + |
| 27 | + /** |
| 28 | + * The icon path or {@link ThemeIcon} for the timeline item. |
| 29 | + */ |
| 30 | + iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon; |
| 31 | + |
| 32 | + /** |
| 33 | + * A human readable string describing less prominent details of the timeline item. |
| 34 | + */ |
| 35 | + description?: string; |
| 36 | + |
| 37 | + /** |
| 38 | + * The tooltip text when you hover over the timeline item. |
| 39 | + */ |
| 40 | + detail?: string; |
| 41 | + |
| 42 | + /** |
| 43 | + * The {@link Command} that should be executed when the timeline item is selected. |
| 44 | + */ |
| 45 | + command?: Command; |
| 46 | + |
| 47 | + /** |
| 48 | + * Context value of the timeline item. This can be used to contribute specific actions to the item. |
| 49 | + * For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context` |
| 50 | + * using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`. |
| 51 | + * ``` |
| 52 | + * "contributes": { |
| 53 | + * "menus": { |
| 54 | + * "timeline/item/context": [ |
| 55 | + * { |
| 56 | + * "command": "extension.copyCommitId", |
| 57 | + * "when": "timelineItem == commit" |
| 58 | + * } |
| 59 | + * ] |
| 60 | + * } |
| 61 | + * } |
| 62 | + * ``` |
| 63 | + * This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`. |
| 64 | + */ |
| 65 | + contextValue?: string; |
| 66 | + |
| 67 | + /** |
| 68 | + * Accessibility information used when screen reader interacts with this timeline item. |
| 69 | + */ |
| 70 | + accessibilityInformation?: AccessibilityInformation; |
| 71 | + |
| 72 | + /** |
| 73 | + * @param label A human-readable string describing the timeline item |
| 74 | + * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred |
| 75 | + */ |
| 76 | + constructor(label: string, timestamp: number); |
| 77 | + } |
| 78 | + |
| 79 | + export interface TimelineChangeEvent { |
| 80 | + /** |
| 81 | + * The {@link Uri} of the resource for which the timeline changed. |
| 82 | + */ |
| 83 | + uri: Uri; |
| 84 | + |
| 85 | + /** |
| 86 | + * A flag which indicates whether the entire timeline should be reset. |
| 87 | + */ |
| 88 | + reset?: boolean; |
| 89 | + } |
| 90 | + |
| 91 | + export interface Timeline { |
| 92 | + readonly paging?: { |
| 93 | + /** |
| 94 | + * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned. |
| 95 | + * Use `undefined` to signal that there are no more items to be returned. |
| 96 | + */ |
| 97 | + readonly cursor: string | undefined; |
| 98 | + }; |
| 99 | + |
| 100 | + /** |
| 101 | + * An array of {@link TimelineItem timeline items}. |
| 102 | + */ |
| 103 | + readonly items: readonly TimelineItem[]; |
| 104 | + } |
| 105 | + |
| 106 | + export interface TimelineOptions { |
| 107 | + /** |
| 108 | + * A provider-defined cursor specifying the starting point of the timeline items that should be returned. |
| 109 | + */ |
| 110 | + cursor?: string; |
| 111 | + |
| 112 | + /** |
| 113 | + * An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned. |
| 114 | + * If `undefined` all timeline items should be returned. |
| 115 | + */ |
| 116 | + limit?: number | { timestamp: number; id?: string }; |
| 117 | + } |
| 118 | + |
| 119 | + export interface TimelineProvider { |
| 120 | + /** |
| 121 | + * An optional event to signal that the timeline for a source has changed. |
| 122 | + * To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`. |
| 123 | + */ |
| 124 | + onDidChange?: Event<TimelineChangeEvent | undefined>; |
| 125 | + |
| 126 | + /** |
| 127 | + * An identifier of the source of the timeline items. This can be used to filter sources. |
| 128 | + */ |
| 129 | + readonly id: string; |
| 130 | + |
| 131 | + /** |
| 132 | + * A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources. |
| 133 | + */ |
| 134 | + readonly label: string; |
| 135 | + |
| 136 | + /** |
| 137 | + * Provide {@link TimelineItem timeline items} for a {@link Uri}. |
| 138 | + * |
| 139 | + * @param uri The {@link Uri} of the file to provide the timeline for. |
| 140 | + * @param options A set of options to determine how results should be returned. |
| 141 | + * @param token A cancellation token. |
| 142 | + * @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result |
| 143 | + * can be signaled by returning `undefined`, `null`, or an empty array. |
| 144 | + */ |
| 145 | + provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>; |
| 146 | + } |
| 147 | + |
| 148 | + export namespace workspace { |
| 149 | + /** |
| 150 | + * Register a timeline provider. |
| 151 | + * |
| 152 | + * Multiple providers can be registered. In that case, providers are asked in |
| 153 | + * parallel and the results are merged. A failing provider (rejected promise or exception) will |
| 154 | + * not cause a failure of the whole operation. |
| 155 | + * |
| 156 | + * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents. |
| 157 | + * @param provider A timeline provider. |
| 158 | + * @return A {@link Disposable} that unregisters this provider when being disposed. |
| 159 | + */ |
| 160 | + export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable; |
| 161 | + } |
| 162 | +} |
0 commit comments