@codingame/monaco-vscode-update-service-override 4.1.0 → 4.1.2

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.
@@ -0,0 +1,413 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import './media/releasenoteseditor.css.js';
3
+ import { CancellationToken } from 'vscode/vscode/vs/base/common/cancellation';
4
+ import { onUnexpectedError } from 'vscode/vscode/vs/base/common/errors';
5
+ import { escapeMarkdownSyntaxTokens } from 'vscode/vscode/vs/base/common/htmlContent';
6
+ import { KeybindingParser } from 'vscode/vscode/vs/base/common/keybindingParser';
7
+ import { escape } from 'vscode/vscode/vs/base/common/strings';
8
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
9
+ import { generateUuid } from 'vscode/vscode/vs/base/common/uuid';
10
+ import { TokenizationRegistry } from 'vscode/vscode/vs/editor/common/languages';
11
+ import { generateTokensCSSForColorMap } from 'vscode/vscode/vs/editor/common/languages/supports/tokenization';
12
+ import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
13
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
14
+ import { IEnvironmentService } from 'vscode/vscode/vs/platform/environment/common/environment';
15
+ import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding';
16
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
17
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
18
+ import { IRequestService, asTextOrError } from 'vscode/vscode/vs/platform/request/common/request';
19
+ import { renderMarkdownDocument, DEFAULT_MARKDOWN_STYLES } from 'vscode/vscode/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer';
20
+ import { IWebviewWorkbenchService } from 'vscode/vscode/vs/workbench/contrib/webviewPanel/browser/webviewWorkbenchService';
21
+ import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService';
22
+ import { ACTIVE_GROUP, IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService';
23
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
24
+ import { supportsTelemetry, getTelemetryLevel } from 'vscode/vscode/vs/platform/telemetry/common/telemetryUtils';
25
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
26
+ import { DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
27
+ import { SimpleSettingRenderer } from '../../markdown/browser/markdownSettingRenderer.js';
28
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
29
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
30
+ import { ICodeEditorService } from 'vscode/vscode/vs/editor/browser/services/codeEditorService';
31
+
32
+ let ReleaseNotesManager = class ReleaseNotesManager {
33
+ constructor(_environmentService, _keybindingService, _languageService, _openerService, _requestService, _configurationService, _editorService, _editorGroupService, _codeEditorService, _webviewWorkbenchService, _extensionService, _productService, _instantiationService) {
34
+ this._environmentService = _environmentService;
35
+ this._keybindingService = _keybindingService;
36
+ this._languageService = _languageService;
37
+ this._openerService = _openerService;
38
+ this._requestService = _requestService;
39
+ this._configurationService = _configurationService;
40
+ this._editorService = _editorService;
41
+ this._editorGroupService = _editorGroupService;
42
+ this._codeEditorService = _codeEditorService;
43
+ this._webviewWorkbenchService = _webviewWorkbenchService;
44
+ this._extensionService = _extensionService;
45
+ this._productService = _productService;
46
+ this._instantiationService = _instantiationService;
47
+ this._releaseNotesCache = ( new Map());
48
+ this._currentReleaseNotes = undefined;
49
+ this.disposables = ( new DisposableStore());
50
+ TokenizationRegistry.onDidChange(() => {
51
+ return this.updateHtml();
52
+ });
53
+ _configurationService.onDidChangeConfiguration(this.onDidChangeConfiguration, this, this.disposables);
54
+ _webviewWorkbenchService.onDidChangeActiveWebviewEditor(this.onDidChangeActiveWebviewEditor, this, this.disposables);
55
+ this._simpleSettingRenderer = this._instantiationService.createInstance(SimpleSettingRenderer);
56
+ }
57
+ async updateHtml() {
58
+ if (!this._currentReleaseNotes || !this._lastText) {
59
+ return;
60
+ }
61
+ const html = await this.renderBody(this._lastText);
62
+ if (this._currentReleaseNotes) {
63
+ this._currentReleaseNotes.webview.setHtml(html);
64
+ }
65
+ }
66
+ async show(version, useCurrentFile) {
67
+ const releaseNoteText = await this.loadReleaseNotes(version, useCurrentFile);
68
+ this._lastText = releaseNoteText;
69
+ const html = await this.renderBody(releaseNoteText);
70
+ const title = ( localizeWithPath(
71
+ 'vs/workbench/contrib/update/browser/releaseNotesEditor',
72
+ 'releaseNotesInputName',
73
+ "Release Notes: {0}",
74
+ version
75
+ ));
76
+ const activeEditorPane = this._editorService.activeEditorPane;
77
+ if (this._currentReleaseNotes) {
78
+ this._currentReleaseNotes.setName(title);
79
+ this._currentReleaseNotes.webview.setHtml(html);
80
+ this._webviewWorkbenchService.revealWebview(this._currentReleaseNotes, activeEditorPane ? activeEditorPane.group : this._editorGroupService.activeGroup, false);
81
+ }
82
+ else {
83
+ this._currentReleaseNotes = this._webviewWorkbenchService.openWebview({
84
+ title,
85
+ options: {
86
+ tryRestoreScrollPosition: true,
87
+ enableFindWidget: true,
88
+ disableServiceWorker: true,
89
+ },
90
+ contentOptions: {
91
+ localResourceRoots: [],
92
+ allowScripts: true
93
+ },
94
+ extension: undefined
95
+ }, 'releaseNotes', title, { group: ACTIVE_GROUP, preserveFocus: false });
96
+ this._currentReleaseNotes.webview.onDidClickLink(uri => this.onDidClickLink(( URI.parse(uri))));
97
+ const disposables = ( new DisposableStore());
98
+ disposables.add(this._currentReleaseNotes.webview.onMessage(e => {
99
+ if (e.message.type === 'showReleaseNotes') {
100
+ this._configurationService.updateValue('update.showReleaseNotes', e.message.value);
101
+ }
102
+ else if (e.message.type === 'clickSetting') {
103
+ const x = this._currentReleaseNotes?.webview.container.offsetLeft + e.message.value.x;
104
+ const y = this._currentReleaseNotes?.webview.container.offsetTop + e.message.value.y;
105
+ this._simpleSettingRenderer.updateSetting(( URI.parse(e.message.value.uri)), x, y);
106
+ }
107
+ }));
108
+ disposables.add(this._currentReleaseNotes.onWillDispose(() => {
109
+ disposables.dispose();
110
+ this._currentReleaseNotes = undefined;
111
+ }));
112
+ this._currentReleaseNotes.webview.setHtml(html);
113
+ }
114
+ return true;
115
+ }
116
+ async loadReleaseNotes(version, useCurrentFile) {
117
+ const match = /^(\d+\.\d+)\./.exec(version);
118
+ if (!match) {
119
+ throw new Error('not found');
120
+ }
121
+ const versionLabel = match[1].replace(/\./g, '_');
122
+ const baseUrl = 'https://code.visualstudio.com/raw';
123
+ const url = `${baseUrl}/v${versionLabel}.md`;
124
+ const unassigned = ( localizeWithPath(
125
+ 'vs/workbench/contrib/update/browser/releaseNotesEditor',
126
+ 'unassigned',
127
+ "unassigned"
128
+ ));
129
+ const escapeMdHtml = (text) => {
130
+ return escape(text).replace(/\\/g, '\\\\');
131
+ };
132
+ const patchKeybindings = (text) => {
133
+ const kb = (match, kb) => {
134
+ const keybinding = this._keybindingService.lookupKeybinding(kb);
135
+ if (!keybinding) {
136
+ return unassigned;
137
+ }
138
+ return keybinding.getLabel() || unassigned;
139
+ };
140
+ const kbstyle = (match, kb) => {
141
+ const keybinding = KeybindingParser.parseKeybinding(kb);
142
+ if (!keybinding) {
143
+ return unassigned;
144
+ }
145
+ const resolvedKeybindings = this._keybindingService.resolveKeybinding(keybinding);
146
+ if (resolvedKeybindings.length === 0) {
147
+ return unassigned;
148
+ }
149
+ return resolvedKeybindings[0].getLabel() || unassigned;
150
+ };
151
+ const kbCode = (match, binding) => {
152
+ const resolved = kb(match, binding);
153
+ return resolved ? `<code title="${binding}">${escapeMdHtml(resolved)}</code>` : resolved;
154
+ };
155
+ const kbstyleCode = (match, binding) => {
156
+ const resolved = kbstyle(match, binding);
157
+ return resolved ? `<code title="${binding}">${escapeMdHtml(resolved)}</code>` : resolved;
158
+ };
159
+ return text
160
+ .replace(/`kb\(([a-z.\d\-]+)\)`/gi, kbCode)
161
+ .replace(/`kbstyle\(([^\)]+)\)`/gi, kbstyleCode)
162
+ .replace(/kb\(([a-z.\d\-]+)\)/gi, (match, binding) => escapeMarkdownSyntaxTokens(kb(match, binding)))
163
+ .replace(/kbstyle\(([^\)]+)\)/gi, (match, binding) => escapeMarkdownSyntaxTokens(kbstyle(match, binding)));
164
+ };
165
+ const fetchReleaseNotes = async () => {
166
+ let text;
167
+ try {
168
+ if (useCurrentFile) {
169
+ const file = this._codeEditorService.getActiveCodeEditor()?.getModel()?.getValue();
170
+ text = file ? file.substring(file.indexOf('#')) : undefined;
171
+ }
172
+ else {
173
+ text = await asTextOrError(await this._requestService.request({ url }, CancellationToken.None));
174
+ }
175
+ }
176
+ catch {
177
+ throw new Error('Failed to fetch release notes');
178
+ }
179
+ if (!text || !/^#\s/.test(text)) {
180
+ throw new Error('Invalid release notes');
181
+ }
182
+ return patchKeybindings(text);
183
+ };
184
+ if (useCurrentFile) {
185
+ return fetchReleaseNotes();
186
+ }
187
+ if (!( this._releaseNotesCache.has(version))) {
188
+ this._releaseNotesCache.set(version, (async () => {
189
+ try {
190
+ return await fetchReleaseNotes();
191
+ }
192
+ catch (err) {
193
+ this._releaseNotesCache.delete(version);
194
+ throw err;
195
+ }
196
+ })());
197
+ }
198
+ return this._releaseNotesCache.get(version);
199
+ }
200
+ async onDidClickLink(uri) {
201
+ if (uri.scheme === Schemas.codeSetting) ;
202
+ else {
203
+ this.addGAParameters(uri, 'ReleaseNotes')
204
+ .then(updated => this._openerService.open(updated, { allowCommands: ['workbench.action.openSettings'] }))
205
+ .then(undefined, onUnexpectedError);
206
+ }
207
+ }
208
+ async addGAParameters(uri, origin, experiment = '1') {
209
+ if (supportsTelemetry(this._productService, this._environmentService) && getTelemetryLevel(this._configurationService) === 3 ) {
210
+ if (uri.scheme === 'https' && uri.authority === 'code.visualstudio.com') {
211
+ return uri.with({ query: `${uri.query ? uri.query + '&' : ''}utm_source=VsCode&utm_medium=${encodeURIComponent(origin)}&utm_content=${encodeURIComponent(experiment)}` });
212
+ }
213
+ }
214
+ return uri;
215
+ }
216
+ async renderBody(text) {
217
+ const nonce = generateUuid();
218
+ const content = await renderMarkdownDocument(text, this._extensionService, this._languageService, false, undefined, undefined, this._simpleSettingRenderer);
219
+ const colorMap = TokenizationRegistry.getColorMap();
220
+ const css = colorMap ? generateTokensCSSForColorMap(colorMap) : '';
221
+ const showReleaseNotes = Boolean(this._configurationService.getValue('update.showReleaseNotes'));
222
+ return `<!DOCTYPE html>
223
+ <html>
224
+ <head>
225
+ <base href="https://code.visualstudio.com/raw/">
226
+ <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
227
+ <meta http-equiv="Content-Security-Policy" content="default-src 'none'; img-src https: data:; media-src https:; style-src 'nonce-${nonce}' https://code.visualstudio.com; script-src 'nonce-${nonce}';">
228
+ <style nonce="${nonce}">
229
+ ${DEFAULT_MARKDOWN_STYLES}
230
+ ${css}
231
+
232
+ /* codesetting */
233
+
234
+ code:has(.codesetting)+code {
235
+ display: none;
236
+ }
237
+
238
+ code:has(.codesetting) {
239
+ background-color: var(--vscode-textPreformat-background);
240
+ color: var(--vscode-textPreformat-foreground);
241
+ padding-left: 1px;
242
+ margin-right: 3px;
243
+ padding-right: 0px;
244
+ }
245
+
246
+ code:has(.codesetting):focus {
247
+ border: 1px solid var(--vscode-button-border, transparent);
248
+ }
249
+
250
+ .codesetting {
251
+ color: var(--vscode-textPreformat-foreground);
252
+ padding: 0px 1px 1px 0px;
253
+ font-size: 0px;
254
+ overflow: hidden;
255
+ text-overflow: ellipsis;
256
+ outline-offset: 2px !important;
257
+ box-sizing: border-box;
258
+ text-align: center;
259
+ cursor: pointer;
260
+ display: inline;
261
+ margin-right: 3px;
262
+ }
263
+ .codesetting svg {
264
+ font-size: 12px;
265
+ text-align: center;
266
+ cursor: pointer;
267
+ border: 1px solid var(--vscode-button-secondaryBorder, transparent);
268
+ outline: 1px solid transparent;
269
+ line-height: 9px;
270
+ margin-bottom: -5px;
271
+ padding-left: 0px;
272
+ padding-top: 2px;
273
+ padding-bottom: 2px;
274
+ padding-right: 2px;
275
+ display: inline-block;
276
+ text-decoration: none;
277
+ text-rendering: auto;
278
+ text-transform: none;
279
+ -webkit-font-smoothing: antialiased;
280
+ -moz-osx-font-smoothing: grayscale;
281
+ user-select: none;
282
+ -webkit-user-select: none;
283
+ }
284
+ .codesetting .setting-name {
285
+ font-size: 13px;
286
+ padding-left: 2px;
287
+ padding-right: 3px;
288
+ padding-top: 1px;
289
+ padding-bottom: 1px;
290
+ margin-left: -5px;
291
+ margin-top: -3px;
292
+ }
293
+ .codesetting:hover {
294
+ color: var(--vscode-textPreformat-foreground) !important;
295
+ text-decoration: none !important;
296
+ }
297
+ code:has(.codesetting):hover {
298
+ filter: brightness(140%);
299
+ text-decoration: none !important;
300
+ }
301
+ .codesetting:focus {
302
+ outline: 0 !important;
303
+ text-decoration: none !important;
304
+ color: var(--vscode-button-hoverForeground) !important;
305
+ }
306
+ .codesetting .separator {
307
+ width: 1px;
308
+ height: 14px;
309
+ margin-bottom: -3px;
310
+ display: inline-block;
311
+ background-color: var(--vscode-editor-background);
312
+ font-size: 12px;
313
+ margin-right: 8px;
314
+ }
315
+
316
+ header { display: flex; align-items: center; padding-top: 1em; }
317
+ </style>
318
+ </head>
319
+ <body>
320
+ ${content}
321
+ <script nonce="${nonce}">
322
+ const vscode = acquireVsCodeApi();
323
+ const container = document.createElement('p');
324
+ container.style.display = 'flex';
325
+ container.style.alignItems = 'center';
326
+
327
+ const input = document.createElement('input');
328
+ input.type = 'checkbox';
329
+ input.id = 'showReleaseNotes';
330
+ input.checked = ${showReleaseNotes};
331
+ container.appendChild(input);
332
+
333
+ const label = document.createElement('label');
334
+ label.htmlFor = 'showReleaseNotes';
335
+ label.textContent = '${( localizeWithPath(
336
+ 'vs/workbench/contrib/update/browser/releaseNotesEditor',
337
+ 'showOnUpdate',
338
+ "Show release notes after an update"
339
+ ))}';
340
+ container.appendChild(label);
341
+
342
+ const beforeElement = document.querySelector("body > h1")?.nextElementSibling;
343
+ if (beforeElement) {
344
+ document.body.insertBefore(container, beforeElement);
345
+ } else {
346
+ document.body.appendChild(container);
347
+ }
348
+
349
+ window.addEventListener('message', event => {
350
+ if (event.data.type === 'showReleaseNotes') {
351
+ input.checked = event.data.value;
352
+ }
353
+ });
354
+
355
+ window.addEventListener('click', event => {
356
+ const href = event.target.href ?? event.target.parentElement.href ?? event.target.parentElement.parentElement?.href;
357
+ if (href && (href.startsWith('${Schemas.codeSetting}'))) {
358
+ vscode.postMessage({ type: 'clickSetting', value: { uri: href, x: event.clientX, y: event.clientY }});
359
+ }
360
+ });
361
+
362
+ window.addEventListener('keypress', event => {
363
+ if (event.keyCode === 13) {
364
+ if (event.target.children.length > 0 && event.target.children[0].href) {
365
+ const clientRect = event.target.getBoundingClientRect();
366
+ vscode.postMessage({ type: 'clickSetting', value: { uri: event.target.children[0].href, x: clientRect.right , y: clientRect.bottom }});
367
+ }
368
+ }
369
+ });
370
+
371
+ input.addEventListener('change', event => {
372
+ vscode.postMessage({ type: 'showReleaseNotes', value: input.checked }, '*');
373
+ });
374
+ </script>
375
+ </body>
376
+ </html>`;
377
+ }
378
+ onDidChangeConfiguration(e) {
379
+ if (e.affectsConfiguration('update.showReleaseNotes')) {
380
+ this.updateCheckboxWebview();
381
+ }
382
+ }
383
+ onDidChangeActiveWebviewEditor(input) {
384
+ if (input && input === this._currentReleaseNotes) {
385
+ this.updateCheckboxWebview();
386
+ }
387
+ }
388
+ updateCheckboxWebview() {
389
+ if (this._currentReleaseNotes) {
390
+ this._currentReleaseNotes.webview.postMessage({
391
+ type: 'showReleaseNotes',
392
+ value: this._configurationService.getValue('update.showReleaseNotes')
393
+ });
394
+ }
395
+ }
396
+ };
397
+ ReleaseNotesManager = ( __decorate([
398
+ ( __param(0, IEnvironmentService)),
399
+ ( __param(1, IKeybindingService)),
400
+ ( __param(2, ILanguageService)),
401
+ ( __param(3, IOpenerService)),
402
+ ( __param(4, IRequestService)),
403
+ ( __param(5, IConfigurationService)),
404
+ ( __param(6, IEditorService)),
405
+ ( __param(7, IEditorGroupsService)),
406
+ ( __param(8, ICodeEditorService)),
407
+ ( __param(9, IWebviewWorkbenchService)),
408
+ ( __param(10, IExtensionService)),
409
+ ( __param(11, IProductService)),
410
+ ( __param(12, IInstantiationService))
411
+ ], ReleaseNotesManager));
412
+
413
+ export { ReleaseNotesManager };
@@ -0,0 +1,254 @@
1
+ import '../../../../platform/update/common/update.config.contribution.js';
2
+ import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
4
+ import { Extensions } from 'vscode/vscode/vs/workbench/common/contributions';
5
+ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
6
+ import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
7
+ import { ProductContribution, UpdateContribution, SwitchProductQualityContribution, DOWNLOAD_URL, RELEASE_NOTES_URL, showReleaseNotesInEditor, CONTEXT_UPDATE_STATE } from './update.js';
8
+ import product$1 from 'vscode/vscode/vs/platform/product/common/product';
9
+ import { IUpdateService } from 'vscode/vscode/vs/platform/update/common/update';
10
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
11
+ import { isWindows } from 'vscode/vscode/vs/base/common/platform';
12
+ import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
13
+ import { mnemonicButtonLabel } from 'vscode/vscode/vs/base/common/labels';
14
+ import { ShowCurrentReleaseNotesActionId, ShowCurrentReleaseNotesFromCurrentFileActionId } from 'vscode/vscode/vs/workbench/contrib/update/common/update';
15
+ import { IsWebContext } from 'vscode/vscode/vs/platform/contextkey/common/contextkeys';
16
+ import { IOpenerService } from 'vscode/vscode/vs/platform/opener/common/opener';
17
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
18
+ import { URI } from 'vscode/vscode/vs/base/common/uri';
19
+ import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
20
+ import { IFileDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
21
+
22
+ const workbench = ( Registry.as(Extensions.Workbench));
23
+ workbench.registerWorkbenchContribution(ProductContribution, 3 );
24
+ workbench.registerWorkbenchContribution(UpdateContribution, 3 );
25
+ workbench.registerWorkbenchContribution(SwitchProductQualityContribution, 3 );
26
+ class ShowCurrentReleaseNotesAction extends Action2 {
27
+ constructor() {
28
+ super({
29
+ id: ShowCurrentReleaseNotesActionId,
30
+ title: {
31
+ ...( localize2WithPath(
32
+ 'vs/workbench/contrib/update/browser/update.contribution',
33
+ 'showReleaseNotes',
34
+ "Show Release Notes"
35
+ )),
36
+ mnemonicTitle: ( localizeWithPath(
37
+ 'vs/workbench/contrib/update/browser/update.contribution',
38
+ { key: 'mshowReleaseNotes', comment: ['&& denotes a mnemonic'] },
39
+ "Show &&Release Notes"
40
+ )),
41
+ },
42
+ category: { value: product$1.nameShort, original: product$1.nameShort },
43
+ f1: true,
44
+ precondition: RELEASE_NOTES_URL,
45
+ menu: [{
46
+ id: MenuId.MenubarHelpMenu,
47
+ group: '1_welcome',
48
+ order: 5,
49
+ when: RELEASE_NOTES_URL,
50
+ }]
51
+ });
52
+ }
53
+ async run(accessor) {
54
+ const instantiationService = accessor.get(IInstantiationService);
55
+ const productService = accessor.get(IProductService);
56
+ const openerService = accessor.get(IOpenerService);
57
+ try {
58
+ await showReleaseNotesInEditor(instantiationService, productService.version, false);
59
+ }
60
+ catch (err) {
61
+ if (productService.releaseNotesUrl) {
62
+ await openerService.open(( URI.parse(productService.releaseNotesUrl)));
63
+ }
64
+ else {
65
+ throw new Error(localizeWithPath('vs/workbench/contrib/update/browser/update.contribution', 'update.noReleaseNotesOnline', "This version of {0} does not have release notes online", productService.nameLong));
66
+ }
67
+ }
68
+ }
69
+ }
70
+ class ShowCurrentReleaseNotesFromCurrentFileAction extends Action2 {
71
+ constructor() {
72
+ super({
73
+ id: ShowCurrentReleaseNotesFromCurrentFileActionId,
74
+ title: {
75
+ ...( localize2WithPath(
76
+ 'vs/workbench/contrib/update/browser/update.contribution',
77
+ 'showReleaseNotesCurrentFile',
78
+ "Open Current File as Release Notes"
79
+ )),
80
+ mnemonicTitle: ( localizeWithPath(
81
+ 'vs/workbench/contrib/update/browser/update.contribution',
82
+ { key: 'mshowReleaseNotes', comment: ['&& denotes a mnemonic'] },
83
+ "Show &&Release Notes"
84
+ )),
85
+ },
86
+ category: ( localize2WithPath(
87
+ 'vs/workbench/contrib/update/browser/update.contribution',
88
+ 'developerCategory',
89
+ "Developer"
90
+ )),
91
+ f1: true,
92
+ precondition: RELEASE_NOTES_URL
93
+ });
94
+ }
95
+ async run(accessor) {
96
+ const instantiationService = accessor.get(IInstantiationService);
97
+ const productService = accessor.get(IProductService);
98
+ try {
99
+ await showReleaseNotesInEditor(instantiationService, productService.version, true);
100
+ }
101
+ catch (err) {
102
+ throw new Error(localizeWithPath('vs/workbench/contrib/update/browser/update.contribution', 'releaseNotesFromFileNone', "Cannot open the current file as Release Notes"));
103
+ }
104
+ }
105
+ }
106
+ registerAction2(ShowCurrentReleaseNotesAction);
107
+ registerAction2(ShowCurrentReleaseNotesFromCurrentFileAction);
108
+ class CheckForUpdateAction extends Action2 {
109
+ constructor() {
110
+ super({
111
+ id: 'update.checkForUpdate',
112
+ title: ( localize2WithPath(
113
+ 'vs/workbench/contrib/update/browser/update.contribution',
114
+ 'checkForUpdates',
115
+ 'Check for Updates...'
116
+ )),
117
+ category: { value: product$1.nameShort, original: product$1.nameShort },
118
+ f1: true,
119
+ precondition: ( CONTEXT_UPDATE_STATE.isEqualTo("idle" )),
120
+ });
121
+ }
122
+ async run(accessor) {
123
+ const updateService = accessor.get(IUpdateService);
124
+ return updateService.checkForUpdates(true);
125
+ }
126
+ }
127
+ class DownloadUpdateAction extends Action2 {
128
+ constructor() {
129
+ super({
130
+ id: 'update.downloadUpdate',
131
+ title: ( localize2WithPath(
132
+ 'vs/workbench/contrib/update/browser/update.contribution',
133
+ 'downloadUpdate',
134
+ 'Download Update'
135
+ )),
136
+ category: { value: product$1.nameShort, original: product$1.nameShort },
137
+ f1: true,
138
+ precondition: ( CONTEXT_UPDATE_STATE.isEqualTo("available for download" ))
139
+ });
140
+ }
141
+ async run(accessor) {
142
+ await accessor.get(IUpdateService).downloadUpdate();
143
+ }
144
+ }
145
+ class InstallUpdateAction extends Action2 {
146
+ constructor() {
147
+ super({
148
+ id: 'update.installUpdate',
149
+ title: ( localize2WithPath(
150
+ 'vs/workbench/contrib/update/browser/update.contribution',
151
+ 'installUpdate',
152
+ 'Install Update'
153
+ )),
154
+ category: { value: product$1.nameShort, original: product$1.nameShort },
155
+ f1: true,
156
+ precondition: ( CONTEXT_UPDATE_STATE.isEqualTo("downloaded" ))
157
+ });
158
+ }
159
+ async run(accessor) {
160
+ await accessor.get(IUpdateService).applyUpdate();
161
+ }
162
+ }
163
+ class RestartToUpdateAction extends Action2 {
164
+ constructor() {
165
+ super({
166
+ id: 'update.restartToUpdate',
167
+ title: ( localize2WithPath(
168
+ 'vs/workbench/contrib/update/browser/update.contribution',
169
+ 'restartToUpdate',
170
+ 'Restart to Update'
171
+ )),
172
+ category: { value: product$1.nameShort, original: product$1.nameShort },
173
+ f1: true,
174
+ precondition: ( CONTEXT_UPDATE_STATE.isEqualTo("ready" ))
175
+ });
176
+ }
177
+ async run(accessor) {
178
+ await accessor.get(IUpdateService).quitAndInstall();
179
+ }
180
+ }
181
+ class DownloadAction extends Action2 {
182
+ static { this.ID = 'workbench.action.download'; }
183
+ constructor() {
184
+ super({
185
+ id: DownloadAction.ID,
186
+ title: ( localize2WithPath(
187
+ 'vs/workbench/contrib/update/browser/update.contribution',
188
+ 'openDownloadPage',
189
+ "Download {0}",
190
+ product$1.nameLong
191
+ )),
192
+ precondition: ( ContextKeyExpr.and(IsWebContext, DOWNLOAD_URL)),
193
+ f1: true,
194
+ menu: [{
195
+ id: MenuId.StatusBarWindowIndicatorMenu,
196
+ when: ( ContextKeyExpr.and(IsWebContext, DOWNLOAD_URL))
197
+ }]
198
+ });
199
+ }
200
+ run(accessor) {
201
+ const productService = accessor.get(IProductService);
202
+ const openerService = accessor.get(IOpenerService);
203
+ if (productService.downloadUrl) {
204
+ openerService.open(( URI.parse(productService.downloadUrl)));
205
+ }
206
+ }
207
+ }
208
+ registerAction2(DownloadAction);
209
+ registerAction2(CheckForUpdateAction);
210
+ registerAction2(DownloadUpdateAction);
211
+ registerAction2(InstallUpdateAction);
212
+ registerAction2(RestartToUpdateAction);
213
+ if (isWindows) {
214
+ class DeveloperApplyUpdateAction extends Action2 {
215
+ constructor() {
216
+ super({
217
+ id: '_update.applyupdate',
218
+ title: ( localize2WithPath(
219
+ 'vs/workbench/contrib/update/browser/update.contribution',
220
+ 'applyUpdate',
221
+ 'Apply Update...'
222
+ )),
223
+ category: Categories.Developer,
224
+ f1: true,
225
+ precondition: ( CONTEXT_UPDATE_STATE.isEqualTo("idle" ))
226
+ });
227
+ }
228
+ async run(accessor) {
229
+ const updateService = accessor.get(IUpdateService);
230
+ const fileDialogService = accessor.get(IFileDialogService);
231
+ const updatePath = await fileDialogService.showOpenDialog({
232
+ title: ( localizeWithPath(
233
+ 'vs/workbench/contrib/update/browser/update.contribution',
234
+ 'pickUpdate',
235
+ "Apply Update"
236
+ )),
237
+ filters: [{ name: 'Setup', extensions: ['exe'] }],
238
+ canSelectFiles: true,
239
+ openLabel: mnemonicButtonLabel(( localizeWithPath(
240
+ 'vs/workbench/contrib/update/browser/update.contribution',
241
+ { key: 'updateButton', comment: ['&& denotes a mnemonic'] },
242
+ "&&Update"
243
+ )))
244
+ });
245
+ if (!updatePath || !updatePath[0]) {
246
+ return;
247
+ }
248
+ await updateService._applySpecificUpdate(updatePath[0].fsPath);
249
+ }
250
+ }
251
+ registerAction2(DeveloperApplyUpdateAction);
252
+ }
253
+
254
+ export { CheckForUpdateAction, ShowCurrentReleaseNotesAction, ShowCurrentReleaseNotesFromCurrentFileAction };