@codingame/monaco-vscode-extensions-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.
Files changed (109) hide show
  1. package/_virtual/semver.js +3 -0
  2. package/extensions.js +6 -6
  3. package/external/vscode-semver/semver.js +985 -0
  4. package/override/vs/workbench/browser/parts/editor/textEditor.weak.js +8 -0
  5. package/package.json +9 -9
  6. package/vscode/src/vs/base/common/console.js +62 -0
  7. package/vscode/src/vs/platform/extensionManagement/common/extensionManagementCLI.js +497 -0
  8. package/vscode/src/vs/platform/extensionResourceLoader/browser/extensionResourceLoaderService.js +44 -0
  9. package/vscode/src/vs/platform/lifecycle/common/lifecycle.js +27 -0
  10. package/vscode/src/vs/platform/remote/common/managedSocket.js +98 -0
  11. package/vscode/src/vs/workbench/api/browser/extensionHost.contribution.js +104 -0
  12. package/vscode/src/vs/workbench/api/browser/mainThreadAiEmbeddingVector.js +31 -0
  13. package/vscode/src/vs/workbench/api/browser/mainThreadAiRelatedInformation.js +35 -0
  14. package/vscode/src/vs/workbench/api/browser/mainThreadAuthentication.js +254 -0
  15. package/vscode/src/vs/workbench/api/browser/mainThreadBulkEdits.js +68 -0
  16. package/vscode/src/vs/workbench/api/browser/mainThreadCLICommands.js +103 -0
  17. package/vscode/src/vs/workbench/api/browser/mainThreadChat.js +70 -0
  18. package/vscode/src/vs/workbench/api/browser/mainThreadChatAgents2.js +207 -0
  19. package/vscode/src/vs/workbench/api/browser/mainThreadChatVariables.js +41 -0
  20. package/vscode/src/vs/workbench/api/browser/mainThreadClipboard.js +24 -0
  21. package/vscode/src/vs/workbench/api/browser/mainThreadCodeInsets.js +108 -0
  22. package/vscode/src/vs/workbench/api/browser/mainThreadCommands.js +98 -0
  23. package/vscode/src/vs/workbench/api/browser/mainThreadComments.js +560 -0
  24. package/vscode/src/vs/workbench/api/browser/mainThreadConfiguration.js +80 -0
  25. package/vscode/src/vs/workbench/api/browser/mainThreadConsole.js +35 -0
  26. package/vscode/src/vs/workbench/api/browser/mainThreadCustomEditors.js +579 -0
  27. package/vscode/src/vs/workbench/api/browser/mainThreadDebugService.js +435 -0
  28. package/vscode/src/vs/workbench/api/browser/mainThreadDecorations.js +102 -0
  29. package/vscode/src/vs/workbench/api/browser/mainThreadDiagnostics.js +69 -0
  30. package/vscode/src/vs/workbench/api/browser/mainThreadDialogs.js +68 -0
  31. package/vscode/src/vs/workbench/api/browser/mainThreadDocumentContentProviders.js +79 -0
  32. package/vscode/src/vs/workbench/api/browser/mainThreadDocuments.js +253 -0
  33. package/vscode/src/vs/workbench/api/browser/mainThreadDocumentsAndEditors.js +370 -0
  34. package/vscode/src/vs/workbench/api/browser/mainThreadDownloadService.js +22 -0
  35. package/vscode/src/vs/workbench/api/browser/mainThreadEditSessionIdentityParticipant.js +41 -0
  36. package/vscode/src/vs/workbench/api/browser/mainThreadEditor.js +414 -0
  37. package/vscode/src/vs/workbench/api/browser/mainThreadEditorTabs.js +501 -0
  38. package/vscode/src/vs/workbench/api/browser/mainThreadEditors.js +227 -0
  39. package/vscode/src/vs/workbench/api/browser/mainThreadErrors.js +24 -0
  40. package/vscode/src/vs/workbench/api/browser/mainThreadExtensionService.js +317 -0
  41. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystem.js +208 -0
  42. package/vscode/src/vs/workbench/api/browser/mainThreadFileSystemEventService.js +369 -0
  43. package/vscode/src/vs/workbench/api/browser/mainThreadInlineChat.js +72 -0
  44. package/vscode/src/vs/workbench/api/browser/mainThreadInteractive.js +28 -0
  45. package/vscode/src/vs/workbench/api/browser/mainThreadIssueReporter.js +50 -0
  46. package/vscode/src/vs/workbench/api/browser/mainThreadLabelService.js +27 -0
  47. package/vscode/src/vs/workbench/api/browser/mainThreadLanguageFeatures.js +1016 -0
  48. package/vscode/src/vs/workbench/api/browser/mainThreadLanguageModels.js +185 -0
  49. package/vscode/src/vs/workbench/api/browser/mainThreadLanguages.js +78 -0
  50. package/vscode/src/vs/workbench/api/browser/mainThreadLocalization.js +35 -0
  51. package/vscode/src/vs/workbench/api/browser/mainThreadLogService.js +78 -0
  52. package/vscode/src/vs/workbench/api/browser/mainThreadManagedSockets.js +93 -0
  53. package/vscode/src/vs/workbench/api/browser/mainThreadMessageService.js +137 -0
  54. package/vscode/src/vs/workbench/api/browser/mainThreadNotebook.js +194 -0
  55. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocuments.js +123 -0
  56. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDocumentsAndEditors.js +188 -0
  57. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookDto.js +129 -0
  58. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookEditors.js +131 -0
  59. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookKernels.js +374 -0
  60. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookRenderers.js +25 -0
  61. package/vscode/src/vs/workbench/api/browser/mainThreadNotebookSaveParticipant.js +48 -0
  62. package/vscode/src/vs/workbench/api/browser/mainThreadOutputService.js +76 -0
  63. package/vscode/src/vs/workbench/api/browser/mainThreadProfileContentHandlers.js +38 -0
  64. package/vscode/src/vs/workbench/api/browser/mainThreadProgress.js +68 -0
  65. package/vscode/src/vs/workbench/api/browser/mainThreadQuickDiff.js +42 -0
  66. package/vscode/src/vs/workbench/api/browser/mainThreadQuickOpen.js +185 -0
  67. package/vscode/src/vs/workbench/api/browser/mainThreadRemoteConnectionData.js +30 -0
  68. package/vscode/src/vs/workbench/api/browser/mainThreadSCM.js +493 -0
  69. package/vscode/src/vs/workbench/api/browser/mainThreadSaveParticipant.js +49 -0
  70. package/vscode/src/vs/workbench/api/browser/mainThreadSearch.js +168 -0
  71. package/vscode/src/vs/workbench/api/browser/mainThreadSecretState.js +70 -0
  72. package/vscode/src/vs/workbench/api/browser/mainThreadShare.js +50 -0
  73. package/vscode/src/vs/workbench/api/browser/mainThreadSpeech.js +99 -0
  74. package/vscode/src/vs/workbench/api/browser/mainThreadStatusBar.js +53 -0
  75. package/vscode/src/vs/workbench/api/browser/mainThreadStorage.js +72 -0
  76. package/vscode/src/vs/workbench/api/browser/mainThreadTask.js +731 -0
  77. package/vscode/src/vs/workbench/api/browser/mainThreadTelemetry.js +53 -0
  78. package/vscode/src/vs/workbench/api/browser/mainThreadTerminalService.js +409 -0
  79. package/vscode/src/vs/workbench/api/browser/mainThreadTerminalShellIntegration.js +51 -0
  80. package/vscode/src/vs/workbench/api/browser/mainThreadTesting.js +219 -0
  81. package/vscode/src/vs/workbench/api/browser/mainThreadTheming.js +24 -0
  82. package/vscode/src/vs/workbench/api/browser/mainThreadTimeline.js +55 -0
  83. package/vscode/src/vs/workbench/api/browser/mainThreadTreeViews.js +312 -0
  84. package/vscode/src/vs/workbench/api/browser/mainThreadTunnelService.js +223 -0
  85. package/vscode/src/vs/workbench/api/browser/mainThreadUriOpeners.js +110 -0
  86. package/vscode/src/vs/workbench/api/browser/mainThreadUrls.js +61 -0
  87. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewManager.js +29 -0
  88. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewPanels.js +283 -0
  89. package/vscode/src/vs/workbench/api/browser/mainThreadWebviewViews.js +100 -0
  90. package/vscode/src/vs/workbench/api/browser/mainThreadWebviews.js +135 -0
  91. package/vscode/src/vs/workbench/api/browser/mainThreadWindow.js +57 -0
  92. package/vscode/src/vs/workbench/api/browser/mainThreadWorkspace.js +268 -0
  93. package/vscode/src/vs/workbench/api/common/shared/dataTransferCache.js +35 -0
  94. package/vscode/src/vs/workbench/contrib/customEditor/common/customTextEditorModel.js +76 -0
  95. package/vscode/src/vs/workbench/contrib/externalUriOpener/common/contributedOpeners.js +83 -0
  96. package/vscode/src/vs/workbench/services/extensions/browser/extensionService.js +285 -0
  97. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerExtensionHost.js +276 -0
  98. package/vscode/src/vs/workbench/services/extensions/browser/webWorkerFileSystemProvider.js +52 -0
  99. package/vscode/src/vs/workbench/services/extensions/common/abstractExtensionService.js +1149 -0
  100. package/vscode/src/vs/workbench/services/extensions/common/extHostCustomers.js +41 -0
  101. package/vscode/src/vs/workbench/services/extensions/common/extensionDevOptions.js +25 -0
  102. package/vscode/src/vs/workbench/services/extensions/common/extensionHostManager.js +512 -0
  103. package/vscode/src/vs/workbench/services/extensions/common/extensionRunningLocationTracker.js +274 -0
  104. package/vscode/src/vs/workbench/services/extensions/common/extensionStorageMigration.js +58 -0
  105. package/vscode/src/vs/workbench/services/extensions/common/extensionsProposedApi.js +80 -0
  106. package/vscode/src/vs/workbench/services/extensions/common/extensionsUtil.js +64 -0
  107. package/vscode/src/vs/workbench/services/extensions/common/lazyCreateExtensionHostManager.js +161 -0
  108. package/vscode/src/vs/workbench/services/extensions/common/remoteConsoleUtil.js +49 -0
  109. package/vscode/src/vs/workbench/services/extensions/common/remoteExtensionHost.js +222 -0
@@ -0,0 +1,1149 @@
1
+ import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
+ import { Barrier } from 'vscode/vscode/vs/base/common/async';
3
+ import { toErrorMessage } from 'vscode/vscode/vs/base/common/errorMessage';
4
+ import { Emitter } from 'vscode/vscode/vs/base/common/event';
5
+ import { MarkdownString } from 'vscode/vscode/vs/base/common/htmlContent';
6
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
7
+ import { Schemas } from 'vscode/vscode/vs/base/common/network';
8
+ import { mark } from 'vscode/vscode/vs/base/common/performance';
9
+ import { isCI } from 'vscode/vscode/vs/base/common/platform';
10
+ import { isEqualOrParent } from 'vscode/vscode/vs/base/common/resources';
11
+ import { StopWatch } from 'vscode/vscode/vs/base/common/stopwatch';
12
+ import { localizeWithPath } from 'vscode/vscode/vs/nls';
13
+ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration';
14
+ import '../../../../../../../override/vs/platform/dialogs/common/dialogs.js';
15
+ import { ImplicitActivationEvents } from 'vscode/vscode/vs/platform/extensionManagement/common/implicitActivationEvents';
16
+ import { ExtensionIdentifierMap, ExtensionIdentifier } from 'vscode/vscode/vs/platform/extensions/common/extensions';
17
+ import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
18
+ import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
19
+ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
20
+ import { handleVetos } from '../../../../platform/lifecycle/common/lifecycle.js';
21
+ import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
22
+ import { INotificationService, Severity } from 'vscode/vscode/vs/platform/notification/common/notification';
23
+ import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService';
24
+ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
25
+ import { IRemoteAuthorityResolverService, RemoteAuthorityResolverError, getRemoteAuthorityPrefix, RemoteAuthorityResolverErrorCode } from 'vscode/vscode/vs/platform/remote/common/remoteAuthorityResolver';
26
+ import { IRemoteExtensionsScannerService } from 'vscode/vscode/vs/platform/remote/common/remoteExtensionsScanner';
27
+ import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry';
28
+ import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace';
29
+ import { IWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/common/environmentService';
30
+ import { Extensions } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
31
+ import { IWorkbenchExtensionEnablementService, IWorkbenchExtensionManagementService } from 'vscode/vscode/vs/workbench/services/extensionManagement/common/extensionManagement';
32
+ import { LockableExtensionDescriptionRegistry } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionDescriptionRegistry';
33
+ import { parseExtensionDevOptions } from './extensionDevOptions.js';
34
+ import { ExtensionHostManager } from './extensionHostManager.js';
35
+ import { IExtensionManifestPropertiesService } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionManifestPropertiesService';
36
+ import { RemoteRunningLocation, LocalProcessRunningLocation, LocalWebWorkerRunningLocation } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionRunningLocation';
37
+ import { ExtensionRunningLocationTracker, filterExtensionIdentifiers } from './extensionRunningLocationTracker.js';
38
+ import { ExtensionPointContribution, ActivationTimes, toExtension } from 'vscode/vscode/vs/workbench/services/extensions/common/extensions';
39
+ import { ExtensionsRegistry, ExtensionMessageCollector } from 'vscode/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
40
+ import { LazyCreateExtensionHostManager } from './lazyCreateExtensionHostManager.js';
41
+ import { checkGlobFileExists, checkActivateWorkspaceContainsExtension } from 'vscode/vscode/vs/workbench/services/extensions/common/workspaceContains';
42
+ import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
43
+ import { IRemoteAgentService } from 'vscode/vscode/vs/workbench/services/remote/common/remoteAgentService';
44
+ import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
45
+
46
+ var AbstractExtensionService_1;
47
+ const hasOwnProperty = Object.hasOwnProperty;
48
+ const NO_OP_VOID_PROMISE = Promise.resolve(undefined);
49
+ let AbstractExtensionService = AbstractExtensionService_1 = class AbstractExtensionService extends Disposable {
50
+ constructor(_extensionsProposedApi, _extensionHostFactory, _extensionHostKindPicker, _instantiationService, _notificationService, _environmentService, _telemetryService, _extensionEnablementService, _fileService, _productService, _extensionManagementService, _contextService, _configurationService, _extensionManifestPropertiesService, _logService, _remoteAgentService, _remoteExtensionsScannerService, _lifecycleService, _remoteAuthorityResolverService, _dialogService) {
51
+ super();
52
+ this._extensionsProposedApi = _extensionsProposedApi;
53
+ this._extensionHostFactory = _extensionHostFactory;
54
+ this._extensionHostKindPicker = _extensionHostKindPicker;
55
+ this._instantiationService = _instantiationService;
56
+ this._notificationService = _notificationService;
57
+ this._environmentService = _environmentService;
58
+ this._telemetryService = _telemetryService;
59
+ this._extensionEnablementService = _extensionEnablementService;
60
+ this._fileService = _fileService;
61
+ this._productService = _productService;
62
+ this._extensionManagementService = _extensionManagementService;
63
+ this._contextService = _contextService;
64
+ this._configurationService = _configurationService;
65
+ this._extensionManifestPropertiesService = _extensionManifestPropertiesService;
66
+ this._logService = _logService;
67
+ this._remoteAgentService = _remoteAgentService;
68
+ this._remoteExtensionsScannerService = _remoteExtensionsScannerService;
69
+ this._lifecycleService = _lifecycleService;
70
+ this._remoteAuthorityResolverService = _remoteAuthorityResolverService;
71
+ this._dialogService = _dialogService;
72
+ this._onDidRegisterExtensions = this._register(( new Emitter()));
73
+ this.onDidRegisterExtensions = this._onDidRegisterExtensions.event;
74
+ this._onDidChangeExtensionsStatus = this._register(( new Emitter()));
75
+ this.onDidChangeExtensionsStatus = this._onDidChangeExtensionsStatus.event;
76
+ this._onDidChangeExtensions = this._register(( new Emitter({ leakWarningThreshold: 400 })));
77
+ this.onDidChangeExtensions = this._onDidChangeExtensions.event;
78
+ this._onWillActivateByEvent = this._register(( new Emitter()));
79
+ this.onWillActivateByEvent = this._onWillActivateByEvent.event;
80
+ this._onDidChangeResponsiveChange = this._register(( new Emitter()));
81
+ this.onDidChangeResponsiveChange = this._onDidChangeResponsiveChange.event;
82
+ this._onWillStop = this._register(( new Emitter()));
83
+ this.onWillStop = this._onWillStop.event;
84
+ this._activationEventReader = ( new ImplicitActivationAwareReader());
85
+ this._registry = ( new LockableExtensionDescriptionRegistry(this._activationEventReader));
86
+ this._installedExtensionsReady = ( new Barrier());
87
+ this._extensionStatus = ( new ExtensionIdentifierMap());
88
+ this._allRequestedActivateEvents = ( new Set());
89
+ this._remoteCrashTracker = ( new ExtensionHostCrashTracker());
90
+ this._deltaExtensionsQueue = [];
91
+ this._inHandleDeltaExtensions = false;
92
+ this._extensionHostManagers = [];
93
+ this._resolveAuthorityAttempt = 0;
94
+ this._register(this._fileService.onWillActivateFileSystemProvider(e => {
95
+ if (e.scheme !== Schemas.vscodeRemote) {
96
+ e.join(this.activateByEvent(`onFileSystem:${e.scheme}`));
97
+ }
98
+ }));
99
+ this._runningLocations = ( new ExtensionRunningLocationTracker(
100
+ this._registry,
101
+ this._extensionHostKindPicker,
102
+ this._environmentService,
103
+ this._configurationService,
104
+ this._logService,
105
+ this._extensionManifestPropertiesService
106
+ ));
107
+ this._register(this._extensionEnablementService.onEnablementChanged((extensions) => {
108
+ const toAdd = [];
109
+ const toRemove = [];
110
+ for (const extension of extensions) {
111
+ if (this._safeInvokeIsEnabled(extension)) {
112
+ toAdd.push(extension);
113
+ }
114
+ else {
115
+ toRemove.push(extension);
116
+ }
117
+ }
118
+ if (isCI) {
119
+ this._logService.info(`AbstractExtensionService.onEnablementChanged fired for ${( extensions.map(e => e.identifier.id)).join(', ')}`);
120
+ }
121
+ this._handleDeltaExtensions(( new DeltaExtensionsQueueItem(toAdd, toRemove)));
122
+ }));
123
+ this._register(this._extensionManagementService.onDidChangeProfile(({ added, removed }) => {
124
+ if (added.length || removed.length) {
125
+ if (isCI) {
126
+ this._logService.info(`AbstractExtensionService.onDidChangeProfile fired`);
127
+ }
128
+ this._handleDeltaExtensions(( new DeltaExtensionsQueueItem(added, removed)));
129
+ }
130
+ }));
131
+ this._register(this._extensionManagementService.onDidEnableExtensions(extensions => {
132
+ if (extensions.length) {
133
+ if (isCI) {
134
+ this._logService.info(`AbstractExtensionService.onDidEnableExtensions fired`);
135
+ }
136
+ this._handleDeltaExtensions(( new DeltaExtensionsQueueItem(extensions, [])));
137
+ }
138
+ }));
139
+ this._register(this._extensionManagementService.onDidInstallExtensions((result) => {
140
+ const extensions = [];
141
+ for (const { local, operation } of result) {
142
+ if (local && local.isValid && operation !== 4 && this._safeInvokeIsEnabled(local)) {
143
+ extensions.push(local);
144
+ }
145
+ }
146
+ if (extensions.length) {
147
+ if (isCI) {
148
+ this._logService.info(`AbstractExtensionService.onDidInstallExtensions fired for ${( extensions.map(e => e.identifier.id)).join(', ')}`);
149
+ }
150
+ this._handleDeltaExtensions(( new DeltaExtensionsQueueItem(extensions, [])));
151
+ }
152
+ }));
153
+ this._register(this._extensionManagementService.onDidUninstallExtension((event) => {
154
+ if (!event.error) {
155
+ if (isCI) {
156
+ this._logService.info(`AbstractExtensionService.onDidUninstallExtension fired for ${event.identifier.id}`);
157
+ }
158
+ this._handleDeltaExtensions(( new DeltaExtensionsQueueItem([], [event.identifier.id])));
159
+ }
160
+ }));
161
+ this._register(this._lifecycleService.onDidShutdown(() => {
162
+ const connection = this._remoteAgentService.getConnection();
163
+ connection?.dispose();
164
+ this._doStopExtensionHosts();
165
+ }));
166
+ }
167
+ _getExtensionHostManagers(kind) {
168
+ return this._extensionHostManagers.filter(extHostManager => extHostManager.kind === kind);
169
+ }
170
+ _getExtensionHostManagerByRunningLocation(runningLocation) {
171
+ for (const extensionHostManager of this._extensionHostManagers) {
172
+ if (extensionHostManager.representsRunningLocation(runningLocation)) {
173
+ return extensionHostManager;
174
+ }
175
+ }
176
+ return null;
177
+ }
178
+ async _handleDeltaExtensions(item) {
179
+ this._deltaExtensionsQueue.push(item);
180
+ if (this._inHandleDeltaExtensions) {
181
+ return;
182
+ }
183
+ let lock = null;
184
+ try {
185
+ this._inHandleDeltaExtensions = true;
186
+ await this._installedExtensionsReady.wait();
187
+ lock = await this._registry.acquireLock('handleDeltaExtensions');
188
+ while (this._deltaExtensionsQueue.length > 0) {
189
+ const item = this._deltaExtensionsQueue.shift();
190
+ await this._deltaExtensions(lock, item.toAdd, item.toRemove);
191
+ }
192
+ }
193
+ finally {
194
+ this._inHandleDeltaExtensions = false;
195
+ lock?.dispose();
196
+ }
197
+ }
198
+ async _deltaExtensions(lock, _toAdd, _toRemove) {
199
+ if (isCI) {
200
+ this._logService.info(`AbstractExtensionService._deltaExtensions: toAdd: [${( _toAdd.map(e => e.identifier.id)).join(',')}] toRemove: [${( _toRemove.map(e => typeof e === 'string' ? e : e.identifier.id)).join(',')}]`);
201
+ }
202
+ let toRemove = [];
203
+ for (let i = 0, len = _toRemove.length; i < len; i++) {
204
+ const extensionOrId = _toRemove[i];
205
+ const extensionId = (typeof extensionOrId === 'string' ? extensionOrId : extensionOrId.identifier.id);
206
+ const extension = (typeof extensionOrId === 'string' ? null : extensionOrId);
207
+ const extensionDescription = this._registry.getExtensionDescription(extensionId);
208
+ if (!extensionDescription) {
209
+ continue;
210
+ }
211
+ if (extension && extensionDescription.extensionLocation.scheme !== extension.location.scheme) {
212
+ continue;
213
+ }
214
+ if (!this.canRemoveExtension(extensionDescription)) {
215
+ continue;
216
+ }
217
+ toRemove.push(extensionDescription);
218
+ }
219
+ const toAdd = [];
220
+ for (let i = 0, len = _toAdd.length; i < len; i++) {
221
+ const extension = _toAdd[i];
222
+ const extensionDescription = await this._scanSingleExtension(extension);
223
+ if (!extensionDescription) {
224
+ continue;
225
+ }
226
+ if (!this._canAddExtension(extensionDescription, toRemove)) {
227
+ continue;
228
+ }
229
+ toAdd.push(extensionDescription);
230
+ }
231
+ if (toAdd.length === 0 && toRemove.length === 0) {
232
+ return;
233
+ }
234
+ const result = this._registry.deltaExtensions(lock, toAdd, ( toRemove.map(e => e.identifier)));
235
+ this._onDidChangeExtensions.fire({ added: toAdd, removed: toRemove });
236
+ toRemove = toRemove.concat(result.removedDueToLooping);
237
+ if (result.removedDueToLooping.length > 0) {
238
+ this._notificationService.notify({
239
+ severity: Severity.Error,
240
+ message: ( localizeWithPath(
241
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
242
+ 'looping',
243
+ "The following extensions contain dependency loops and have been disabled: {0}",
244
+ ( result.removedDueToLooping.map(e => `'${e.identifier.value}'`)).join(', ')
245
+ ))
246
+ });
247
+ }
248
+ this._extensionsProposedApi.updateEnabledApiProposals(toAdd);
249
+ this._doHandleExtensionPoints([].concat(toAdd).concat(toRemove));
250
+ await this._updateExtensionsOnExtHosts(result.versionId, toAdd, ( toRemove.map(e => e.identifier)));
251
+ for (let i = 0; i < toAdd.length; i++) {
252
+ this._activateAddedExtensionIfNeeded(toAdd[i]);
253
+ }
254
+ }
255
+ async _updateExtensionsOnExtHosts(versionId, toAdd, toRemove) {
256
+ const removedRunningLocation = this._runningLocations.deltaExtensions(toAdd, toRemove);
257
+ const promises = ( this._extensionHostManagers.map(
258
+ extHostManager => this._updateExtensionsOnExtHost(extHostManager, versionId, toAdd, toRemove, removedRunningLocation)
259
+ ));
260
+ await Promise.all(promises);
261
+ }
262
+ async _updateExtensionsOnExtHost(extensionHostManager, versionId, toAdd, toRemove, removedRunningLocation) {
263
+ const myToAdd = this._runningLocations.filterByExtensionHostManager(toAdd, extensionHostManager);
264
+ const myToRemove = filterExtensionIdentifiers(toRemove, removedRunningLocation, extRunningLocation => extensionHostManager.representsRunningLocation(extRunningLocation));
265
+ const addActivationEvents = ImplicitActivationEvents.createActivationEventsMap(toAdd);
266
+ if (isCI) {
267
+ const printExtIds = (extensions) => ( extensions.map(e => e.identifier.value)).join(',');
268
+ const printIds = (extensions) => ( extensions.map(e => e.value)).join(',');
269
+ this._logService.info(`AbstractExtensionService: Calling deltaExtensions: toRemove: [${printIds(toRemove)}], toAdd: [${printExtIds(toAdd)}], myToRemove: [${printIds(myToRemove)}], myToAdd: [${printExtIds(myToAdd)}],`);
270
+ }
271
+ await extensionHostManager.deltaExtensions({ versionId, toRemove, toAdd, addActivationEvents, myToRemove, myToAdd: ( myToAdd.map(extension => extension.identifier)) });
272
+ }
273
+ canAddExtension(extension) {
274
+ return this._canAddExtension(extension, []);
275
+ }
276
+ _canAddExtension(extension, extensionsBeingRemoved) {
277
+ const existing = this._registry.getExtensionDescriptionByIdOrUUID(extension.identifier, extension.id);
278
+ if (existing) {
279
+ const isBeingRemoved = ( extensionsBeingRemoved.some(
280
+ (extensionDescription) => ExtensionIdentifier.equals(extension.identifier, extensionDescription.identifier)
281
+ ));
282
+ if (!isBeingRemoved) {
283
+ return false;
284
+ }
285
+ }
286
+ const extensionKinds = this._runningLocations.readExtensionKinds(extension);
287
+ const isRemote = extension.extensionLocation.scheme === Schemas.vscodeRemote;
288
+ const extensionHostKind = this._extensionHostKindPicker.pickExtensionHostKind(extension.identifier, extensionKinds, !isRemote, isRemote, 0 );
289
+ if (extensionHostKind === null) {
290
+ return false;
291
+ }
292
+ return true;
293
+ }
294
+ canRemoveExtension(extension) {
295
+ const extensionDescription = this._registry.getExtensionDescription(extension.identifier);
296
+ if (!extensionDescription) {
297
+ return false;
298
+ }
299
+ if (this._extensionStatus.get(extensionDescription.identifier)?.activationStarted) {
300
+ return false;
301
+ }
302
+ return true;
303
+ }
304
+ async _activateAddedExtensionIfNeeded(extensionDescription) {
305
+ let shouldActivate = false;
306
+ let shouldActivateReason = null;
307
+ let hasWorkspaceContains = false;
308
+ const activationEvents = this._activationEventReader.readActivationEvents(extensionDescription);
309
+ for (const activationEvent of activationEvents) {
310
+ if (( this._allRequestedActivateEvents.has(activationEvent))) {
311
+ shouldActivate = true;
312
+ shouldActivateReason = activationEvent;
313
+ break;
314
+ }
315
+ if (activationEvent === '*') {
316
+ shouldActivate = true;
317
+ shouldActivateReason = activationEvent;
318
+ break;
319
+ }
320
+ if (/^workspaceContains/.test(activationEvent)) {
321
+ hasWorkspaceContains = true;
322
+ }
323
+ if (activationEvent === 'onStartupFinished') {
324
+ shouldActivate = true;
325
+ shouldActivateReason = activationEvent;
326
+ break;
327
+ }
328
+ }
329
+ if (shouldActivate) {
330
+ await Promise.all(( this._extensionHostManagers.map(
331
+ extHostManager => extHostManager.activate(extensionDescription.identifier, { startup: false, extensionId: extensionDescription.identifier, activationEvent: shouldActivateReason })
332
+ ))).then(() => { });
333
+ }
334
+ else if (hasWorkspaceContains) {
335
+ const workspace = await this._contextService.getCompleteWorkspace();
336
+ const forceUsingSearch = !!this._environmentService.remoteAuthority;
337
+ const host = {
338
+ logService: this._logService,
339
+ folders: ( workspace.folders.map(folder => folder.uri)),
340
+ forceUsingSearch: forceUsingSearch,
341
+ exists: (uri) => this._fileService.exists(uri),
342
+ checkExists: (folders, includes, token) => this._instantiationService.invokeFunction((accessor) => checkGlobFileExists(accessor, folders, includes, token))
343
+ };
344
+ const result = await checkActivateWorkspaceContainsExtension(host, extensionDescription);
345
+ if (!result) {
346
+ return;
347
+ }
348
+ await Promise.all(( this._extensionHostManagers.map(
349
+ extHostManager => extHostManager.activate(extensionDescription.identifier, { startup: false, extensionId: extensionDescription.identifier, activationEvent: result.activationEvent })
350
+ ))).then(() => { });
351
+ }
352
+ }
353
+ async _initialize() {
354
+ mark('code/willLoadExtensions');
355
+ this._startExtensionHostsIfNecessary(true, []);
356
+ const lock = await this._registry.acquireLock('_initialize');
357
+ try {
358
+ const resolvedExtensions = await this._resolveExtensions();
359
+ this._processExtensions(lock, resolvedExtensions);
360
+ const snapshot = this._registry.getSnapshot();
361
+ for (const extHostManager of this._extensionHostManagers) {
362
+ if (extHostManager.startup !== 1 ) {
363
+ const extensions = this._runningLocations.filterByExtensionHostManager(snapshot.extensions, extHostManager);
364
+ extHostManager.start(snapshot.versionId, snapshot.extensions, ( extensions.map(extension => extension.identifier)));
365
+ }
366
+ }
367
+ }
368
+ finally {
369
+ lock.dispose();
370
+ }
371
+ this._releaseBarrier();
372
+ mark('code/didLoadExtensions');
373
+ await this._handleExtensionTests();
374
+ }
375
+ _processExtensions(lock, resolvedExtensions) {
376
+ const { allowRemoteExtensionsInLocalWebWorker, hasLocalProcess } = resolvedExtensions;
377
+ const localExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.local, false);
378
+ let remoteExtensions = checkEnabledAndProposedAPI(this._logService, this._extensionEnablementService, this._extensionsProposedApi, resolvedExtensions.remote, false);
379
+ this._runningLocations.initializeRunningLocation(localExtensions, remoteExtensions);
380
+ this._startExtensionHostsIfNecessary(true, []);
381
+ const remoteExtensionsThatNeedToRunLocally = (allowRemoteExtensionsInLocalWebWorker ? this._runningLocations.filterByExtensionHostKind(remoteExtensions, 2 ) : []);
382
+ const localProcessExtensions = (hasLocalProcess ? this._runningLocations.filterByExtensionHostKind(localExtensions, 1 ) : []);
383
+ const localWebWorkerExtensions = this._runningLocations.filterByExtensionHostKind(localExtensions, 2 );
384
+ remoteExtensions = this._runningLocations.filterByExtensionHostKind(remoteExtensions, 3 );
385
+ for (const ext of remoteExtensionsThatNeedToRunLocally) {
386
+ if (!includes(localWebWorkerExtensions, ext.identifier)) {
387
+ localWebWorkerExtensions.push(ext);
388
+ }
389
+ }
390
+ const allExtensions = remoteExtensions.concat(localProcessExtensions).concat(localWebWorkerExtensions);
391
+ const result = this._registry.deltaExtensions(lock, allExtensions, []);
392
+ if (result.removedDueToLooping.length > 0) {
393
+ this._notificationService.notify({
394
+ severity: Severity.Error,
395
+ message: ( localizeWithPath(
396
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
397
+ 'looping',
398
+ "The following extensions contain dependency loops and have been disabled: {0}",
399
+ ( result.removedDueToLooping.map(e => `'${e.identifier.value}'`)).join(', ')
400
+ ))
401
+ });
402
+ }
403
+ this._doHandleExtensionPoints(this._registry.getAllExtensionDescriptions());
404
+ }
405
+ async _handleExtensionTests() {
406
+ if (!this._environmentService.isExtensionDevelopment || !this._environmentService.extensionTestsLocationURI) {
407
+ return;
408
+ }
409
+ const extensionHostManager = this.findTestExtensionHost(this._environmentService.extensionTestsLocationURI);
410
+ if (!extensionHostManager) {
411
+ const msg = ( localizeWithPath(
412
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
413
+ 'extensionTestError',
414
+ "No extension host found that can launch the test runner at {0}.",
415
+ ( this._environmentService.extensionTestsLocationURI.toString())
416
+ ));
417
+ console.error(msg);
418
+ this._notificationService.error(msg);
419
+ return;
420
+ }
421
+ let exitCode;
422
+ try {
423
+ exitCode = await extensionHostManager.extensionTestsExecute();
424
+ if (isCI) {
425
+ this._logService.info(`Extension host test runner exit code: ${exitCode}`);
426
+ }
427
+ }
428
+ catch (err) {
429
+ if (isCI) {
430
+ this._logService.error(`Extension host test runner error`, err);
431
+ }
432
+ console.error(err);
433
+ exitCode = 1 ;
434
+ }
435
+ this._onExtensionHostExit(exitCode);
436
+ }
437
+ findTestExtensionHost(testLocation) {
438
+ let runningLocation = null;
439
+ for (const extension of this._registry.getAllExtensionDescriptions()) {
440
+ if (isEqualOrParent(testLocation, extension.extensionLocation)) {
441
+ runningLocation = this._runningLocations.getRunningLocation(extension.identifier);
442
+ break;
443
+ }
444
+ }
445
+ if (runningLocation === null) {
446
+ if (testLocation.scheme === Schemas.vscodeRemote) {
447
+ runningLocation = ( new RemoteRunningLocation());
448
+ }
449
+ else {
450
+ runningLocation = ( new LocalProcessRunningLocation(0));
451
+ }
452
+ }
453
+ if (runningLocation !== null) {
454
+ return this._getExtensionHostManagerByRunningLocation(runningLocation);
455
+ }
456
+ return null;
457
+ }
458
+ _releaseBarrier() {
459
+ this._installedExtensionsReady.open();
460
+ this._onDidRegisterExtensions.fire(undefined);
461
+ this._onDidChangeExtensionsStatus.fire(( this._registry.getAllExtensionDescriptions().map(e => e.identifier)));
462
+ }
463
+ async _resolveAuthorityInitial(remoteAuthority) {
464
+ const MAX_ATTEMPTS = 5;
465
+ for (let attempt = 1;; attempt++) {
466
+ try {
467
+ return this._resolveAuthorityWithLogging(remoteAuthority);
468
+ }
469
+ catch (err) {
470
+ if (RemoteAuthorityResolverError.isNoResolverFound(err)) {
471
+ throw err;
472
+ }
473
+ if (RemoteAuthorityResolverError.isNotAvailable(err)) {
474
+ throw err;
475
+ }
476
+ if (attempt >= MAX_ATTEMPTS) {
477
+ throw err;
478
+ }
479
+ }
480
+ }
481
+ }
482
+ async _resolveAuthorityAgain() {
483
+ const remoteAuthority = this._environmentService.remoteAuthority;
484
+ if (!remoteAuthority) {
485
+ return;
486
+ }
487
+ this._remoteAuthorityResolverService._clearResolvedAuthority(remoteAuthority);
488
+ try {
489
+ const result = await this._resolveAuthorityWithLogging(remoteAuthority);
490
+ this._remoteAuthorityResolverService._setResolvedAuthority(result.authority, result.options);
491
+ }
492
+ catch (err) {
493
+ this._remoteAuthorityResolverService._setResolvedAuthorityError(remoteAuthority, err);
494
+ }
495
+ }
496
+ async _resolveAuthorityWithLogging(remoteAuthority) {
497
+ const authorityPrefix = getRemoteAuthorityPrefix(remoteAuthority);
498
+ const sw = StopWatch.create(false);
499
+ this._logService.info(`Invoking resolveAuthority(${authorityPrefix})...`);
500
+ try {
501
+ mark(`code/willResolveAuthority/${authorityPrefix}`);
502
+ const result = await this._resolveAuthority(remoteAuthority);
503
+ mark(`code/didResolveAuthorityOK/${authorityPrefix}`);
504
+ this._logService.info(`resolveAuthority(${authorityPrefix}) returned '${result.authority.connectTo}' after ${sw.elapsed()} ms`);
505
+ return result;
506
+ }
507
+ catch (err) {
508
+ mark(`code/didResolveAuthorityError/${authorityPrefix}`);
509
+ this._logService.error(`resolveAuthority(${authorityPrefix}) returned an error after ${sw.elapsed()} ms`, err);
510
+ throw err;
511
+ }
512
+ }
513
+ async _resolveAuthorityOnExtensionHosts(kind, remoteAuthority) {
514
+ const extensionHosts = this._getExtensionHostManagers(kind);
515
+ if (extensionHosts.length === 0) {
516
+ throw new Error(`Cannot resolve authority`);
517
+ }
518
+ this._resolveAuthorityAttempt++;
519
+ const results = await Promise.all(( extensionHosts.map(
520
+ extHost => extHost.resolveAuthority(remoteAuthority, this._resolveAuthorityAttempt)
521
+ )));
522
+ let bestErrorResult = null;
523
+ for (const result of results) {
524
+ if (result.type === 'ok') {
525
+ return result.value;
526
+ }
527
+ if (!bestErrorResult) {
528
+ bestErrorResult = result;
529
+ continue;
530
+ }
531
+ const bestErrorIsUnknown = (bestErrorResult.error.code === RemoteAuthorityResolverErrorCode.Unknown);
532
+ const errorIsUnknown = (result.error.code === RemoteAuthorityResolverErrorCode.Unknown);
533
+ if (bestErrorIsUnknown && !errorIsUnknown) {
534
+ bestErrorResult = result;
535
+ }
536
+ }
537
+ throw new RemoteAuthorityResolverError(bestErrorResult.error.message, bestErrorResult.error.code, bestErrorResult.error.detail);
538
+ }
539
+ stopExtensionHosts(reason) {
540
+ return this._doStopExtensionHostsWithVeto(reason);
541
+ }
542
+ _doStopExtensionHosts() {
543
+ const previouslyActivatedExtensionIds = [];
544
+ for (const extensionStatus of ( this._extensionStatus.values())) {
545
+ if (extensionStatus.activationStarted) {
546
+ previouslyActivatedExtensionIds.push(extensionStatus.id);
547
+ }
548
+ }
549
+ for (let i = this._extensionHostManagers.length - 1; i >= 0; i--) {
550
+ this._extensionHostManagers[i].dispose();
551
+ }
552
+ this._extensionHostManagers = [];
553
+ for (const extensionStatus of ( this._extensionStatus.values())) {
554
+ extensionStatus.clearRuntimeStatus();
555
+ }
556
+ if (previouslyActivatedExtensionIds.length > 0) {
557
+ this._onDidChangeExtensionsStatus.fire(previouslyActivatedExtensionIds);
558
+ }
559
+ }
560
+ async _doStopExtensionHostsWithVeto(reason) {
561
+ const vetos = [];
562
+ const vetoReasons = ( new Set());
563
+ this._onWillStop.fire({
564
+ reason,
565
+ veto(value, reason) {
566
+ vetos.push(value);
567
+ if (typeof value === 'boolean') {
568
+ if (value === true) {
569
+ vetoReasons.add(reason);
570
+ }
571
+ }
572
+ else {
573
+ value.then(value => {
574
+ if (value) {
575
+ vetoReasons.add(reason);
576
+ }
577
+ }).catch(error => {
578
+ vetoReasons.add(( localizeWithPath(
579
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
580
+ 'extensionStopVetoError',
581
+ "{0} (Error: {1})",
582
+ reason,
583
+ toErrorMessage(error)
584
+ )));
585
+ });
586
+ }
587
+ }
588
+ });
589
+ const veto = await handleVetos(vetos, error => this._logService.error(error));
590
+ if (!veto) {
591
+ this._doStopExtensionHosts();
592
+ }
593
+ else {
594
+ const vetoReasonsArray = Array.from(vetoReasons);
595
+ this._logService.warn(`Extension host was not stopped because of veto (stop reason: ${reason}, veto reason: ${vetoReasonsArray.join(', ')})`);
596
+ await this._dialogService.warn(( localizeWithPath(
597
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
598
+ 'extensionStopVetoMessage',
599
+ "The following operation was blocked: {0}",
600
+ reason
601
+ )), vetoReasonsArray.length === 1 ?
602
+ ( localizeWithPath(
603
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
604
+ 'extensionStopVetoDetailsOne',
605
+ "The reason for blocking the operation: {0}",
606
+ vetoReasonsArray[0]
607
+ )) :
608
+ ( localizeWithPath(
609
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
610
+ 'extensionStopVetoDetailsMany',
611
+ "The reasons for blocking the operation:\n- {0}",
612
+ vetoReasonsArray.join('\n -')
613
+ )));
614
+ }
615
+ return !veto;
616
+ }
617
+ _startExtensionHostsIfNecessary(isInitialStart, initialActivationEvents) {
618
+ const locations = [];
619
+ for (let affinity = 0; affinity <= this._runningLocations.maxLocalProcessAffinity; affinity++) {
620
+ locations.push(( new LocalProcessRunningLocation(affinity)));
621
+ }
622
+ for (let affinity = 0; affinity <= this._runningLocations.maxLocalWebWorkerAffinity; affinity++) {
623
+ locations.push(( new LocalWebWorkerRunningLocation(affinity)));
624
+ }
625
+ locations.push(( new RemoteRunningLocation()));
626
+ for (const location of locations) {
627
+ if (this._getExtensionHostManagerByRunningLocation(location)) {
628
+ continue;
629
+ }
630
+ const extHostManager = this._createExtensionHostManager(location, isInitialStart, initialActivationEvents);
631
+ if (extHostManager) {
632
+ this._extensionHostManagers.push(extHostManager);
633
+ }
634
+ }
635
+ }
636
+ _createExtensionHostManager(runningLocation, isInitialStart, initialActivationEvents) {
637
+ const extensionHost = this._extensionHostFactory.createExtensionHost(this._runningLocations, runningLocation, isInitialStart);
638
+ if (!extensionHost) {
639
+ return null;
640
+ }
641
+ const processManager = this._doCreateExtensionHostManager(extensionHost, initialActivationEvents);
642
+ processManager.onDidExit(([code, signal]) => this._onExtensionHostCrashOrExit(processManager, code, signal));
643
+ processManager.onDidChangeResponsiveState((responsiveState) => {
644
+ this._logService.info(`Extension host (${processManager.friendyName}) is ${responsiveState === 0 ? 'responsive' : 'unresponsive'}.`);
645
+ this._onDidChangeResponsiveChange.fire({
646
+ extensionHostKind: processManager.kind,
647
+ isResponsive: responsiveState === 0 ,
648
+ getInspectPort: (tryEnableInspector) => {
649
+ return processManager.getInspectPort(tryEnableInspector);
650
+ }
651
+ });
652
+ });
653
+ return processManager;
654
+ }
655
+ _doCreateExtensionHostManager(extensionHost, initialActivationEvents) {
656
+ const internalExtensionService = this._acquireInternalAPI(extensionHost);
657
+ if (extensionHost.startup === 3 && initialActivationEvents.length === 0) {
658
+ return this._instantiationService.createInstance(LazyCreateExtensionHostManager, extensionHost, internalExtensionService);
659
+ }
660
+ return this._instantiationService.createInstance(ExtensionHostManager, extensionHost, initialActivationEvents, internalExtensionService);
661
+ }
662
+ _onExtensionHostCrashOrExit(extensionHost, code, signal) {
663
+ const isExtensionDevHost = parseExtensionDevOptions(this._environmentService).isExtensionDevHost;
664
+ if (!isExtensionDevHost) {
665
+ this._onExtensionHostCrashed(extensionHost, code, signal);
666
+ return;
667
+ }
668
+ this._onExtensionHostExit(code);
669
+ }
670
+ _onExtensionHostCrashed(extensionHost, code, signal) {
671
+ console.error(`Extension host (${extensionHost.friendyName}) terminated unexpectedly. Code: ${code}, Signal: ${signal}`);
672
+ if (extensionHost.kind === 1 ) {
673
+ this._doStopExtensionHosts();
674
+ }
675
+ else if (extensionHost.kind === 3 ) {
676
+ if (signal) {
677
+ this._onRemoteExtensionHostCrashed(extensionHost, signal);
678
+ }
679
+ for (let i = 0; i < this._extensionHostManagers.length; i++) {
680
+ if (this._extensionHostManagers[i] === extensionHost) {
681
+ this._extensionHostManagers[i].dispose();
682
+ this._extensionHostManagers.splice(i, 1);
683
+ break;
684
+ }
685
+ }
686
+ }
687
+ }
688
+ _getExtensionHostExitInfoWithTimeout(reconnectionToken) {
689
+ return ( new Promise((resolve, reject) => {
690
+ const timeoutHandle = setTimeout(() => {
691
+ reject(( new Error('getExtensionHostExitInfo timed out')));
692
+ }, 2000);
693
+ this._remoteAgentService.getExtensionHostExitInfo(reconnectionToken).then((r) => {
694
+ clearTimeout(timeoutHandle);
695
+ resolve(r);
696
+ }, reject);
697
+ }));
698
+ }
699
+ async _onRemoteExtensionHostCrashed(extensionHost, reconnectionToken) {
700
+ try {
701
+ const info = await this._getExtensionHostExitInfoWithTimeout(reconnectionToken);
702
+ if (info) {
703
+ this._logService.error(`Extension host (${extensionHost.friendyName}) terminated unexpectedly with code ${info.code}.`);
704
+ }
705
+ this._logExtensionHostCrash(extensionHost);
706
+ this._remoteCrashTracker.registerCrash();
707
+ if (this._remoteCrashTracker.shouldAutomaticallyRestart()) {
708
+ this._logService.info(`Automatically restarting the remote extension host.`);
709
+ this._notificationService.status(( localizeWithPath(
710
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
711
+ 'extensionService.autoRestart',
712
+ "The remote extension host terminated unexpectedly. Restarting..."
713
+ )), { hideAfter: 5000 });
714
+ this._startExtensionHostsIfNecessary(false, Array.from(( this._allRequestedActivateEvents.keys())));
715
+ }
716
+ else {
717
+ this._notificationService.prompt(Severity.Error, ( localizeWithPath(
718
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
719
+ 'extensionService.crash',
720
+ "Remote Extension host terminated unexpectedly 3 times within the last 5 minutes."
721
+ )), [{
722
+ label: ( localizeWithPath(
723
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
724
+ 'restart',
725
+ "Restart Remote Extension Host"
726
+ )),
727
+ run: () => {
728
+ this._startExtensionHostsIfNecessary(false, Array.from(( this._allRequestedActivateEvents.keys())));
729
+ }
730
+ }]);
731
+ }
732
+ }
733
+ catch (err) {
734
+ }
735
+ }
736
+ _logExtensionHostCrash(extensionHost) {
737
+ const activatedExtensions = [];
738
+ for (const extensionStatus of ( this._extensionStatus.values())) {
739
+ if (extensionStatus.activationStarted && extensionHost.containsExtension(extensionStatus.id)) {
740
+ activatedExtensions.push(extensionStatus.id);
741
+ }
742
+ }
743
+ if (activatedExtensions.length > 0) {
744
+ this._logService.error(`Extension host (${extensionHost.friendyName}) terminated unexpectedly. The following extensions were running: ${( activatedExtensions.map(id => id.value)).join(', ')}`);
745
+ }
746
+ else {
747
+ this._logService.error(`Extension host (${extensionHost.friendyName}) terminated unexpectedly. No extensions were activated.`);
748
+ }
749
+ }
750
+ async startExtensionHosts(updates) {
751
+ this._doStopExtensionHosts();
752
+ if (updates) {
753
+ await this._handleDeltaExtensions(( new DeltaExtensionsQueueItem(updates.toAdd, updates.toRemove)));
754
+ }
755
+ const lock = await this._registry.acquireLock('startExtensionHosts');
756
+ try {
757
+ this._startExtensionHostsIfNecessary(false, Array.from(( this._allRequestedActivateEvents.keys())));
758
+ const localProcessExtensionHosts = this._getExtensionHostManagers(1 );
759
+ await Promise.all(( localProcessExtensionHosts.map(extHost => extHost.ready())));
760
+ }
761
+ finally {
762
+ lock.dispose();
763
+ }
764
+ }
765
+ activateByEvent(activationEvent, activationKind = 0 ) {
766
+ if (this._installedExtensionsReady.isOpen()) {
767
+ this._allRequestedActivateEvents.add(activationEvent);
768
+ if (!this._registry.containsActivationEvent(activationEvent)) {
769
+ return NO_OP_VOID_PROMISE;
770
+ }
771
+ return this._activateByEvent(activationEvent, activationKind);
772
+ }
773
+ else {
774
+ this._allRequestedActivateEvents.add(activationEvent);
775
+ if (activationKind === 1 ) {
776
+ return this._activateByEvent(activationEvent, activationKind);
777
+ }
778
+ return this._installedExtensionsReady.wait().then(() => this._activateByEvent(activationEvent, activationKind));
779
+ }
780
+ }
781
+ _activateByEvent(activationEvent, activationKind) {
782
+ const result = Promise.all(( this._extensionHostManagers.map(
783
+ extHostManager => extHostManager.activateByEvent(activationEvent, activationKind)
784
+ ))).then(() => { });
785
+ this._onWillActivateByEvent.fire({
786
+ event: activationEvent,
787
+ activation: result
788
+ });
789
+ return result;
790
+ }
791
+ activateById(extensionId, reason) {
792
+ return this._activateById(extensionId, reason);
793
+ }
794
+ activationEventIsDone(activationEvent) {
795
+ if (!this._installedExtensionsReady.isOpen()) {
796
+ return false;
797
+ }
798
+ if (!this._registry.containsActivationEvent(activationEvent)) {
799
+ return true;
800
+ }
801
+ return this._extensionHostManagers.every(manager => manager.activationEventIsDone(activationEvent));
802
+ }
803
+ whenInstalledExtensionsRegistered() {
804
+ return this._installedExtensionsReady.wait();
805
+ }
806
+ get extensions() {
807
+ return this._registry.getAllExtensionDescriptions();
808
+ }
809
+ _getExtensionRegistrySnapshotWhenReady() {
810
+ return this._installedExtensionsReady.wait().then(() => this._registry.getSnapshot());
811
+ }
812
+ getExtension(id) {
813
+ return this._installedExtensionsReady.wait().then(() => {
814
+ return this._registry.getExtensionDescription(id);
815
+ });
816
+ }
817
+ readExtensionPointContributions(extPoint) {
818
+ return this._installedExtensionsReady.wait().then(() => {
819
+ const availableExtensions = this._registry.getAllExtensionDescriptions();
820
+ const result = [];
821
+ for (const desc of availableExtensions) {
822
+ if (desc.contributes && hasOwnProperty.call(desc.contributes, extPoint.name)) {
823
+ result.push(( new ExtensionPointContribution(desc, desc.contributes[extPoint.name])));
824
+ }
825
+ }
826
+ return result;
827
+ });
828
+ }
829
+ getExtensionsStatus() {
830
+ const result = Object.create(null);
831
+ if (this._registry) {
832
+ const extensions = this._registry.getAllExtensionDescriptions();
833
+ for (const extension of extensions) {
834
+ const extensionStatus = this._extensionStatus.get(extension.identifier);
835
+ result[extension.identifier.value] = {
836
+ id: extension.identifier,
837
+ messages: extensionStatus?.messages ?? [],
838
+ activationStarted: extensionStatus?.activationStarted ?? false,
839
+ activationTimes: extensionStatus?.activationTimes ?? undefined,
840
+ runtimeErrors: extensionStatus?.runtimeErrors ?? [],
841
+ runningLocation: this._runningLocations.getRunningLocation(extension.identifier),
842
+ };
843
+ }
844
+ }
845
+ return result;
846
+ }
847
+ async getInspectPorts(extensionHostKind, tryEnableInspector) {
848
+ const result = await Promise.all(( this._getExtensionHostManagers(extensionHostKind).map(extHost => extHost.getInspectPort(tryEnableInspector))));
849
+ return result.filter(element => Boolean(element));
850
+ }
851
+ async setRemoteEnvironment(env) {
852
+ await ( this._extensionHostManagers
853
+ .map(manager => manager.setRemoteEnvironment(env)));
854
+ }
855
+ _safeInvokeIsEnabled(extension) {
856
+ try {
857
+ return this._extensionEnablementService.isEnabled(extension);
858
+ }
859
+ catch (err) {
860
+ return false;
861
+ }
862
+ }
863
+ _doHandleExtensionPoints(affectedExtensions) {
864
+ const affectedExtensionPoints = Object.create(null);
865
+ for (const extensionDescription of affectedExtensions) {
866
+ if (extensionDescription.contributes) {
867
+ for (const extPointName in extensionDescription.contributes) {
868
+ if (hasOwnProperty.call(extensionDescription.contributes, extPointName)) {
869
+ affectedExtensionPoints[extPointName] = true;
870
+ }
871
+ }
872
+ }
873
+ }
874
+ const messageHandler = (msg) => this._handleExtensionPointMessage(msg);
875
+ const availableExtensions = this._registry.getAllExtensionDescriptions();
876
+ const extensionPoints = ExtensionsRegistry.getExtensionPoints();
877
+ mark('code/willHandleExtensionPoints');
878
+ for (const extensionPoint of extensionPoints) {
879
+ if (affectedExtensionPoints[extensionPoint.name]) {
880
+ mark(`code/willHandleExtensionPoint/${extensionPoint.name}`);
881
+ AbstractExtensionService_1._handleExtensionPoint(extensionPoint, availableExtensions, messageHandler);
882
+ mark(`code/didHandleExtensionPoint/${extensionPoint.name}`);
883
+ }
884
+ }
885
+ mark('code/didHandleExtensionPoints');
886
+ }
887
+ _getOrCreateExtensionStatus(extensionId) {
888
+ if (!( this._extensionStatus.has(extensionId))) {
889
+ this._extensionStatus.set(extensionId, ( new ExtensionStatus(extensionId)));
890
+ }
891
+ return this._extensionStatus.get(extensionId);
892
+ }
893
+ _handleExtensionPointMessage(msg) {
894
+ const extensionStatus = this._getOrCreateExtensionStatus(msg.extensionId);
895
+ extensionStatus.addMessage(msg);
896
+ const extension = this._registry.getExtensionDescription(msg.extensionId);
897
+ const strMsg = `[${msg.extensionId.value}]: ${msg.message}`;
898
+ if (msg.type === Severity.Error) {
899
+ if (extension && extension.isUnderDevelopment) {
900
+ this._notificationService.notify({ severity: Severity.Error, message: strMsg });
901
+ }
902
+ this._logService.error(strMsg);
903
+ }
904
+ else if (msg.type === Severity.Warning) {
905
+ if (extension && extension.isUnderDevelopment) {
906
+ this._notificationService.notify({ severity: Severity.Warning, message: strMsg });
907
+ }
908
+ this._logService.warn(strMsg);
909
+ }
910
+ else {
911
+ this._logService.info(strMsg);
912
+ }
913
+ if (msg.extensionId && this._environmentService.isBuilt && !this._environmentService.isExtensionDevelopment) {
914
+ const { type, extensionId, extensionPointId, message } = msg;
915
+ this._telemetryService.publicLog2('extensionsMessage', {
916
+ type, extensionId: extensionId.value, extensionPointId, message
917
+ });
918
+ }
919
+ }
920
+ static _handleExtensionPoint(extensionPoint, availableExtensions, messageHandler) {
921
+ const users = [];
922
+ for (const desc of availableExtensions) {
923
+ if (desc.contributes && hasOwnProperty.call(desc.contributes, extensionPoint.name)) {
924
+ users.push({
925
+ description: desc,
926
+ value: desc.contributes[extensionPoint.name],
927
+ collector: ( new ExtensionMessageCollector(messageHandler, desc, extensionPoint.name))
928
+ });
929
+ }
930
+ }
931
+ extensionPoint.acceptUsers(users);
932
+ }
933
+ _acquireInternalAPI(extensionHost) {
934
+ return {
935
+ _activateById: (extensionId, reason) => {
936
+ return this._activateById(extensionId, reason);
937
+ },
938
+ _onWillActivateExtension: (extensionId) => {
939
+ return this._onWillActivateExtension(extensionId, extensionHost.runningLocation);
940
+ },
941
+ _onDidActivateExtension: (extensionId, codeLoadingTime, activateCallTime, activateResolvedTime, activationReason) => {
942
+ return this._onDidActivateExtension(extensionId, codeLoadingTime, activateCallTime, activateResolvedTime, activationReason);
943
+ },
944
+ _onDidActivateExtensionError: (extensionId, error) => {
945
+ return this._onDidActivateExtensionError(extensionId, error);
946
+ },
947
+ _onExtensionRuntimeError: (extensionId, err) => {
948
+ return this._onExtensionRuntimeError(extensionId, err);
949
+ }
950
+ };
951
+ }
952
+ async _activateById(extensionId, reason) {
953
+ const results = await Promise.all(( this._extensionHostManagers.map(manager => manager.activate(extensionId, reason))));
954
+ const activated = ( results.some(e => e));
955
+ if (!activated) {
956
+ throw new Error(`Unknown extension ${extensionId.value}`);
957
+ }
958
+ }
959
+ _onWillActivateExtension(extensionId, runningLocation) {
960
+ this._runningLocations.set(extensionId, runningLocation);
961
+ const extensionStatus = this._getOrCreateExtensionStatus(extensionId);
962
+ extensionStatus.onWillActivate();
963
+ }
964
+ _onDidActivateExtension(extensionId, codeLoadingTime, activateCallTime, activateResolvedTime, activationReason) {
965
+ const extensionStatus = this._getOrCreateExtensionStatus(extensionId);
966
+ extensionStatus.setActivationTimes(( new ActivationTimes(codeLoadingTime, activateCallTime, activateResolvedTime, activationReason)));
967
+ this._onDidChangeExtensionsStatus.fire([extensionId]);
968
+ }
969
+ _onDidActivateExtensionError(extensionId, error) {
970
+ this._telemetryService.publicLog2('extensionActivationError', {
971
+ extensionId: extensionId.value,
972
+ error: error.message
973
+ });
974
+ }
975
+ _onExtensionRuntimeError(extensionId, err) {
976
+ const extensionStatus = this._getOrCreateExtensionStatus(extensionId);
977
+ extensionStatus.addRuntimeError(err);
978
+ this._onDidChangeExtensionsStatus.fire([extensionId]);
979
+ }
980
+ };
981
+ AbstractExtensionService = AbstractExtensionService_1 = ( __decorate([
982
+ ( __param(3, IInstantiationService)),
983
+ ( __param(4, INotificationService)),
984
+ ( __param(5, IWorkbenchEnvironmentService)),
985
+ ( __param(6, ITelemetryService)),
986
+ ( __param(7, IWorkbenchExtensionEnablementService)),
987
+ ( __param(8, IFileService)),
988
+ ( __param(9, IProductService)),
989
+ ( __param(10, IWorkbenchExtensionManagementService)),
990
+ ( __param(11, IWorkspaceContextService)),
991
+ ( __param(12, IConfigurationService)),
992
+ ( __param(13, IExtensionManifestPropertiesService)),
993
+ ( __param(14, ILogService)),
994
+ ( __param(15, IRemoteAgentService)),
995
+ ( __param(16, IRemoteExtensionsScannerService)),
996
+ ( __param(17, ILifecycleService)),
997
+ ( __param(18, IRemoteAuthorityResolverService)),
998
+ ( __param(19, IDialogService))
999
+ ], AbstractExtensionService));
1000
+ class ResolvedExtensions {
1001
+ constructor(local, remote, hasLocalProcess, allowRemoteExtensionsInLocalWebWorker) {
1002
+ this.local = local;
1003
+ this.remote = remote;
1004
+ this.hasLocalProcess = hasLocalProcess;
1005
+ this.allowRemoteExtensionsInLocalWebWorker = allowRemoteExtensionsInLocalWebWorker;
1006
+ }
1007
+ }
1008
+ class DeltaExtensionsQueueItem {
1009
+ constructor(toAdd, toRemove) {
1010
+ this.toAdd = toAdd;
1011
+ this.toRemove = toRemove;
1012
+ }
1013
+ }
1014
+ function checkEnabledAndProposedAPI(logService, extensionEnablementService, extensionsProposedApi, extensions, ignoreWorkspaceTrust) {
1015
+ extensionsProposedApi.updateEnabledApiProposals(extensions);
1016
+ return filterEnabledExtensions(logService, extensionEnablementService, extensions, ignoreWorkspaceTrust);
1017
+ }
1018
+ function filterEnabledExtensions(logService, extensionEnablementService, extensions, ignoreWorkspaceTrust) {
1019
+ const enabledExtensions = [], extensionsToCheck = [], mappedExtensions = [];
1020
+ for (const extension of extensions) {
1021
+ if (extension.isUnderDevelopment) {
1022
+ enabledExtensions.push(extension);
1023
+ }
1024
+ else {
1025
+ extensionsToCheck.push(extension);
1026
+ mappedExtensions.push(toExtension(extension));
1027
+ }
1028
+ }
1029
+ const enablementStates = extensionEnablementService.getEnablementStates(mappedExtensions, ignoreWorkspaceTrust ? { trusted: true } : undefined);
1030
+ for (let index = 0; index < enablementStates.length; index++) {
1031
+ if (extensionEnablementService.isEnabledEnablementState(enablementStates[index])) {
1032
+ enabledExtensions.push(extensionsToCheck[index]);
1033
+ }
1034
+ else {
1035
+ if (isCI) {
1036
+ logService.info(`filterEnabledExtensions: extension '${extensionsToCheck[index].identifier.value}' is disabled`);
1037
+ }
1038
+ }
1039
+ }
1040
+ return enabledExtensions;
1041
+ }
1042
+ function includes(extensions, identifier) {
1043
+ for (const extension of extensions) {
1044
+ if (ExtensionIdentifier.equals(extension.identifier, identifier)) {
1045
+ return true;
1046
+ }
1047
+ }
1048
+ return false;
1049
+ }
1050
+ class ExtensionStatus {
1051
+ get messages() {
1052
+ return this._messages;
1053
+ }
1054
+ get activationTimes() {
1055
+ return this._activationTimes;
1056
+ }
1057
+ get runtimeErrors() {
1058
+ return this._runtimeErrors;
1059
+ }
1060
+ get activationStarted() {
1061
+ return this._activationStarted;
1062
+ }
1063
+ constructor(id) {
1064
+ this.id = id;
1065
+ this._messages = [];
1066
+ this._activationTimes = null;
1067
+ this._runtimeErrors = [];
1068
+ this._activationStarted = false;
1069
+ }
1070
+ clearRuntimeStatus() {
1071
+ this._activationStarted = false;
1072
+ this._activationTimes = null;
1073
+ this._runtimeErrors = [];
1074
+ }
1075
+ addMessage(msg) {
1076
+ this._messages.push(msg);
1077
+ }
1078
+ setActivationTimes(activationTimes) {
1079
+ this._activationTimes = activationTimes;
1080
+ }
1081
+ addRuntimeError(err) {
1082
+ this._runtimeErrors.push(err);
1083
+ }
1084
+ onWillActivate() {
1085
+ this._activationStarted = true;
1086
+ }
1087
+ }
1088
+ class ExtensionHostCrashTracker {
1089
+ constructor() {
1090
+ this._recentCrashes = [];
1091
+ }
1092
+ static { this._TIME_LIMIT = 5 * 60 * 1000; }
1093
+ static { this._CRASH_LIMIT = 3; }
1094
+ _removeOldCrashes() {
1095
+ const limit = Date.now() - ExtensionHostCrashTracker._TIME_LIMIT;
1096
+ while (this._recentCrashes.length > 0 && this._recentCrashes[0].timestamp < limit) {
1097
+ this._recentCrashes.shift();
1098
+ }
1099
+ }
1100
+ registerCrash() {
1101
+ this._removeOldCrashes();
1102
+ this._recentCrashes.push({ timestamp: Date.now() });
1103
+ }
1104
+ shouldAutomaticallyRestart() {
1105
+ this._removeOldCrashes();
1106
+ return (this._recentCrashes.length < ExtensionHostCrashTracker._CRASH_LIMIT);
1107
+ }
1108
+ }
1109
+ class ImplicitActivationAwareReader {
1110
+ readActivationEvents(extensionDescription) {
1111
+ return ImplicitActivationEvents.readActivationEvents(extensionDescription);
1112
+ }
1113
+ }
1114
+ class ActivationFeatureMarkdowneRenderer extends Disposable {
1115
+ constructor() {
1116
+ super(...arguments);
1117
+ this.type = 'markdown';
1118
+ }
1119
+ shouldRender(manifest) {
1120
+ return !!manifest.activationEvents;
1121
+ }
1122
+ render(manifest) {
1123
+ const activationEvents = manifest.activationEvents || [];
1124
+ const data = ( new MarkdownString());
1125
+ if (activationEvents.length) {
1126
+ for (const activationEvent of activationEvents) {
1127
+ data.appendMarkdown(`- \`${activationEvent}\`\n`);
1128
+ }
1129
+ }
1130
+ return {
1131
+ data,
1132
+ dispose: () => { }
1133
+ };
1134
+ }
1135
+ }
1136
+ ( Registry.as(Extensions.ExtensionFeaturesRegistry)).registerExtensionFeature({
1137
+ id: 'activationEvents',
1138
+ label: ( localizeWithPath(
1139
+ 'vs/workbench/services/extensions/common/abstractExtensionService',
1140
+ 'activation',
1141
+ "Activation Events"
1142
+ )),
1143
+ access: {
1144
+ canToggle: false
1145
+ },
1146
+ renderer: ( new SyncDescriptor(ActivationFeatureMarkdowneRenderer)),
1147
+ });
1148
+
1149
+ export { AbstractExtensionService, DeltaExtensionsQueueItem, ExtensionHostCrashTracker, ExtensionStatus, ImplicitActivationAwareReader, ResolvedExtensions, checkEnabledAndProposedAPI, filterEnabledExtensions };