Skip to content

Commit

Permalink
Remove cycle browserHostService.ts -> web.api.ts. (#198221)
Browse files Browse the repository at this point in the history
* Remove cycle  browserHostService.ts -> web.api.ts.

Before this change, `IWorkbenchConstructionOptions` in web.api.ts
depended on `IWorkspaceProvider` in browserHostService.ts, which
depends on some types from web.api.ts.

While this apparently does not pose problems in VS Code's build, other
build system of downstream projects do not allow this, and it is also
overall harder to follow the code if "the API" depends on types defined
in ""the implementation".

* Fix one reference I missed
  • Loading branch information
rehmsen authored Nov 15, 2023
1 parent 0bc6184 commit b3a649f
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 47 deletions.
3 changes: 1 addition & 2 deletions src/vs/code/browser/workbench/workbench.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ import { URI, UriComponents } from 'vs/base/common/uri';
import product from 'vs/platform/product/common/product';
import { ISecretStorageProvider } from 'vs/platform/secrets/common/secrets';
import { isFolderToOpen, isWorkspaceToOpen } from 'vs/platform/window/common/window';
import type { IWorkbenchConstructionOptions } from 'vs/workbench/browser/web.api';
import type { IWorkbenchConstructionOptions, IWorkspace, IWorkspaceProvider } from 'vs/workbench/browser/web.api';
import { AuthenticationSessionInfo } from 'vs/workbench/services/authentication/browser/authenticationService';
import type { IWorkspace, IWorkspaceProvider } from 'vs/workbench/services/host/browser/browserHostService';
import type { IURLCallbackProvider } from 'vs/workbench/services/url/browser/urlService';
import { create } from 'vs/workbench/workbench.web.main';

Expand Down
43 changes: 42 additions & 1 deletion src/vs/workbench/browser/web.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import type { IURLCallbackProvider } from 'vs/workbench/services/url/browser/url
import type { LogLevel } from 'vs/platform/log/common/log';
import type { IUpdateProvider } from 'vs/workbench/services/update/browser/updateService';
import type { Event } from 'vs/base/common/event';
import type { IWorkspaceProvider } from 'vs/workbench/services/host/browser/browserHostService';
import type { IProductConfiguration } from 'vs/base/common/product';
import type { ISecretStorageProvider } from 'vs/platform/secrets/common/secrets';
import type { TunnelProviderFeatures } from 'vs/platform/tunnel/common/tunnel';
import type { IProgress, IProgressCompositeOptions, IProgressDialogOptions, IProgressNotificationOptions, IProgressOptions, IProgressStep, IProgressWindowOptions } from 'vs/platform/progress/common/progress';
import type { ITextEditorOptions } from 'vs/platform/editor/common/editor';
import type { IFolderToOpen, IWorkspaceToOpen } from 'vs/platform/window/common/window';
import type { EditorGroupLayout } from 'vs/workbench/services/editor/common/editorGroupsService';
import type { IEmbedderTerminalOptions } from 'vs/workbench/services/terminal/common/embedderTerminalService';

Expand Down Expand Up @@ -363,6 +363,47 @@ export interface IWorkbenchConstructionOptions {

}


/**
* A workspace to open in the workbench can either be:
* - a workspace file with 0-N folders (via `workspaceUri`)
* - a single folder (via `folderUri`)
* - empty (via `undefined`)
*/
export type IWorkspace = IWorkspaceToOpen | IFolderToOpen | undefined;

export interface IWorkspaceProvider {

/**
* The initial workspace to open.
*/
readonly workspace: IWorkspace;

/**
* Arbitrary payload from the `IWorkspaceProvider.open` call.
*/
readonly payload?: object;

/**
* Return `true` if the provided [workspace](#IWorkspaceProvider.workspace) is trusted, `false` if not trusted, `undefined` if unknown.
*/
readonly trusted: boolean | undefined;

/**
* Asks to open a workspace in the current or a new window.
*
* @param workspace the workspace to open.
* @param options optional options for the workspace to open.
* - `reuse`: whether to open inside the current window or a new window
* - `payload`: arbitrary payload that should be made available
* to the opening window via the `IWorkspaceProvider.payload` property.
* @param payload optional payload to send to the workspace to open.
*
* @returns true if successfully opened, false otherwise.
*/
open(workspace: IWorkspace, options?: { reuse?: boolean; payload?: object }): Promise<boolean>;
}

export interface IResourceUriProvider {
(uri: URI): URI;
}
Expand Down
3 changes: 1 addition & 2 deletions src/vs/workbench/browser/web.main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import { WorkspaceService } from 'vs/workbench/services/configuration/browser/co
import { ConfigurationCache } from 'vs/workbench/services/configuration/common/configurationCache';
import { ISignService } from 'vs/platform/sign/common/sign';
import { SignService } from 'vs/platform/sign/browser/signService';
import { IWorkbenchConstructionOptions, IWorkbench, ITunnel } from 'vs/workbench/browser/web.api';
import { IWorkbenchConstructionOptions, IWorkbench, IWorkspace, ITunnel } from 'vs/workbench/browser/web.api';
import { BrowserStorageService } from 'vs/workbench/services/storage/browser/storageService';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { toLocalISOString } from 'vs/base/common/date';
Expand Down Expand Up @@ -63,7 +63,6 @@ import { HTMLFileSystemProvider } from 'vs/platform/files/browser/htmlFileSystem
import { IOpenerService } from 'vs/platform/opener/common/opener';
import { mixin, safeStringify } from 'vs/base/common/objects';
import { IndexedDB } from 'vs/base/browser/indexedDB';
import { IWorkspace } from 'vs/workbench/services/host/browser/browserHostService';
import { WebFileSystemAccess } from 'vs/platform/files/browser/webFileSystemAccess';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IProgressService } from 'vs/platform/progress/common/progress';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import { ILogService } from 'vs/platform/log/common/log';
import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storage/common/storage';
import { isFolderToOpen, isWorkspaceToOpen } from 'vs/platform/window/common/window';
import { IWorkspaceContextService, isSingleFolderWorkspaceIdentifier, isWorkspaceIdentifier, toWorkspaceIdentifier, hasWorkspaceFileExtension } from 'vs/platform/workspace/common/workspace';
import { IWorkspace, IWorkspaceProvider } from 'vs/workbench/browser/web.api';
import { IBrowserWorkbenchEnvironmentService } from 'vs/workbench/services/environment/browser/environmentService';
import { IWorkspace, IWorkspaceProvider } from 'vs/workbench/services/host/browser/browserHostService';
import { IHostService } from 'vs/workbench/services/host/browser/host';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';

Expand Down
43 changes: 2 additions & 41 deletions src/vs/workbench/services/host/browser/browserHostService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ import { InstantiationType, registerSingleton } from 'vs/platform/instantiation/
import { ILayoutService } from 'vs/platform/layout/browser/layoutService';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IWindowSettings, IWindowOpenable, IOpenWindowOptions, isFolderToOpen, isWorkspaceToOpen, isFileToOpen, IOpenEmptyWindowOptions, IPathData, IFileToOpen, IWorkspaceToOpen, IFolderToOpen, IPoint } from 'vs/platform/window/common/window';
import { IWindowSettings, IWindowOpenable, IOpenWindowOptions, isFolderToOpen, isWorkspaceToOpen, isFileToOpen, IOpenEmptyWindowOptions, IPathData, IFileToOpen, IPoint } from 'vs/platform/window/common/window';
import { isResourceEditorInput, pathsToEditors } from 'vs/workbench/common/editor';
import { whenEditorClosed } from 'vs/workbench/browser/editor';
import { IWorkspace, IWorkspaceProvider } from 'vs/workbench/browser/web.api';
import { IFileService } from 'vs/platform/files/common/files';
import { ILabelService, Verbosity } from 'vs/platform/label/common/label';
import { ModifierKeyEmitter, disposableWindowInterval, getActiveDocument, getWindowId, onDidRegisterWindow, trackFocus } from 'vs/base/browser/dom';
Expand Down Expand Up @@ -39,46 +40,6 @@ import { IUserDataProfileService } from 'vs/workbench/services/userDataProfile/c
import { coalesce } from 'vs/base/common/arrays';
import { mainWindow, isAuxiliaryWindow } from 'vs/base/browser/window';

/**
* A workspace to open in the workbench can either be:
* - a workspace file with 0-N folders (via `workspaceUri`)
* - a single folder (via `folderUri`)
* - empty (via `undefined`)
*/
export type IWorkspace = IWorkspaceToOpen | IFolderToOpen | undefined;

export interface IWorkspaceProvider {

/**
* The initial workspace to open.
*/
readonly workspace: IWorkspace;

/**
* Arbitrary payload from the `IWorkspaceProvider.open` call.
*/
readonly payload?: object;

/**
* Return `true` if the provided [workspace](#IWorkspaceProvider.workspace) is trusted, `false` if not trusted, `undefined` if unknown.
*/
readonly trusted: boolean | undefined;

/**
* Asks to open a workspace in the current or a new window.
*
* @param workspace the workspace to open.
* @param options optional options for the workspace to open.
* - `reuse`: whether to open inside the current window or a new window
* - `payload`: arbitrary payload that should be made available
* to the opening window via the `IWorkspaceProvider.payload` property.
* @param payload optional payload to send to the workspace to open.
*
* @returns true if successfully opened, false otherwise.
*/
open(workspace: IWorkspace, options?: { reuse?: boolean; payload?: object }): Promise<boolean>;
}

enum HostShutdownReason {

/**
Expand Down

0 comments on commit b3a649f

Please sign in to comment.