From 5cb3edbfc4b1507a9fe7878ff7bd534a1098a089 Mon Sep 17 00:00:00 2001 From: Tyler James Leonhardt Date: Thu, 21 Nov 2024 17:20:12 -0800 Subject: [PATCH] Move `env.nativeHandle` to `window.nativeHandle` (#234395) --- .../microsoft-authentication/src/node/authProvider.ts | 6 +++--- src/vs/workbench/api/common/extHost.api.impl.ts | 8 ++++---- src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts | 4 ++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/extensions/microsoft-authentication/src/node/authProvider.ts b/extensions/microsoft-authentication/src/node/authProvider.ts index f6c771e4f9a..af34273afa4 100644 --- a/extensions/microsoft-authentication/src/node/authProvider.ts +++ b/extensions/microsoft-authentication/src/node/authProvider.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { AccountInfo, AuthenticationResult, ServerError } from '@azure/msal-node'; -import { AuthenticationGetSessionOptions, AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationProviderSessionOptions, AuthenticationSession, AuthenticationSessionAccountInformation, CancellationError, env, EventEmitter, ExtensionContext, l10n, LogOutputChannel, Memento, SecretStorage, Uri, window } from 'vscode'; +import { AuthenticationGetSessionOptions, AuthenticationProvider, AuthenticationProviderAuthenticationSessionsChangeEvent, AuthenticationProviderSessionOptions, AuthenticationSession, AuthenticationSessionAccountInformation, CancellationError, env, EventEmitter, ExtensionContext, l10n, LogOutputChannel, Uri, window } from 'vscode'; import { Environment } from '@azure/ms-rest-azure-env'; import { CachedPublicClientApplicationManager } from './publicClientCache'; import { UriHandlerLoopbackClient } from '../common/loopbackClientAndOpener'; @@ -190,7 +190,7 @@ export class MsalAuthProvider implements AuthenticationProvider { let result: AuthenticationResult | undefined; try { - const windowHandle = env.nativeHandle ? Buffer.from(env.nativeHandle) : undefined; + const windowHandle = window.nativeHandle ? Buffer.from(window.nativeHandle) : undefined; result = await cachedPca.acquireTokenInteractive({ openBrowser: async (url: string) => { await env.openExternal(Uri.parse(url)); }, scopes: scopeData.scopesToSend, @@ -232,7 +232,7 @@ export class MsalAuthProvider implements AuthenticationProvider { // The user wants to try the loopback client or we got an error likely due to spinning up the server const loopbackClient = new UriHandlerLoopbackClient(this._uriHandler, redirectUri, this._logger); try { - const windowHandle = env.nativeHandle ? Buffer.from(env.nativeHandle) : undefined; + const windowHandle = window.nativeHandle ? Buffer.from(window.nativeHandle) : undefined; result = await cachedPca.acquireTokenInteractive({ openBrowser: (url: string) => loopbackClient.openBrowser(url), scopes: scopeData.scopesToSend, diff --git a/src/vs/workbench/api/common/extHost.api.impl.ts b/src/vs/workbench/api/common/extHost.api.impl.ts index 672848e05fe..f8a27ed0675 100644 --- a/src/vs/workbench/api/common/extHost.api.impl.ts +++ b/src/vs/workbench/api/common/extHost.api.impl.ts @@ -436,10 +436,6 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I get appCommit(): string | undefined { checkProposedApiEnabled(extension, 'resolvers'); return initData.commit; - }, - get nativeHandle(): Uint8Array | undefined { - checkProposedApiEnabled(extension, 'nativeWindowHandle'); - return extHostWindow.nativeHandle; } }; if (!initData.environment.extensionTestsLocationURI) { @@ -927,6 +923,10 @@ export function createApiFactoryAndRegisterActors(accessor: ServicesAccessor): I registerShareProvider(selector: vscode.DocumentSelector, provider: vscode.ShareProvider): vscode.Disposable { checkProposedApiEnabled(extension, 'shareProvider'); return extHostShare.registerShareProvider(checkSelector(selector), provider); + }, + get nativeHandle(): Uint8Array | undefined { + checkProposedApiEnabled(extension, 'nativeWindowHandle'); + return extHostWindow.nativeHandle; } }; diff --git a/src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts b/src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts index 592f3266e14..fa9c7732c00 100644 --- a/src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts +++ b/src/vscode-dts/vscode.proposed.nativeWindowHandle.d.ts @@ -7,10 +7,10 @@ declare module 'vscode' { - export namespace env { + export namespace window { /** * Retrieves the native window handle of the current active window. - * The current active window may not be associated with this extension host. + * This will be updated when the active window changes. */ export const nativeHandle: Uint8Array | undefined; }