diff --git a/src/vs/workbench/api/browser/viewsExtensionPoint.ts b/src/vs/workbench/api/browser/viewsExtensionPoint.ts index c90faec496b..4ad9fee8a91 100644 --- a/src/vs/workbench/api/browser/viewsExtensionPoint.ts +++ b/src/vs/workbench/api/browser/viewsExtensionPoint.ts @@ -405,7 +405,7 @@ class ViewsExtensionHandler implements IWorkbenchContribution { return; } - if (entry.key === 'remote' && !isProposedApiEnabled(extension.description)) { + if (entry.key === 'remote' && !isProposedApiEnabled(extension.description, undefined)) { collector.warn(localize('ViewContainerRequiresProposedAPI', "View container '{0}' requires 'enableProposedApi' turned on to be added to 'Remote'.", entry.key)); return; } diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 96e3f393275..6f343668646 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -228,13 +228,13 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I const authentication: typeof vscode.authentication = { getSession(providerId: string, scopes: readonly string[], options?: vscode.AuthenticationGetSessionOptions) { if (options?.forceNewSession) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'authSession'); } return extHostAuthentication.getSession(extension, providerId, scopes, options as any); }, // TODO: remove this after GHPR and Codespaces move off of it async hasSession(providerId: string, scopes: readonly string[]) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'authSession'); return !!(await extHostAuthentication.getSession(extension, providerId, scopes, { silent: true } as any)); }, get onDidChangeSessions(): Event { @@ -600,7 +600,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return >extHostMessageService.showMessage(extension, Severity.Error, message, rest[0], >rest.slice(1)); }, showQuickPick(items: any, options?: vscode.QuickPickOptions, token?: vscode.CancellationToken): any { - return extHostQuickOpen.showQuickPick(items, isProposedApiEnabled(extension), options, token); + return extHostQuickOpen.showQuickPick(items, isProposedApiEnabled(extension, undefined), options, token); }, showWorkspaceFolderPick(options?: vscode.WorkspaceFolderPickOptions) { return extHostQuickOpen.showWorkspaceFolderPick(options); @@ -689,7 +689,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostUrls.registerUriHandler(extension.identifier, handler); }, createQuickPick(): vscode.QuickPick { - return extHostQuickOpen.createQuickPick(extension.identifier, isProposedApiEnabled(extension)); + return extHostQuickOpen.createQuickPick(extension.identifier, isProposedApiEnabled(extension, undefined)); }, createInputBox(): vscode.InputBox { return extHostQuickOpen.createInputBox(extension.identifier); @@ -1102,7 +1102,7 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostNotebook.registerNotebookCellStatusBarItemProvider(extension, notebookType, provider); }, get onDidSaveNotebookDocument(): Event { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'notebookEditor'); return extHostNotebookDocuments.onDidSaveNotebookDocument; }, createNotebookEditorDecorationType(options: vscode.NotebookDecorationRenderOptions): vscode.NotebookEditorDecorationType { @@ -1113,11 +1113,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostNotebookRenderers.createRendererMessaging(extension, rendererId); }, onDidChangeNotebookDocumentMetadata(listener, thisArgs?, disposables?) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'notebookEditor'); return extHostNotebookDocuments.onDidChangeNotebookDocumentMetadata(listener, thisArgs, disposables); }, onDidChangeNotebookCells(listener, thisArgs?, disposables?) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'notebookEditor'); return extHostNotebook.onDidChangeNotebookCells(listener, thisArgs, disposables); }, onDidChangeNotebookCellExecutionState(listener, thisArgs?, disposables?) { @@ -1125,11 +1125,11 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I return extHostNotebook.onDidChangeNotebookCellExecutionState(listener, thisArgs, disposables); }, onDidChangeCellOutputs(listener, thisArgs?, disposables?) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'notebookEditor'); return extHostNotebook.onDidChangeCellOutputs(listener, thisArgs, disposables); }, onDidChangeCellMetadata(listener, thisArgs?, disposables?) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'notebookEditor'); return extHostNotebook.onDidChangeCellMetadata(listener, thisArgs, disposables); }, createConcatTextDocument(notebook, selector) { diff --git a/src/vs/workbench/api/common/extHostMessageService.ts b/src/vs/workbench/api/common/extHostMessageService.ts index 9f36d8dd3ac..be719110986 100644 --- a/src/vs/workbench/api/common/extHostMessageService.ts +++ b/src/vs/workbench/api/common/extHostMessageService.ts @@ -44,7 +44,7 @@ export class ExtHostMessageService { } if (options.useCustom) { - checkProposedApiEnabled(extension); + checkProposedApiEnabled(extension, 'resolvers'); } const commands: { title: string; isCloseAffordance: boolean; handle: number; }[] = []; diff --git a/src/vs/workbench/api/common/extHostNotebookRenderers.ts b/src/vs/workbench/api/common/extHostNotebookRenderers.ts index c217759d9bd..3cc008e1010 100644 --- a/src/vs/workbench/api/common/extHostNotebookRenderers.ts +++ b/src/vs/workbench/api/common/extHostNotebookRenderers.ts @@ -32,7 +32,7 @@ export class ExtHostNotebookRenderers implements ExtHostNotebookRenderersShape { // In the stable API, the editor is given as an empty object, and this map // is used to maintain references. This can be removed after editor finalization. - const notebookEditorVisible = isProposedApiEnabled(manifest); + const notebookEditorVisible = isProposedApiEnabled(manifest, 'notebookEditor'); const notebookEditorAliases = new WeakMap<{}, vscode.NotebookEditor>(); const messaging: vscode.NotebookRendererMessaging = { diff --git a/src/vs/workbench/api/common/extHostSCM.ts b/src/vs/workbench/api/common/extHostSCM.ts index 306e7e373f8..574976beb09 100644 --- a/src/vs/workbench/api/common/extHostSCM.ts +++ b/src/vs/workbench/api/common/extHostSCM.ts @@ -502,7 +502,7 @@ class ExtHostSourceControl implements vscode.SourceControl { private _actionButtonDisposables = new MutableDisposable(); private _actionButton: vscode.Command | undefined; get actionButton(): vscode.Command | undefined { - checkProposedApiEnabled(this._extension); + checkProposedApiEnabled(this._extension, 'scmActionButton'); return this._actionButton; } set actionButton(actionButton: vscode.Command | undefined) { diff --git a/src/vs/workbench/api/common/menusExtensionPoint.ts b/src/vs/workbench/api/common/menusExtensionPoint.ts index 82999144a2e..5ee2881e6f8 100644 --- a/src/vs/workbench/api/common/menusExtensionPoint.ts +++ b/src/vs/workbench/api/common/menusExtensionPoint.ts @@ -634,7 +634,7 @@ commandsExtensionPoint.setHandler(extensions => { title, source: extension.description.displayName ?? extension.description.name, shortTitle, - tooltip: isProposedApiEnabled(extension.description) ? title : undefined, + tooltip: isProposedApiEnabled(extension.description, undefined) ? title : undefined, category, precondition: ContextKeyExpr.deserialize(enablement), icon: absoluteIcon @@ -764,7 +764,7 @@ menusExtensionPoint.setHandler(extensions => { return; } - if (menu.proposed && !isProposedApiEnabled(extension.description)) { + if (menu.proposed && !isProposedApiEnabled(extension.description, undefined)) { collector.error(localize('proposedAPI.invalid', "{0} is a proposed menu identifier and is only available when running out of dev or with the following command line switch: --enable-proposed-api {1}", entry.key, extension.description.identifier.value)); return; } diff --git a/src/vs/workbench/contrib/remote/browser/remote.ts b/src/vs/workbench/contrib/remote/browser/remote.ts index 4d48e2e58ca..dff2881e612 100644 --- a/src/vs/workbench/contrib/remote/browser/remote.ts +++ b/src/vs/workbench/contrib/remote/browser/remote.ts @@ -498,7 +498,7 @@ export class RemoteViewPaneContainer extends FilterViewPaneContainer implements } private _handleRemoteInfoExtensionPoint(extension: IExtensionPointUser, helpInformation: HelpInformation[]) { - if (!isProposedApiEnabled(extension.description)) { + if (!isProposedApiEnabled(extension.description, undefined)) { return; } diff --git a/src/vs/workbench/contrib/welcome/common/viewsWelcomeContribution.ts b/src/vs/workbench/contrib/welcome/common/viewsWelcomeContribution.ts index da5323be01f..b9a713343c4 100644 --- a/src/vs/workbench/contrib/welcome/common/viewsWelcomeContribution.ts +++ b/src/vs/workbench/contrib/welcome/common/viewsWelcomeContribution.ts @@ -73,7 +73,7 @@ function parseGroupAndOrder(welcome: ViewWelcome, contribution: IExtensionPointU let group: string | undefined; let order: number | undefined; if (welcome.group) { - if (!isProposedApiEnabled(contribution.description)) { + if (!isProposedApiEnabled(contribution.description, undefined)) { contribution.collector.warn(nls.localize('ViewsWelcomeExtensionPoint.proposedAPI', "The viewsWelcome contribution in '{0}' requires 'enableProposedApi' to be enabled.", contribution.description.identifier.value)); return { group, order }; } diff --git a/src/vs/workbench/services/extensions/common/extensions.ts b/src/vs/workbench/services/extensions/common/extensions.ts index 912c8b55818..02ab47e2c30 100644 --- a/src/vs/workbench/services/extensions/common/extensions.ts +++ b/src/vs/workbench/services/extensions/common/extensions.ts @@ -134,7 +134,7 @@ export interface IExtensionHost { dispose(): void; } -export function isProposedApiEnabled(extension: IExtensionDescription, proposal?: ApiProposalName): boolean { +export function isProposedApiEnabled(extension: IExtensionDescription, proposal: ApiProposalName | undefined): boolean { if (!proposal) { return Boolean(extension.enableProposedApi); } @@ -144,7 +144,7 @@ export function isProposedApiEnabled(extension: IExtensionDescription, proposal? return Boolean(extension.enableProposedApi); } -export function checkProposedApiEnabled(extension: IExtensionDescription, proposal?: ApiProposalName): void { +export function checkProposedApiEnabled(extension: IExtensionDescription, proposal: ApiProposalName | undefined): void { if (!isProposedApiEnabled(extension, proposal)) { throw new Error(`[${extension.identifier.value}]: Proposed API is only available when running out of dev or with the following command line switch: --enable-proposed-api ${extension.identifier.value}`); } diff --git a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts index 8f8a4ee8d24..f60c1461dee 100644 --- a/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts +++ b/src/vs/workbench/services/extensions/common/extensionsApiProposals.ts @@ -6,6 +6,7 @@ // THIS IS A GENERATED FILE. DO NOT EDIT DIRECTLY. export const allApiProposals = Object.freeze({ + authSession: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.authSession.d.ts', customEditorMove: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.customEditorMove.d.ts', diffCommand: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.diffCommand.d.ts', documentFiltersExclusive: 'https://raw.githubusercontent.com/microsoft/vscode/main/src/vscode-dts/vscode.proposed.documentFiltersExclusive.d.ts', diff --git a/src/vs/workbench/services/extensions/node/proxyResolver.ts b/src/vs/workbench/services/extensions/node/proxyResolver.ts index 9c29c7d2b55..ac2ea9c022c 100644 --- a/src/vs/workbench/services/extensions/node/proxyResolver.ts +++ b/src/vs/workbench/services/extensions/node/proxyResolver.ts @@ -130,7 +130,7 @@ function configureModuleLoading(extensionService: ExtHostExtensionService, looku } if (!cache[request]) { let mod = modules.default; - if (ext && isProposedApiEnabled(ext)) { + if (ext && isProposedApiEnabled(ext, undefined)) { mod = (modules as any)[(ext).proxySupport] || modules.onRequest; } cache[request] = { ...mod }; // Copy to work around #93167. diff --git a/src/vs/workbench/services/label/common/labelService.ts b/src/vs/workbench/services/label/common/labelService.ts index 15252f0546e..509be770cf7 100644 --- a/src/vs/workbench/services/label/common/labelService.ts +++ b/src/vs/workbench/services/label/common/labelService.ts @@ -84,7 +84,7 @@ class ResourceLabelFormattersHandler implements IWorkbenchContribution { constructor(@ILabelService labelService: ILabelService) { resourceLabelFormattersExtPoint.setHandler((extensions, delta) => { delta.added.forEach(added => added.value.forEach(formatter => { - if (!isProposedApiEnabled(added.description) && formatter.formatting.workspaceTooltip) { + if (!isProposedApiEnabled(added.description, undefined) && formatter.formatting.workspaceTooltip) { // workspaceTooltip is only proposed formatter.formatting.workspaceTooltip = undefined; } diff --git a/src/vs/workbench/services/themes/common/iconExtensionPoint.ts b/src/vs/workbench/services/themes/common/iconExtensionPoint.ts index cfee6d8370b..addcda618e8 100644 --- a/src/vs/workbench/services/themes/common/iconExtensionPoint.ts +++ b/src/vs/workbench/services/themes/common/iconExtensionPoint.ts @@ -126,7 +126,7 @@ export class IconExtensionPoint { const extensionValue = extension.value; const collector = extension.collector; - if (!isProposedApiEnabled(extension.description)) { + if (!isProposedApiEnabled(extension.description, undefined)) { collector.error(nls.localize('invalid.icons.proposedAPI', "'configuration.icons is a proposed contribution point and only available when running out of dev or with the following command line switch: --enable-proposed-api {0}", extension.description.identifier.value)); return; } @@ -180,7 +180,7 @@ export class IconFontExtensionPoint { const extensionValue = extension.value; const collector = extension.collector; - if (!isProposedApiEnabled(extension.description)) { + if (!isProposedApiEnabled(extension.description, undefined)) { collector.error(nls.localize('invalid.iconFonts.proposedAPI', "'configuration.iconFonts is a proposed contribution point and only available when running out of dev or with the following command line switch: --enable-proposed-api {0}", extension.description.identifier.value)); return; } diff --git a/src/vscode-dts/vscode.proposed.authSession.d.ts b/src/vscode-dts/vscode.proposed.authSession.d.ts new file mode 100644 index 00000000000..a3e593d4224 --- /dev/null +++ b/src/vscode-dts/vscode.proposed.authSession.d.ts @@ -0,0 +1,40 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +declare module 'vscode' { + + /** + * More options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}. + */ + export interface AuthenticationGetSessionOptions { + /** + * Whether we should attempt to reauthenticate even if there is already a session available. + * + * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios + * where the token needs to be re minted because it has lost some authorization. + * + * Defaults to false. + */ + forceNewSession?: boolean | { detail: string }; + } + + export namespace authentication { + /** + * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not + * registered, or if the user does not consent to sharing authentication information with + * the extension. If there are multiple sessions with the same scopes, the user will be shown a + * quickpick to select which account they would like to use. + * + * Currently, there are only two authentication providers that are contributed from built in extensions + * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'. + * @param providerId The id of the provider to use + * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider + * @param options The {@link AuthenticationGetSessionOptions} to use + * @returns A thenable that resolves to an authentication session + */ + export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true | { detail: string } }): Thenable; + export function hasSession(providerId: string, scopes: readonly string[]): Thenable; + } +} diff --git a/src/vscode-dts/vscode.proposed.resolvers.d.ts b/src/vscode-dts/vscode.proposed.resolvers.d.ts index a73316c11a8..9847b67bac3 100644 --- a/src/vscode-dts/vscode.proposed.resolvers.d.ts +++ b/src/vscode-dts/vscode.proposed.resolvers.d.ts @@ -159,39 +159,6 @@ declare module 'vscode' { candidatePortSource?: CandidatePortSource; } - /** - * More options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}. - */ - export interface AuthenticationGetSessionOptions { - /** - * Whether we should attempt to reauthenticate even if there is already a session available. - * - * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios - * where the token needs to be re minted because it has lost some authorization. - * - * Defaults to false. - */ - forceNewSession?: boolean | { detail: string }; - } - - export namespace authentication { - /** - * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not - * registered, or if the user does not consent to sharing authentication information with - * the extension. If there are multiple sessions with the same scopes, the user will be shown a - * quickpick to select which account they would like to use. - * - * Currently, there are only two authentication providers that are contributed from built in extensions - * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'. - * @param providerId The id of the provider to use - * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider - * @param options The {@link AuthenticationGetSessionOptions} to use - * @returns A thenable that resolves to an authentication session - */ - export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true | { detail: string } }): Thenable; - export function hasSession(providerId: string, scopes: readonly string[]): Thenable; - } - export namespace workspace { /** * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.