Path: blob/main/src/vs/workbench/workbench.web.main.ts
3291 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/456// ####################################7// ### ###8// ### !!! PLEASE DO NOT MODIFY !!! ###9// ### ###10// ####################################1112// TODO@esm remove me once we stop supporting our web-esm-bridge1314(function () {1516// #region Types17type IGlobalDefine = {18(moduleName: string, dependencies: string[], callback: (...args: any[]) => any): any;19(moduleName: string, dependencies: string[], definition: any): any;20(moduleName: string, callback: (...args: any[]) => any): any;21(moduleName: string, definition: any): any;22(dependencies: string[], callback: (...args: any[]) => any): any;23(dependencies: string[], definition: any): any;24};2526interface ILoaderPlugin {27load: (pluginParam: string, parentRequire: IRelativeRequire, loadCallback: IPluginLoadCallback, options: IConfigurationOptions) => void;28write?: (pluginName: string, moduleName: string, write: IPluginWriteCallback) => void;29writeFile?: (pluginName: string, moduleName: string, req: IRelativeRequire, write: IPluginWriteFileCallback, config: IConfigurationOptions) => void;30finishBuild?: (write: (filename: string, contents: string) => void) => void;31}32interface IRelativeRequire {33(dependencies: string[], callback: Function, errorback?: (error: Error) => void): void;34toUrl(id: string): string;35}36interface IPluginLoadCallback {37(value: any): void;38error(err: any): void;39}40interface IConfigurationOptions {41isBuild: boolean | undefined;42[key: string]: any;43}44interface IPluginWriteCallback {45(contents: string): void;46getEntryPoint(): string;47asModule(moduleId: string, contents: string): void;48}49interface IPluginWriteFileCallback {50(filename: string, contents: string): void;51getEntryPoint(): string;52asModule(moduleId: string, contents: string): void;53}5455//#endregion5657const define: IGlobalDefine = (globalThis as any).define;58const require: { getConfig?(): any } | undefined = (globalThis as any).require;5960if (!define || !require || typeof require.getConfig !== 'function') {61throw new Error('Expected global define() and require() functions. Please only load this module in an AMD context!');62}6364let baseUrl = require?.getConfig().baseUrl;65if (!baseUrl) {66throw new Error('Failed to determine baseUrl for loading AMD modules (tried require.getConfig().baseUrl)');67}68if (!baseUrl.endsWith('/')) {69baseUrl = baseUrl + '/';70}71globalThis._VSCODE_FILE_ROOT = baseUrl;7273const trustedTypesPolicy: Pick<TrustedTypePolicy<{ createScriptURL(value: string): string }>, 'name' | 'createScriptURL'> | undefined = require.getConfig().trustedTypesPolicy;74if (trustedTypesPolicy) {75globalThis._VSCODE_WEB_PACKAGE_TTP = trustedTypesPolicy;76}7778const promise = new Promise(resolve => {79(globalThis as any).__VSCODE_WEB_ESM_PROMISE = resolve;80});8182define('vs/web-api', [], (): ILoaderPlugin => {83return {84load: (_name, _req, _load, _config) => {85const script: any = document.createElement('script');86script.type = 'module';87script.src = trustedTypesPolicy ? trustedTypesPolicy.createScriptURL(`${baseUrl}vs/workbench/workbench.web.main.internal.js`) as any as string : `${baseUrl}vs/workbench/workbench.web.main.internal.js`;88document.head.appendChild(script);8990return promise.then(mod => _load(mod));91}92};93});9495define(96'vs/workbench/workbench.web.main',97['require', 'exports', 'vs/web-api!'],98function (_require, exports, webApi) {99Object.assign(exports, webApi);100}101);102})();103104105