web - change API to URI (from UriComponents)

This commit is contained in:
Benjamin Pasero 2019-09-17 07:43:53 +02:00
parent bdd1971f2c
commit 08a5964645
8 changed files with 29 additions and 21 deletions

View file

@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { URI, UriComponents } from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
import * as platform from 'vs/base/common/platform';
export namespace Schemas {
@ -60,7 +60,7 @@ class RemoteAuthoritiesImpl {
private readonly _ports: { [authority: string]: number; };
private readonly _connectionTokens: { [authority: string]: string; };
private _preferredWebSchema: 'http' | 'https';
private _delegate: ((uri: URI) => UriComponents) | null;
private _delegate: ((uri: URI) => URI) | null;
constructor() {
this._hosts = Object.create(null);
@ -74,7 +74,7 @@ class RemoteAuthoritiesImpl {
this._preferredWebSchema = schema;
}
public setDelegate(delegate: (uri: URI) => UriComponents): void {
public setDelegate(delegate: (uri: URI) => URI): void {
this._delegate = delegate;
}
@ -89,8 +89,7 @@ class RemoteAuthoritiesImpl {
public rewrite(uri: URI): URI {
if (this._delegate) {
const result = this._delegate(uri);
return URI.revive(result);
return this._delegate(uri);
}
const authority = uri.authority;
const host = this._hosts[authority];

View file

@ -113,8 +113,8 @@ class PollingURLCallbackProvider extends Disposable implements IURLCallbackProvi
FRAGMENT: 'vscode-fragment'
};
private readonly _onCallback: Emitter<UriComponents> = this._register(new Emitter<UriComponents>());
readonly onCallback: Event<UriComponents> = this._onCallback.event;
private readonly _onCallback: Emitter<URI> = this._register(new Emitter<URI>());
readonly onCallback: Event<URI> = this._onCallback.event;
create(options?: Partial<UriComponents>): URI {
const queryValues: Map<string, string> = new Map();
@ -164,7 +164,7 @@ class PollingURLCallbackProvider extends Disposable implements IURLCallbackProvi
const content = await streamToBuffer(result.stream);
if (content.byteLength > 0) {
try {
this._onCallback.fire(JSON.parse(content.toString()));
this._onCallback.fire(URI.revive(JSON.parse(content.toString())));
} catch (error) {
console.error(error);
}
@ -201,4 +201,12 @@ const options: IWorkbenchConstructionOptions = JSON.parse(document.getElementByI
options.urlCallbackProvider = new PollingURLCallbackProvider();
options.credentialsProvider = new LocalStorageCredentialsProvider();
if (options.folderUri) {
options.folderUri = URI.revive(options.folderUri);
}
if (options.workspaceUri) {
options.workspaceUri = URI.revive(options.workspaceUri);
}
create(document.body, options);

View file

@ -5,14 +5,14 @@
import { ResolvedAuthority, IRemoteAuthorityResolverService, ResolverResult } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { RemoteAuthorities } from 'vs/base/common/network';
import { URI, UriComponents } from 'vs/base/common/uri';
import { URI } from 'vs/base/common/uri';
export class RemoteAuthorityResolverService implements IRemoteAuthorityResolverService {
_serviceBrand: undefined;
constructor(
resourceUriProvider: ((uri: URI) => UriComponents) | undefined
resourceUriProvider: ((uri: URI) => URI) | undefined
) {
if (resourceUriProvider) {
RemoteAuthorities.setDelegate(resourceUriProvider);

View file

@ -266,12 +266,12 @@ class CodeRendererMain extends Disposable {
// Multi-root workspace
if (this.configuration.workspaceUri) {
return { id: hash(URI.revive(this.configuration.workspaceUri).toString()).toString(16), configPath: URI.revive(this.configuration.workspaceUri) };
return { id: hash(this.configuration.workspaceUri.toString()).toString(16), configPath: this.configuration.workspaceUri };
}
// Single-folder workspace
if (this.configuration.folderUri) {
return { id: hash(URI.revive(this.configuration.folderUri).toString()).toString(16), folder: URI.revive(this.configuration.folderUri) };
return { id: hash(this.configuration.folderUri.toString()).toString(16), folder: this.configuration.folderUri };
}
return { id: 'empty-window' };

View file

@ -10,7 +10,9 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
export interface ICredentialsProvider {
getPassword(service: string, account: string): Promise<string | null>;
setPassword(service: string, account: string, password: string): Promise<void>;
deletePassword(service: string, account: string): Promise<boolean>;
findPassword(service: string): Promise<string | null>;
findCredentials(service: string): Promise<Array<{ account: string, password: string }>>;
}

View file

@ -5,7 +5,6 @@
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IExtensionDescription, ExtensionIdentifier } from 'vs/platform/extensions/common/extensions';
import { URI } from 'vs/base/common/uri';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
@ -27,7 +26,7 @@ export class StaticExtensionsService implements IStaticExtensionsService {
this._descriptions = staticExtensions.map(data => <IExtensionDescription>{
identifier: new ExtensionIdentifier(`${data.packageJSON.publisher}.${data.packageJSON.name}`),
extensionLocation: URI.revive(data.extensionLocation),
extensionLocation: data.extensionLocation,
...data.packageJSON,
});
}

View file

@ -16,7 +16,7 @@ export interface IURLCallbackProvider {
* Indicates that a Uri has been opened outside of VSCode. The Uri
* will be forwarded to all installed Uri handlers in the system.
*/
readonly onCallback: Event<UriComponents>;
readonly onCallback: Event<URI>;
/**
* Creates a Uri that - if opened in a browser - must result in
@ -54,7 +54,7 @@ export class BrowserURLService extends AbstractURLService {
private registerListeners(): void {
if (this.provider) {
this._register(this.provider.onCallback(uri => this.open(URI.revive(uri))));
this._register(this.provider.onCallback(uri => this.open(uri)));
}
}

View file

@ -38,12 +38,12 @@ interface IWorkbenchConstructionOptions {
/**
* Experimental: An optional folder that is set as workspace context for the workbench.
*/
folderUri?: UriComponents;
folderUri?: URI;
/**
* Experimental: An optional workspace that is set as workspace context for the workbench.
*/
workspaceUri?: UriComponents;
workspaceUri?: URI;
/**
* Experimental: The userDataProvider is used to handle user specific application
@ -59,7 +59,7 @@ interface IWorkbenchConstructionOptions {
/**
* A provider for resource URIs.
*/
resourceUriProvider?: (uri: URI) => UriComponents;
resourceUriProvider?: (uri: URI) => URI;
/**
* Experimental: Whether to enable the smoke test driver.
@ -74,7 +74,7 @@ interface IWorkbenchConstructionOptions {
/**
* Experimental: Add static extensions that cannot be uninstalled but only be disabled.
*/
staticExtensions?: { packageJSON: IExtensionManifest, extensionLocation: UriComponents }[];
staticExtensions?: { packageJSON: IExtensionManifest, extensionLocation: URI }[];
/**
* Experimental: Support for URL callbacks.
@ -109,8 +109,8 @@ export {
IWorkbenchConstructionOptions,
// Basic Types
UriComponents,
URI,
UriComponents,
Event,
Emitter,
IDisposable,