@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
@@ -1,181 +1,107 @@
1
1
 
2
2
  import { registerCss } from '@codingame/monaco-vscode-api/css';
3
3
  import { __decorate, __param } from '@codingame/monaco-vscode-api/external/tslib/tslib.es6';
4
- import { $, append } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/dom';
5
- import { ActionBar } from '@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionbar';
6
- import { toAction } from '@codingame/monaco-vscode-api/vscode/vs/base/common/actions';
7
- import { Codicon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/codicons';
8
- import { Disposable, MutableDisposable, DisposableStore } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
4
+ import { Disposable, MutableDisposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
9
5
  import { isWeb } from '@codingame/monaco-vscode-api/vscode/vs/base/common/platform';
10
- import { ThemeIcon } from '@codingame/monaco-vscode-api/vscode/vs/base/common/themables';
11
6
  import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
12
- import { ICommandService } from '@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service';
13
7
  import { IConfigurationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service';
14
- import { nativeHoverDelegate } from '@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover';
15
- import { IHoverService } from '@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service';
16
- import { IProductService } from '@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service';
8
+ import { IInstantiationService } from '@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation';
17
9
  import { StateType } from '@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update';
18
10
  import { IUpdateService } from '@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update.service';
19
11
  import { ShowTooltipCommand, StatusbarAlignment } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/statusbar/browser/statusbar';
20
12
  import { IStatusbarService } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/statusbar/browser/statusbar.service';
13
+ import { computeProgressPercent, formatBytes } from '../common/updateUtils.js';
21
14
  import * as updateStatusBarEntry from './media/updateStatusBarEntry.css';
15
+ import { UpdateTooltip } from './updateTooltip.js';
22
16
 
23
- var UpdateStatusBarEntryContribution_1;
17
+ var UpdateStatusBarContribution_1;
24
18
  registerCss(updateStatusBarEntry);
25
- let UpdateStatusBarEntryContribution = class UpdateStatusBarEntryContribution extends Disposable {
19
+ let UpdateStatusBarContribution = class UpdateStatusBarContribution extends Disposable {
26
20
  static {
27
- UpdateStatusBarEntryContribution_1 = this;
21
+ UpdateStatusBarContribution_1 = this;
28
22
  }
29
23
  static {
30
- this.NAME = ( localize(14512, "Update Status"));
24
+ this.actionableStates = [StateType.AvailableForDownload, StateType.Downloaded, StateType.Ready];
31
25
  }
32
26
  constructor(
33
- updateService,
27
+ configurationService,
28
+ instantiationService,
34
29
  statusbarService,
35
- productService,
36
- commandService,
37
- hoverService,
38
- configurationService
30
+ updateService
39
31
  ) {
40
32
  super();
41
- this.updateService = updateService;
42
- this.statusbarService = statusbarService;
43
- this.productService = productService;
44
- this.commandService = commandService;
45
- this.hoverService = hoverService;
46
33
  this.configurationService = configurationService;
47
- this.statusBarEntryAccessor = this._register(( new MutableDisposable()));
34
+ this.statusbarService = statusbarService;
35
+ this.accessor = this._register(( new MutableDisposable()));
48
36
  if (isWeb) {
49
37
  return;
50
38
  }
51
- this._register(this.updateService.onStateChange(state => this.onUpdateStateChange(state)));
39
+ this.tooltip = this._register(instantiationService.createInstance(UpdateTooltip, false));
40
+ this._register(updateService.onStateChange(this.onStateChange.bind(this)));
52
41
  this._register(this.configurationService.onDidChangeConfiguration(e => {
53
- if (e.affectsConfiguration("update.statusBar")) {
54
- this.onUpdateStateChange(this.updateService.state);
42
+ if (e.affectsConfiguration("update.statusBar") || e.affectsConfiguration("update.titleBar")) {
43
+ this.onStateChange(updateService.state);
55
44
  }
56
45
  }));
57
- this.onUpdateStateChange(this.updateService.state);
46
+ this.onStateChange(updateService.state);
58
47
  }
59
- onUpdateStateChange(state) {
60
- if (this.lastStateType !== state.type) {
61
- this.statusBarEntryAccessor.clear();
62
- this.lastStateType = state.type;
63
- }
64
- const statusBarMode = this.configurationService.getValue("update.statusBar");
65
- if (statusBarMode === "hidden") {
66
- this.statusBarEntryAccessor.clear();
48
+ onStateChange(state) {
49
+ const titleBarMode = this.configurationService.getValue("update.titleBar");
50
+ if (titleBarMode !== "none") {
51
+ this.accessor.clear();
67
52
  return;
68
53
  }
69
- const actionRequiredStates = [StateType.AvailableForDownload, StateType.Downloaded, StateType.Ready];
70
- if (statusBarMode === "actionable" && !actionRequiredStates.includes(state.type)) {
71
- this.statusBarEntryAccessor.clear();
54
+ const mode = this.configurationService.getValue("update.statusBar");
55
+ if (mode === "hidden" || mode === "actionable" && !UpdateStatusBarContribution_1.actionableStates.includes(state.type)) {
56
+ this.accessor.clear();
72
57
  return;
73
58
  }
59
+ if (this.lastStateType !== state.type) {
60
+ this.accessor.clear();
61
+ this.lastStateType = state.type;
62
+ }
63
+ this.tooltip.renderState(state);
74
64
  switch (state.type) {
75
- case StateType.Uninitialized:
76
- case StateType.Idle:
77
- case StateType.Disabled:
78
- this.statusBarEntryAccessor.clear();
79
- break;
80
65
  case StateType.CheckingForUpdates:
81
- this.updateStatusBarEntry({
82
- name: UpdateStatusBarEntryContribution_1.NAME,
83
- text: ( localize(14513, "$(sync~spin) Checking for updates...")),
84
- ariaLabel: ( localize(14514, "Checking for updates")),
85
- tooltip: this.getCheckingTooltip(),
86
- command: ShowTooltipCommand
87
- });
66
+ this.updateEntry("$(loading~spin) " + ( localize(14778, "Checking for updates...")), ( localize(14779, "Checking for updates")), ShowTooltipCommand);
88
67
  break;
89
68
  case StateType.AvailableForDownload:
90
- this.updateStatusBarEntry({
91
- name: UpdateStatusBarEntryContribution_1.NAME,
92
- text: ( localize(14515, "$(circle-filled) Update available, click to download.")),
93
- ariaLabel: ( localize(14516, "Update available, click to download.")),
94
- tooltip: this.getAvailableTooltip(state.update),
95
- command: "update.downloadNow"
96
- });
69
+ this.updateEntry("$(circle-filled) " + ( localize(14780, "Update available, click to download.")), ( localize(14781, "Update available, click to download.")), "update.downloadNow");
97
70
  break;
98
71
  case StateType.Downloading:
99
- this.updateStatusBarEntry({
100
- name: UpdateStatusBarEntryContribution_1.NAME,
101
- text: this.getDownloadingText(state),
102
- ariaLabel: ( localize(14517, "Downloading update")),
103
- tooltip: this.getDownloadingTooltip(state),
104
- command: ShowTooltipCommand
105
- });
72
+ this.updateEntry(this.getDownloadingText(state), ( localize(14782, "Downloading update")), ShowTooltipCommand);
106
73
  break;
107
74
  case StateType.Downloaded:
108
- this.updateStatusBarEntry({
109
- name: UpdateStatusBarEntryContribution_1.NAME,
110
- text: ( localize(14518, "$(circle-filled) Update downloaded, click to install.")),
111
- ariaLabel: ( localize(14519, "Update downloaded, click to install.")),
112
- tooltip: this.getReadyToInstallTooltip(state.update),
113
- command: "update.install"
114
- });
75
+ this.updateEntry("$(circle-filled) " + ( localize(14783, "Update downloaded, click to install.")), ( localize(14784, "Update downloaded, click to install.")), "update.install");
115
76
  break;
116
77
  case StateType.Updating:
117
- this.updateStatusBarEntry({
118
- name: UpdateStatusBarEntryContribution_1.NAME,
119
- text: this.getUpdatingText(state),
120
- ariaLabel: this.getUpdatingText(state),
121
- tooltip: this.getUpdatingTooltip(state),
122
- command: ShowTooltipCommand
123
- });
78
+ this.updateEntry(this.getUpdatingText(state), undefined, ShowTooltipCommand);
124
79
  break;
125
80
  case StateType.Ready:
126
- {
127
- this.updateStatusBarEntry({
128
- name: UpdateStatusBarEntryContribution_1.NAME,
129
- text: ( localize(14520, "$(circle-filled) Update is ready, click to restart.")),
130
- ariaLabel: ( localize(14521, "Update is ready, click to restart.")),
131
- tooltip: this.getRestartToUpdateTooltip(state.update),
132
- command: "update.restart"
133
- });
134
- break;
135
- }
81
+ this.updateEntry("$(circle-filled) " + ( localize(14785, "Update is ready, click to restart.")), ( localize(14786, "Update is ready, click to restart.")), "update.restart");
82
+ break;
136
83
  case StateType.Overwriting:
137
- this.updateStatusBarEntry({
138
- name: UpdateStatusBarEntryContribution_1.NAME,
139
- text: ( localize(14522, "$(sync~spin) Downloading update...")),
140
- ariaLabel: ( localize(14523, "Downloading a newer update")),
141
- tooltip: this.getOverwritingTooltip(state),
142
- command: ShowTooltipCommand
143
- });
84
+ this.updateEntry("$(loading~spin) " + ( localize(14787, "Downloading update...")), ( localize(14788, "Downloading a newer update")), ShowTooltipCommand);
85
+ break;
86
+ default:
87
+ this.accessor.clear();
144
88
  break;
145
89
  }
146
90
  }
147
- updateStatusBarEntry(entry) {
148
- if (this.statusBarEntryAccessor.value) {
149
- this.statusBarEntryAccessor.value.update(entry);
91
+ updateEntry(text, ariaLabel, command) {
92
+ const entry = {
93
+ text,
94
+ ariaLabel: ariaLabel ?? text,
95
+ name: ( localize(14789, "Update Status")),
96
+ tooltip: this.tooltip?.domNode,
97
+ command
98
+ };
99
+ if (this.accessor.value) {
100
+ this.accessor.value.update(entry);
150
101
  } else {
151
- this.statusBarEntryAccessor.value = this.statusbarService.addEntry(entry, "status.update", StatusbarAlignment.LEFT, -Number.MAX_VALUE);
102
+ this.accessor.value = this.statusbarService.addEntry(entry, "status.update", StatusbarAlignment.LEFT, -Number.MAX_VALUE);
152
103
  }
153
104
  }
154
- getCheckingTooltip() {
155
- return {
156
- element: token => {
157
- const store = this.createTooltipDisposableStore(token);
158
- const container = $(".update-status-tooltip");
159
- this.appendHeader(container, ( localize(14524, "Checking for Updates")), store);
160
- this.appendProductInfo(container);
161
- const message = append(container, $(".progress-details"));
162
- message.textContent = ( localize(14525, "Checking for updates, please wait..."));
163
- return container;
164
- }
165
- };
166
- }
167
- getAvailableTooltip(update) {
168
- return {
169
- element: token => {
170
- const store = this.createTooltipDisposableStore(token);
171
- const container = $(".update-status-tooltip");
172
- this.appendHeader(container, ( localize(14526, "Update Available")), store);
173
- this.appendProductInfo(container, update);
174
- this.appendWhatsIncluded(container);
175
- return container;
176
- }
177
- };
178
- }
179
105
  getDownloadingText(
180
106
  {
181
107
  downloadedBytes,
@@ -183,289 +109,32 @@ let UpdateStatusBarEntryContribution = class UpdateStatusBarEntryContribution ex
183
109
  }
184
110
  ) {
185
111
  if (downloadedBytes !== undefined && totalBytes !== undefined && totalBytes > 0) {
186
- return localize(
187
- 14527,
188
- "$(sync~spin) Downloading update: {0} / {1} • {2}%",
112
+ const percent = computeProgressPercent(downloadedBytes, totalBytes) ?? 0;
113
+ return "$(loading~spin) " + ( localize(
114
+ 14790,
115
+ "Downloading update: {0} / {1} • {2}%",
189
116
  formatBytes(downloadedBytes),
190
117
  formatBytes(totalBytes),
191
- getProgressPercent(downloadedBytes, totalBytes) ?? 0
192
- );
118
+ percent
119
+ ));
193
120
  } else {
194
- return localize(14528, "$(sync~spin) Downloading update...");
121
+ return "$(loading~spin) " + ( localize(14791, "Downloading update..."));
195
122
  }
196
123
  }
197
- getDownloadingTooltip(state) {
198
- return {
199
- element: token => {
200
- const store = this.createTooltipDisposableStore(token);
201
- const container = $(".update-status-tooltip");
202
- this.appendHeader(container, ( localize(14529, "Downloading Update")), store);
203
- this.appendProductInfo(container, state.update);
204
- const {
205
- downloadedBytes,
206
- totalBytes
207
- } = state;
208
- if (downloadedBytes !== undefined && totalBytes !== undefined && totalBytes > 0) {
209
- const percentage = getProgressPercent(downloadedBytes, totalBytes) ?? 0;
210
- const progressContainer = append(container, $(".progress-container"));
211
- const progressBar = append(progressContainer, $(".progress-bar"));
212
- const progressFill = append(progressBar, $(".progress-fill"));
213
- progressFill.style.width = `${percentage}%`;
214
- const progressText = append(progressContainer, $(".progress-text"));
215
- const percentageSpan = append(progressText, $("span"));
216
- percentageSpan.textContent = `${percentage}%`;
217
- const sizeSpan = append(progressText, $("span"));
218
- sizeSpan.textContent = `${formatBytes(downloadedBytes)} / ${formatBytes(totalBytes)}`;
219
- const speed = computeDownloadSpeed(state);
220
- if (speed !== undefined && speed > 0) {
221
- const speedInfo = append(container, $(".speed-info"));
222
- speedInfo.textContent = ( localize(14530, "{0}/s", formatBytes(speed)));
223
- }
224
- const timeRemaining = computeDownloadTimeRemaining(state);
225
- if (timeRemaining !== undefined && timeRemaining > 0) {
226
- const timeRemainingNode = append(container, $(".time-remaining"));
227
- timeRemainingNode.textContent = `~${formatTimeRemaining(timeRemaining)} ${( localize(14531, "remaining"))}`;
228
- }
229
- } else {
230
- const message = append(container, $(".progress-details"));
231
- message.textContent = ( localize(14532, "Downloading, please wait..."));
232
- }
233
- return container;
234
- }
235
- };
236
- }
237
- getReadyToInstallTooltip(update) {
238
- return {
239
- element: token => {
240
- const store = this.createTooltipDisposableStore(token);
241
- const container = $(".update-status-tooltip");
242
- this.appendHeader(container, ( localize(14533, "Update is Ready to Install")), store);
243
- this.appendProductInfo(container, update);
244
- this.appendWhatsIncluded(container);
245
- return container;
246
- }
247
- };
248
- }
249
- getRestartToUpdateTooltip(update) {
250
- return {
251
- element: token => {
252
- const store = this.createTooltipDisposableStore(token);
253
- const container = $(".update-status-tooltip");
254
- this.appendHeader(container, ( localize(14534, "Update Installed")), store);
255
- this.appendProductInfo(container, update);
256
- this.appendWhatsIncluded(container);
257
- return container;
258
- }
259
- };
260
- }
261
124
  getUpdatingText(
262
125
  {
263
126
  currentProgress,
264
127
  maxProgress
265
128
  }
266
129
  ) {
267
- const percentage = getProgressPercent(currentProgress, maxProgress);
130
+ const percentage = computeProgressPercent(currentProgress, maxProgress);
268
131
  if (percentage !== undefined) {
269
- return localize(14535, "$(sync~spin) Installing update: {0}%", percentage);
132
+ return "$(loading~spin) " + ( localize(14792, "Installing update: {0}%", percentage));
270
133
  } else {
271
- return localize(14536, "$(sync~spin) Installing update...");
134
+ return "$(loading~spin) " + ( localize(14793, "Installing update..."));
272
135
  }
273
136
  }
274
- getUpdatingTooltip(state) {
275
- return {
276
- element: token => {
277
- const store = this.createTooltipDisposableStore(token);
278
- const container = $(".update-status-tooltip");
279
- this.appendHeader(container, ( localize(14537, "Installing Update")), store);
280
- this.appendProductInfo(container, state.update);
281
- const {
282
- currentProgress,
283
- maxProgress
284
- } = state;
285
- const percentage = getProgressPercent(currentProgress, maxProgress);
286
- if (percentage !== undefined) {
287
- const progressContainer = append(container, $(".progress-container"));
288
- const progressBar = append(progressContainer, $(".progress-bar"));
289
- const progressFill = append(progressBar, $(".progress-fill"));
290
- progressFill.style.width = `${percentage}%`;
291
- const progressText = append(progressContainer, $(".progress-text"));
292
- const percentageSpan = append(progressText, $("span"));
293
- percentageSpan.textContent = `${percentage}%`;
294
- } else {
295
- const message = append(container, $(".progress-details"));
296
- message.textContent = ( localize(14538, "Installing update, please wait..."));
297
- }
298
- return container;
299
- }
300
- };
301
- }
302
- getOverwritingTooltip(state) {
303
- return {
304
- element: token => {
305
- const store = this.createTooltipDisposableStore(token);
306
- const container = $(".update-status-tooltip");
307
- this.appendHeader(container, ( localize(14539, "Downloading Newer Update")), store);
308
- this.appendProductInfo(container, state.update);
309
- const message = append(container, $(".progress-details"));
310
- message.textContent = ( localize(14540, "A newer update was released. Downloading, please wait..."));
311
- return container;
312
- }
313
- };
314
- }
315
- createTooltipDisposableStore(token) {
316
- const store = ( new DisposableStore());
317
- store.add(token.onCancellationRequested(() => store.dispose()));
318
- return store;
319
- }
320
- runCommandAndClose(command, ...args) {
321
- this.commandService.executeCommand(command, ...args);
322
- this.hoverService.hideHover(true);
323
- }
324
- appendHeader(container, title, store) {
325
- const header = append(container, $(".header"));
326
- const text = append(header, $(".title"));
327
- text.textContent = title;
328
- const actionBar = store.add(( new ActionBar(header, {
329
- hoverDelegate: nativeHoverDelegate
330
- })));
331
- actionBar.push([toAction({
332
- id: "update.openSettings",
333
- label: ( localize(14541, "Update Settings")),
334
- class: ThemeIcon.asClassName(Codicon.gear),
335
- run: () => this.runCommandAndClose("workbench.action.openSettings", "@id:update*")
336
- })], {
337
- icon: true,
338
- label: false
339
- });
340
- }
341
- appendProductInfo(container, update) {
342
- const productInfo = append(container, $(".product-info"));
343
- const logoContainer = append(productInfo, $(".product-logo"));
344
- logoContainer.setAttribute("role", "img");
345
- logoContainer.setAttribute("aria-label", this.productService.nameLong);
346
- const details = append(productInfo, $(".product-details"));
347
- const productName = append(details, $(".product-name"));
348
- productName.textContent = this.productService.nameLong;
349
- const productVersion = this.productService.version;
350
- if (productVersion) {
351
- const currentVersion = append(details, $(".product-version"));
352
- const currentCommitId = this.productService.commit?.substring(0, 7);
353
- currentVersion.textContent = currentCommitId ? ( localize(14542, "Current Version: {0} ({1})", productVersion, currentCommitId)) : ( localize(14543, "Current Version: {0}", productVersion));
354
- }
355
- const version = update?.productVersion;
356
- if (version) {
357
- const latestVersion = append(details, $(".product-version"));
358
- const updateCommitId = update.version?.substring(0, 7);
359
- latestVersion.textContent = updateCommitId ? ( localize(14544, "Latest Version: {0} ({1})", version, updateCommitId)) : ( localize(14545, "Latest Version: {0}", version));
360
- }
361
- const releaseDate = update?.timestamp ?? tryParseDate(this.productService.date);
362
- if (typeof releaseDate === "number" && releaseDate > 0) {
363
- const releaseDateNode = append(details, $(".product-release-date"));
364
- releaseDateNode.textContent = ( localize(14546, "Released {0}", formatDate(releaseDate)));
365
- }
366
- const releaseNotesVersion = version ?? productVersion;
367
- if (releaseNotesVersion) {
368
- const link = append(details, $("a.release-notes-link"));
369
- link.textContent = ( localize(14547, "Release Notes"));
370
- link.href = "#";
371
- link.addEventListener("click", e => {
372
- e.preventDefault();
373
- this.runCommandAndClose("update.showCurrentReleaseNotes", releaseNotesVersion);
374
- });
375
- }
376
- }
377
- appendWhatsIncluded(container) {}
378
137
  };
379
- UpdateStatusBarEntryContribution = UpdateStatusBarEntryContribution_1 = ( __decorate([( __param(0, IUpdateService)), ( __param(1, IStatusbarService)), ( __param(2, IProductService)), ( __param(3, ICommandService)), ( __param(4, IHoverService)), ( __param(5, IConfigurationService))], UpdateStatusBarEntryContribution));
380
- function getProgressPercent(current, max) {
381
- if (current === undefined || max === undefined || max <= 0) {
382
- return undefined;
383
- } else {
384
- return Math.max(Math.min(Math.round((current / max) * 100), 100), 0);
385
- }
386
- }
387
- function tryParseDate(date) {
388
- if (date === undefined) {
389
- return undefined;
390
- }
391
- const parsed = Date.parse(date);
392
- return isNaN(parsed) ? undefined : parsed;
393
- }
394
- function formatDate(timestamp) {
395
- return ( new Date(timestamp)).toLocaleDateString(undefined, {
396
- year: "numeric",
397
- month: "short",
398
- day: "numeric"
399
- });
400
- }
401
- function computeDownloadTimeRemaining(state) {
402
- const {
403
- downloadedBytes,
404
- totalBytes,
405
- startTime
406
- } = state;
407
- if (downloadedBytes === undefined || totalBytes === undefined || startTime === undefined) {
408
- return undefined;
409
- }
410
- const elapsedMs = Date.now() - startTime;
411
- if (downloadedBytes <= 0 || totalBytes <= 0 || elapsedMs <= 0) {
412
- return undefined;
413
- }
414
- const remainingBytes = totalBytes - downloadedBytes;
415
- if (remainingBytes <= 0) {
416
- return 0;
417
- }
418
- const bytesPerMs = downloadedBytes / elapsedMs;
419
- if (bytesPerMs <= 0) {
420
- return undefined;
421
- }
422
- const remainingMs = remainingBytes / bytesPerMs;
423
- return Math.ceil(remainingMs / 1000);
424
- }
425
- function formatTimeRemaining(seconds) {
426
- const hours = seconds / 3600;
427
- if (hours >= 1) {
428
- const formattedHours = formatDecimal(hours);
429
- return formattedHours === "1" ? ( localize(14548, "{0} hour", formattedHours)) : ( localize(14549, "{0} hours", formattedHours));
430
- }
431
- const minutes = Math.floor(seconds / 60);
432
- if (minutes >= 1) {
433
- return localize(14550, "{0} min", minutes);
434
- }
435
- return localize(14551, "{0}s", seconds);
436
- }
437
- function formatBytes(bytes) {
438
- if (bytes < 1024) {
439
- return localize(14552, "{0} B", bytes);
440
- }
441
- const kb = bytes / 1024;
442
- if (kb < 1024) {
443
- return localize(14553, "{0} KB", formatDecimal(kb));
444
- }
445
- const mb = kb / 1024;
446
- if (mb < 1024) {
447
- return localize(14554, "{0} MB", formatDecimal(mb));
448
- }
449
- const gb = mb / 1024;
450
- return localize(14555, "{0} GB", formatDecimal(gb));
451
- }
452
- function formatDecimal(value) {
453
- const rounded = Math.round(value * 10) / 10;
454
- return rounded % 1 === 0 ? ( rounded.toString()) : rounded.toFixed(1);
455
- }
456
- function computeDownloadSpeed(state) {
457
- const {
458
- downloadedBytes,
459
- startTime
460
- } = state;
461
- if (downloadedBytes === undefined || startTime === undefined) {
462
- return undefined;
463
- }
464
- const elapsedMs = Date.now() - startTime;
465
- if (elapsedMs <= 0 || downloadedBytes <= 0) {
466
- return undefined;
467
- }
468
- return (downloadedBytes / elapsedMs) * 1000;
469
- }
138
+ UpdateStatusBarContribution = UpdateStatusBarContribution_1 = ( __decorate([( __param(0, IConfigurationService)), ( __param(1, IInstantiationService)), ( __param(2, IStatusbarService)), ( __param(3, IUpdateService))], UpdateStatusBarContribution));
470
139
 
471
- export { UpdateStatusBarEntryContribution, computeDownloadSpeed, computeDownloadTimeRemaining, formatBytes, formatDate, formatTimeRemaining, getProgressPercent, tryParseDate };
140
+ export { UpdateStatusBarContribution };
@@ -0,0 +1,58 @@
1
+ import { BaseActionViewItem, IBaseActionViewItemOptions } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/actionbar/actionViewItems";
2
+ import { IManagedHoverContent } from "@codingame/monaco-vscode-api/vscode/vs/base/browser/ui/hover/hover";
3
+ import { IAction } from "@codingame/monaco-vscode-api/vscode/vs/base/common/actions";
4
+ import { Disposable } from "@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle";
5
+ import { IActionViewItemService } from "@codingame/monaco-vscode-api/vscode/vs/platform/actions/browser/actionViewItemService.service";
6
+ import { ICommandService } from "@codingame/monaco-vscode-api/vscode/vs/platform/commands/common/commands.service";
7
+ import { IConfigurationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/configuration/common/configuration.service";
8
+ import { IContextKeyService } from "@codingame/monaco-vscode-api/vscode/vs/platform/contextkey/common/contextkey.service";
9
+ import { IHoverService } from "@codingame/monaco-vscode-api/vscode/vs/platform/hover/browser/hover.service";
10
+ import { IInstantiationService } from "@codingame/monaco-vscode-api/vscode/vs/platform/instantiation/common/instantiation";
11
+ import { IProductService } from "@codingame/monaco-vscode-api/vscode/vs/platform/product/common/productService.service";
12
+ import { IStorageService } from "@codingame/monaco-vscode-api/vscode/vs/platform/storage/common/storage.service";
13
+ import { ITelemetryService } from "@codingame/monaco-vscode-api/vscode/vs/platform/telemetry/common/telemetry.service";
14
+ import { IUpdateService } from "@codingame/monaco-vscode-api/vscode/vs/platform/update/common/update.service";
15
+ import { IWorkbenchContribution } from "@codingame/monaco-vscode-api/vscode/vs/workbench/common/contributions";
16
+ import { IHostService } from "@codingame/monaco-vscode-api/vscode/vs/workbench/services/host/browser/host.service";
17
+ import { UpdateTooltip } from "./updateTooltip.js";
18
+ /**
19
+ * Displays update status and actions in the title bar.
20
+ */
21
+ export declare class UpdateTitleBarContribution extends Disposable implements IWorkbenchContribution {
22
+ private readonly configurationService;
23
+ private readonly hostService;
24
+ private readonly productService;
25
+ private readonly storageService;
26
+ private readonly telemetryService;
27
+ private readonly context;
28
+ private readonly tooltip;
29
+ private mode;
30
+ private state;
31
+ private entry;
32
+ private tooltipVisible;
33
+ constructor(actionViewItemService: IActionViewItemService, configurationService: IConfigurationService, contextKeyService: IContextKeyService, hostService: IHostService, instantiationService: IInstantiationService, productService: IProductService, storageService: IStorageService, telemetryService: ITelemetryService, updateService: IUpdateService);
34
+ private updateContext;
35
+ private onStateChange;
36
+ private detectVersionChange;
37
+ private trackVersionChange;
38
+ }
39
+ /**
40
+ * Custom action view item for the update indicator in the title bar.
41
+ */
42
+ export declare class UpdateTitleBarEntry extends BaseActionViewItem {
43
+ private readonly tooltip;
44
+ private readonly onUserDismissedTooltip;
45
+ private readonly commandService;
46
+ private readonly hoverService;
47
+ private readonly telemetryService;
48
+ private readonly updateService;
49
+ private content;
50
+ private showTooltipOnRender;
51
+ constructor(action: IAction, options: IBaseActionViewItemOptions, tooltip: UpdateTooltip, onUserDismissedTooltip: () => void, commandService: ICommandService, hoverService: IHoverService, telemetryService: ITelemetryService, updateService: IUpdateService);
52
+ render(container: HTMLElement): void;
53
+ showTooltip(focus?: boolean): void;
54
+ protected getHoverContents(): IManagedHoverContent;
55
+ private runAction;
56
+ private onStateChange;
57
+ private renderProgressState;
58
+ }