@codingame/monaco-vscode-update-service-override 28.4.0 → 29.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (20) hide show
  1. package/package.json +2 -2
  2. package/vscode/src/vs/platform/update/common/update.config.contribution.js +39 -20
  3. package/vscode/src/vs/workbench/contrib/markdown/browser/markdownSettingRenderer.js +14 -14
  4. package/vscode/src/vs/workbench/contrib/update/browser/media/updateStatusBarEntry.css +0 -133
  5. package/vscode/src/vs/workbench/contrib/update/browser/media/updateTitleBarEntry.css +109 -0
  6. package/vscode/src/vs/workbench/contrib/update/browser/media/updateTooltip.css +159 -0
  7. package/vscode/src/vs/workbench/contrib/update/browser/releaseNotesEditor.d.ts +22 -1
  8. package/vscode/src/vs/workbench/contrib/update/browser/releaseNotesEditor.js +32 -14
  9. package/vscode/src/vs/workbench/contrib/update/browser/update.contribution.js +19 -17
  10. package/vscode/src/vs/workbench/contrib/update/browser/update.d.ts +5 -1
  11. package/vscode/src/vs/workbench/contrib/update/browser/update.js +132 -94
  12. package/vscode/src/vs/workbench/contrib/update/browser/updateStatusBarEntry.d.ts +9 -55
  13. package/vscode/src/vs/workbench/contrib/update/browser/updateStatusBarEntry.js +64 -395
  14. package/vscode/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.d.ts +58 -0
  15. package/vscode/src/vs/workbench/contrib/update/browser/updateTitleBarEntry.js +319 -0
  16. package/vscode/src/vs/workbench/contrib/update/browser/updateTooltip.d.ts +66 -0
  17. package/vscode/src/vs/workbench/contrib/update/browser/updateTooltip.js +429 -0
  18. package/vscode/src/vs/workbench/contrib/update/common/updateUtils.d.ts +61 -0
  19. package/vscode/src/vs/workbench/contrib/update/common/updateUtils.js +141 -0
  20. package/vscode/src/vs/workbench/contrib/update/browser/media/releasenoteseditor.css +0 -9
@@ -0,0 +1,319 @@
1
+
2
+ import { registerCss } from '@codingame/monaco-vscode-api/css';
3
+ import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
+ import { append, $, scheduleAtNextAnimationFrame, getWindow, clearNode } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
5
+ import { BaseActionViewItem } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems';
6
+ import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
7
+ import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
8
+ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
9
+ import { IActionViewItemService } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/actionViewItemService.service';
10
+ import { registerAction2, Action2, MenuId } from '@codingame/monaco-vscode-api/vscode/vs/platform/actions/common/actions';
11
+ import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
12
+ import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
13
+ import { RawContextKey } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey';
14
+ import { IContextKeyService } from '@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service';
15
+ import { IHoverService } from '@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service';
16
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
17
+ import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
18
+ import { StorageScope, StorageTarget } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage';
19
+ import { IStorageService } from '@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service';
20
+ import { ITelemetryService } from '@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service';
21
+ import { StateType, DisablementReason } from '@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update';
22
+ import { IUpdateService } from '@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update.service';
23
+ import { IHostService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service';
24
+ import { isMajorMinorVersionChange, computeProgressPercent } from '../common/updateUtils.js';
25
+ import * as updateTitleBarEntry from './media/updateTitleBarEntry.css';
26
+ import { UpdateTooltip } from './updateTooltip.js';
27
+
28
+ registerCss(updateTitleBarEntry);
29
+ const UPDATE_TITLE_BAR_ACTION_ID = "workbench.actions.updateIndicator";
30
+ const UPDATE_TITLE_BAR_CONTEXT = ( new RawContextKey("updateTitleBar", false));
31
+ const ACTIONABLE_STATES = [StateType.AvailableForDownload, StateType.Downloaded, StateType.Ready];
32
+ const DETAILED_STATES = [
33
+ ...ACTIONABLE_STATES,
34
+ StateType.CheckingForUpdates,
35
+ StateType.Downloading,
36
+ StateType.Updating,
37
+ StateType.Overwriting
38
+ ];
39
+ const LAST_KNOWN_VERSION_KEY = "updateTitleBarEntry/lastKnownVersion";
40
+ registerAction2(class UpdateIndicatorTitleBarAction extends Action2 {
41
+ constructor() {
42
+ super({
43
+ id: UPDATE_TITLE_BAR_ACTION_ID,
44
+ title: ( localize(14794, "Update")),
45
+ f1: false,
46
+ menu: [{
47
+ id: MenuId.TitleBarAdjacentCenter,
48
+ order: 0,
49
+ when: UPDATE_TITLE_BAR_CONTEXT
50
+ }]
51
+ });
52
+ }
53
+ async run() {}
54
+ });
55
+ let UpdateTitleBarContribution = class UpdateTitleBarContribution extends Disposable {
56
+ constructor(
57
+ actionViewItemService,
58
+ configurationService,
59
+ contextKeyService,
60
+ hostService,
61
+ instantiationService,
62
+ productService,
63
+ storageService,
64
+ telemetryService,
65
+ updateService
66
+ ) {
67
+ super();
68
+ this.configurationService = configurationService;
69
+ this.hostService = hostService;
70
+ this.productService = productService;
71
+ this.storageService = storageService;
72
+ this.telemetryService = telemetryService;
73
+ this.mode = "none";
74
+ this.tooltipVisible = false;
75
+ if (isWeb) {
76
+ return;
77
+ }
78
+ this.context = UPDATE_TITLE_BAR_CONTEXT.bindTo(contextKeyService);
79
+ this.tooltip = this._register(instantiationService.createInstance(UpdateTooltip, true));
80
+ this.mode = configurationService.getValue("update.titleBar");
81
+ this._register(configurationService.onDidChangeConfiguration(e => {
82
+ if (e.affectsConfiguration("update.titleBar")) {
83
+ this.mode = configurationService.getValue("update.titleBar");
84
+ this.onStateChange();
85
+ }
86
+ }));
87
+ this.state = updateService.state;
88
+ this._register(updateService.onStateChange(state => {
89
+ this.state = state;
90
+ this.onStateChange();
91
+ }));
92
+ this._register(actionViewItemService.register(
93
+ MenuId.TitleBarAdjacentCenter,
94
+ UPDATE_TITLE_BAR_ACTION_ID,
95
+ (action, options) => {
96
+ this.entry = instantiationService.createInstance(UpdateTitleBarEntry, action, options, this.tooltip, () => {
97
+ this.tooltipVisible = false;
98
+ this.updateContext();
99
+ });
100
+ if (this.tooltipVisible) {
101
+ this.entry.showTooltip();
102
+ }
103
+ return this.entry;
104
+ }
105
+ ));
106
+ void this.onStateChange(true);
107
+ }
108
+ updateContext() {
109
+ switch (this.mode) {
110
+ case "always":
111
+ this.context.set(true);
112
+ break;
113
+ case "detailed":
114
+ this.context.set(DETAILED_STATES.includes(this.state.type));
115
+ break;
116
+ case "actionable":
117
+ this.context.set(ACTIONABLE_STATES.includes(this.state.type));
118
+ break;
119
+ default:
120
+ this.context.set(false);
121
+ break;
122
+ }
123
+ }
124
+ async onStateChange(startup = false) {
125
+ this.updateContext();
126
+ if (this.mode === "none" || this.tooltipVisible || !(await this.hostService.hadLastFocus())) {
127
+ return;
128
+ }
129
+ let showTooltip = startup && this.detectVersionChange();
130
+ if (showTooltip) {
131
+ this.tooltip.renderPostInstall();
132
+ } else {
133
+ this.tooltip.renderState(this.state);
134
+ switch (this.state.type) {
135
+ case StateType.Disabled:
136
+ if (startup) {
137
+ const reason = this.state.reason;
138
+ showTooltip = reason === DisablementReason.InvalidConfiguration || reason === DisablementReason.RunningAsAdmin;
139
+ }
140
+ break;
141
+ case StateType.Idle:
142
+ showTooltip = !!this.state.error || !!this.state.notAvailable;
143
+ break;
144
+ }
145
+ }
146
+ if (showTooltip) {
147
+ this.tooltipVisible = true;
148
+ this.context.set(true);
149
+ this.entry?.showTooltip();
150
+ }
151
+ }
152
+ detectVersionChange() {
153
+ let from;
154
+ try {
155
+ from = this.storageService.getObject(LAST_KNOWN_VERSION_KEY, StorageScope.APPLICATION);
156
+ } catch {}
157
+ const to = {
158
+ version: this.productService.version,
159
+ commit: this.productService.commit,
160
+ timestamp: Date.now()
161
+ };
162
+ if (from?.commit === to.commit) {
163
+ return false;
164
+ }
165
+ this.storageService.store(
166
+ LAST_KNOWN_VERSION_KEY,
167
+ JSON.stringify(to),
168
+ StorageScope.APPLICATION,
169
+ StorageTarget.MACHINE
170
+ );
171
+ if (from) {
172
+ this.trackVersionChange(from, to);
173
+ return isMajorMinorVersionChange(from.version, to.version);
174
+ }
175
+ return false;
176
+ }
177
+ trackVersionChange(from, to) {
178
+ this.telemetryService.publicLog2("update:versionChanged", {
179
+ fromVersion: from.version,
180
+ fromCommit: from.commit,
181
+ fromVersionTime: from.timestamp,
182
+ toVersion: to.version,
183
+ toCommit: to.commit,
184
+ timeToUpdateMs: from.timestamp !== undefined ? to.timestamp - from.timestamp : undefined,
185
+ updateMode: this.configurationService.getValue("update.mode"),
186
+ titleBarMode: this.mode
187
+ });
188
+ }
189
+ };
190
+ UpdateTitleBarContribution = ( __decorate([( __param(0, IActionViewItemService)), ( __param(1, IConfigurationService)), ( __param(2, IContextKeyService)), ( __param(3, IHostService)), ( __param(4, IInstantiationService)), ( __param(5, IProductService)), ( __param(6, IStorageService)), ( __param(7, ITelemetryService)), ( __param(8, IUpdateService))], UpdateTitleBarContribution));
191
+ let UpdateTitleBarEntry = class UpdateTitleBarEntry extends BaseActionViewItem {
192
+ constructor(
193
+ action,
194
+ options,
195
+ tooltip,
196
+ onUserDismissedTooltip,
197
+ commandService,
198
+ hoverService,
199
+ telemetryService,
200
+ updateService
201
+ ) {
202
+ super(undefined, action, options);
203
+ this.tooltip = tooltip;
204
+ this.onUserDismissedTooltip = onUserDismissedTooltip;
205
+ this.commandService = commandService;
206
+ this.hoverService = hoverService;
207
+ this.telemetryService = telemetryService;
208
+ this.updateService = updateService;
209
+ this.showTooltipOnRender = false;
210
+ this.action.run = () => this.runAction();
211
+ this._register(this.updateService.onStateChange(state => this.onStateChange(state)));
212
+ }
213
+ render(container) {
214
+ super.render(container);
215
+ this.content = append(container, $(".update-indicator"));
216
+ this.updateTooltip();
217
+ this.onStateChange(this.updateService.state);
218
+ if (this.showTooltipOnRender) {
219
+ this.showTooltipOnRender = false;
220
+ scheduleAtNextAnimationFrame(getWindow(container), () => this.showTooltip());
221
+ }
222
+ }
223
+ showTooltip(focus = false) {
224
+ if (!this.content?.isConnected) {
225
+ this.showTooltipOnRender = true;
226
+ return;
227
+ }
228
+ this.hoverService.showInstantHover({
229
+ content: this.tooltip.domNode,
230
+ target: {
231
+ targetElements: [this.content],
232
+ dispose: () => {
233
+ if (!!this.content?.isConnected) {
234
+ this.onUserDismissedTooltip();
235
+ }
236
+ }
237
+ },
238
+ persistence: {
239
+ sticky: true
240
+ },
241
+ appearance: {
242
+ showPointer: true,
243
+ compact: true
244
+ }
245
+ }, focus);
246
+ }
247
+ getHoverContents() {
248
+ return this.tooltip.domNode;
249
+ }
250
+ async runAction() {
251
+ let commandId;
252
+ switch (this.updateService.state.type) {
253
+ case StateType.AvailableForDownload:
254
+ commandId = "update.downloadNow";
255
+ break;
256
+ case StateType.Downloaded:
257
+ commandId = "update.install";
258
+ break;
259
+ case StateType.Ready:
260
+ commandId = "update.restart";
261
+ break;
262
+ default:
263
+ this.showTooltip(true);
264
+ return;
265
+ }
266
+ this.telemetryService.publicLog2("workbenchActionExecuted", {
267
+ id: commandId,
268
+ from: "titlebar"
269
+ });
270
+ await this.commandService.executeCommand(commandId);
271
+ }
272
+ onStateChange(state) {
273
+ if (!this.content) {
274
+ return;
275
+ }
276
+ clearNode(this.content);
277
+ this.content.classList.remove("prominent", "progress-indefinite", "progress-percent", "update-disabled");
278
+ this.content.style.removeProperty("--update-progress");
279
+ const label = append(this.content, $(".indicator-label"));
280
+ label.textContent = ( localize(14795, "Update"));
281
+ switch (state.type) {
282
+ case StateType.Disabled:
283
+ this.content.classList.add("update-disabled");
284
+ break;
285
+ case StateType.CheckingForUpdates:
286
+ case StateType.Overwriting:
287
+ this.renderProgressState(this.content);
288
+ break;
289
+ case StateType.AvailableForDownload:
290
+ case StateType.Downloaded:
291
+ case StateType.Ready:
292
+ this.content.classList.add("prominent");
293
+ break;
294
+ case StateType.Downloading:
295
+ this.renderProgressState(
296
+ this.content,
297
+ computeProgressPercent(state.downloadedBytes, state.totalBytes)
298
+ );
299
+ break;
300
+ case StateType.Updating:
301
+ this.renderProgressState(
302
+ this.content,
303
+ computeProgressPercent(state.currentProgress, state.maxProgress)
304
+ );
305
+ break;
306
+ }
307
+ }
308
+ renderProgressState(content, percentage) {
309
+ if (percentage !== undefined) {
310
+ content.classList.add("progress-percent");
311
+ content.style.setProperty("--update-progress", `${percentage}%`);
312
+ } else {
313
+ content.classList.add("progress-indefinite");
314
+ }
315
+ }
316
+ };
317
+ UpdateTitleBarEntry = ( __decorate([( __param(4, ICommandService)), ( __param(5, IHoverService)), ( __param(6, ITelemetryService)), ( __param(7, IUpdateService))], UpdateTitleBarEntry));
318
+
319
+ export { UpdateTitleBarContribution, UpdateTitleBarEntry };
@@ -0,0 +1,66 @@
1
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
2
+ import { IClipboardService } from "@codingame/monaco-vscode-api/vscode/vs/platform/clipboard/common/clipboardService.service";
3
+ import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
4
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
5
+ import { IHoverService } from "@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service";
6
+ import { IMarkdownRendererService } from "@codingame/monaco-vscode-api/vscode/vs/platform/markdown/browser/markdownRenderer.service";
7
+ import { IMeteredConnectionService } from "@codingame/monaco-vscode-api/vscode/vs/platform/meteredConnection/common/meteredConnection.service";
8
+ import { IOpenerService } from "@codingame/monaco-vscode-api/vscode/vs/platform/opener/common/opener.service";
9
+ import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
10
+ import { IRequestService } from "@codingame/monaco-vscode-api/vscode/vs/platform/request/common/request.service";
11
+ import { State } from "@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update";
12
+ /**
13
+ * A stateful tooltip control for the update status.
14
+ */
15
+ export declare class UpdateTooltip extends Disposable {
16
+ private readonly hostedByTitleBar;
17
+ private readonly clipboardService;
18
+ private readonly commandService;
19
+ private readonly configurationService;
20
+ private readonly hoverService;
21
+ private readonly markdownRendererService;
22
+ private readonly meteredConnectionService;
23
+ private readonly openerService;
24
+ private readonly productService;
25
+ private readonly requestService;
26
+ readonly domNode: HTMLElement;
27
+ private readonly titleNode;
28
+ private readonly productInfoNode;
29
+ private readonly productNameNode;
30
+ private readonly currentVersionNode;
31
+ private readonly currentVersionCopyValue;
32
+ private readonly latestVersionNode;
33
+ private readonly latestVersionCopyValue;
34
+ private readonly releaseDateNode;
35
+ private readonly releaseNotesLink;
36
+ private readonly progressContainer;
37
+ private readonly progressFill;
38
+ private readonly progressPercentNode;
39
+ private readonly progressSizeNode;
40
+ private readonly downloadStatsContainer;
41
+ private readonly timeRemainingNode;
42
+ private readonly speedInfoNode;
43
+ private readonly markdownContainer;
44
+ private readonly markdown;
45
+ private readonly messageNode;
46
+ private releaseNotesVersion;
47
+ constructor(hostedByTitleBar: boolean, clipboardService: IClipboardService, commandService: ICommandService, configurationService: IConfigurationService, hoverService: IHoverService, markdownRendererService: IMarkdownRendererService, meteredConnectionService: IMeteredConnectionService, openerService: IOpenerService, productService: IProductService, requestService: IRequestService);
48
+ private updateCurrentVersion;
49
+ private hideAll;
50
+ renderState(state: State): void;
51
+ private renderUninitialized;
52
+ private renderDisabled;
53
+ private renderIdle;
54
+ private renderCheckingForUpdates;
55
+ private renderAvailableForDownload;
56
+ private renderDownloading;
57
+ private renderDownloaded;
58
+ private renderUpdating;
59
+ private renderReady;
60
+ private renderOverwriting;
61
+ renderPostInstall(): Promise<void>;
62
+ private renderTitleAndInfo;
63
+ private renderMessage;
64
+ private createVersionRow;
65
+ private runCommandAndClose;
66
+ }