Merge from vscode 1b314ab317fbff7d799b21754326b7d849889ceb

This commit is contained in:
ADS Merger
2020-07-15 23:51:18 +00:00
parent aae013d498
commit 9d3f12d0b7
554 changed files with 15159 additions and 8223 deletions

View File

@@ -9,7 +9,6 @@ import { isUNC } from 'vs/base/common/extpath';
import { Schemas } from 'vs/base/common/network';
import { sep } from 'vs/base/common/path';
import { URI } from 'vs/base/common/uri';
import { IFileService } from 'vs/platform/files/common/files';
import { IRemoteConnectionData } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IRequestService } from 'vs/platform/request/common/request';
import { getWebviewContentMimeType } from 'vs/platform/webview/common/mimeTypes';
@@ -35,6 +34,10 @@ export namespace WebviewResourceResponse {
export type StreamResponse = StreamSuccess | typeof Failed | typeof AccessDenied;
}
interface FileReader {
readFileStream(resource: URI): Promise<VSBufferReadableStream>;
}
export async function loadLocalResource(
requestUri: URI,
options: {
@@ -43,7 +46,7 @@ export async function loadLocalResource(
remoteConnectionData?: IRemoteConnectionData | null;
rewriteUri?: (uri: URI) => URI,
},
fileService: IFileService,
fileReader: FileReader,
requestService: IRequestService,
): Promise<WebviewResourceResponse.StreamResponse> {
let resourceToLoad = getResourceToLoad(requestUri, options.roots);
@@ -67,8 +70,8 @@ export async function loadLocalResource(
}
try {
const contents = await fileService.readFileStream(resourceToLoad);
return new WebviewResourceResponse.StreamSuccess(contents.value, mime);
const contents = await fileReader.readFileStream(resourceToLoad);
return new WebviewResourceResponse.StreamSuccess(contents, mime);
} catch (err) {
console.log(err);
return WebviewResourceResponse.Failed;
@@ -96,8 +99,14 @@ function normalizeRequestPath(requestUri: URI) {
//
// vscode-webview-resource://id/scheme//authority?/path
//
const resourceUri = URI.parse(requestUri.path.replace(/^\/([a-z0-9\-]+)\/{1,2}/i, '$1://'));
const resourceUri = URI.parse(requestUri.path.replace(/^\/([a-z0-9\-]+)(\/{1,2})/i, (_: string, scheme: string, sep: string) => {
if (sep.length === 1) {
return `${scheme}:///`; // Add empty authority.
} else {
return `${scheme}://`; // Url has own authority.
}
}));
console.log(requestUri, resourceUri);
return resourceUri.with({
query: requestUri.query,
fragment: requestUri.fragment

View File

@@ -3,6 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { VSBuffer } from 'vs/base/common/buffer';
import { UriComponents } from 'vs/base/common/uri';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { IRemoteConnectionData } from 'vs/platform/remote/common/remoteAuthorityResolver';
@@ -13,10 +14,12 @@ export const IWebviewManagerService = createDecorator<IWebviewManagerService>('w
export interface IWebviewManagerService {
_serviceBrand: unknown;
registerWebview(id: string, webContentsId: number | undefined, metadata: RegisterWebviewMetadata): Promise<void>;
registerWebview(id: string, webContentsId: number | undefined, windowId: number, metadata: RegisterWebviewMetadata): Promise<void>;
unregisterWebview(id: string): Promise<void>;
updateWebviewMetadata(id: string, metadataDelta: Partial<RegisterWebviewMetadata>): Promise<void>;
didLoadResource(requestId: number, content: VSBuffer | undefined): void;
setIgnoreMenuShortcuts(webContentsId: number, enabled: boolean): Promise<void>;
}