@sussudio/platform
Version:
Internal APIs for VS Code's service injection the base services.
24 lines (23 loc) • 1.03 kB
JavaScript
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { getMediaMime, Mimes } from '@sussudio/base/common/mime.mjs';
import { extname } from '@sussudio/base/common/path.mjs';
const webviewMimeTypes = new Map([
['.svg', 'image/svg+xml'],
['.txt', Mimes.text],
['.css', 'text/css'],
['.js', 'application/javascript'],
['.json', 'application/json'],
['.html', 'text/html'],
['.htm', 'text/html'],
['.xhtml', 'application/xhtml+xml'],
['.oft', 'font/otf'],
['.xml', 'application/xml'],
['.wasm', 'application/wasm'],
]);
export function getWebviewContentMimeType(resource) {
const ext = extname(resource.fsPath).toLowerCase();
return webviewMimeTypes.get(ext) || getMediaMime(resource.fsPath) || Mimes.unknown;
}