@codingame/monaco-vscode-extension-gallery-service-override 1.83.9

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 (66) hide show
  1. package/extensionGallery.d.ts +12 -0
  2. package/extensionGallery.js +76 -0
  3. package/external/rollup-plugin-styles/dist/runtime/inject-css.js +3 -0
  4. package/external/tslib/tslib.es6.js +11 -0
  5. package/index.d.ts +1 -0
  6. package/index.js +1 -0
  7. package/override/vs/platform/dialogs/common/dialogs.js +8 -0
  8. package/package.json +30 -0
  9. package/vscode/src/vs/platform/extensionManagement/common/abstractExtensionManagementService.js +784 -0
  10. package/vscode/src/vs/platform/extensionManagement/common/extensionEnablementService.js +142 -0
  11. package/vscode/src/vs/platform/extensionManagement/common/extensionGalleryService.js +855 -0
  12. package/vscode/src/vs/platform/extensionManagement/common/extensionManagementIpc.js +119 -0
  13. package/vscode/src/vs/platform/extensionManagement/common/extensionTipsService.js +57 -0
  14. package/vscode/src/vs/platform/extensionManagement/common/unsupportedExtensionsMigration.js +58 -0
  15. package/vscode/src/vs/platform/externalServices/common/marketplace.js +17 -0
  16. package/vscode/src/vs/workbench/contrib/extensions/browser/abstractRuntimeExtensionsEditor.js +492 -0
  17. package/vscode/src/vs/workbench/contrib/extensions/browser/browserRuntimeExtensionsEditor.js +28 -0
  18. package/vscode/src/vs/workbench/contrib/extensions/browser/configBasedRecommendations.js +78 -0
  19. package/vscode/src/vs/workbench/contrib/extensions/browser/deprecatedExtensionsChecker.js +87 -0
  20. package/vscode/src/vs/workbench/contrib/extensions/browser/exeBasedRecommendations.js +60 -0
  21. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionEditor.js +1868 -0
  22. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionEnablementWorkspaceTrustTransitionParticipant.js +52 -0
  23. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService.js +437 -0
  24. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionRecommendations.js +17 -0
  25. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionRecommendationsService.js +221 -0
  26. package/vscode/src/vs/workbench/contrib/extensions/browser/extensions.contribution.js +2063 -0
  27. package/vscode/src/vs/workbench/contrib/extensions/browser/extensions.web.contribution.js +13 -0
  28. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsActivationProgress.js +46 -0
  29. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsCompletionItemsProvider.js +65 -0
  30. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsDependencyChecker.js +98 -0
  31. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsList.js +224 -0
  32. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsQuickAccess.js +121 -0
  33. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewer.js +285 -0
  34. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViewlet.js +912 -0
  35. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsViews.js +1270 -0
  36. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWidgets.js +824 -0
  37. package/vscode/src/vs/workbench/contrib/extensions/browser/extensionsWorkbenchService.js +1730 -0
  38. package/vscode/src/vs/workbench/contrib/extensions/browser/fileBasedRecommendations.js +324 -0
  39. package/vscode/src/vs/workbench/contrib/extensions/browser/keymapRecommendations.js +28 -0
  40. package/vscode/src/vs/workbench/contrib/extensions/browser/languageRecommendations.js +28 -0
  41. package/vscode/src/vs/workbench/contrib/extensions/browser/media/extension.css.js +6 -0
  42. package/vscode/src/vs/workbench/contrib/extensions/browser/media/extensionEditor.css.js +6 -0
  43. package/vscode/src/vs/workbench/contrib/extensions/browser/media/extensionsViewlet.css.js +6 -0
  44. package/vscode/src/vs/workbench/contrib/extensions/browser/media/extensionsWidgets.css.js +6 -0
  45. package/vscode/src/vs/workbench/contrib/extensions/browser/media/runtimeExtensionsEditor.css.js +6 -0
  46. package/vscode/src/vs/workbench/contrib/extensions/browser/remoteRecommendations.js +29 -0
  47. package/vscode/src/vs/workbench/contrib/extensions/browser/unsupportedExtensionsMigrationContribution.js +26 -0
  48. package/vscode/src/vs/workbench/contrib/extensions/browser/webRecommendations.js +38 -0
  49. package/vscode/src/vs/workbench/contrib/extensions/browser/workspaceRecommendations.js +88 -0
  50. package/vscode/src/vs/workbench/contrib/extensions/common/extensionQuery.js +67 -0
  51. package/vscode/src/vs/workbench/contrib/extensions/common/extensionsInput.js +43 -0
  52. package/vscode/src/vs/workbench/contrib/extensions/common/extensionsUtils.js +104 -0
  53. package/vscode/src/vs/workbench/contrib/extensions/common/reportExtensionIssueAction.js +31 -0
  54. package/vscode/src/vs/workbench/contrib/extensions/common/runtimeExtensionsInput.js +41 -0
  55. package/vscode/src/vs/workbench/contrib/markdown/browser/markdownDocumentRenderer.js +207 -0
  56. package/vscode/src/vs/workbench/contrib/update/common/update.js +3 -0
  57. package/vscode/src/vs/workbench/services/extensionManagement/browser/builtinExtensionsScannerService.js +84 -0
  58. package/vscode/src/vs/workbench/services/extensionManagement/browser/extensionEnablementService.js +634 -0
  59. package/vscode/src/vs/workbench/services/extensionManagement/browser/webExtensionsScannerService.js +883 -0
  60. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementChannelClient.js +109 -0
  61. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementServerService.js +62 -0
  62. package/vscode/src/vs/workbench/services/extensionManagement/common/extensionManagementService.js +633 -0
  63. package/vscode/src/vs/workbench/services/extensionManagement/common/remoteExtensionManagementService.js +58 -0
  64. package/vscode/src/vs/workbench/services/extensionManagement/common/webExtensionManagementService.js +269 -0
  65. package/vscode/src/vs/workbench/services/extensionRecommendations/common/extensionIgnoredRecommendationsService.js +83 -0
  66. package/vscode/src/vs/workbench/services/remote/common/remoteExtensionsScanner.js +73 -0
@@ -0,0 +1,52 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
3
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
4
+ import { IWorkspaceTrustEnablementService, IWorkspaceTrustManagementService } from 'monaco-editor/esm/vs/platform/workspace/common/workspaceTrust.js';
5
+ import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
6
+ import { IWorkbenchExtensionEnablementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
7
+ import { IExtensionService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
8
+ import { IHostService } from 'vscode/vscode/vs/workbench/services/host/browser/host';
9
+
10
+ let ExtensionEnablementWorkspaceTrustTransitionParticipant = class ExtensionEnablementWorkspaceTrustTransitionParticipant extends Disposable {
11
+ constructor(extensionService, hostService, environmentService, extensionEnablementService, workspaceTrustEnablementService, workspaceTrustManagementService) {
12
+ super();
13
+ if (workspaceTrustEnablementService.isWorkspaceTrustEnabled()) {
14
+ workspaceTrustManagementService.workspaceTrustInitialized.then(() => {
15
+ const workspaceTrustTransitionParticipant = new (class {
16
+ async participate(trusted) {
17
+ if (trusted) {
18
+ await extensionEnablementService.updateExtensionsEnablementsWhenWorkspaceTrustChanges();
19
+ }
20
+ else {
21
+ if (environmentService.remoteAuthority) {
22
+ hostService.reload();
23
+ }
24
+ else {
25
+ const stopped = await extensionService.stopExtensionHosts(( localizeWithPath(
26
+ 'vs/workbench/contrib/extensions/browser/extensionEnablementWorkspaceTrustTransitionParticipant',
27
+ 'restartExtensionHost.reason',
28
+ "Restarting extension host due to workspace trust change."
29
+ )));
30
+ await extensionEnablementService.updateExtensionsEnablementsWhenWorkspaceTrustChanges();
31
+ if (stopped) {
32
+ extensionService.startExtensionHosts();
33
+ }
34
+ }
35
+ }
36
+ }
37
+ });
38
+ this._register(workspaceTrustManagementService.addWorkspaceTrustTransitionParticipant(workspaceTrustTransitionParticipant));
39
+ });
40
+ }
41
+ }
42
+ };
43
+ ExtensionEnablementWorkspaceTrustTransitionParticipant = ( __decorate([
44
+ ( __param(0, IExtensionService)),
45
+ ( __param(1, IHostService)),
46
+ ( __param(2, IWorkbenchEnvironmentService)),
47
+ ( __param(3, IWorkbenchExtensionEnablementService)),
48
+ ( __param(4, IWorkspaceTrustEnablementService)),
49
+ ( __param(5, IWorkspaceTrustManagementService))
50
+ ], ExtensionEnablementWorkspaceTrustTransitionParticipant));
51
+
52
+ export { ExtensionEnablementWorkspaceTrustTransitionParticipant };
@@ -0,0 +1,437 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { distinct } from 'monaco-editor/esm/vs/base/common/arrays.js';
3
+ import { raceCancellablePromises, createCancelablePromise, raceCancellation, timeout, Promises } from 'monaco-editor/esm/vs/base/common/async.js';
4
+ import { CancellationToken } from 'monaco-editor/esm/vs/base/common/cancellation.js';
5
+ import { isCancellationError } from 'monaco-editor/esm/vs/base/common/errors.js';
6
+ import { Event, Emitter } from 'monaco-editor/esm/vs/base/common/event.js';
7
+ import { Disposable, DisposableStore, isDisposable, toDisposable, MutableDisposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
8
+ import { localizeWithPath } from 'monaco-editor/esm/vs/nls.js';
9
+ import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
10
+ import { areSameExtensions } from 'vscode/vscode/vs/platform/extensionManagement/common/extensionManagementUtil';
11
+ import { RecommendationSourceToString } from 'vscode/vscode/vs/platform/extensionRecommendations/common/extensionRecommendations';
12
+ import { IInstantiationService } from 'monaco-editor/esm/vs/platform/instantiation/common/instantiation.js';
13
+ import { Severity, INotificationService, NotificationPriority } from 'monaco-editor/esm/vs/platform/notification/common/notification.js';
14
+ import { IStorageService } from 'monaco-editor/esm/vs/platform/storage/common/storage.js';
15
+ import { ITelemetryService } from 'monaco-editor/esm/vs/platform/telemetry/common/telemetry.js';
16
+ import { IUserDataSyncEnablementService } from 'vscode/vscode/vs/platform/userDataSync/common/userDataSync';
17
+ import { SearchExtensionsAction } from 'vscode/vscode/vs/workbench/contrib/extensions/browser/extensionsActions';
18
+ import { IExtensionsWorkbenchService } from 'vscode/vscode/vs/workbench/contrib/extensions/common/extensions';
19
+ import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
20
+ import { IWorkbenchExtensionManagementService, IWorkbenchExtensionEnablementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
21
+ import { IExtensionIgnoredRecommendationsService } from 'vscode/vscode/vs/workbench/services/extensionRecommendations/common/extensionRecommendations';
22
+
23
+ const ignoreImportantExtensionRecommendationStorageKey = 'extensionsAssistant/importantRecommendationsIgnore';
24
+ const donotShowWorkspaceRecommendationsStorageKey = 'extensionsAssistant/workspaceRecommendationsIgnore';
25
+ const choiceNever = ( localizeWithPath(
26
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
27
+ 'neverShowAgain',
28
+ "Don't Show Again"
29
+ ));
30
+ class RecommendationsNotification extends Disposable {
31
+ constructor(severity, message, choices, notificationService) {
32
+ super();
33
+ this.severity = severity;
34
+ this.message = message;
35
+ this.choices = choices;
36
+ this.notificationService = notificationService;
37
+ this._onDidClose = this._register(( new Emitter()));
38
+ this.onDidClose = this._onDidClose.event;
39
+ this._onDidChangeVisibility = this._register(( new Emitter()));
40
+ this.onDidChangeVisibility = this._onDidChangeVisibility.event;
41
+ this.cancelled = false;
42
+ this.onDidCloseDisposable = this._register(( new MutableDisposable()));
43
+ this.onDidChangeVisibilityDisposable = this._register(( new MutableDisposable()));
44
+ }
45
+ show() {
46
+ if (!this.notificationHandle) {
47
+ this.updateNotificationHandle(this.notificationService.prompt(this.severity, this.message, this.choices, { sticky: true, onCancel: () => this.cancelled = true }));
48
+ }
49
+ }
50
+ hide() {
51
+ if (this.notificationHandle) {
52
+ this.onDidCloseDisposable.clear();
53
+ this.notificationHandle.close();
54
+ this.cancelled = false;
55
+ this.updateNotificationHandle(this.notificationService.prompt(this.severity, this.message, this.choices, { priority: NotificationPriority.SILENT, onCancel: () => this.cancelled = true }));
56
+ }
57
+ }
58
+ isCancelled() {
59
+ return this.cancelled;
60
+ }
61
+ updateNotificationHandle(notificationHandle) {
62
+ this.onDidCloseDisposable.clear();
63
+ this.onDidChangeVisibilityDisposable.clear();
64
+ this.notificationHandle = notificationHandle;
65
+ this.onDidCloseDisposable.value = this.notificationHandle.onDidClose(() => {
66
+ this.onDidCloseDisposable.dispose();
67
+ this.onDidChangeVisibilityDisposable.dispose();
68
+ this._onDidClose.fire();
69
+ this._onDidClose.dispose();
70
+ this._onDidChangeVisibility.dispose();
71
+ });
72
+ this.onDidChangeVisibilityDisposable.value = this.notificationHandle.onDidChangeVisibility((e) => this._onDidChangeVisibility.fire(e));
73
+ }
74
+ }
75
+ let ExtensionRecommendationNotificationService = class ExtensionRecommendationNotificationService extends Disposable {
76
+ get ignoredRecommendations() {
77
+ return distinct(( [...JSON.parse(this.storageService.get(ignoreImportantExtensionRecommendationStorageKey, 0 , '[]'))].map(i => i.toLowerCase())));
78
+ }
79
+ constructor(configurationService, storageService, notificationService, telemetryService, instantiationService, extensionsWorkbenchService, extensionManagementService, extensionEnablementService, extensionIgnoredRecommendationsService, userDataSyncEnablementService, workbenchEnvironmentService) {
80
+ super();
81
+ this.configurationService = configurationService;
82
+ this.storageService = storageService;
83
+ this.notificationService = notificationService;
84
+ this.telemetryService = telemetryService;
85
+ this.instantiationService = instantiationService;
86
+ this.extensionsWorkbenchService = extensionsWorkbenchService;
87
+ this.extensionManagementService = extensionManagementService;
88
+ this.extensionEnablementService = extensionEnablementService;
89
+ this.extensionIgnoredRecommendationsService = extensionIgnoredRecommendationsService;
90
+ this.userDataSyncEnablementService = userDataSyncEnablementService;
91
+ this.workbenchEnvironmentService = workbenchEnvironmentService;
92
+ this.recommendedExtensions = [];
93
+ this.recommendationSources = [];
94
+ this.pendingNotificaitons = [];
95
+ }
96
+ hasToIgnoreRecommendationNotifications() {
97
+ const config = this.configurationService.getValue('extensions');
98
+ return config.ignoreRecommendations || !!config.showRecommendationsOnlyOnDemand;
99
+ }
100
+ async promptImportantExtensionsInstallNotification(extensionRecommendations) {
101
+ const ignoredRecommendations = [...this.extensionIgnoredRecommendationsService.ignoredRecommendations, ...this.ignoredRecommendations];
102
+ const extensions = extensionRecommendations.extensions.filter(id => !ignoredRecommendations.includes(id));
103
+ if (!extensions.length) {
104
+ return "ignored" ;
105
+ }
106
+ return this.promptRecommendationsNotification({ ...extensionRecommendations, extensions }, {
107
+ onDidInstallRecommendedExtensions: (extensions) => extensions.forEach(extension => this.telemetryService.publicLog2('extensionRecommendations:popup', { userReaction: 'install', extensionId: extension.identifier.id, source: RecommendationSourceToString(extensionRecommendations.source) })),
108
+ onDidShowRecommendedExtensions: (extensions) => extensions.forEach(extension => this.telemetryService.publicLog2('extensionRecommendations:popup', { userReaction: 'show', extensionId: extension.identifier.id, source: RecommendationSourceToString(extensionRecommendations.source) })),
109
+ onDidCancelRecommendedExtensions: (extensions) => extensions.forEach(extension => this.telemetryService.publicLog2('extensionRecommendations:popup', { userReaction: 'cancelled', extensionId: extension.identifier.id, source: RecommendationSourceToString(extensionRecommendations.source) })),
110
+ onDidNeverShowRecommendedExtensionsAgain: (extensions) => {
111
+ for (const extension of extensions) {
112
+ this.addToImportantRecommendationsIgnore(extension.identifier.id);
113
+ this.telemetryService.publicLog2('extensionRecommendations:popup', { userReaction: 'neverShowAgain', extensionId: extension.identifier.id, source: RecommendationSourceToString(extensionRecommendations.source) });
114
+ }
115
+ this.notificationService.prompt(Severity.Info, ( localizeWithPath(
116
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
117
+ 'ignoreExtensionRecommendations',
118
+ "Do you want to ignore all extension recommendations?"
119
+ )), [{
120
+ label: ( localizeWithPath(
121
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
122
+ 'ignoreAll',
123
+ "Yes, Ignore All"
124
+ )),
125
+ run: () => this.setIgnoreRecommendationsConfig(true)
126
+ }, {
127
+ label: ( localizeWithPath(
128
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
129
+ 'no',
130
+ "No"
131
+ )),
132
+ run: () => this.setIgnoreRecommendationsConfig(false)
133
+ }]);
134
+ },
135
+ });
136
+ }
137
+ async promptWorkspaceRecommendations(recommendations) {
138
+ if (this.storageService.getBoolean(donotShowWorkspaceRecommendationsStorageKey, 1 , false)) {
139
+ return;
140
+ }
141
+ let installed = await this.extensionManagementService.getInstalled();
142
+ installed = installed.filter(l => this.extensionEnablementService.getEnablementState(l) !== 1 );
143
+ recommendations = recommendations.filter(extensionId => installed.every(local => !areSameExtensions({ id: extensionId }, local.identifier)));
144
+ if (!recommendations.length) {
145
+ return;
146
+ }
147
+ await this.promptRecommendationsNotification({ extensions: recommendations, source: 2 , name: ( localizeWithPath(
148
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
149
+ { key: 'this repository', comment: ['this repository means the current repository that is opened'] },
150
+ "this repository"
151
+ )) }, {
152
+ onDidInstallRecommendedExtensions: () => this.telemetryService.publicLog2('extensionWorkspaceRecommendations:popup', { userReaction: 'install' }),
153
+ onDidShowRecommendedExtensions: () => this.telemetryService.publicLog2('extensionWorkspaceRecommendations:popup', { userReaction: 'show' }),
154
+ onDidCancelRecommendedExtensions: () => this.telemetryService.publicLog2('extensionWorkspaceRecommendations:popup', { userReaction: 'cancelled' }),
155
+ onDidNeverShowRecommendedExtensionsAgain: () => {
156
+ this.telemetryService.publicLog2('extensionWorkspaceRecommendations:popup', { userReaction: 'neverShowAgain' });
157
+ this.storageService.store(donotShowWorkspaceRecommendationsStorageKey, true, 1 , 1 );
158
+ },
159
+ });
160
+ }
161
+ async promptRecommendationsNotification({ extensions: extensionIds, source, name, searchValue }, recommendationsNotificationActions) {
162
+ if (this.hasToIgnoreRecommendationNotifications()) {
163
+ return "ignored" ;
164
+ }
165
+ if (source === 3 && this.workbenchEnvironmentService.remoteAuthority) {
166
+ return "incompatibleWindow" ;
167
+ }
168
+ if (source === 3 && (this.recommendationSources.includes(3 ) || this.recommendationSources.length >= 2)) {
169
+ return "toomany" ;
170
+ }
171
+ this.recommendationSources.push(source);
172
+ if (source === 3 && extensionIds.every(id => this.recommendedExtensions.includes(id))) {
173
+ return "ignored" ;
174
+ }
175
+ const extensions = await this.getInstallableExtensions(extensionIds);
176
+ if (!extensions.length) {
177
+ return "ignored" ;
178
+ }
179
+ this.recommendedExtensions = distinct([...this.recommendedExtensions, ...extensionIds]);
180
+ let extensionsMessage = '';
181
+ if (extensions.length === 1) {
182
+ extensionsMessage = ( localizeWithPath(
183
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
184
+ 'extensionFromPublisher',
185
+ "'{0}' extension from {1}",
186
+ extensions[0].displayName,
187
+ extensions[0].publisherDisplayName
188
+ ));
189
+ }
190
+ else {
191
+ const publishers = [...extensions.reduce((result, extension) => result.add(extension.publisherDisplayName), ( new Set()))];
192
+ if (publishers.length > 2) {
193
+ extensionsMessage = ( localizeWithPath(
194
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
195
+ 'extensionsFromMultiplePublishers',
196
+ "extensions from {0}, {1} and others",
197
+ publishers[0],
198
+ publishers[1]
199
+ ));
200
+ }
201
+ else if (publishers.length === 2) {
202
+ extensionsMessage = ( localizeWithPath(
203
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
204
+ 'extensionsFromPublishers',
205
+ "extensions from {0} and {1}",
206
+ publishers[0],
207
+ publishers[1]
208
+ ));
209
+ }
210
+ else {
211
+ extensionsMessage = ( localizeWithPath(
212
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
213
+ 'extensionsFromPublisher',
214
+ "extensions from {0}",
215
+ publishers[0]
216
+ ));
217
+ }
218
+ }
219
+ let message = ( localizeWithPath(
220
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
221
+ 'recommended',
222
+ "Do you want to install the recommended {0} for {1}?",
223
+ extensionsMessage,
224
+ name
225
+ ));
226
+ if (source === 3 ) {
227
+ message = ( localizeWithPath(
228
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
229
+ { key: 'exeRecommended', comment: ['Placeholder string is the name of the software that is installed.'] },
230
+ "You have {0} installed on your system. Do you want to install the recommended {1} for it?",
231
+ name,
232
+ extensionsMessage
233
+ ));
234
+ }
235
+ if (!searchValue) {
236
+ searchValue = source === 2 ? '@recommended' : ( extensions.map(extensionId => `@id:${extensionId.identifier.id}`)).join(' ');
237
+ }
238
+ return raceCancellablePromises([
239
+ this._registerP(this.showRecommendationsNotification(extensions, message, searchValue, source, recommendationsNotificationActions)),
240
+ this._registerP(this.waitUntilRecommendationsAreInstalled(extensions))
241
+ ]);
242
+ }
243
+ showRecommendationsNotification(extensions, message, searchValue, source, { onDidInstallRecommendedExtensions, onDidShowRecommendedExtensions, onDidCancelRecommendedExtensions, onDidNeverShowRecommendedExtensionsAgain }) {
244
+ return createCancelablePromise(async (token) => {
245
+ let accepted = false;
246
+ const choices = [];
247
+ const installExtensions = async (isMachineScoped) => {
248
+ this.runAction(this.instantiationService.createInstance(SearchExtensionsAction, searchValue));
249
+ onDidInstallRecommendedExtensions(extensions);
250
+ await Promises.settled([
251
+ Promises.settled(( extensions.map(
252
+ extension => this.extensionsWorkbenchService.open(extension, { pinned: true })
253
+ ))),
254
+ this.extensionManagementService.installGalleryExtensions(( extensions.map(e => ({ extension: e.gallery, options: { isMachineScoped } }))))
255
+ ]);
256
+ };
257
+ choices.push({
258
+ label: ( localizeWithPath(
259
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
260
+ 'install',
261
+ "Install"
262
+ )),
263
+ run: () => installExtensions(false),
264
+ menu: this.userDataSyncEnablementService.isEnabled() && this.userDataSyncEnablementService.isResourceEnabled("extensions" ) ? [{
265
+ label: ( localizeWithPath(
266
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
267
+ 'install and do no sync',
268
+ "Install (Do not sync)"
269
+ )),
270
+ run: () => installExtensions(true)
271
+ }] : undefined,
272
+ });
273
+ choices.push(...[{
274
+ label: ( localizeWithPath(
275
+ 'vs/workbench/contrib/extensions/browser/extensionRecommendationNotificationService',
276
+ 'show recommendations',
277
+ "Show Recommendations"
278
+ )),
279
+ run: async () => {
280
+ onDidShowRecommendedExtensions(extensions);
281
+ for (const extension of extensions) {
282
+ this.extensionsWorkbenchService.open(extension, { pinned: true });
283
+ }
284
+ this.runAction(this.instantiationService.createInstance(SearchExtensionsAction, searchValue));
285
+ }
286
+ }, {
287
+ label: choiceNever,
288
+ isSecondary: true,
289
+ run: () => {
290
+ onDidNeverShowRecommendedExtensionsAgain(extensions);
291
+ }
292
+ }]);
293
+ try {
294
+ accepted = await this.doShowRecommendationsNotification(Severity.Info, message, choices, source, token);
295
+ }
296
+ catch (error) {
297
+ if (!isCancellationError(error)) {
298
+ throw error;
299
+ }
300
+ }
301
+ if (accepted) {
302
+ return "reacted" ;
303
+ }
304
+ else {
305
+ onDidCancelRecommendedExtensions(extensions);
306
+ return "cancelled" ;
307
+ }
308
+ });
309
+ }
310
+ waitUntilRecommendationsAreInstalled(extensions) {
311
+ const installedExtensions = [];
312
+ const disposables = ( new DisposableStore());
313
+ return createCancelablePromise(async (token) => {
314
+ disposables.add(token.onCancellationRequested(e => disposables.dispose()));
315
+ return ( new Promise((c, e) => {
316
+ disposables.add(this.extensionManagementService.onInstallExtension(e => {
317
+ installedExtensions.push(e.identifier.id.toLowerCase());
318
+ if (extensions.every(e => installedExtensions.includes(e.identifier.id.toLowerCase()))) {
319
+ c("reacted" );
320
+ }
321
+ }));
322
+ }));
323
+ });
324
+ }
325
+ async doShowRecommendationsNotification(severity, message, choices, source, token) {
326
+ const disposables = ( new DisposableStore());
327
+ try {
328
+ const recommendationsNotification = disposables.add(( new RecommendationsNotification(severity, message, choices, this.notificationService)));
329
+ disposables.add(Event.once(Event.filter(recommendationsNotification.onDidChangeVisibility, e => !e))(() => this.showNextNotification()));
330
+ if (this.visibleNotification) {
331
+ const index = this.pendingNotificaitons.length;
332
+ disposables.add(token.onCancellationRequested(() => this.pendingNotificaitons.splice(index, 1)));
333
+ this.pendingNotificaitons.push({ recommendationsNotification, source, token });
334
+ if (source !== 3 && source <= this.visibleNotification.source) {
335
+ this.hideVisibleNotification(3000);
336
+ }
337
+ }
338
+ else {
339
+ this.visibleNotification = { recommendationsNotification, source, from: Date.now() };
340
+ recommendationsNotification.show();
341
+ }
342
+ await raceCancellation(( new Promise(
343
+ c => disposables.add(Event.once(recommendationsNotification.onDidClose)(c))
344
+ )), token);
345
+ return !recommendationsNotification.isCancelled();
346
+ }
347
+ finally {
348
+ disposables.dispose();
349
+ }
350
+ }
351
+ showNextNotification() {
352
+ const index = this.getNextPendingNotificationIndex();
353
+ const [nextNotificaiton] = index > -1 ? this.pendingNotificaitons.splice(index, 1) : [];
354
+ timeout(nextNotificaiton ? 500 : 0)
355
+ .then(() => {
356
+ this.unsetVisibileNotification();
357
+ if (nextNotificaiton) {
358
+ this.visibleNotification = { recommendationsNotification: nextNotificaiton.recommendationsNotification, source: nextNotificaiton.source, from: Date.now() };
359
+ nextNotificaiton.recommendationsNotification.show();
360
+ }
361
+ });
362
+ }
363
+ getNextPendingNotificationIndex() {
364
+ let index = this.pendingNotificaitons.length - 1;
365
+ if (this.pendingNotificaitons.length) {
366
+ for (let i = 0; i < this.pendingNotificaitons.length; i++) {
367
+ if (this.pendingNotificaitons[i].source <= this.pendingNotificaitons[index].source) {
368
+ index = i;
369
+ }
370
+ }
371
+ }
372
+ return index;
373
+ }
374
+ hideVisibleNotification(timeInMillis) {
375
+ if (this.visibleNotification && !this.hideVisibleNotificationPromise) {
376
+ const visibleNotification = this.visibleNotification;
377
+ this.hideVisibleNotificationPromise = timeout(Math.max(timeInMillis - (Date.now() - visibleNotification.from), 0));
378
+ this.hideVisibleNotificationPromise.then(() => visibleNotification.recommendationsNotification.hide());
379
+ }
380
+ }
381
+ unsetVisibileNotification() {
382
+ this.hideVisibleNotificationPromise?.cancel();
383
+ this.hideVisibleNotificationPromise = undefined;
384
+ this.visibleNotification = undefined;
385
+ }
386
+ async getInstallableExtensions(extensionIds) {
387
+ const result = [];
388
+ if (extensionIds.length) {
389
+ const extensions = await this.extensionsWorkbenchService.getExtensions(( extensionIds.map(id => ({ id }))), { source: 'install-recommendations' }, CancellationToken.None);
390
+ for (const extension of extensions) {
391
+ if (extension.gallery && (await this.extensionManagementService.canInstall(extension.gallery))) {
392
+ result.push(extension);
393
+ }
394
+ }
395
+ }
396
+ return result;
397
+ }
398
+ async runAction(action) {
399
+ try {
400
+ await action.run();
401
+ }
402
+ finally {
403
+ if (isDisposable(action)) {
404
+ action.dispose();
405
+ }
406
+ }
407
+ }
408
+ addToImportantRecommendationsIgnore(id) {
409
+ const importantRecommendationsIgnoreList = [...this.ignoredRecommendations];
410
+ if (!importantRecommendationsIgnoreList.includes(id.toLowerCase())) {
411
+ importantRecommendationsIgnoreList.push(id.toLowerCase());
412
+ this.storageService.store(ignoreImportantExtensionRecommendationStorageKey, JSON.stringify(importantRecommendationsIgnoreList), 0 , 0 );
413
+ }
414
+ }
415
+ setIgnoreRecommendationsConfig(configVal) {
416
+ this.configurationService.updateValue('extensions.ignoreRecommendations', configVal);
417
+ }
418
+ _registerP(o) {
419
+ this._register(toDisposable(() => o.cancel()));
420
+ return o;
421
+ }
422
+ };
423
+ ExtensionRecommendationNotificationService = ( __decorate([
424
+ ( __param(0, IConfigurationService)),
425
+ ( __param(1, IStorageService)),
426
+ ( __param(2, INotificationService)),
427
+ ( __param(3, ITelemetryService)),
428
+ ( __param(4, IInstantiationService)),
429
+ ( __param(5, IExtensionsWorkbenchService)),
430
+ ( __param(6, IWorkbenchExtensionManagementService)),
431
+ ( __param(7, IWorkbenchExtensionEnablementService)),
432
+ ( __param(8, IExtensionIgnoredRecommendationsService)),
433
+ ( __param(9, IUserDataSyncEnablementService)),
434
+ ( __param(10, IWorkbenchEnvironmentService))
435
+ ], ExtensionRecommendationNotificationService));
436
+
437
+ export { ExtensionRecommendationNotificationService };
@@ -0,0 +1,17 @@
1
+ import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
2
+
3
+ class ExtensionRecommendations extends Disposable {
4
+ constructor() {
5
+ super(...arguments);
6
+ this._activationPromise = null;
7
+ }
8
+ get activated() { return this._activationPromise !== null; }
9
+ activate() {
10
+ if (!this._activationPromise) {
11
+ this._activationPromise = this.doActivate();
12
+ }
13
+ return this._activationPromise;
14
+ }
15
+ }
16
+
17
+ export { ExtensionRecommendations };