@codingame/monaco-vscode-update-service-override 3.2.3 → 4.1.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.
@@ -1,656 +0,0 @@
1
- import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
- import { localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import Severity from 'vscode/vscode/vs/base/common/severity';
4
- import { Disposable, MutableDisposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
- import { URI } from 'vscode/vscode/vs/base/common/uri';
6
- import { NumberBadge, ProgressBadge, IActivityService } from 'vscode/vscode/vs/workbench/services/activity/common/activity';
7
- import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
8
- import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
9
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
10
- import { IUpdateService } from 'vscode/vscode/vs/platform/update/common/update';
11
- import { Severity as Severity$1, INotificationService } from 'vscode/vscode/vs/platform/notification/common/notification';
12
- import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
13
- import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService';
14
- import { ReleaseNotesManager } from './releaseNotesEditor.js';
15
- import { isWeb, isWindows } from 'vscode/vscode/vs/base/common/platform';
16
- import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
17
- import { RawContextKey, ContextKeyExpr, IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
18
- import { MenuRegistry, MenuId, registerAction2, Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
19
- import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
20
- import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
21
- import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
22
- import { IUserDataSyncEnablementService, IUserDataSyncStoreManagementService, IUserDataSyncService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
23
- import { IsWebContext } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
24
- import { Promises } from 'vscode/vscode/vs/base/common/async';
25
- import { IUserDataSyncWorkbenchService } from 'vscode/vscode/vs/workbench/services/userDataSync/common/userDataSync';
26
- import { Event } from 'vscode/vscode/vs/base/common/event';
27
- import { Action } from 'vscode/vscode/vs/base/common/actions';
28
- import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
29
-
30
- var ProductContribution_1;
31
- const CONTEXT_UPDATE_STATE = ( new RawContextKey('updateState', "uninitialized" ));
32
- const MAJOR_MINOR_UPDATE_AVAILABLE = ( new RawContextKey('majorMinorUpdateAvailable', false));
33
- const RELEASE_NOTES_URL = ( new RawContextKey('releaseNotesUrl', ''));
34
- const DOWNLOAD_URL = ( new RawContextKey('downloadUrl', ''));
35
- let releaseNotesManager = undefined;
36
- function showReleaseNotesInEditor(instantiationService, version, useCurrentFile) {
37
- if (!releaseNotesManager) {
38
- releaseNotesManager = instantiationService.createInstance(ReleaseNotesManager);
39
- }
40
- return releaseNotesManager.show(version, useCurrentFile);
41
- }
42
- async function openLatestReleaseNotesInBrowser(accessor) {
43
- const openerService = accessor.get(IOpenerService);
44
- const productService = accessor.get(IProductService);
45
- if (productService.releaseNotesUrl) {
46
- const uri = ( URI.parse(productService.releaseNotesUrl));
47
- await openerService.open(uri);
48
- }
49
- else {
50
- throw new Error(localizeWithPath('vs/workbench/contrib/update/browser/update', 'update.noReleaseNotesOnline', "This version of {0} does not have release notes online", productService.nameLong));
51
- }
52
- }
53
- async function showReleaseNotes(accessor, version) {
54
- const instantiationService = accessor.get(IInstantiationService);
55
- try {
56
- await showReleaseNotesInEditor(instantiationService, version, false);
57
- }
58
- catch (err) {
59
- try {
60
- await instantiationService.invokeFunction(openLatestReleaseNotesInBrowser);
61
- }
62
- catch (err2) {
63
- throw new Error(`${err.message} and ${err2.message}`);
64
- }
65
- }
66
- }
67
- function parseVersion(version) {
68
- const match = /([0-9]+)\.([0-9]+)\.([0-9]+)/.exec(version);
69
- if (!match) {
70
- return undefined;
71
- }
72
- return {
73
- major: parseInt(match[1]),
74
- minor: parseInt(match[2]),
75
- patch: parseInt(match[3])
76
- };
77
- }
78
- function isMajorMinorUpdate(before, after) {
79
- return before.major < after.major || before.minor < after.minor;
80
- }
81
- let ProductContribution = class ProductContribution {
82
- static { ProductContribution_1 = this; }
83
- static { this.KEY = 'releaseNotes/lastVersion'; }
84
- constructor(storageService, instantiationService, notificationService, environmentService, openerService, configurationService, hostService, productService, contextKeyService) {
85
- if (productService.releaseNotesUrl) {
86
- const releaseNotesUrlKey = RELEASE_NOTES_URL.bindTo(contextKeyService);
87
- releaseNotesUrlKey.set(productService.releaseNotesUrl);
88
- }
89
- if (productService.downloadUrl) {
90
- const downloadUrlKey = DOWNLOAD_URL.bindTo(contextKeyService);
91
- downloadUrlKey.set(productService.downloadUrl);
92
- }
93
- if (isWeb) {
94
- return;
95
- }
96
- hostService.hadLastFocus().then(async (hadLastFocus) => {
97
- if (!hadLastFocus) {
98
- return;
99
- }
100
- const lastVersion = parseVersion(storageService.get(ProductContribution_1.KEY, -1 , ''));
101
- const currentVersion = parseVersion(productService.version);
102
- const shouldShowReleaseNotes = configurationService.getValue('update.showReleaseNotes');
103
- const releaseNotesUrl = productService.releaseNotesUrl;
104
- if (shouldShowReleaseNotes && !environmentService.skipReleaseNotes && releaseNotesUrl && lastVersion && currentVersion && isMajorMinorUpdate(lastVersion, currentVersion)) {
105
- showReleaseNotesInEditor(instantiationService, productService.version, false)
106
- .then(undefined, () => {
107
- notificationService.prompt(Severity.Info, ( localizeWithPath(
108
- 'vs/workbench/contrib/update/browser/update',
109
- 'read the release notes',
110
- "Welcome to {0} v{1}! Would you like to read the Release Notes?",
111
- productService.nameLong,
112
- productService.version
113
- )), [{
114
- label: ( localizeWithPath(
115
- 'vs/workbench/contrib/update/browser/update',
116
- 'releaseNotes',
117
- "Release Notes"
118
- )),
119
- run: () => {
120
- const uri = ( URI.parse(releaseNotesUrl));
121
- openerService.open(uri);
122
- }
123
- }]);
124
- });
125
- }
126
- storageService.store(ProductContribution_1.KEY, productService.version, -1 , 1 );
127
- });
128
- }
129
- };
130
- ProductContribution = ProductContribution_1 = ( __decorate([
131
- ( __param(0, IStorageService)),
132
- ( __param(1, IInstantiationService)),
133
- ( __param(2, INotificationService)),
134
- ( __param(3, IBrowserWorkbenchEnvironmentService)),
135
- ( __param(4, IOpenerService)),
136
- ( __param(5, IConfigurationService)),
137
- ( __param(6, IHostService)),
138
- ( __param(7, IProductService)),
139
- ( __param(8, IContextKeyService))
140
- ], ProductContribution));
141
- let UpdateContribution = class UpdateContribution extends Disposable {
142
- constructor(storageService, instantiationService, notificationService, dialogService, updateService, activityService, contextKeyService, productService, openerService, hostService) {
143
- super();
144
- this.storageService = storageService;
145
- this.instantiationService = instantiationService;
146
- this.notificationService = notificationService;
147
- this.dialogService = dialogService;
148
- this.updateService = updateService;
149
- this.activityService = activityService;
150
- this.contextKeyService = contextKeyService;
151
- this.productService = productService;
152
- this.openerService = openerService;
153
- this.hostService = hostService;
154
- this.badgeDisposable = this._register(( new MutableDisposable()));
155
- this.state = updateService.state;
156
- this.updateStateContextKey = CONTEXT_UPDATE_STATE.bindTo(this.contextKeyService);
157
- this.majorMinorUpdateAvailableContextKey = MAJOR_MINOR_UPDATE_AVAILABLE.bindTo(this.contextKeyService);
158
- this._register(updateService.onStateChange(this.onUpdateStateChange, this));
159
- this.onUpdateStateChange(this.updateService.state);
160
- const currentVersion = this.productService.commit;
161
- const lastKnownVersion = this.storageService.get('update/lastKnownVersion', -1 );
162
- if (currentVersion !== lastKnownVersion) {
163
- this.storageService.remove('update/lastKnownVersion', -1 );
164
- this.storageService.remove('update/updateNotificationTime', -1 );
165
- }
166
- this.registerGlobalActivityActions();
167
- }
168
- async onUpdateStateChange(state) {
169
- this.updateStateContextKey.set(state.type);
170
- switch (state.type) {
171
- case "disabled" :
172
- if (state.reason === 5 ) {
173
- this.notificationService.notify({
174
- severity: Severity$1.Info,
175
- message: ( localizeWithPath(
176
- 'vs/workbench/contrib/update/browser/update',
177
- 'update service disabled',
178
- "Updates are disabled because you are running the user-scope installation of {0} as Administrator.",
179
- this.productService.nameLong
180
- )),
181
- actions: {
182
- primary: [
183
- ( new Action('', ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'learn more', "Learn More")), undefined, undefined, () => {
184
- this.openerService.open('https://aka.ms/vscode-windows-setup');
185
- }))
186
- ]
187
- },
188
- neverShowAgain: { id: 'no-updates-running-as-admin', }
189
- });
190
- }
191
- break;
192
- case "idle" :
193
- if (state.error) {
194
- this.onError(state.error);
195
- }
196
- else if (this.state.type === "checking for updates" && this.state.explicit && (await this.hostService.hadLastFocus())) {
197
- this.onUpdateNotAvailable();
198
- }
199
- break;
200
- case "available for download" :
201
- this.onUpdateAvailable(state.update);
202
- break;
203
- case "downloaded" :
204
- this.onUpdateDownloaded(state.update);
205
- break;
206
- case "ready" : {
207
- const currentVersion = parseVersion(this.productService.version);
208
- const nextVersion = parseVersion(state.update.productVersion);
209
- this.majorMinorUpdateAvailableContextKey.set(Boolean(currentVersion && nextVersion && isMajorMinorUpdate(currentVersion, nextVersion)));
210
- this.onUpdateReady(state.update);
211
- break;
212
- }
213
- }
214
- let badge = undefined;
215
- let priority = undefined;
216
- if (state.type === "available for download" || state.type === "downloaded" || state.type === "ready" ) {
217
- badge = ( new NumberBadge(1, () => ( localizeWithPath(
218
- 'vs/workbench/contrib/update/browser/update',
219
- 'updateIsReady',
220
- "New {0} update available.",
221
- this.productService.nameShort
222
- ))));
223
- }
224
- else if (state.type === "checking for updates" ) {
225
- badge = ( new ProgressBadge(() => ( localizeWithPath(
226
- 'vs/workbench/contrib/update/browser/update',
227
- 'checkingForUpdates',
228
- "Checking for Updates..."
229
- ))));
230
- priority = 1;
231
- }
232
- else if (state.type === "downloading" ) {
233
- badge = ( new ProgressBadge(() => ( localizeWithPath(
234
- 'vs/workbench/contrib/update/browser/update',
235
- 'downloading',
236
- "Downloading..."
237
- ))));
238
- priority = 1;
239
- }
240
- else if (state.type === "updating" ) {
241
- badge = ( new ProgressBadge(() => ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'updating', "Updating..."))));
242
- priority = 1;
243
- }
244
- this.badgeDisposable.clear();
245
- if (badge) {
246
- this.badgeDisposable.value = this.activityService.showGlobalActivity({ badge, priority });
247
- }
248
- this.state = state;
249
- }
250
- onError(error) {
251
- if (/The request timed out|The network connection was lost/i.test(error)) {
252
- return;
253
- }
254
- error = error.replace(/See https:\/\/github\.com\/Squirrel\/Squirrel\.Mac\/issues\/182 for more information/, 'This might mean the application was put on quarantine by macOS. See [this link](https://github.com/microsoft/vscode/issues/7426#issuecomment-425093469) for more information');
255
- this.notificationService.notify({
256
- severity: Severity$1.Error,
257
- message: error,
258
- source: ( localizeWithPath(
259
- 'vs/workbench/contrib/update/browser/update',
260
- 'update service',
261
- "Update Service"
262
- )),
263
- });
264
- }
265
- onUpdateNotAvailable() {
266
- this.dialogService.info(( localizeWithPath(
267
- 'vs/workbench/contrib/update/browser/update',
268
- 'noUpdatesAvailable',
269
- "There are currently no updates available."
270
- )));
271
- }
272
- onUpdateAvailable(update) {
273
- if (!this.shouldShowNotification()) {
274
- return;
275
- }
276
- this.notificationService.prompt(Severity.Info, ( localizeWithPath(
277
- 'vs/workbench/contrib/update/browser/update',
278
- 'thereIsUpdateAvailable',
279
- "There is an available update."
280
- )), [{
281
- label: ( localizeWithPath(
282
- 'vs/workbench/contrib/update/browser/update',
283
- 'download update',
284
- "Download Update"
285
- )),
286
- run: () => this.updateService.downloadUpdate()
287
- }, {
288
- label: ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'later', "Later")),
289
- run: () => { }
290
- }, {
291
- label: ( localizeWithPath(
292
- 'vs/workbench/contrib/update/browser/update',
293
- 'releaseNotes',
294
- "Release Notes"
295
- )),
296
- run: () => {
297
- this.instantiationService.invokeFunction(accessor => showReleaseNotes(accessor, update.productVersion));
298
- }
299
- }]);
300
- }
301
- onUpdateDownloaded(update) {
302
- if (!this.shouldShowNotification()) {
303
- return;
304
- }
305
- this.notificationService.prompt(Severity.Info, ( localizeWithPath(
306
- 'vs/workbench/contrib/update/browser/update',
307
- 'updateAvailable',
308
- "There's an update available: {0} {1}",
309
- this.productService.nameLong,
310
- update.productVersion
311
- )), [{
312
- label: ( localizeWithPath(
313
- 'vs/workbench/contrib/update/browser/update',
314
- 'installUpdate',
315
- "Install Update"
316
- )),
317
- run: () => this.updateService.applyUpdate()
318
- }, {
319
- label: ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'later', "Later")),
320
- run: () => { }
321
- }, {
322
- label: ( localizeWithPath(
323
- 'vs/workbench/contrib/update/browser/update',
324
- 'releaseNotes',
325
- "Release Notes"
326
- )),
327
- run: () => {
328
- this.instantiationService.invokeFunction(accessor => showReleaseNotes(accessor, update.productVersion));
329
- }
330
- }]);
331
- }
332
- onUpdateReady(update) {
333
- if (!(isWindows && this.productService.target !== 'user') && !this.shouldShowNotification()) {
334
- return;
335
- }
336
- const actions = [{
337
- label: ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'updateNow', "Update Now")),
338
- run: () => this.updateService.quitAndInstall()
339
- }, {
340
- label: ( localizeWithPath('vs/workbench/contrib/update/browser/update', 'later', "Later")),
341
- run: () => { }
342
- }];
343
- if (update.productVersion) {
344
- actions.push({
345
- label: ( localizeWithPath(
346
- 'vs/workbench/contrib/update/browser/update',
347
- 'releaseNotes',
348
- "Release Notes"
349
- )),
350
- run: () => {
351
- this.instantiationService.invokeFunction(accessor => showReleaseNotes(accessor, update.productVersion));
352
- }
353
- });
354
- }
355
- this.notificationService.prompt(Severity.Info, ( localizeWithPath(
356
- 'vs/workbench/contrib/update/browser/update',
357
- 'updateAvailableAfterRestart',
358
- "Restart {0} to apply the latest update.",
359
- this.productService.nameLong
360
- )), actions, { sticky: true });
361
- }
362
- shouldShowNotification() {
363
- const currentVersion = this.productService.commit;
364
- const currentMillis = ( new Date()).getTime();
365
- const lastKnownVersion = this.storageService.get('update/lastKnownVersion', -1 );
366
- if (currentVersion !== lastKnownVersion) {
367
- this.storageService.store('update/lastKnownVersion', currentVersion, -1 , 1 );
368
- this.storageService.store('update/updateNotificationTime', currentMillis, -1 , 1 );
369
- }
370
- const updateNotificationMillis = this.storageService.getNumber('update/updateNotificationTime', -1 , currentMillis);
371
- const diffDays = (currentMillis - updateNotificationMillis) / (1000 * 60 * 60 * 24);
372
- return diffDays > 5;
373
- }
374
- registerGlobalActivityActions() {
375
- CommandsRegistry.registerCommand('update.check', () => this.updateService.checkForUpdates(true));
376
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
377
- group: '7_update',
378
- command: {
379
- id: 'update.check',
380
- title: ( localizeWithPath(
381
- 'vs/workbench/contrib/update/browser/update',
382
- 'checkForUpdates',
383
- "Check for Updates..."
384
- ))
385
- },
386
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("idle" ))
387
- });
388
- CommandsRegistry.registerCommand('update.checking', () => { });
389
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
390
- group: '7_update',
391
- command: {
392
- id: 'update.checking',
393
- title: ( localizeWithPath(
394
- 'vs/workbench/contrib/update/browser/update',
395
- 'checkingForUpdates',
396
- "Checking for Updates..."
397
- )),
398
- precondition: ( ContextKeyExpr.false())
399
- },
400
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("checking for updates" ))
401
- });
402
- CommandsRegistry.registerCommand('update.downloadNow', () => this.updateService.downloadUpdate());
403
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
404
- group: '7_update',
405
- command: {
406
- id: 'update.downloadNow',
407
- title: ( localizeWithPath(
408
- 'vs/workbench/contrib/update/browser/update',
409
- 'download update_1',
410
- "Download Update (1)"
411
- ))
412
- },
413
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("available for download" ))
414
- });
415
- CommandsRegistry.registerCommand('update.downloading', () => { });
416
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
417
- group: '7_update',
418
- command: {
419
- id: 'update.downloading',
420
- title: ( localizeWithPath(
421
- 'vs/workbench/contrib/update/browser/update',
422
- 'DownloadingUpdate',
423
- "Downloading Update..."
424
- )),
425
- precondition: ( ContextKeyExpr.false())
426
- },
427
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("downloading" ))
428
- });
429
- CommandsRegistry.registerCommand('update.install', () => this.updateService.applyUpdate());
430
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
431
- group: '7_update',
432
- command: {
433
- id: 'update.install',
434
- title: ( localizeWithPath(
435
- 'vs/workbench/contrib/update/browser/update',
436
- 'installUpdate...',
437
- "Install Update... (1)"
438
- ))
439
- },
440
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("downloaded" ))
441
- });
442
- CommandsRegistry.registerCommand('update.updating', () => { });
443
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
444
- group: '7_update',
445
- command: {
446
- id: 'update.updating',
447
- title: ( localizeWithPath(
448
- 'vs/workbench/contrib/update/browser/update',
449
- 'installingUpdate',
450
- "Installing Update..."
451
- )),
452
- precondition: ( ContextKeyExpr.false())
453
- },
454
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("updating" ))
455
- });
456
- if (this.productService.quality === 'stable') {
457
- CommandsRegistry.registerCommand('update.showUpdateReleaseNotes', () => {
458
- if (this.updateService.state.type !== "ready" ) {
459
- return;
460
- }
461
- const version = this.updateService.state.update.version;
462
- this.instantiationService.invokeFunction(accessor => showReleaseNotes(accessor, version));
463
- });
464
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
465
- group: '7_update',
466
- order: 1,
467
- command: {
468
- id: 'update.showUpdateReleaseNotes',
469
- title: ( localizeWithPath(
470
- 'vs/workbench/contrib/update/browser/update',
471
- 'showUpdateReleaseNotes',
472
- "Show Update Release Notes"
473
- ))
474
- },
475
- when: ( ContextKeyExpr.and(( CONTEXT_UPDATE_STATE.isEqualTo("ready" )), MAJOR_MINOR_UPDATE_AVAILABLE))
476
- });
477
- }
478
- CommandsRegistry.registerCommand('update.restart', () => this.updateService.quitAndInstall());
479
- MenuRegistry.appendMenuItem(MenuId.GlobalActivity, {
480
- group: '7_update',
481
- order: 2,
482
- command: {
483
- id: 'update.restart',
484
- title: ( localizeWithPath(
485
- 'vs/workbench/contrib/update/browser/update',
486
- 'restartToUpdate',
487
- "Restart to Update (1)"
488
- ))
489
- },
490
- when: ( CONTEXT_UPDATE_STATE.isEqualTo("ready" ))
491
- });
492
- CommandsRegistry.registerCommand('_update.state', () => {
493
- return this.state;
494
- });
495
- }
496
- };
497
- UpdateContribution = ( __decorate([
498
- ( __param(0, IStorageService)),
499
- ( __param(1, IInstantiationService)),
500
- ( __param(2, INotificationService)),
501
- ( __param(3, IDialogService)),
502
- ( __param(4, IUpdateService)),
503
- ( __param(5, IActivityService)),
504
- ( __param(6, IContextKeyService)),
505
- ( __param(7, IProductService)),
506
- ( __param(8, IOpenerService)),
507
- ( __param(9, IHostService))
508
- ], UpdateContribution));
509
- let SwitchProductQualityContribution = class SwitchProductQualityContribution extends Disposable {
510
- constructor(productService, environmentService) {
511
- super();
512
- this.productService = productService;
513
- this.environmentService = environmentService;
514
- this.registerGlobalActivityActions();
515
- }
516
- registerGlobalActivityActions() {
517
- const quality = this.productService.quality;
518
- const productQualityChangeHandler = this.environmentService.options?.productQualityChangeHandler;
519
- if (productQualityChangeHandler && (quality === 'stable' || quality === 'insider')) {
520
- const newQuality = quality === 'stable' ? 'insider' : 'stable';
521
- const commandId = `update.switchQuality.${newQuality}`;
522
- const isSwitchingToInsiders = newQuality === 'insider';
523
- registerAction2(class SwitchQuality extends Action2 {
524
- constructor() {
525
- super({
526
- id: commandId,
527
- title: isSwitchingToInsiders ? ( localizeWithPath(
528
- 'vs/workbench/contrib/update/browser/update',
529
- 'switchToInsiders',
530
- "Switch to Insiders Version..."
531
- )) : ( localizeWithPath(
532
- 'vs/workbench/contrib/update/browser/update',
533
- 'switchToStable',
534
- "Switch to Stable Version..."
535
- )),
536
- precondition: IsWebContext,
537
- menu: {
538
- id: MenuId.GlobalActivity,
539
- when: IsWebContext,
540
- group: '7_update',
541
- }
542
- });
543
- }
544
- async run(accessor) {
545
- const dialogService = accessor.get(IDialogService);
546
- const userDataSyncEnablementService = accessor.get(IUserDataSyncEnablementService);
547
- const userDataSyncStoreManagementService = accessor.get(IUserDataSyncStoreManagementService);
548
- const storageService = accessor.get(IStorageService);
549
- const userDataSyncWorkbenchService = accessor.get(IUserDataSyncWorkbenchService);
550
- const userDataSyncService = accessor.get(IUserDataSyncService);
551
- const notificationService = accessor.get(INotificationService);
552
- try {
553
- const selectSettingsSyncServiceDialogShownKey = 'switchQuality.selectSettingsSyncServiceDialogShown';
554
- const userDataSyncStore = userDataSyncStoreManagementService.userDataSyncStore;
555
- let userDataSyncStoreType;
556
- if (userDataSyncStore && isSwitchingToInsiders && userDataSyncEnablementService.isEnabled()
557
- && !storageService.getBoolean(selectSettingsSyncServiceDialogShownKey, -1 , false)) {
558
- userDataSyncStoreType = await this.selectSettingsSyncService(dialogService);
559
- if (!userDataSyncStoreType) {
560
- return;
561
- }
562
- storageService.store(selectSettingsSyncServiceDialogShownKey, true, -1 , 0 );
563
- if (userDataSyncStoreType === 'stable') {
564
- await userDataSyncStoreManagementService.switch(userDataSyncStoreType);
565
- }
566
- }
567
- const res = await dialogService.confirm({
568
- type: 'info',
569
- message: ( localizeWithPath(
570
- 'vs/workbench/contrib/update/browser/update',
571
- 'relaunchMessage',
572
- "Changing the version requires a reload to take effect"
573
- )),
574
- detail: newQuality === 'insider' ?
575
- ( localizeWithPath(
576
- 'vs/workbench/contrib/update/browser/update',
577
- 'relaunchDetailInsiders',
578
- "Press the reload button to switch to the Insiders version of VS Code."
579
- )) :
580
- ( localizeWithPath(
581
- 'vs/workbench/contrib/update/browser/update',
582
- 'relaunchDetailStable',
583
- "Press the reload button to switch to the Stable version of VS Code."
584
- )),
585
- primaryButton: ( localizeWithPath(
586
- 'vs/workbench/contrib/update/browser/update',
587
- { key: 'reload', comment: ['&& denotes a mnemonic'] },
588
- "&&Reload"
589
- ))
590
- });
591
- if (res.confirmed) {
592
- const promises = [];
593
- if (userDataSyncService.status === "syncing" ) {
594
- promises.push(Event.toPromise(Event.filter(userDataSyncService.onDidChangeStatus, status => status !== "syncing" )));
595
- }
596
- if (isSwitchingToInsiders && userDataSyncStoreType) {
597
- promises.push(userDataSyncWorkbenchService.synchroniseUserDataSyncStoreType());
598
- }
599
- await Promises.settled(promises);
600
- productQualityChangeHandler(newQuality);
601
- }
602
- else {
603
- if (userDataSyncStoreType) {
604
- storageService.remove(selectSettingsSyncServiceDialogShownKey, -1 );
605
- }
606
- }
607
- }
608
- catch (error) {
609
- notificationService.error(error);
610
- }
611
- }
612
- async selectSettingsSyncService(dialogService) {
613
- const { result } = await dialogService.prompt({
614
- type: Severity$1.Info,
615
- message: ( localizeWithPath(
616
- 'vs/workbench/contrib/update/browser/update',
617
- 'selectSyncService.message',
618
- "Choose the settings sync service to use after changing the version"
619
- )),
620
- detail: ( localizeWithPath(
621
- 'vs/workbench/contrib/update/browser/update',
622
- 'selectSyncService.detail',
623
- "The Insiders version of VS Code will synchronize your settings, keybindings, extensions, snippets and UI State using separate insiders settings sync service by default."
624
- )),
625
- buttons: [
626
- {
627
- label: ( localizeWithPath(
628
- 'vs/workbench/contrib/update/browser/update',
629
- { key: 'use insiders', comment: ['&& denotes a mnemonic'] },
630
- "&&Insiders"
631
- )),
632
- run: () => 'insiders'
633
- },
634
- {
635
- label: ( localizeWithPath(
636
- 'vs/workbench/contrib/update/browser/update',
637
- { key: 'use stable', comment: ['&& denotes a mnemonic'] },
638
- "&&Stable (current)"
639
- )),
640
- run: () => 'stable'
641
- }
642
- ],
643
- cancelButton: true
644
- });
645
- return result;
646
- }
647
- });
648
- }
649
- }
650
- };
651
- SwitchProductQualityContribution = ( __decorate([
652
- ( __param(0, IProductService)),
653
- ( __param(1, IBrowserWorkbenchEnvironmentService))
654
- ], SwitchProductQualityContribution));
655
-
656
- export { CONTEXT_UPDATE_STATE, DOWNLOAD_URL, MAJOR_MINOR_UPDATE_AVAILABLE, ProductContribution, RELEASE_NOTES_URL, SwitchProductQualityContribution, UpdateContribution, showReleaseNotesInEditor };