mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-28 06:31:58 +00:00
esm - remove AMD modifications in sources
This commit is contained in:
parent
332b89f198
commit
d2701aa2ec
18
.vscode/shared.code-snippets
vendored
18
.vscode/shared.code-snippets
vendored
@ -36,23 +36,5 @@
|
||||
"private readonly _onDid$1 = new Emitter<$2>();",
|
||||
"readonly onDid$1: Event<$2> = this._onDid$1.event;"
|
||||
],
|
||||
},
|
||||
"esm-comment": {
|
||||
"scope": "typescript,javascript",
|
||||
"prefix": "esm-comment",
|
||||
"body": [
|
||||
"// ESM-comment-begin",
|
||||
"$SELECTION$0",
|
||||
"// ESM-comment-end",
|
||||
]
|
||||
},
|
||||
"esm-uncomment": {
|
||||
"scope": "typescript,javascript",
|
||||
"prefix": "esm-uncomment",
|
||||
"body": [
|
||||
"// ESM-uncomment-begin",
|
||||
"// $SELECTION$0",
|
||||
"// ESM-uncomment-end",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@ -96,8 +96,7 @@ const serverWithWebResourceIncludes = [
|
||||
|
||||
const serverWithWebResourceExcludes = [
|
||||
...serverResourceExcludes,
|
||||
'!out-build/vs/code/**/*-dev.html',
|
||||
'!out-build/vs/code/**/*-dev.esm.html',
|
||||
'!out-build/vs/code/**/*-dev.html'
|
||||
];
|
||||
|
||||
const serverWithWebResources = [
|
||||
|
||||
@ -57,7 +57,7 @@ const vscodeResourceIncludes = [
|
||||
'out-build/nls.keys.json',
|
||||
|
||||
// Workbench
|
||||
'out-build/vs/code/electron-sandbox/workbench/workbench.esm.html',
|
||||
'out-build/vs/code/electron-sandbox/workbench/workbench.html',
|
||||
|
||||
// Electron Preload
|
||||
'out-build/vs/base/parts/sandbox/electron-sandbox/preload.js',
|
||||
@ -94,16 +94,16 @@ const vscodeResourceIncludes = [
|
||||
'out-build/vs/workbench/contrib/webview/browser/pre/*.{js,html}',
|
||||
|
||||
// Extension Host Worker
|
||||
'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.esm.html',
|
||||
'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html',
|
||||
|
||||
// Process Explorer
|
||||
'out-build/vs/code/electron-sandbox/processExplorer/processExplorer.esm.html',
|
||||
'out-build/vs/code/electron-sandbox/processExplorer/processExplorer.html',
|
||||
|
||||
// Tree Sitter highlights
|
||||
'out-build/vs/editor/common/languages/highlights/*.scm',
|
||||
|
||||
// Issue Reporter
|
||||
'out-build/vs/workbench/contrib/issue/electron-sandbox/issueReporter.esm.html'
|
||||
'out-build/vs/workbench/contrib/issue/electron-sandbox/issueReporter.html'
|
||||
];
|
||||
|
||||
const vscodeResources = [
|
||||
@ -115,9 +115,7 @@ const vscodeResources = [
|
||||
'!out-build/vs/code/browser/**',
|
||||
'!out-build/vs/editor/standalone/**',
|
||||
'!out-build/vs/code/**/*-dev.html',
|
||||
'!out-build/vs/code/**/*-dev.esm.html',
|
||||
'!out-build/vs/workbench/contrib/issue/**/*-dev.html',
|
||||
'!out-build/vs/workbench/contrib/issue/**/*-dev.esm.html',
|
||||
'!**/test/**'
|
||||
];
|
||||
|
||||
@ -256,7 +254,7 @@ function packageTask(platform, arch, sourceFolderName, destinationFolderName, op
|
||||
'vs/workbench/workbench.desktop.main.js',
|
||||
'vs/workbench/workbench.desktop.main.css',
|
||||
'vs/workbench/api/node/extensionHostProcess.js',
|
||||
'vs/code/electron-sandbox/workbench/workbench.esm.html',
|
||||
'vs/code/electron-sandbox/workbench/workbench.html',
|
||||
'vs/code/electron-sandbox/workbench/workbench.js'
|
||||
]);
|
||||
|
||||
|
||||
@ -53,7 +53,7 @@ const vscodeWebResourceIncludes = [
|
||||
'out-build/vs/editor/common/languages/highlights/*.scm',
|
||||
|
||||
// Extension Host Worker
|
||||
'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.esm.html',
|
||||
'out-build/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html',
|
||||
];
|
||||
exports.vscodeWebResourceIncludes = vscodeWebResourceIncludes;
|
||||
|
||||
@ -67,7 +67,6 @@ const vscodeWebResources = [
|
||||
'!out-build/vs/editor/standalone/**',
|
||||
'!out-build/vs/workbench/**/*-tb.png',
|
||||
'!out-build/vs/code/**/*-dev.html',
|
||||
'!out-build/vs/code/**/*-dev.esm.html',
|
||||
'!**/test/**'
|
||||
];
|
||||
|
||||
|
||||
71
src/bootstrap-amd.js
vendored
71
src/bootstrap-amd.js
vendored
@ -11,7 +11,6 @@
|
||||
* @import { IProductConfiguration } from './vs/base/common/product'
|
||||
*/
|
||||
|
||||
// ESM-uncomment-begin
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
@ -44,16 +43,10 @@ if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
|
||||
}`;
|
||||
register(`data:text/javascript;base64,${Buffer.from(jsCode).toString('base64')}`, import.meta.url);
|
||||
}
|
||||
// ESM-uncomment-end
|
||||
|
||||
// VSCODE_GLOBALS: package/product.json
|
||||
/** @type Partial<IProductConfiguration> */
|
||||
// ESM-comment-begin
|
||||
// globalThis._VSCODE_PRODUCT_JSON = require('./bootstrap-meta').product;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
globalThis._VSCODE_PRODUCT_JSON = { ...product };
|
||||
// ESM-uncomment-end
|
||||
if (process.env['VSCODE_DEV']) {
|
||||
// Patch product overrides when running out of sources
|
||||
try {
|
||||
@ -62,22 +55,11 @@ if (process.env['VSCODE_DEV']) {
|
||||
globalThis._VSCODE_PRODUCT_JSON = Object.assign(globalThis._VSCODE_PRODUCT_JSON, overrides);
|
||||
} catch (error) { /* ignore */ }
|
||||
}
|
||||
// ESM-comment-begin
|
||||
// globalThis._VSCODE_PACKAGE_JSON = require('./bootstrap-meta').pkg;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
globalThis._VSCODE_PACKAGE_JSON = { ...pkg };
|
||||
// ESM-uncomment-end
|
||||
|
||||
// VSCODE_GLOBALS: file root of all resources
|
||||
globalThis._VSCODE_FILE_ROOT = __dirname;
|
||||
|
||||
// ESM-comment-begin
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const performance = require(`./vs/base/common/performance`);
|
||||
// const fs = require('fs');
|
||||
// ESM-comment-end
|
||||
|
||||
//#region NLS helpers
|
||||
|
||||
/** @type {Promise<INLSConfiguration | undefined> | undefined} */
|
||||
@ -161,7 +143,6 @@ async function doSetupNLS() {
|
||||
|
||||
//#region Loader Config
|
||||
|
||||
// ESM-uncomment-begin
|
||||
/**
|
||||
* @param {string=} entrypoint
|
||||
* @param {(value: any) => void} [onLoad]
|
||||
@ -182,59 +163,7 @@ module.exports.load = function (entrypoint, onLoad, onError) {
|
||||
import(entrypoint).then(onLoad, onError);
|
||||
});
|
||||
};
|
||||
// ESM-uncomment-end
|
||||
|
||||
// ESM-comment-begin
|
||||
// // @ts-ignore
|
||||
// const loader = require('./vs/loader');
|
||||
//
|
||||
// loader.config({
|
||||
// baseUrl: bootstrapNode.fileUriFromPath(__dirname, { isWindows: process.platform === 'win32' }),
|
||||
// catchError: true,
|
||||
// nodeRequire,
|
||||
// amdModulesPattern: /^vs\//,
|
||||
// recordStats: true
|
||||
// });
|
||||
//
|
||||
// // Running in Electron
|
||||
// if (process.env['ELECTRON_RUN_AS_NODE'] || process.versions['electron']) {
|
||||
// loader.define('fs', ['original-fs'], function (/** @type {import('fs')} */originalFS) {
|
||||
// return originalFS; // replace the patched electron fs with the original node fs for all AMD code
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * @param {string=} entrypoint
|
||||
// * @param {(value: any) => void} [onLoad]
|
||||
// * @param {(err: Error) => void} [onError]
|
||||
// */
|
||||
// module.exports.load = function (entrypoint, onLoad, onError) {
|
||||
// if (!entrypoint) {
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// // code cache config
|
||||
// if (process.env['VSCODE_CODE_CACHE_PATH']) {
|
||||
// loader.config({
|
||||
// nodeCachedData: {
|
||||
// path: process.env['VSCODE_CODE_CACHE_PATH'],
|
||||
// seed: entrypoint
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// onLoad = onLoad || function () { };
|
||||
// onError = onError || function (err) { console.error(err); };
|
||||
//
|
||||
// setupNLS().then(() => {
|
||||
// performance.mark('code/fork/willLoadCode');
|
||||
// loader([entrypoint], onLoad, onError);
|
||||
// });
|
||||
// };
|
||||
// ESM-comment-end
|
||||
|
||||
//#endregion
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const load = module.exports.load;
|
||||
// ESM-uncomment-end
|
||||
|
||||
10
src/bootstrap-fork.js
vendored
10
src/bootstrap-fork.js
vendored
@ -6,16 +6,9 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-comment-begin
|
||||
// const performance = require('./vs/base/common/performance');
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const bootstrapAmd = require('./bootstrap-amd');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import * as performance from './vs/base/common/performance.js';
|
||||
import * as bootstrapNode from './bootstrap-node.js';
|
||||
import * as bootstrapAmd from './bootstrap-amd.js';
|
||||
// ESM-uncomment-end
|
||||
|
||||
performance.mark('code/fork/start');
|
||||
|
||||
@ -25,9 +18,6 @@ configureCrashReporter();
|
||||
// Remove global paths from the node module lookup (node.js only)
|
||||
bootstrapNode.removeGlobalNodeJsModuleLookupPaths();
|
||||
|
||||
// Enable ASAR in our forked processes
|
||||
bootstrapNode.enableASARSupport();
|
||||
|
||||
if (process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']) {
|
||||
bootstrapNode.devInjectNodeModuleLookupPath(process.env['VSCODE_DEV_INJECT_NODE_MODULE_LOOKUP_PATH']);
|
||||
}
|
||||
|
||||
4
src/bootstrap-meta.js
vendored
4
src/bootstrap-meta.js
vendored
@ -10,13 +10,11 @@
|
||||
* @import { IProductConfiguration } from './vs/base/common/product'
|
||||
*/
|
||||
|
||||
// ESM-uncomment-begin
|
||||
import { createRequire } from 'node:module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
/** @type Partial<IProductConfiguration> & { BUILD_INSERT_PRODUCT_CONFIGURATION?: string } */
|
||||
let productObj = { BUILD_INSERT_PRODUCT_CONFIGURATION: 'BUILD_INSERT_PRODUCT_CONFIGURATION' }; // DO NOT MODIFY, PATCHED DURING BUILD
|
||||
@ -35,7 +33,5 @@ if (pkgObj['BUILD_INSERT_PACKAGE_CONFIGURATION']) {
|
||||
module.exports.product = productObj;
|
||||
module.exports.pkg = pkgObj;
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const product = module.exports.product;
|
||||
export const pkg = module.exports.pkg;
|
||||
// ESM-uncomment-end
|
||||
|
||||
98
src/bootstrap-node.js
vendored
98
src/bootstrap-node.js
vendored
@ -6,12 +6,6 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-comment-begin
|
||||
// const path = require('path');
|
||||
// const fs = require('fs');
|
||||
// const Module = require('module');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
@ -22,7 +16,6 @@ const require = createRequire(import.meta.url);
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
// ESM-uncomment-end
|
||||
|
||||
// increase number of stack frames(from 10, https://github.com/v8/v8/wiki/Stack-Trace-API)
|
||||
Error.stackTraceLimit = 100;
|
||||
@ -84,31 +77,8 @@ module.exports.devInjectNodeModuleLookupPath = function (injectPath) {
|
||||
}
|
||||
|
||||
const Module = require('node:module');
|
||||
// ESM-uncomment-begin
|
||||
// register a loader hook
|
||||
Module.register('./bootstrap-import.js', { parentURL: import.meta.url, data: injectPath });
|
||||
// ESM-uncomment-end
|
||||
// ESM-comment-begin
|
||||
// const nodeModulesPath = path.join(__dirname, '../node_modules');
|
||||
//
|
||||
// // @ts-ignore
|
||||
// const originalResolveLookupPaths = Module._resolveLookupPaths;
|
||||
//
|
||||
// // @ts-ignore
|
||||
// Module._resolveLookupPaths = function (moduleName, parent) {
|
||||
// const paths = originalResolveLookupPaths(moduleName, parent);
|
||||
// if (Array.isArray(paths)) {
|
||||
// for (let i = 0, len = paths.length; i < len; i++) {
|
||||
// if (paths[i] === nodeModulesPath) {
|
||||
// paths.splice(i, 0, injectPath);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return paths;
|
||||
// };
|
||||
// ESM-comment-end
|
||||
};
|
||||
|
||||
module.exports.removeGlobalNodeJsModuleLookupPaths = function () {
|
||||
@ -204,76 +174,8 @@ module.exports.configurePortable = function (product) {
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to enable ASAR support.
|
||||
*/
|
||||
module.exports.enableASARSupport = function () {
|
||||
// ESM-comment-begin
|
||||
// const NODE_MODULES_PATH = path.join(__dirname, '../node_modules');
|
||||
// const NODE_MODULES_ASAR_PATH = `${NODE_MODULES_PATH}.asar`;
|
||||
//
|
||||
// // @ts-ignore
|
||||
// const originalResolveLookupPaths = Module._resolveLookupPaths;
|
||||
//
|
||||
// // @ts-ignore
|
||||
// Module._resolveLookupPaths = function (request, parent) {
|
||||
// const paths = originalResolveLookupPaths(request, parent);
|
||||
// if (Array.isArray(paths)) {
|
||||
// for (let i = 0, len = paths.length; i < len; i++) {
|
||||
// if (paths[i] === NODE_MODULES_PATH) {
|
||||
// paths.splice(i, 0, NODE_MODULES_ASAR_PATH);
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return paths;
|
||||
// };
|
||||
// ESM-comment-end
|
||||
};
|
||||
|
||||
/**
|
||||
* Helper to convert a file path to a URI.
|
||||
*
|
||||
* TODO@bpasero TODO@esm check for removal once ESM has landed.
|
||||
*
|
||||
* @param {string} path
|
||||
* @param {{ isWindows?: boolean, scheme?: string, fallbackAuthority?: string }} config
|
||||
* @returns {string}
|
||||
*/
|
||||
module.exports.fileUriFromPath = function (path, config) {
|
||||
|
||||
// Since we are building a URI, we normalize any backslash
|
||||
// to slashes and we ensure that the path begins with a '/'.
|
||||
let pathName = path.replace(/\\/g, '/');
|
||||
if (pathName.length > 0 && pathName.charAt(0) !== '/') {
|
||||
pathName = `/${pathName}`;
|
||||
}
|
||||
|
||||
/** @type {string} */
|
||||
let uri;
|
||||
|
||||
// Windows: in order to support UNC paths (which start with '//')
|
||||
// that have their own authority, we do not use the provided authority
|
||||
// but rather preserve it.
|
||||
if (config.isWindows && pathName.startsWith('//')) {
|
||||
uri = encodeURI(`${config.scheme || 'file'}:${pathName}`);
|
||||
}
|
||||
|
||||
// Otherwise we optionally add the provided authority if specified
|
||||
else {
|
||||
uri = encodeURI(`${config.scheme || 'file'}://${config.fallbackAuthority || ''}${pathName}`);
|
||||
}
|
||||
|
||||
return uri.replace(/#/g, '%23');
|
||||
};
|
||||
|
||||
//#endregion
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const devInjectNodeModuleLookupPath = module.exports.devInjectNodeModuleLookupPath;
|
||||
export const removeGlobalNodeJsModuleLookupPaths = module.exports.removeGlobalNodeJsModuleLookupPaths;
|
||||
export const configurePortable = module.exports.configurePortable;
|
||||
export const enableASARSupport = module.exports.enableASARSupport;
|
||||
export const fileUriFromPath = module.exports.fileUriFromPath;
|
||||
// ESM-uncomment-end
|
||||
|
||||
71
src/bootstrap-window.js
vendored
71
src/bootstrap-window.js
vendored
@ -36,8 +36,7 @@
|
||||
* removeDeveloperKeybindingsAfterLoad?: boolean
|
||||
* },
|
||||
* canModifyDOM?: (config: ISandboxConfiguration) => void,
|
||||
* beforeLoaderConfig?: (loaderConfig: object) => void,
|
||||
* beforeRequire?: (config: ISandboxConfiguration) => void
|
||||
* beforeImport?: (config: ISandboxConfiguration) => void
|
||||
* }} [options]
|
||||
*/
|
||||
async function load(modulePaths, resultCallback, options) {
|
||||
@ -88,10 +87,9 @@
|
||||
|
||||
window['MonacoEnvironment'] = {};
|
||||
|
||||
// ESM-uncomment-begin
|
||||
// Signal before require()
|
||||
if (typeof options?.beforeRequire === 'function') {
|
||||
options.beforeRequire(configuration);
|
||||
// Signal before import()
|
||||
if (typeof options?.beforeImport === 'function') {
|
||||
options.beforeImport(configuration);
|
||||
}
|
||||
|
||||
const baseUrl = new URL(`${fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out/`);
|
||||
@ -148,72 +146,13 @@
|
||||
link.href = new URL(`${cssModule}.css`, baseUrl).href;
|
||||
document.head.appendChild(link);
|
||||
return Promise.resolve();
|
||||
|
||||
} else {
|
||||
// ESM/JS module loading
|
||||
return import(new URL(`${modulePath}.js`, baseUrl).href);
|
||||
}
|
||||
}));
|
||||
|
||||
result.then((res) => invokeResult(res[0]), onUnexpectedError);
|
||||
// ESM-uncomment-end
|
||||
|
||||
// ESM-comment-begin
|
||||
// /** @type {LoaderConfig} */
|
||||
// const loaderConfig = {
|
||||
// baseUrl: `${fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out`,
|
||||
// preferScriptTags: true
|
||||
// };
|
||||
//
|
||||
// // use a trusted types policy when loading via script tags
|
||||
// loaderConfig.trustedTypesPolicy = window.trustedTypes?.createPolicy('amdLoader', {
|
||||
// createScriptURL(value) {
|
||||
// if (value.startsWith(window.location.origin)) {
|
||||
// return value;
|
||||
// }
|
||||
// throw new Error(`Invalid script url: ${value}`);
|
||||
// }
|
||||
// });
|
||||
//
|
||||
// // Teach the loader the location of the node modules we use in renderers
|
||||
// // This will enable to load these modules via <script> tags instead of
|
||||
// // using a fallback such as node.js require which does not exist in sandbox
|
||||
// const baseNodeModulesPath = isDev ? '../node_modules' : '../node_modules.asar';
|
||||
// loaderConfig.paths = {
|
||||
// '@vscode/tree-sitter-wasm': `${baseNodeModulesPath}/@vscode/tree-sitter-wasm/wasm/tree-sitter.js`,
|
||||
// 'vscode-textmate': `${baseNodeModulesPath}/vscode-textmate/release/main.js`,
|
||||
// 'vscode-oniguruma': `${baseNodeModulesPath}/vscode-oniguruma/release/main.js`,
|
||||
// 'vsda': `${baseNodeModulesPath}/vsda/index.js`,
|
||||
// '@xterm/xterm': `${baseNodeModulesPath}/@xterm/xterm/lib/xterm.js`,
|
||||
// '@xterm/addon-clipboard': `${baseNodeModulesPath}/@xterm/addon-clipboard/lib/addon-clipboard.js`,
|
||||
// '@xterm/addon-image': `${baseNodeModulesPath}/@xterm/addon-image/lib/addon-image.js`,
|
||||
// '@xterm/addon-search': `${baseNodeModulesPath}/@xterm/addon-search/lib/addon-search.js`,
|
||||
// '@xterm/addon-serialize': `${baseNodeModulesPath}/@xterm/addon-serialize/lib/addon-serialize.js`,
|
||||
// '@xterm/addon-unicode11': `${baseNodeModulesPath}/@xterm/addon-unicode11/lib/addon-unicode11.js`,
|
||||
// '@xterm/addon-webgl': `${baseNodeModulesPath}/@xterm/addon-webgl/lib/addon-webgl.js`,
|
||||
// '@vscode/iconv-lite-umd': `${baseNodeModulesPath}/@vscode/iconv-lite-umd/lib/iconv-lite-umd.js`,
|
||||
// 'jschardet': `${baseNodeModulesPath}/jschardet/dist/jschardet.min.js`,
|
||||
// '@vscode/vscode-languagedetection': `${baseNodeModulesPath}/@vscode/vscode-languagedetection/dist/lib/index.js`,
|
||||
// 'vscode-regexp-languagedetection': `${baseNodeModulesPath}/vscode-regexp-languagedetection/dist/index.js`,
|
||||
// 'tas-client-umd': `${baseNodeModulesPath}/tas-client-umd/lib/tas-client-umd.js`
|
||||
// };
|
||||
//
|
||||
// // Signal before require.config()
|
||||
// if (typeof options?.beforeLoaderConfig === 'function') {
|
||||
// options.beforeLoaderConfig(loaderConfig);
|
||||
// }
|
||||
//
|
||||
// // Configure loader
|
||||
// require.config(loaderConfig);
|
||||
//
|
||||
// // Signal before require()
|
||||
// if (typeof options?.beforeRequire === 'function') {
|
||||
// options.beforeRequire(configuration);
|
||||
// }
|
||||
//
|
||||
// // Actually require the main module as specified
|
||||
// require(modulePaths, invokeResult, onUnexpectedError);
|
||||
// ESM-comment-end
|
||||
result.then(res => invokeResult(res[0]), onUnexpectedError);
|
||||
|
||||
/**
|
||||
* @param {any} firstModule
|
||||
|
||||
17
src/cli.js
17
src/cli.js
@ -6,19 +6,6 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-comment-begin
|
||||
// // Delete `VSCODE_CWD` very early. We have seen
|
||||
// // reports where `code .` would use the wrong
|
||||
// // current working directory due to our variable
|
||||
// // somehow escaping to the parent shell
|
||||
// // (https://github.com/microsoft/vscode/issues/126399)
|
||||
// delete process.env['VSCODE_CWD'];
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const bootstrapAmd = require('./bootstrap-amd');
|
||||
// const { resolveNLSConfiguration } = require('./vs/base/node/nls');
|
||||
// const product = require('./bootstrap-meta').product;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import './bootstrap-cli.js'; // this MUST come before other imports as it changes global state
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
@ -28,7 +15,6 @@ import { resolveNLSConfiguration } from './vs/base/node/nls.js';
|
||||
import { product } from './bootstrap-meta.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
// ESM-uncomment-end
|
||||
|
||||
async function start() {
|
||||
|
||||
@ -40,9 +26,6 @@ async function start() {
|
||||
// @ts-ignore
|
||||
bootstrapNode.configurePortable(product);
|
||||
|
||||
// Enable ASAR support
|
||||
bootstrapNode.enableASARSupport();
|
||||
|
||||
// Signal processes that we got launched as CLI
|
||||
process.env['VSCODE_CLI'] = '1';
|
||||
|
||||
|
||||
23
src/main.js
23
src/main.js
@ -11,21 +11,6 @@
|
||||
* @import { NativeParsedArgs } from './vs/platform/environment/common/argv'
|
||||
*/
|
||||
|
||||
// ESM-comment-begin
|
||||
// const path = require('path');
|
||||
// const fs = require('original-fs');
|
||||
// const os = require('os');
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const bootstrapAmd = require('./bootstrap-amd');
|
||||
// const { getUserDataPath } = require(`./vs/platform/environment/node/userDataPath`);
|
||||
// const { parse } = require('./vs/base/common/jsonc');
|
||||
// const perf = require('./vs/base/common/performance');
|
||||
// const { resolveNLSConfiguration } = require('./vs/base/node/nls');
|
||||
// const { getUNCHost, addUNCHostToAllowlist } = require('./vs/base/node/unc');
|
||||
// const product = require('./bootstrap-meta').product;
|
||||
// const { app, protocol, crashReporter, Menu, contentTracing } = require('electron');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import * as path from 'path';
|
||||
import * as fs from 'original-fs';
|
||||
import * as os from 'os';
|
||||
@ -42,20 +27,12 @@ import { resolveNLSConfiguration } from './vs/base/node/nls.js';
|
||||
import { getUNCHost, addUNCHostToAllowlist } from './vs/base/node/unc.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
// ESM-uncomment-end
|
||||
|
||||
perf.mark('code/didStartMain');
|
||||
|
||||
// Enable portable support
|
||||
const portable = bootstrapNode.configurePortable(product);
|
||||
|
||||
// Enable ASAR support
|
||||
bootstrapNode.enableASARSupport();
|
||||
|
||||
// ESM-comment-begin
|
||||
// const minimist = require('minimist'); // !!! IMPORTANT: MUST come after bootstrap#enableASARSupport
|
||||
// ESM-comment-end
|
||||
|
||||
const args = parseCLIArgs();
|
||||
// Configure static command line arguments
|
||||
const argvConfig = configureCommandlineSwitchesSync(args);
|
||||
|
||||
@ -6,16 +6,6 @@
|
||||
// @ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-comment-begin
|
||||
// // Keep bootstrap-amd.js from redefining 'fs'.
|
||||
// delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
// const path = require('path');
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const bootstrapAmd = require('./bootstrap-amd');
|
||||
// const { resolveNLSConfiguration } = require('./vs/base/node/nls');
|
||||
// const product = require('./bootstrap-meta').product;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import './bootstrap-server.js'; // this MUST come before other imports as it changes global state
|
||||
import * as path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
@ -25,7 +15,6 @@ import { resolveNLSConfiguration } from './vs/base/node/nls.js';
|
||||
import { product } from './bootstrap-meta.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
// ESM-uncomment-end
|
||||
|
||||
async function start() {
|
||||
|
||||
|
||||
@ -11,23 +11,6 @@
|
||||
* @import { IServerAPI } from './vs/server/node/remoteExtensionHostAgentServer'
|
||||
*/
|
||||
|
||||
// ESM-comment-begin
|
||||
// // Keep bootstrap-amd.js from redefining 'fs'.
|
||||
// delete process.env['ELECTRON_RUN_AS_NODE'];
|
||||
//
|
||||
// const path = require('path');
|
||||
// const http = require('http');
|
||||
// const os = require('os');
|
||||
// const readline = require('readline');
|
||||
// const performance = require('perf_hooks').performance;
|
||||
// const bootstrapNode = require('./bootstrap-node');
|
||||
// const bootstrapAmd = require('./bootstrap-amd');
|
||||
// const { resolveNLSConfiguration } = require('./vs/base/node/nls');
|
||||
// const product = require('./bootstrap-meta').product;
|
||||
// const perf = require(`./vs/base/common/performance`);
|
||||
// const minimist = require('minimist');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import './bootstrap-server.js'; // this MUST come before other imports as it changes global state
|
||||
import * as path from 'path';
|
||||
import * as http from 'http';
|
||||
@ -43,7 +26,6 @@ import { product } from './bootstrap-meta.js';
|
||||
import * as perf from './vs/base/common/performance.js';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
// ESM-uncomment-end
|
||||
|
||||
perf.mark('code/server/start');
|
||||
// @ts-ignore
|
||||
|
||||
@ -3,11 +3,10 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { isESM, canASAR } from './base/common/amd.js';
|
||||
import { canASAR } from './base/common/amd.js';
|
||||
import { AppResourcePath, FileAccess, nodeModulesAsarPath, nodeModulesPath, Schemas, VSCODE_AUTHORITY } from './base/common/network.js';
|
||||
import * as platform from './base/common/platform.js';
|
||||
import { IProductConfiguration } from './base/common/product.js';
|
||||
import { assertType } from './base/common/types.js';
|
||||
import { URI } from './base/common/uri.js';
|
||||
import { generateUuid } from './base/common/uuid.js';
|
||||
|
||||
@ -175,11 +174,7 @@ class AMDModuleImporter {
|
||||
if (this._amdPolicy) {
|
||||
scriptSrc = this._amdPolicy.createScriptURL(scriptSrc) as any as string;
|
||||
}
|
||||
if (isESM) {
|
||||
await import(scriptSrc);
|
||||
} else {
|
||||
importScripts(scriptSrc);
|
||||
}
|
||||
await import(scriptSrc);
|
||||
return this._defineCalls.pop();
|
||||
}
|
||||
|
||||
@ -211,39 +206,32 @@ const cache = new Map<string, Promise<any>>();
|
||||
* e.g. pass in `vscode-textmate/release/main.js`
|
||||
*/
|
||||
export async function importAMDNodeModule<T>(nodeModuleName: string, pathInsideNodeModule: string, isBuilt?: boolean): Promise<T> {
|
||||
if (isESM) {
|
||||
|
||||
if (isBuilt === undefined) {
|
||||
const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration;
|
||||
isBuilt = Boolean((product ?? (globalThis as any).vscode?.context?.configuration()?.product)?.commit);
|
||||
}
|
||||
|
||||
const nodeModulePath = pathInsideNodeModule ? `${nodeModuleName}/${pathInsideNodeModule}` : nodeModuleName;
|
||||
if (cache.has(nodeModulePath)) {
|
||||
return cache.get(nodeModulePath)!;
|
||||
}
|
||||
let scriptSrc: string;
|
||||
if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) {
|
||||
// looks like a URL
|
||||
// bit of a special case for: src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts
|
||||
scriptSrc = nodeModulePath;
|
||||
} else {
|
||||
const useASAR = (canASAR && isBuilt && !platform.isWeb);
|
||||
const actualNodeModulesPath = (useASAR ? nodeModulesAsarPath : nodeModulesPath);
|
||||
const resourcePath: AppResourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
|
||||
scriptSrc = FileAccess.asBrowserUri(resourcePath).toString(true);
|
||||
}
|
||||
const result = AMDModuleImporter.INSTANCE.load<T>(scriptSrc);
|
||||
cache.set(nodeModulePath, result);
|
||||
return result;
|
||||
} else {
|
||||
return await import(nodeModuleName);
|
||||
if (isBuilt === undefined) {
|
||||
const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration;
|
||||
isBuilt = Boolean((product ?? (globalThis as any).vscode?.context?.configuration()?.product)?.commit);
|
||||
}
|
||||
|
||||
const nodeModulePath = pathInsideNodeModule ? `${nodeModuleName}/${pathInsideNodeModule}` : nodeModuleName;
|
||||
if (cache.has(nodeModulePath)) {
|
||||
return cache.get(nodeModulePath)!;
|
||||
}
|
||||
let scriptSrc: string;
|
||||
if (/^\w[\w\d+.-]*:\/\//.test(nodeModulePath)) {
|
||||
// looks like a URL
|
||||
// bit of a special case for: src/vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.ts
|
||||
scriptSrc = nodeModulePath;
|
||||
} else {
|
||||
const useASAR = (canASAR && isBuilt && !platform.isWeb);
|
||||
const actualNodeModulesPath = (useASAR ? nodeModulesAsarPath : nodeModulesPath);
|
||||
const resourcePath: AppResourcePath = `${actualNodeModulesPath}/${nodeModulePath}`;
|
||||
scriptSrc = FileAccess.asBrowserUri(resourcePath).toString(true);
|
||||
}
|
||||
const result = AMDModuleImporter.INSTANCE.load<T>(scriptSrc);
|
||||
cache.set(nodeModulePath, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
export function resolveAmdNodeModulePath(nodeModuleName: string, pathInsideNodeModule: string): string {
|
||||
assertType(isESM);
|
||||
|
||||
const product = globalThis._VSCODE_PRODUCT_JSON as unknown as IProductConfiguration;
|
||||
const isBuilt = Boolean((product ?? (globalThis as any).vscode?.context?.configuration()?.product)?.commit);
|
||||
const useASAR = (canASAR && isBuilt && !platform.isWeb);
|
||||
|
||||
@ -12,13 +12,6 @@ import { Disposable, toDisposable } from '../common/lifecycle.js';
|
||||
import { coalesce } from '../common/arrays.js';
|
||||
import { getNLSLanguage, getNLSMessages } from '../../nls.js';
|
||||
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
// Reuse the trusted types policy defined from worker bootstrap
|
||||
// when available.
|
||||
// Refs https://github.com/microsoft/vscode/issues/222193
|
||||
@ -33,7 +26,7 @@ export function createBlobWorker(blobUrl: string, options?: WorkerOptions): Work
|
||||
if (!blobUrl.startsWith('blob:')) {
|
||||
throw new URIError('Not a blob-url: ' + blobUrl);
|
||||
}
|
||||
return new Worker(ttPolicy ? ttPolicy.createScriptURL(blobUrl) as unknown as string : blobUrl, { ...options, type: isESM ? 'module' : undefined });
|
||||
return new Worker(ttPolicy ? ttPolicy.createScriptURL(blobUrl) as unknown as string : blobUrl, { ...options, type: 'module' });
|
||||
}
|
||||
|
||||
function getWorker(esmWorkerLocation: URI | undefined, label: string): Worker | Promise<Worker> {
|
||||
@ -49,26 +42,13 @@ function getWorker(esmWorkerLocation: URI | undefined, label: string): Worker |
|
||||
}
|
||||
if (typeof monacoEnvironment.getWorkerUrl === 'function') {
|
||||
const workerUrl = monacoEnvironment.getWorkerUrl('workerMain.js', label);
|
||||
return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: isESM ? 'module' : undefined });
|
||||
return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: 'module' });
|
||||
}
|
||||
}
|
||||
// ESM-comment-begin
|
||||
// if (typeof require === 'function') {
|
||||
// const workerMainLocation = require.toUrl('vs/base/worker/workerMain.js'); // explicitly using require.toUrl(), see https://github.com/microsoft/vscode/issues/107440#issuecomment-698982321
|
||||
// const factoryModuleId = 'vs/base/worker/defaultWorkerFactory.js';
|
||||
// const workerBaseUrl = require.toUrl(factoryModuleId).slice(0, -factoryModuleId.length); // explicitly using require.toUrl(), see https://github.com/microsoft/vscode/issues/107440#issuecomment-698982321
|
||||
// const workerUrl = getWorkerBootstrapUrl(label, workerMainLocation, workerBaseUrl);
|
||||
// return new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: isESM ? 'module' : undefined });
|
||||
// }
|
||||
// ESM-comment-end
|
||||
if (esmWorkerLocation) {
|
||||
const workerUrl = getWorkerBootstrapUrl(label, esmWorkerLocation.toString(true));
|
||||
const worker = new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: isESM ? 'module' : undefined });
|
||||
if (isESM) {
|
||||
return whenESMWorkerReady(worker);
|
||||
} else {
|
||||
return worker;
|
||||
}
|
||||
const worker = new Worker(ttPolicy ? ttPolicy.createScriptURL(workerUrl) as unknown as string : workerUrl, { name: label, type: 'module' });
|
||||
return whenESMWorkerReady(worker);
|
||||
}
|
||||
throw new Error(`You must define a function MonacoEnvironment.getWorkerUrl or MonacoEnvironment.getWorker`);
|
||||
}
|
||||
@ -104,8 +84,8 @@ function getWorkerBootstrapUrl(label: string, workerScriptUrl: string, workerBas
|
||||
`globalThis._VSCODE_FILE_ROOT = ${JSON.stringify(globalThis._VSCODE_FILE_ROOT)};`,
|
||||
`const ttPolicy = globalThis.trustedTypes?.createPolicy('defaultWorkerFactory', { createScriptURL: value => value });`,
|
||||
`globalThis.workerttPolicy = ttPolicy;`,
|
||||
isESM ? `await import(ttPolicy?.createScriptURL(${JSON.stringify(workerScriptUrl)}) ?? ${JSON.stringify(workerScriptUrl)});` : `importScripts(ttPolicy?.createScriptURL(${JSON.stringify(workerScriptUrl)}) ?? ${JSON.stringify(workerScriptUrl)});`,
|
||||
isESM ? `globalThis.postMessage({ type: 'vscode-worker-ready' });` : undefined, // in ESM signal we are ready after the async import
|
||||
`await import(ttPolicy?.createScriptURL(${JSON.stringify(workerScriptUrl)}) ?? ${JSON.stringify(workerScriptUrl)});`,
|
||||
`globalThis.postMessage({ type: 'vscode-worker-ready' });`,
|
||||
`/*${label}*/`
|
||||
]).join('')], { type: 'application/javascript' });
|
||||
return URL.createObjectURL(blob);
|
||||
@ -195,7 +175,7 @@ export class WorkerDescriptor implements IWorkerDescriptor {
|
||||
public readonly amdModuleId: string,
|
||||
readonly label: string | undefined,
|
||||
) {
|
||||
this.esmModuleLocation = (isESM ? FileAccess.asBrowserUri(`${amdModuleId}.esm.js` as AppResourcePath) : undefined);
|
||||
this.esmModuleLocation = FileAccess.asBrowserUri(`${amdModuleId}.esm.js` as AppResourcePath);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1621,11 +1621,6 @@ function createDOMPurify() {
|
||||
|
||||
var purify = createDOMPurify();
|
||||
|
||||
// ESM-comment-begin
|
||||
// define(function () { return purify; });
|
||||
// ESM-comment-end
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export default purify;
|
||||
export const version = purify.version;
|
||||
export const isSupported = purify.isSupported;
|
||||
@ -1637,4 +1632,3 @@ export const addHook = purify.addHook;
|
||||
export const removeHook = purify.removeHook;
|
||||
export const removeHooks = purify.removeHooks;
|
||||
export const removeAllHooks = purify.removeAllHooks;
|
||||
// ESM-uncomment-end
|
||||
|
||||
@ -3,14 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// ESM-comment-begin
|
||||
// export const isESM = false;
|
||||
// export const canASAR = true;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
export const isESM = true;
|
||||
export const canASAR = false; // TODO@esm: ASAR disabled in ESM
|
||||
// ESM-uncomment-end
|
||||
|
||||
export const enum LoaderEventType {
|
||||
LoaderAvailable = 1,
|
||||
|
||||
@ -8,18 +8,11 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-uncomment-begin
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
(function () {
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
function factory() {
|
||||
// First group matches a double quoted string
|
||||
@ -90,7 +83,5 @@ const module = { exports: {} };
|
||||
}
|
||||
})();
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const stripComments = module.exports.stripComments;
|
||||
export const parse = module.exports.parse;
|
||||
// ESM-uncomment-end
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -256,12 +256,7 @@ class FileAccessImpl {
|
||||
* **Note:** use `dom.ts#asCSSUrl` whenever the URL is to be used in CSS context.
|
||||
*/
|
||||
asBrowserUri(resourcePath: AppResourcePath | ''): URI {
|
||||
// ESM-comment-begin
|
||||
// const uri = this.toUri(resourcePath, require);
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const uri = this.toUri(resourcePath);
|
||||
// ESM-uncomment-end
|
||||
return this.uriToBrowserUri(uri);
|
||||
}
|
||||
|
||||
@ -308,12 +303,7 @@ class FileAccessImpl {
|
||||
* is responsible for loading.
|
||||
*/
|
||||
asFileUri(resourcePath: AppResourcePath | ''): URI {
|
||||
// ESM-comment-begin
|
||||
// const uri = this.toUri(resourcePath, require);
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const uri = this.toUri(resourcePath);
|
||||
// ESM-uncomment-end
|
||||
return this.uriToFileUri(uri);
|
||||
}
|
||||
|
||||
|
||||
@ -6,18 +6,11 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-uncomment-begin
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
(function () {
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
/**
|
||||
* @returns {{mark(name:string):void, getMarks():{name:string, startTime:number}[]}}
|
||||
@ -136,7 +129,5 @@ const module = { exports: {} };
|
||||
|
||||
})();
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const mark = module.exports.mark;
|
||||
export const getMarks = module.exports.getMarks;
|
||||
// ESM-uncomment-end
|
||||
|
||||
7
src/vs/base/common/semver/semver.d.ts
vendored
7
src/vs/base/common/semver/semver.d.ts
vendored
@ -3,14 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// ESM-comment-begin
|
||||
// export as namespace semver;
|
||||
// export = semver;
|
||||
// ESM-comment-end
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export * from 'semver'
|
||||
// ESM-uncomment-end
|
||||
|
||||
declare namespace semver {
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -12,13 +12,6 @@ import { isWeb } from '../platform.js';
|
||||
import * as strings from '../strings.js';
|
||||
import { URI } from '../uri.js';
|
||||
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
const DEFAULT_CHANNEL = 'default';
|
||||
const INITIALIZE = '$initialize';
|
||||
|
||||
@ -576,37 +569,13 @@ export class SimpleWorkerServer implements IWorkerServer {
|
||||
globalThis.require.config(loaderConfig);
|
||||
}
|
||||
|
||||
if (isESM) {
|
||||
const url = FileAccess.asBrowserUri(`${moduleId}.js` as AppResourcePath).toString(true);
|
||||
return import(`${url}`).then((module: { create: IRequestHandlerFactory }) => {
|
||||
this._requestHandler = module.create(this);
|
||||
const url = FileAccess.asBrowserUri(`${moduleId}.js` as AppResourcePath).toString(true);
|
||||
return import(`${url}`).then((module: { create: IRequestHandlerFactory }) => {
|
||||
this._requestHandler = module.create(this);
|
||||
|
||||
if (!this._requestHandler) {
|
||||
throw new Error(`No RequestHandler!`);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
// Use the global require to be sure to get the global config
|
||||
|
||||
// ESM-comment-begin
|
||||
// const req = (globalThis.require || require);
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const req = globalThis.require;
|
||||
// ESM-uncomment-end
|
||||
|
||||
req([moduleId], (module: { create: IRequestHandlerFactory }) => {
|
||||
this._requestHandler = module.create(this);
|
||||
|
||||
if (!this._requestHandler) {
|
||||
reject(new Error(`No RequestHandler!`));
|
||||
return;
|
||||
}
|
||||
|
||||
resolve();
|
||||
}, reject);
|
||||
if (!this._requestHandler) {
|
||||
throw new Error(`No RequestHandler!`);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -13,22 +13,15 @@
|
||||
* @import { IResolveNLSConfigurationContext } from './nls'
|
||||
*/
|
||||
|
||||
// ESM-uncomment-begin
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
import * as perf from '../common/performance.js';
|
||||
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
(function () {
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
/**
|
||||
* @param {typeof import('path')} path
|
||||
@ -264,17 +257,10 @@ const module = { exports: {} };
|
||||
define(['path', 'fs', 'vs/base/common/performance'], function (/** @type {typeof import('path')} */ path, /** @type {typeof import('fs')} */ fs, /** @type {typeof import('../common/performance')} */ perf) { return factory(path, fs, perf); });
|
||||
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
// commonjs
|
||||
// ESM-comment-begin
|
||||
// const path = require('path');
|
||||
// const fs = require('fs');
|
||||
// const perf = require('../common/performance');
|
||||
// ESM-comment-end
|
||||
module.exports = factory(path, fs, perf);
|
||||
} else {
|
||||
throw new Error('vs/base/node/nls defined in UNKNOWN context (neither requirejs or commonjs)');
|
||||
}
|
||||
})();
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const resolveNLSConfiguration = module.exports.resolveNLSConfiguration;
|
||||
// ESM-uncomment-end
|
||||
|
||||
@ -6,18 +6,11 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-uncomment-begin
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
(function () {
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
function factory() {
|
||||
|
||||
@ -159,10 +152,8 @@ const module = { exports: {} };
|
||||
}
|
||||
})();
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const getUNCHost = module.exports.getUNCHost;
|
||||
export const getUNCHostAllowlist = module.exports.getUNCHostAllowlist;
|
||||
export const addUNCHostToAllowlist = module.exports.addUNCHostToAllowlist;
|
||||
export const disableUNCAccessRestrictions = module.exports.disableUNCAccessRestrictions;
|
||||
export const isUNCAccessRestrictionsDisabled = module.exports.isUNCAccessRestrictionsDisabled;
|
||||
// ESM-uncomment-end
|
||||
|
||||
@ -309,12 +309,7 @@ export class SQLiteStorageDatabase implements IStorageDatabase {
|
||||
private doConnect(path: string): Promise<IDatabaseConnection> {
|
||||
return new Promise((resolve, reject) => {
|
||||
import('@vscode/sqlite3').then(sqlite3 => {
|
||||
// ESM-comment-begin
|
||||
// const ctor = (this.logger.isTracing ? sqlite3.verbose().Database : sqlite3.Database);
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const ctor = (this.logger.isTracing ? sqlite3.default.verbose().Database : sqlite3.default.Database);
|
||||
// ESM-uncomment-end
|
||||
const connection: IDatabaseConnection = {
|
||||
db: new ctor(path, (error: (Error & { code?: string }) | null) => {
|
||||
if (error) {
|
||||
|
||||
@ -15,7 +15,6 @@ import { isWindows } from '../../../common/platform.js';
|
||||
import { configureFlushOnWrite, Promises, RimRafMode, rimrafSync, SymlinkSupport, writeFileSync } from '../../../node/pfs.js';
|
||||
import { ensureNoDisposablesAreLeakedInTestSuite } from '../../common/utils.js';
|
||||
import { flakySuite, getRandomTestPath } from '../testUtils.js';
|
||||
import { isESM } from '../../../common/amd.js';
|
||||
|
||||
configureFlushOnWrite(false); // speed up all unit tests by disabling flush on write
|
||||
|
||||
@ -175,7 +174,7 @@ flakySuite('PFS', function () {
|
||||
assert.ok(!fs.existsSync(testDir));
|
||||
});
|
||||
|
||||
(!isESM ? test.skip : test /* somehow fails in AMD with ENOENT for fixtures dir */)('copy, rename and delete', async () => {
|
||||
test('copy, rename and delete', async () => {
|
||||
const sourceDir = FileAccess.asFileUri('vs/base/test/node/pfs/fixtures').fsPath;
|
||||
const parentDir = join(tmpdir(), 'vsctests', 'pfs');
|
||||
const targetDir = randomPath(parentDir);
|
||||
@ -210,7 +209,7 @@ flakySuite('PFS', function () {
|
||||
assert.ok(!fs.existsSync(parentDir));
|
||||
});
|
||||
|
||||
(!isESM ? test.skip : test /* somehow fails in AMD with ENOENT for fixtures dir */)('rename without retry', async () => {
|
||||
test('rename without retry', async () => {
|
||||
const sourceDir = FileAccess.asFileUri('vs/base/test/node/pfs/fixtures').fsPath;
|
||||
const parentDir = join(tmpdir(), 'vsctests', 'pfs');
|
||||
const targetDir = randomPath(parentDir);
|
||||
|
||||
@ -5,130 +5,9 @@
|
||||
|
||||
(function () {
|
||||
|
||||
interface IMonacoEnvironment {
|
||||
baseUrl?: string;
|
||||
createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>>;
|
||||
}
|
||||
const monacoEnvironment: IMonacoEnvironment | undefined = (globalThis as any).MonacoEnvironment;
|
||||
|
||||
const monacoBaseUrl = monacoEnvironment && monacoEnvironment.baseUrl ? monacoEnvironment.baseUrl : '../../../';
|
||||
|
||||
function createTrustedTypesPolicy<Options extends TrustedTypePolicyOptions>(
|
||||
policyName: string,
|
||||
policyOptions?: Options,
|
||||
): undefined | Pick<TrustedTypePolicy<Options>, 'name' | Extract<keyof Options, keyof TrustedTypePolicyOptions>> {
|
||||
|
||||
if (monacoEnvironment?.createTrustedTypesPolicy) {
|
||||
try {
|
||||
return monacoEnvironment.createTrustedTypesPolicy(policyName, policyOptions);
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
return self.trustedTypes?.createPolicy(policyName, policyOptions);
|
||||
} catch (err) {
|
||||
console.warn(err);
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
const trustedTypesPolicy = createTrustedTypesPolicy('amdLoader', {
|
||||
createScriptURL: value => value,
|
||||
createScript: (_, ...args: string[]) => {
|
||||
// workaround a chrome issue not allowing to create new functions
|
||||
// see https://github.com/w3c/webappsec-trusted-types/wiki/Trusted-Types-for-function-constructor
|
||||
const fnArgs = args.slice(0, -1).join(',');
|
||||
const fnBody = args.pop()!.toString();
|
||||
// Do not add a new line to fnBody, as this will confuse source maps.
|
||||
const body = `(function anonymous(${fnArgs}) { ${fnBody}\n})`;
|
||||
return body;
|
||||
}
|
||||
});
|
||||
|
||||
function canUseEval(): boolean {
|
||||
try {
|
||||
const func = (
|
||||
trustedTypesPolicy
|
||||
? globalThis.eval(<any>trustedTypesPolicy.createScript('', 'true')) // CodeQL [SM01632] fetch + eval is used on the web worker instead of importScripts if possible because importScripts is synchronous and we observed deadlocks on Safari
|
||||
: new Function('true') // CodeQL [SM01632] fetch + eval is used on the web worker instead of importScripts if possible because importScripts is synchronous and we observed deadlocks on Safari
|
||||
);
|
||||
func.call(globalThis);
|
||||
return true;
|
||||
} catch (err) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function loadAMDLoader() {
|
||||
return new Promise<void>((resolve, reject) => {
|
||||
if (typeof (<any>globalThis).define === 'function' && (<any>globalThis).define.amd) {
|
||||
return resolve();
|
||||
}
|
||||
const loaderSrc: string | TrustedScriptURL = monacoBaseUrl + 'vs/loader.js';
|
||||
|
||||
const isCrossOrigin = (/^((http:)|(https:)|(file:))/.test(loaderSrc) && loaderSrc.substring(0, globalThis.origin.length) !== globalThis.origin);
|
||||
if (!isCrossOrigin && canUseEval()) {
|
||||
// use `fetch` if possible because `importScripts`
|
||||
// is synchronous and can lead to deadlocks on Safari
|
||||
fetch(loaderSrc).then((response) => {
|
||||
if (response.status !== 200) {
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
return response.text();
|
||||
}).then((text) => {
|
||||
text = `${text}\n//# sourceURL=${loaderSrc}`;
|
||||
const func = (
|
||||
trustedTypesPolicy
|
||||
? globalThis.eval(trustedTypesPolicy.createScript('', text) as unknown as string) // CodeQL [SM01632] fetch + eval is used on the web worker instead of importScripts if possible because importScripts is synchronous and we observed deadlocks on Safari
|
||||
: new Function(text) // CodeQL [SM01632] fetch + eval is used on the web worker instead of importScripts if possible because importScripts is synchronous and we observed deadlocks on Safari
|
||||
);
|
||||
func.call(globalThis);
|
||||
resolve();
|
||||
}).then(undefined, reject);
|
||||
return;
|
||||
}
|
||||
|
||||
if (trustedTypesPolicy) {
|
||||
importScripts(trustedTypesPolicy.createScriptURL(loaderSrc) as unknown as string);
|
||||
} else {
|
||||
importScripts(loaderSrc as string);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
}
|
||||
|
||||
// ESM-comment-begin
|
||||
// function configureAMDLoader() {
|
||||
// require.config({
|
||||
// baseUrl: monacoBaseUrl,
|
||||
// catchError: true,
|
||||
// trustedTypesPolicy,
|
||||
// amdModulesPattern: /^vs\//
|
||||
// });
|
||||
// }
|
||||
// ESM-comment-end
|
||||
|
||||
function loadCode(moduleId: string): Promise<SimpleWorkerModule> {
|
||||
// ESM-uncomment-begin
|
||||
if (typeof loadAMDLoader === 'function') { /* fixes unused import, remove me */ }
|
||||
const moduleUrl = new URL(`${moduleId}.js`, globalThis._VSCODE_FILE_ROOT);
|
||||
return import(moduleUrl.href);
|
||||
// ESM-uncomment-end
|
||||
|
||||
// ESM-comment-begin
|
||||
// return loadAMDLoader().then(() => {
|
||||
// configureAMDLoader();
|
||||
// return new Promise<SimpleWorkerModule>((resolve, reject) => {
|
||||
// require([moduleId], resolve, reject);
|
||||
// });
|
||||
// });
|
||||
// ESM-comment-end
|
||||
}
|
||||
|
||||
interface MessageHandler {
|
||||
@ -153,15 +32,6 @@
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// If the loader is already defined, configure it immediately
|
||||
// This helps in the bundled case, where we must load nls files
|
||||
// and they need a correct baseUrl to be loaded.
|
||||
// ESM-comment-begin
|
||||
// if (typeof (<any>globalThis).define === 'function' && (<any>globalThis).define.amd) {
|
||||
// configureAMDLoader();
|
||||
// }
|
||||
// ESM-comment-end
|
||||
|
||||
let isFirstMessage = true;
|
||||
const beforeReadyMessages: MessageEvent[] = [];
|
||||
globalThis.onmessage = (message: MessageEvent) => {
|
||||
|
||||
@ -1,67 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
performance.mark('code/didStartRenderer');
|
||||
</script>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<!-- Mobile tweaks -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-title" content="Code">
|
||||
<link rel="apple-touch-icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/code-192.png" />
|
||||
|
||||
<!-- Disable pinch zooming -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||
|
||||
<!-- Workbench Configuration -->
|
||||
<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}">
|
||||
|
||||
<!-- Workbench Auth Session -->
|
||||
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
|
||||
|
||||
<!-- Builtin Extensions (running out of sources) -->
|
||||
<meta id="vscode-workbench-builtin-extensions" data-settings="{{WORKBENCH_BUILTIN_EXTENSIONS}}">
|
||||
|
||||
<!-- Workbench Icon/Manifest/CSS -->
|
||||
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
|
||||
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
|
||||
<style id="vscode-css-modules" type="text/css" media="screen"></style>
|
||||
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script>
|
||||
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
|
||||
globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
|
||||
</script>
|
||||
<script>
|
||||
const sheet = document.getElementById('vscode-css-modules').sheet;
|
||||
globalThis._VSCODE_CSS_LOAD = function (url) {
|
||||
sheet.insertRule(`@import url(${url});`);
|
||||
};
|
||||
|
||||
const importMap = { imports: {} };
|
||||
const cssModules = JSON.parse('{{WORKBENCH_DEV_CSS_MODULES}}');
|
||||
for (const cssModule of cssModules) {
|
||||
const cssUrl = new URL(cssModule, globalThis._VSCODE_FILE_ROOT).href;
|
||||
const jsSrc = `globalThis._VSCODE_CSS_LOAD('${cssUrl}');\n`;
|
||||
const blob = new Blob([jsSrc], { type: 'application/javascript' });
|
||||
importMap.imports[cssUrl] = URL.createObjectURL(blob);
|
||||
}
|
||||
const importMapElement = document.createElement('script');
|
||||
importMapElement.type = 'importmap';
|
||||
importMapElement.setAttribute('nonce', '1nline-m4p')
|
||||
importMapElement.textContent = JSON.stringify(importMap, undefined, 2);
|
||||
document.head.appendChild(importMapElement);
|
||||
</script>
|
||||
<script>
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
</script>
|
||||
<script type="module" src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
|
||||
</html>
|
||||
@ -28,6 +28,7 @@
|
||||
<!-- Workbench Icon/Manifest/CSS -->
|
||||
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
|
||||
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
|
||||
<style id="vscode-css-modules" type="text/css" media="screen"></style>
|
||||
|
||||
</head>
|
||||
|
||||
@ -35,31 +36,32 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
|
||||
<script>
|
||||
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
|
||||
Object.keys(self.webPackagePaths).map(function (key, index) {
|
||||
self.webPackagePaths[key] = `${baseUrl}/remote/web/node_modules/${key}/${self.webPackagePaths[key]}`;
|
||||
});
|
||||
require.config({
|
||||
baseUrl: `${baseUrl}/out`,
|
||||
recordStats: true,
|
||||
trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
|
||||
createScriptURL(value) {
|
||||
if(value.startsWith(window.location.origin)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`Invalid script url: ${value}`)
|
||||
}
|
||||
}),
|
||||
paths: self.webPackagePaths
|
||||
});
|
||||
globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
|
||||
</script>
|
||||
<script>
|
||||
const sheet = document.getElementById('vscode-css-modules').sheet;
|
||||
globalThis._VSCODE_CSS_LOAD = function (url) {
|
||||
sheet.insertRule(`@import url(${url});`);
|
||||
};
|
||||
|
||||
const importMap = { imports: {} };
|
||||
const cssModules = JSON.parse('{{WORKBENCH_DEV_CSS_MODULES}}');
|
||||
for (const cssModule of cssModules) {
|
||||
const cssUrl = new URL(cssModule, globalThis._VSCODE_FILE_ROOT).href;
|
||||
const jsSrc = `globalThis._VSCODE_CSS_LOAD('${cssUrl}');\n`;
|
||||
const blob = new Blob([jsSrc], { type: 'application/javascript' });
|
||||
importMap.imports[cssUrl] = URL.createObjectURL(blob);
|
||||
}
|
||||
const importMapElement = document.createElement('script');
|
||||
importMapElement.type = 'importmap';
|
||||
importMapElement.setAttribute('nonce', '1nline-m4p')
|
||||
importMapElement.textContent = JSON.stringify(importMap, undefined, 2);
|
||||
document.head.appendChild(importMapElement);
|
||||
</script>
|
||||
<script>
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
</script>
|
||||
<script>
|
||||
require(['vs/code/browser/workbench/workbench'], function() {});
|
||||
</script>
|
||||
<script type="module" src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
|
||||
</html>
|
||||
|
||||
@ -1,48 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<script>
|
||||
performance.mark('code/didStartRenderer');
|
||||
</script>
|
||||
<meta charset="utf-8" />
|
||||
|
||||
<!-- Mobile tweaks -->
|
||||
<meta name="mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-capable" content="yes" />
|
||||
<meta name="apple-mobile-web-app-title" content="Code">
|
||||
<link rel="apple-touch-icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/code-192.png" />
|
||||
|
||||
<!-- Disable pinch zooming -->
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no">
|
||||
|
||||
<!-- Workbench Configuration -->
|
||||
<meta id="vscode-workbench-web-configuration" data-settings="{{WORKBENCH_WEB_CONFIGURATION}}">
|
||||
|
||||
<!-- Workbench Auth Session -->
|
||||
<meta id="vscode-workbench-auth-session" data-settings="{{WORKBENCH_AUTH_SESSION}}">
|
||||
|
||||
<!-- Workbench Icon/Manifest/CSS -->
|
||||
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
|
||||
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
|
||||
<link rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.css">
|
||||
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script>
|
||||
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
|
||||
globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
|
||||
</script>
|
||||
<script>
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
</script>
|
||||
<!-- always ensure built in english NLS messages -->
|
||||
<script type="module" src="{{WORKBENCH_NLS_FALLBACK_URL}}"></script>
|
||||
<!-- attempt to load NLS messages in case non-english -->
|
||||
<script type="module" src="{{WORKBENCH_NLS_URL}}"></script>
|
||||
<script type="module" src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
|
||||
</html>
|
||||
@ -25,7 +25,7 @@
|
||||
<!-- Workbench Icon/Manifest/CSS -->
|
||||
<link rel="icon" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/favicon.ico" type="image/x-icon" />
|
||||
<link rel="manifest" href="{{WORKBENCH_WEB_BASE_URL}}/resources/server/manifest.json" crossorigin="use-credentials" />
|
||||
<link data-name="vs/workbench/workbench.web.main" rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.css">
|
||||
<link rel="stylesheet" href="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.css">
|
||||
|
||||
</head>
|
||||
|
||||
@ -33,38 +33,16 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/loader.js"></script>
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/webPackagePaths.js"></script>
|
||||
<script>
|
||||
|
||||
// Packages
|
||||
const baseUrl = new URL('{{WORKBENCH_WEB_BASE_URL}}', window.location.origin).toString();
|
||||
Object.keys(self.webPackagePaths).map(function (key, index) {
|
||||
self.webPackagePaths[key] = `${baseUrl}/node_modules/${key}/${self.webPackagePaths[key]}`;
|
||||
});
|
||||
|
||||
// AMD Loader
|
||||
require.config({
|
||||
baseUrl: `${baseUrl}/out`,
|
||||
recordStats: true,
|
||||
trustedTypesPolicy: window.trustedTypes?.createPolicy('amdLoader', {
|
||||
createScriptURL(value) {
|
||||
if(value.startsWith(window.location.origin)) {
|
||||
return value;
|
||||
}
|
||||
throw new Error(`Invalid script url: ${value}`)
|
||||
}
|
||||
}),
|
||||
paths: self.webPackagePaths
|
||||
});
|
||||
globalThis._VSCODE_FILE_ROOT = baseUrl + '/out/';
|
||||
</script>
|
||||
<script>
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
</script>
|
||||
<!-- always ensure built in english NLS messages -->
|
||||
<script src="{{WORKBENCH_NLS_FALLBACK_URL}}"></script>
|
||||
<script type="module" src="{{WORKBENCH_NLS_FALLBACK_URL}}"></script>
|
||||
<!-- attempt to load NLS messages in case non-english -->
|
||||
<script src="{{WORKBENCH_NLS_URL}}"></script>
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/workbench/workbench.web.main.internal.js"></script>
|
||||
<script src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
|
||||
<script type="module" src="{{WORKBENCH_NLS_URL}}"></script>
|
||||
<script type="module" src="{{WORKBENCH_WEB_BASE_URL}}/out/vs/code/browser/workbench/workbench.js"></script>
|
||||
</html>
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
;
|
||||
">
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
<div id="process-list"></div>
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="../../../../bootstrap-window.js"></script>
|
||||
<script src="./processExplorer.js"></script>
|
||||
</html>
|
||||
@ -15,6 +15,8 @@
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
|
||||
@ -1,42 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
;
|
||||
">
|
||||
<link rel="stylesheet" href="./processExplorerMain.css">
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
<div id="process-list"></div>
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="./processExplorer.js" type="module"></script>
|
||||
</html>
|
||||
@ -15,6 +15,8 @@
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
@ -28,6 +30,7 @@
|
||||
'self'
|
||||
;
|
||||
">
|
||||
<link rel="stylesheet" href="./processExplorerMain.css">
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
@ -35,5 +38,5 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="processExplorer.js"></script>
|
||||
<script src="./processExplorer.js" type="module"></script>
|
||||
</html>
|
||||
|
||||
@ -1,75 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
blob:
|
||||
vscode-remote-resource:
|
||||
vscode-managed-remote-resource:
|
||||
https:
|
||||
;
|
||||
media-src
|
||||
'self'
|
||||
;
|
||||
frame-src
|
||||
'self'
|
||||
vscode-webview:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
'unsafe-eval'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
ws:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
vscode-remote-resource:
|
||||
vscode-managed-remote-resource:
|
||||
https://*.vscode-unpkg.net
|
||||
;
|
||||
require-trusted-types-for
|
||||
'script'
|
||||
;
|
||||
trusted-types
|
||||
vscode-bootstrapImportMap
|
||||
amdLoader
|
||||
cellRendererEditorText
|
||||
defaultWorkerFactory
|
||||
diffEditorWidget
|
||||
diffReview
|
||||
domLineBreaksComputer
|
||||
dompurify
|
||||
editorGhostText
|
||||
editorViewLayer
|
||||
notebookRenderer
|
||||
stickyScrollViewLayer
|
||||
tokenizeToString
|
||||
;
|
||||
"/>
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="../../../../bootstrap-window.js"></script>
|
||||
<script src="./workbench.js"></script>
|
||||
</html>
|
||||
@ -28,6 +28,7 @@
|
||||
'self'
|
||||
'unsafe-eval'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
@ -48,6 +49,7 @@
|
||||
'script'
|
||||
;
|
||||
trusted-types
|
||||
vscode-bootstrapImportMap
|
||||
amdLoader
|
||||
cellRendererEditorText
|
||||
defaultWorkerFactory
|
||||
@ -68,7 +70,6 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="../../../../vs/loader.js"></script>
|
||||
<script src="../../../../bootstrap-window.js"></script>
|
||||
<script src="./workbench.js"></script>
|
||||
</html>
|
||||
|
||||
@ -1,72 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
blob:
|
||||
vscode-remote-resource:
|
||||
vscode-managed-remote-resource:
|
||||
https:
|
||||
;
|
||||
media-src
|
||||
'self'
|
||||
;
|
||||
frame-src
|
||||
'self'
|
||||
vscode-webview:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
'unsafe-eval'
|
||||
blob:
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
ws:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
vscode-remote-resource:
|
||||
vscode-managed-remote-resource:
|
||||
https://*.vscode-unpkg.net
|
||||
;
|
||||
require-trusted-types-for
|
||||
'script'
|
||||
;
|
||||
trusted-types
|
||||
amdLoader
|
||||
cellRendererEditorText
|
||||
defaultWorkerFactory
|
||||
diffEditorWidget
|
||||
diffReview
|
||||
domLineBreaksComputer
|
||||
dompurify
|
||||
editorGhostText
|
||||
editorViewLayer
|
||||
notebookRenderer
|
||||
stickyScrollViewLayer
|
||||
tokenizeToString
|
||||
;
|
||||
"/>
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="./workbench.js" type="module"></script>
|
||||
</html>
|
||||
@ -68,5 +68,5 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="workbench.js"></script>
|
||||
<script src="./workbench.js" type="module"></script>
|
||||
</html>
|
||||
|
||||
@ -48,11 +48,7 @@
|
||||
canModifyDOM: function (windowConfig) {
|
||||
showSplash(windowConfig);
|
||||
},
|
||||
beforeLoaderConfig: function (loaderConfig) {
|
||||
// @ts-ignore
|
||||
loaderConfig.recordStats = true;
|
||||
},
|
||||
beforeRequire: function (windowConfig) {
|
||||
beforeImport: function (windowConfig) {
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
|
||||
// Code windows have a `vscodeWindowId` property to identify them
|
||||
@ -91,8 +87,7 @@
|
||||
* removeDeveloperKeybindingsAfterLoad?: boolean
|
||||
* },
|
||||
* canModifyDOM?: (config: INativeWindowConfiguration & NativeParsedArgs) => void,
|
||||
* beforeLoaderConfig?: (loaderConfig: object) => void,
|
||||
* beforeRequire?: (config: ISandboxConfiguration) => void
|
||||
* beforeImport?: (config: ISandboxConfiguration) => void
|
||||
* }
|
||||
* ) => Promise<unknown>
|
||||
* }}
|
||||
|
||||
@ -397,10 +397,7 @@ export async function main(argv: string[]): Promise<any> {
|
||||
return false;
|
||||
}
|
||||
if (target.type === 'page') {
|
||||
return target.url.indexOf('workbench/workbench.html') > 0 ||
|
||||
target.url.indexOf('workbench/workbench-dev.html') > 0 ||
|
||||
target.url.indexOf('workbench/workbench.esm.html') > 0 ||
|
||||
target.url.indexOf('workbench/workbench-dev.esm.html') > 0;
|
||||
return target.url.indexOf('workbench/workbench.html') > 0 || target.url.indexOf('workbench/workbench-dev.html') > 0;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -32,13 +32,6 @@ import { FindSectionHeaderOptions, SectionHeader, findSectionHeaders } from './f
|
||||
import { IRawModelData, IWorkerTextModelSyncChannelServer } from './textModelSync/textModelSync.protocol.js';
|
||||
import { ICommonModel, WorkerTextModelSyncServer } from './textModelSync/textModelSync.impl.js';
|
||||
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
export interface IMirrorModel extends IMirrorTextModel {
|
||||
readonly uri: URI;
|
||||
readonly version: number;
|
||||
@ -565,12 +558,8 @@ export class EditorSimpleWorker extends BaseEditorSimpleWorker {
|
||||
resolve(getAllMethodNames(this._foreignModule));
|
||||
};
|
||||
|
||||
if (!isESM) {
|
||||
require([`${moduleId}`], onModuleCallback, reject);
|
||||
} else {
|
||||
const url = FileAccess.asBrowserUri(`${moduleId}.js` as AppResourcePath).toString(true);
|
||||
import(`${url}`).then(onModuleCallback).catch(reject);
|
||||
}
|
||||
const url = FileAccess.asBrowserUri(`${moduleId}.js` as AppResourcePath).toString(true);
|
||||
import(`${url}`).then(onModuleCallback).catch(reject);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
import { spawn } from 'child_process';
|
||||
import { relative } from 'path';
|
||||
import { isESM } from '../../../base/common/amd.js';
|
||||
import { FileAccess } from '../../../base/common/network.js';
|
||||
import { StopWatch } from '../../../base/common/stopwatch.js';
|
||||
import { IEnvironmentService } from '../../environment/common/environment.js';
|
||||
@ -32,7 +31,7 @@ export class CSSDevelopmentService implements ICSSDevelopmentService {
|
||||
) { }
|
||||
|
||||
get isEnabled(): boolean {
|
||||
return !this.envService.isBuilt && isESM;
|
||||
return !this.envService.isBuilt;
|
||||
}
|
||||
|
||||
getCssModules(): Promise<string[]> {
|
||||
|
||||
@ -8,21 +8,14 @@
|
||||
//@ts-check
|
||||
'use strict';
|
||||
|
||||
// ESM-uncomment-begin
|
||||
import * as os from 'os';
|
||||
import * as path from 'path';
|
||||
|
||||
/** @type any */
|
||||
const module = { exports: {} };
|
||||
// ESM-uncomment-end
|
||||
|
||||
(function () {
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
/**
|
||||
* @import { NativeParsedArgs } from '../../environment/common/argv'
|
||||
@ -132,17 +125,10 @@ const module = { exports: {} };
|
||||
return factory(path, os, process.cwd()); // amd
|
||||
});
|
||||
} else if (typeof module === 'object' && typeof module.exports === 'object') {
|
||||
// ESM-comment-begin
|
||||
// const path = require('path');
|
||||
// const os = require('os');
|
||||
// ESM-comment-end
|
||||
|
||||
module.exports = factory(path, os, process.env['VSCODE_CWD'] || process.cwd()); // commonjs
|
||||
} else {
|
||||
throw new Error('Unknown context');
|
||||
}
|
||||
}());
|
||||
|
||||
// ESM-uncomment-begin
|
||||
export const getUserDataPath = module.exports.getUserDataPath;
|
||||
// ESM-uncomment-end
|
||||
|
||||
@ -107,32 +107,17 @@ flakySuite('Native Modules (all platforms)', () => {
|
||||
});
|
||||
|
||||
test('@vscode/sqlite3', async () => {
|
||||
// ESM-comment-begin
|
||||
// const sqlite3 = await import('@vscode/sqlite3');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const { default: sqlite3 } = await import('@vscode/sqlite3');
|
||||
// ESM-uncomment-end
|
||||
assert.ok(typeof sqlite3.Database === 'function', testErrorMessage('@vscode/sqlite3'));
|
||||
});
|
||||
|
||||
test('http-proxy-agent', async () => {
|
||||
// ESM-comment-begin
|
||||
// const mod = await import('http-proxy-agent');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const { default: mod } = await import('http-proxy-agent');
|
||||
// ESM-uncomment-end
|
||||
assert.ok(typeof mod.HttpProxyAgent === 'function', testErrorMessage('http-proxy-agent'));
|
||||
});
|
||||
|
||||
test('https-proxy-agent', async () => {
|
||||
// ESM-comment-begin
|
||||
// const mod = await import('https-proxy-agent');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const { default: mod } = await import('https-proxy-agent');
|
||||
// ESM-uncomment-end
|
||||
assert.ok(typeof mod.HttpsProxyAgent === 'function', testErrorMessage('https-proxy-agent'));
|
||||
});
|
||||
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule } from '../../../amdX.js';
|
||||
import { getErrorMessage } from '../../../base/common/errors.js';
|
||||
import { TargetPlatform } from '../../extensions/common/extensions.js';
|
||||
import { createDecorator } from '../../instantiation/common/instantiation.js';
|
||||
@ -67,15 +66,8 @@ export class ExtensionSignatureVerificationService implements IExtensionSignatur
|
||||
}
|
||||
|
||||
private async resolveVsceSign(): Promise<typeof vsceSign> {
|
||||
// ESM-uncomment-begin
|
||||
if (typeof importAMDNodeModule === 'function') { /* fixes unused import, remove me */ }
|
||||
const mod = '@vscode/vsce-sign';
|
||||
return import(mod);
|
||||
// ESM-uncomment-end
|
||||
|
||||
// ESM-comment-begin
|
||||
// return importAMDNodeModule('@vscode/vsce-sign', 'src/main.js');
|
||||
// ESM-comment-end
|
||||
}
|
||||
|
||||
public async verify(extensionId: string, version: string, vsixFilePath: string, signatureArchiveFilePath: string, clientTargetPlatform?: TargetPlatform): Promise<IExtensionSignatureVerificationResult | undefined> {
|
||||
|
||||
@ -20,7 +20,6 @@ import { etag, IFileAtomicReadOptions, FileOperation, FileOperationError, FileOp
|
||||
import { FileService } from '../../common/fileService.js';
|
||||
import { DiskFileSystemProvider } from '../../node/diskFileSystemProvider.js';
|
||||
import { NullLogService } from '../../../log/common/log.js';
|
||||
import { isESM } from '../../../../base/common/amd.js';
|
||||
|
||||
function getByName(root: IFileStat, name: string): IFileStat | undefined {
|
||||
if (root.children === undefined) {
|
||||
@ -132,7 +131,7 @@ export class TestDiskFileSystemProvider extends DiskFileSystemProvider {
|
||||
|
||||
DiskFileSystemProvider.configureFlushOnWrite(false); // speed up all unit tests by disabling flush on write
|
||||
|
||||
(!isESM ? suite.skip : flakySuite /* somehow fails in AMD with ENOENT for fixtures dir */)('Disk File Service', function () {
|
||||
flakySuite('Disk File Service', function () {
|
||||
|
||||
const testSchema = 'test';
|
||||
|
||||
|
||||
@ -22,7 +22,6 @@ import { IIPCObjectUrl, IProtocolMainService } from '../../protocol/electron-mai
|
||||
import { zoomLevelToZoomFactor } from '../../window/common/window.js';
|
||||
import { ICodeWindow, IWindowState } from '../../window/electron-main/window.js';
|
||||
import { IWindowsMainService } from '../../windows/electron-main/windows.js';
|
||||
import { isESM } from '../../../base/common/amd.js';
|
||||
import { ICSSDevelopmentService } from '../../cssDev/node/cssDevService.js';
|
||||
|
||||
interface IBrowserWindowOptions {
|
||||
@ -93,7 +92,7 @@ export class IssueMainService implements IIssueMainService {
|
||||
});
|
||||
|
||||
this.issueReporterWindow.loadURL(
|
||||
FileAccess.asBrowserUri(`vs/workbench/contrib/issue/electron-sandbox/issueReporter${this.environmentMainService.isBuilt ? '' : '-dev'}.${isESM ? 'esm.' : ''}html`).toString(true)
|
||||
FileAccess.asBrowserUri(`vs/workbench/contrib/issue/electron-sandbox/issueReporter${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true)
|
||||
);
|
||||
|
||||
this.issueReporterWindow.on('close', () => {
|
||||
|
||||
@ -26,7 +26,6 @@ import { IStateService } from '../../state/node/state.js';
|
||||
import { UtilityProcess } from '../../utilityProcess/electron-main/utilityProcess.js';
|
||||
import { zoomLevelToZoomFactor } from '../../window/common/window.js';
|
||||
import { IWindowState } from '../../window/electron-main/window.js';
|
||||
import { isESM } from '../../../base/common/amd.js';
|
||||
|
||||
const processExplorerWindowState = 'issue.processExplorerWindowState';
|
||||
|
||||
@ -165,7 +164,7 @@ export class ProcessMainService implements IProcessMainService {
|
||||
});
|
||||
|
||||
this.processExplorerWindow.loadURL(
|
||||
FileAccess.asBrowserUri(`vs/code/electron-sandbox/processExplorer/processExplorer${this.environmentMainService.isBuilt ? '' : '-dev'}.${isESM ? 'esm.' : ''}html`).toString(true)
|
||||
FileAccess.asBrowserUri(`vs/code/electron-sandbox/processExplorer/processExplorer${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true)
|
||||
);
|
||||
|
||||
this.processExplorerWindow.on('close', () => {
|
||||
|
||||
@ -97,7 +97,7 @@ export class ProtocolMainService extends Disposable implements IProtocolMainServ
|
||||
let headers: Record<string, string> | undefined;
|
||||
if (this.environmentService.crossOriginIsolated) {
|
||||
const pathBasename = basename(path);
|
||||
if (pathBasename === 'workbench.html' || pathBasename === 'workbench-dev.html' || pathBasename === 'workbench.esm.html' || pathBasename === 'workbench-dev.esm.html') {
|
||||
if (pathBasename === 'workbench.html' || pathBasename === 'workbench-dev.html') {
|
||||
headers = COI.CoopAndCoep;
|
||||
} else {
|
||||
headers = COI.getHeadersFromQuery(request.url);
|
||||
|
||||
@ -45,20 +45,10 @@ export async function getProxyAgent(rawRequestURL: string, env: typeof process.e
|
||||
};
|
||||
|
||||
if (requestURL.protocol === 'http:') {
|
||||
// ESM-comment-begin
|
||||
// const mod = await import('http-proxy-agent');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const { default: mod } = await import('http-proxy-agent');
|
||||
// ESM-uncomment-end
|
||||
return new mod.HttpProxyAgent(proxyURL, opts);
|
||||
} else {
|
||||
// ESM-comment-begin
|
||||
// const mod = await import('https-proxy-agent');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const { default: mod } = await import('https-proxy-agent');
|
||||
// ESM-uncomment-end
|
||||
return new mod.HttpsProxyAgent(proxyURL, opts);
|
||||
}
|
||||
}
|
||||
|
||||
@ -6,9 +6,7 @@
|
||||
import { importAMDNodeModule, resolveAmdNodeModulePath } from '../../../amdX.js';
|
||||
import { WindowIntervalTimer } from '../../../base/browser/dom.js';
|
||||
import { mainWindow } from '../../../base/browser/window.js';
|
||||
import { isESM } from '../../../base/common/amd.js';
|
||||
import { memoize } from '../../../base/common/decorators.js';
|
||||
import { FileAccess } from '../../../base/common/network.js';
|
||||
import { IProductService } from '../../product/common/productService.js';
|
||||
import { AbstractSignService, IVsdaValidator } from '../common/abstractSignService.js';
|
||||
import { ISignService } from '../common/sign.js';
|
||||
@ -88,9 +86,7 @@ export class SignService extends AbstractSignService implements ISignService {
|
||||
}
|
||||
|
||||
private async getWasmBytes(): Promise<ArrayBuffer> {
|
||||
const url = isESM
|
||||
? resolveAmdNodeModulePath('vsda', 'rust/web/vsda_bg.wasm')
|
||||
: FileAccess.asBrowserUri('vsda/../vsda_bg.wasm').toString(true);
|
||||
const url = resolveAmdNodeModulePath('vsda', 'rust/web/vsda_bg.wasm');
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error('error loading vsda');
|
||||
|
||||
@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule } from '../../../amdX.js';
|
||||
import { AbstractSignService, IVsdaValidator } from '../common/abstractSignService.js';
|
||||
import { ISignService } from '../common/sign.js';
|
||||
|
||||
@ -30,15 +29,8 @@ export class SignService extends AbstractSignService implements ISignService {
|
||||
}
|
||||
|
||||
private async vsda(): Promise<typeof vsda> {
|
||||
// ESM-uncomment-begin
|
||||
if (typeof importAMDNodeModule === 'function') { /* fixes unused import, remove me */ }
|
||||
const mod = 'vsda';
|
||||
const { default: vsda } = await import(mod);
|
||||
return vsda;
|
||||
// ESM-uncomment-end
|
||||
|
||||
// ESM-comment-begin
|
||||
// return importAMDNodeModule('vsda', 'index.js');
|
||||
// ESM-comment-end
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,17 +23,10 @@ const endpointUrl = 'https://mobile.events.data.microsoft.com/OneCollector/1.0';
|
||||
const endpointHealthUrl = 'https://mobile.events.data.microsoft.com/ping';
|
||||
|
||||
async function getClient(instrumentationKey: string, addInternalFlag?: boolean, xhrOverride?: IXHROverride): Promise<IAppInsightsCore> {
|
||||
// ESM-comment-begin
|
||||
// if (isWeb) { /* fix the import warning */ }
|
||||
// const oneDs = await importAMDNodeModule<typeof import('@microsoft/1ds-core-js')>('@microsoft/1ds-core-js', 'dist/ms.core.js');
|
||||
// const postPlugin = await importAMDNodeModule<typeof import('@microsoft/1ds-post-js')>('@microsoft/1ds-post-js', 'dist/ms.post.js');
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
// eslint-disable-next-line local/code-amd-node-module
|
||||
const oneDs = isWeb ? await importAMDNodeModule<typeof import('@microsoft/1ds-core-js')>('@microsoft/1ds-core-js', 'bundle/ms.core.min.js') : await import('@microsoft/1ds-core-js');
|
||||
// eslint-disable-next-line local/code-amd-node-module
|
||||
const postPlugin = isWeb ? await importAMDNodeModule<typeof import('@microsoft/1ds-post-js')>('@microsoft/1ds-post-js', 'bundle/ms.post.min.js') : await import('@microsoft/1ds-post-js');
|
||||
// ESM-uncomment-end
|
||||
|
||||
const appInsightsCore = new oneDs.AppInsightsCore();
|
||||
const collectorChannelPlugin: PostChannel = new postPlugin.PostChannel();
|
||||
|
||||
@ -31,14 +31,9 @@ import { IProductService } from '../../product/common/productService.js';
|
||||
import { join } from 'path';
|
||||
import { memoize } from '../../../base/common/decorators.js';
|
||||
import * as performance from '../../../base/common/performance.js';
|
||||
// ESM-comment-begin
|
||||
// import { Terminal as XtermTerminal } from '@xterm/headless';
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
import pkg from '@xterm/headless';
|
||||
type XtermTerminal = pkg.Terminal;
|
||||
const { Terminal: XtermTerminal } = pkg;
|
||||
// ESM-uncomment-end
|
||||
|
||||
export function traceRpc(_target: any, key: string, descriptor: any) {
|
||||
if (typeof descriptor.value !== 'function') {
|
||||
|
||||
@ -43,7 +43,6 @@ import { IStateService } from '../../state/node/state.js';
|
||||
import { IUserDataProfilesMainService } from '../../userDataProfile/electron-main/userDataProfile.js';
|
||||
import { ILoggerMainService } from '../../log/electron-main/loggerService.js';
|
||||
import { IInstantiationService } from '../../instantiation/common/instantiation.js';
|
||||
import { isESM } from '../../../base/common/amd.js';
|
||||
|
||||
export interface IWindowCreationOptions {
|
||||
readonly state: IWindowState;
|
||||
@ -1036,7 +1035,7 @@ export class CodeWindow extends BaseWindow implements ICodeWindow {
|
||||
this.readyState = ReadyState.NAVIGATING;
|
||||
|
||||
// Load URL
|
||||
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-sandbox/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.${isESM ? 'esm.' : ''}html`).toString(true));
|
||||
this._win.loadURL(FileAccess.asBrowserUri(`vs/code/electron-sandbox/workbench/workbench${this.environmentMainService.isBuilt ? '' : '-dev'}.html`).toString(true));
|
||||
|
||||
// Remember that we did load
|
||||
const wasLoaded = this.wasLoaded;
|
||||
|
||||
@ -9,7 +9,7 @@ import * as http from 'http';
|
||||
import * as net from 'net';
|
||||
import { performance } from 'perf_hooks';
|
||||
import * as url from 'url';
|
||||
import { LoaderStats, isESM } from '../../base/common/amd.js';
|
||||
import { LoaderStats } from '../../base/common/amd.js';
|
||||
import { VSBuffer } from '../../base/common/buffer.js';
|
||||
import { CharCode } from '../../base/common/charCode.js';
|
||||
import { isSigPipeError, onUnexpectedError, setUnexpectedErrorHandler } from '../../base/common/errors.js';
|
||||
@ -40,10 +40,8 @@ import { determineServerConnectionToken, requestHasValidConnectionToken as httpR
|
||||
import { IServerEnvironmentService, ServerParsedArgs } from './serverEnvironmentService.js';
|
||||
import { setupServerServices, SocketServer } from './serverServices.js';
|
||||
import { CacheControl, serveError, serveFile, WebClientServer } from './webClientServer.js';
|
||||
// ESM-uncomment-begin
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
// ESM-uncomment-end
|
||||
|
||||
const SHUTDOWN_TIMEOUT = 5 * 60 * 1000;
|
||||
|
||||
@ -785,7 +783,7 @@ export async function createServer(address: string | net.AddressInfo | null, arg
|
||||
serverBasePath = `/${serverBasePath}`;
|
||||
}
|
||||
|
||||
const hasWebClient = fs.existsSync(FileAccess.asFileUri(`vs/code/browser/workbench/workbench.${isESM ? 'esm.' : ''}html`).fsPath);
|
||||
const hasWebClient = fs.existsSync(FileAccess.asFileUri(`vs/code/browser/workbench/workbench.html`).fsPath);
|
||||
|
||||
if (hasWebClient && address && typeof address !== 'string') {
|
||||
// ships the web ui!
|
||||
|
||||
@ -28,7 +28,6 @@ import { IProductConfiguration } from '../../base/common/product.js';
|
||||
import { isString } from '../../base/common/types.js';
|
||||
import { CharCode } from '../../base/common/charCode.js';
|
||||
import { IExtensionManifest } from '../../platform/extensions/common/extensions.js';
|
||||
import { isESM } from '../../base/common/amd.js';
|
||||
import { ICSSDevelopmentService } from '../../platform/cssDev/node/cssDevService.js';
|
||||
|
||||
const textMimeType: { [ext: string]: string | undefined } = {
|
||||
@ -300,7 +299,7 @@ export class WebClientServer {
|
||||
|
||||
const resolveWorkspaceURI = (defaultLocation?: string) => defaultLocation && URI.file(path.resolve(defaultLocation)).with({ scheme: Schemas.vscodeRemote, authority: remoteAuthority });
|
||||
|
||||
const filePath = FileAccess.asFileUri(`vs/code/browser/workbench/workbench${this._environmentService.isBuilt ? '' : '-dev'}.${isESM ? 'esm.' : ''}html`).fsPath;
|
||||
const filePath = FileAccess.asFileUri(`vs/code/browser/workbench/workbench${this._environmentService.isBuilt ? '' : '-dev'}.html`).fsPath;
|
||||
const authSessionInfo = !this._environmentService.isBuilt && this._environmentService.args['github-auth'] ? {
|
||||
id: generateUuid(),
|
||||
providerId: 'github',
|
||||
@ -387,15 +386,13 @@ export class WebClientServer {
|
||||
return void res.end('Not found');
|
||||
}
|
||||
|
||||
const webWorkerExtensionHostIframeScriptSHA = isESM ? 'sha256-2Q+j4hfT09+1+imS46J2YlkCtHWQt0/BE79PXjJ0ZJ8=' : 'sha256-V28GQnL3aYxbwgpV3yW1oJ+VKKe/PBSzWntNyH8zVXA=';
|
||||
const webWorkerExtensionHostIframeScriptSHA = 'sha256-2Q+j4hfT09+1+imS46J2YlkCtHWQt0/BE79PXjJ0ZJ8=';
|
||||
|
||||
const cspDirectives = [
|
||||
'default-src \'self\';',
|
||||
'img-src \'self\' https: data: blob:;',
|
||||
'media-src \'self\';',
|
||||
isESM ?
|
||||
`script-src 'self' 'unsafe-eval' ${WORKBENCH_NLS_BASE_URL ?? ''} blob: 'nonce-1nline-m4p' ${this._getScriptCspHashes(data).join(' ')} '${webWorkerExtensionHostIframeScriptSHA}' 'sha256-/r7rqQ+yrxt57sxLuQ6AMYcy/lUpvAIzHjIJt/OeLWU=' ${useTestResolver ? '' : `http://${remoteAuthority}`};` : // the sha is the same as in src/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.esm.html
|
||||
`script-src 'self' 'unsafe-eval' ${WORKBENCH_NLS_BASE_URL ?? ''} ${this._getScriptCspHashes(data).join(' ')} '${webWorkerExtensionHostIframeScriptSHA}' ${useTestResolver ? '' : `http://${remoteAuthority}`};`, // the sha is the same as in src/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html
|
||||
`script-src 'self' 'unsafe-eval' ${WORKBENCH_NLS_BASE_URL ?? ''} blob: 'nonce-1nline-m4p' ${this._getScriptCspHashes(data).join(' ')} '${webWorkerExtensionHostIframeScriptSHA}' 'sha256-/r7rqQ+yrxt57sxLuQ6AMYcy/lUpvAIzHjIJt/OeLWU=' ${useTestResolver ? '' : `http://${remoteAuthority}`};`, // the sha is the same as in src/vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html
|
||||
'child-src \'self\';',
|
||||
`frame-src 'self' https://*.vscode-cdn.net data:;`,
|
||||
'worker-src \'self\' data: blob:;',
|
||||
|
||||
@ -18,10 +18,8 @@ import { CLIServer } from './extHostCLIServer.js';
|
||||
import { realpathSync } from '../../../base/node/extpath.js';
|
||||
import { ExtHostConsoleForwarder } from './extHostConsoleForwarder.js';
|
||||
import { ExtHostDiskFileSystemProvider } from './extHostDiskFileSystemProvider.js';
|
||||
// ESM-uncomment-begin
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
// ESM-uncomment-end
|
||||
|
||||
class NodeModuleRequireInterceptor extends RequireInterceptor {
|
||||
|
||||
@ -46,7 +44,6 @@ class NodeModuleRequireInterceptor extends RequireInterceptor {
|
||||
return originalLookup.call(this, applyAlternatives(request), parent);
|
||||
};
|
||||
|
||||
// ESM-uncomment-begin
|
||||
const originalResolveFilename = node_module._resolveFilename;
|
||||
node_module._resolveFilename = function resolveFilename(request: string, parent: unknown, isMain: boolean, options?: { paths?: string[] }) {
|
||||
if (request === 'vsda' && Array.isArray(options?.paths) && options.paths.length === 0) {
|
||||
@ -58,7 +55,6 @@ class NodeModuleRequireInterceptor extends RequireInterceptor {
|
||||
}
|
||||
return originalResolveFilename.call(this, request, parent, isMain, options);
|
||||
};
|
||||
// ESM-uncomment-end
|
||||
|
||||
const applyAlternatives = (request: string) => {
|
||||
for (const alternativeModuleName of that._alternatives) {
|
||||
|
||||
@ -28,10 +28,8 @@ import { ExtensionHostExitCode, IExtHostReadyMessage, IExtHostReduceGraceTimeMes
|
||||
import { IDisposable } from '../../../base/common/lifecycle.js';
|
||||
import '../common/extHost.common.services.js';
|
||||
import './extHost.node.services.js';
|
||||
// ESM-uncomment-begin
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
// ESM-uncomment-end
|
||||
|
||||
interface ParsedExtHostArgs {
|
||||
transformURIs?: boolean;
|
||||
|
||||
@ -3,13 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
// ESM-comment-begin
|
||||
// import * as http from 'http';
|
||||
// import * as https from 'https';
|
||||
// import * as tls from 'tls';
|
||||
// import * as net from 'net';
|
||||
// ESM-comment-end
|
||||
|
||||
import { IExtHostWorkspaceProvider } from '../common/extHostWorkspace.js';
|
||||
import { ExtHostConfigProvider } from '../common/extHostConfiguration.js';
|
||||
import { MainThreadTelemetryShape } from '../common/extHost.protocol.js';
|
||||
@ -21,15 +14,12 @@ import { IExtensionDescription } from '../../../platform/extensions/common/exten
|
||||
import { LogLevel, createHttpPatch, createProxyResolver, createTlsPatch, ProxySupportSetting, ProxyAgentParams, createNetPatch, loadSystemCertificates } from '@vscode/proxy-agent';
|
||||
import { AuthInfo } from '../../../platform/request/common/request.js';
|
||||
import { DisposableStore } from '../../../base/common/lifecycle.js';
|
||||
|
||||
// ESM-uncomment-begin
|
||||
import { createRequire } from 'node:module';
|
||||
const require = createRequire(import.meta.url);
|
||||
const http = require('http');
|
||||
const https = require('https');
|
||||
const tls = require('tls');
|
||||
const net = require('net');
|
||||
// ESM-uncomment-end
|
||||
|
||||
const systemCertificatesV2Default = false;
|
||||
const useElectronFetchDefault = false;
|
||||
|
||||
@ -4,7 +4,6 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import './style.js';
|
||||
import { localize } from '../../nls.js';
|
||||
import { runWhenWindowIdle } from '../../base/browser/dom.js';
|
||||
import { Event, Emitter, setGlobalLeakWarningThreshold } from '../../base/common/event.js';
|
||||
import { RunOnceScheduler, timeout } from '../../base/common/async.js';
|
||||
@ -50,7 +49,6 @@ import { AccessibilityProgressSignalScheduler } from '../../platform/accessibili
|
||||
import { setProgressAcccessibilitySignalScheduler } from '../../base/browser/ui/progressbar/progressAccessibilitySignal.js';
|
||||
import { AccessibleViewRegistry } from '../../platform/accessibility/browser/accessibleViewRegistry.js';
|
||||
import { NotificationAccessibleView } from './parts/notifications/notificationAccessibleView.js';
|
||||
import { isESM } from '../../base/common/amd.js';
|
||||
|
||||
export interface IWorkbenchOptions {
|
||||
|
||||
@ -98,31 +96,6 @@ export class Workbench extends Layout {
|
||||
|
||||
// Install handler for unexpected errors
|
||||
setUnexpectedErrorHandler(error => this.handleUnexpectedError(error, logService));
|
||||
|
||||
// Inform user about loading issues from the loader
|
||||
if (!isESM && typeof mainWindow.require?.config === 'function') {
|
||||
interface AnnotatedLoadingError extends Error {
|
||||
phase: 'loading';
|
||||
moduleId: string;
|
||||
neededBy: string[];
|
||||
}
|
||||
interface AnnotatedFactoryError extends Error {
|
||||
phase: 'factory';
|
||||
moduleId: string;
|
||||
}
|
||||
interface AnnotatedValidationError extends Error {
|
||||
phase: 'configuration';
|
||||
}
|
||||
type AnnotatedError = AnnotatedLoadingError | AnnotatedFactoryError | AnnotatedValidationError;
|
||||
mainWindow.require.config({
|
||||
onError: (err: AnnotatedError) => {
|
||||
if (err.phase === 'loading') {
|
||||
onUnexpectedError(new Error(localize('loaderErrorNative', "Failed to load a required file. Please restart the application to try again. Details: {0}", JSON.stringify(err))));
|
||||
}
|
||||
console.error(err);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private previousUnexpectedError: { message: string | undefined; time: number } = { message: undefined, time: 0 };
|
||||
|
||||
@ -1,46 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
;
|
||||
">
|
||||
<style>
|
||||
body {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="../../../../../bootstrap-window.js"></script>
|
||||
<script src="./issueReporter.js"></script>
|
||||
</html>
|
||||
@ -15,6 +15,8 @@
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
@ -39,7 +41,6 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="../../../../../vs/loader.js"></script>
|
||||
<script src="../../../../../bootstrap-window.js"></script>
|
||||
<script src="./issueReporter.js"></script>
|
||||
</html>
|
||||
|
||||
@ -1,45 +0,0 @@
|
||||
<!-- Copyright (C) Microsoft Corporation. All rights reserved. -->
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta
|
||||
http-equiv="Content-Security-Policy"
|
||||
content="
|
||||
default-src
|
||||
'none'
|
||||
;
|
||||
img-src
|
||||
'self'
|
||||
data:
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
'unsafe-inline'
|
||||
;
|
||||
connect-src
|
||||
'self'
|
||||
https:
|
||||
;
|
||||
font-src
|
||||
'self'
|
||||
;
|
||||
">
|
||||
<style>
|
||||
body {
|
||||
display: none
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body aria-label="">
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="./issueReporter.js" type="module"></script>
|
||||
</html>
|
||||
@ -15,6 +15,8 @@
|
||||
;
|
||||
script-src
|
||||
'self'
|
||||
blob:
|
||||
'nonce-0c6a828f1297'
|
||||
;
|
||||
style-src
|
||||
'self'
|
||||
@ -39,5 +41,5 @@
|
||||
</body>
|
||||
|
||||
<!-- Startup (do not modify order of script tags!) -->
|
||||
<script src="./issueReporter.js"></script>
|
||||
<script src="./issueReporter.js" type="module"></script>
|
||||
</html>
|
||||
|
||||
@ -17,7 +17,7 @@ import { IExtensionService } from '../../../services/extensions/common/extension
|
||||
import { IDisposable, dispose } from '../../../../base/common/lifecycle.js';
|
||||
import { ICodeEditorService } from '../../../../editor/browser/services/codeEditorService.js';
|
||||
import { writeTransientState } from '../../codeEditor/browser/toggleWordWrap.js';
|
||||
import { LoaderEventType, LoaderStats, isESM } from '../../../../base/common/amd.js';
|
||||
import { LoaderStats } from '../../../../base/common/amd.js';
|
||||
import { IProductService } from '../../../../platform/product/common/productService.js';
|
||||
import { ITextFileService } from '../../../services/textfile/common/textfiles.js';
|
||||
import { IEditorService } from '../../../services/editor/common/editorService.js';
|
||||
@ -156,12 +156,6 @@ class PerfModelContentProvider implements ITextModelContentProvider {
|
||||
this._addWorkbenchContributionsPerfMarksTable(md);
|
||||
md.blank();
|
||||
this._addRawPerfMarks(md);
|
||||
if (!isESM) {
|
||||
md.blank();
|
||||
this._addLoaderStats(md, stats);
|
||||
md.blank();
|
||||
this._addCachedDataStats(md);
|
||||
}
|
||||
md.blank();
|
||||
this._addResourceTimingStats(md);
|
||||
|
||||
@ -310,58 +304,6 @@ class PerfModelContentProvider implements ITextModelContentProvider {
|
||||
}
|
||||
}
|
||||
|
||||
private _addLoaderStats(md: MarkdownBuilder, stats: LoaderStats): void {
|
||||
md.heading(2, 'Loader Stats');
|
||||
md.heading(3, 'Load AMD-module');
|
||||
md.table(['Module', 'Duration'], stats.amdLoad);
|
||||
md.blank();
|
||||
md.heading(3, 'Load commonjs-module');
|
||||
md.table(['Module', 'Duration'], stats.nodeRequire);
|
||||
md.blank();
|
||||
md.heading(3, 'Invoke AMD-module factory');
|
||||
md.table(['Module', 'Duration'], stats.amdInvoke);
|
||||
md.blank();
|
||||
md.heading(3, 'Invoke commonjs-module');
|
||||
md.table(['Module', 'Duration'], stats.nodeEval);
|
||||
}
|
||||
|
||||
private _addCachedDataStats(md: MarkdownBuilder): void {
|
||||
|
||||
const map = new Map<LoaderEventType, string[]>();
|
||||
map.set(LoaderEventType.CachedDataCreated, []);
|
||||
map.set(LoaderEventType.CachedDataFound, []);
|
||||
map.set(LoaderEventType.CachedDataMissed, []);
|
||||
map.set(LoaderEventType.CachedDataRejected, []);
|
||||
if (!isESM && typeof require.getStats === 'function') {
|
||||
for (const stat of require.getStats()) {
|
||||
if (map.has(stat.type)) {
|
||||
map.get(stat.type)!.push(stat.detail);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const printLists = (arr?: string[]) => {
|
||||
if (arr) {
|
||||
arr.sort();
|
||||
for (const e of arr) {
|
||||
md.li(`${e}`);
|
||||
}
|
||||
md.blank();
|
||||
}
|
||||
};
|
||||
|
||||
md.heading(2, 'Node Cached Data Stats');
|
||||
md.blank();
|
||||
md.heading(3, 'cached data used');
|
||||
printLists(map.get(LoaderEventType.CachedDataFound));
|
||||
md.heading(3, 'cached data missed');
|
||||
printLists(map.get(LoaderEventType.CachedDataMissed));
|
||||
md.heading(3, 'cached data rejected');
|
||||
printLists(map.get(LoaderEventType.CachedDataRejected));
|
||||
md.heading(3, 'cached data created (lazy, might need refreshes)');
|
||||
printLists(map.get(LoaderEventType.CachedDataCreated));
|
||||
}
|
||||
|
||||
private _addResourceTimingStats(md: MarkdownBuilder) {
|
||||
const stats = performance.getEntriesByType('resource').map(entry => {
|
||||
return [entry.name, entry.duration];
|
||||
|
||||
@ -225,14 +225,7 @@ export class GettingStartedDetailsRenderer {
|
||||
const contents = await new Promise<string>((resolve, reject) => {
|
||||
const provider = gettingStartedContentRegistry.getProvider(moduleId);
|
||||
if (!provider) {
|
||||
// ESM-comment-begin
|
||||
// require([moduleId], content => {
|
||||
// resolve(content.default());
|
||||
// });
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
reject(`Getting started: no provider registered for ${moduleId}`);
|
||||
// ESM-uncomment-end
|
||||
} else {
|
||||
resolve(provider());
|
||||
}
|
||||
|
||||
@ -46,20 +46,7 @@ export async function moduleToContent(instantiationService: IInstantiationServic
|
||||
|
||||
const provider = walkThroughContentRegistry.getProvider(query.moduleId);
|
||||
if (!provider) {
|
||||
// ESM-comment-begin
|
||||
// return new Promise<string>((resolve, reject) => {
|
||||
// require([query.moduleId], content => {
|
||||
// try {
|
||||
// resolve(instantiationService.invokeFunction(content.default));
|
||||
// } catch (err) {
|
||||
// reject(err);
|
||||
// }
|
||||
// });
|
||||
// });
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
throw new Error(`Walkthrough: no provider registered for ${query.moduleId}`);
|
||||
// ESM-uncomment-end
|
||||
}
|
||||
|
||||
return instantiationService.invokeFunction(provider);
|
||||
|
||||
@ -31,7 +31,7 @@ import { Disposable, DisposableStore, MutableDisposable, toDisposable } from '..
|
||||
import { LifecyclePhase, ILifecycleService, WillShutdownEvent, ShutdownReason, BeforeShutdownErrorEvent, BeforeShutdownEvent } from '../services/lifecycle/common/lifecycle.js';
|
||||
import { IWorkspaceFolderCreationData } from '../../platform/workspaces/common/workspaces.js';
|
||||
import { IIntegrityService } from '../services/integrity/common/integrity.js';
|
||||
import { isWindows, isMacintosh, isCI } from '../../base/common/platform.js';
|
||||
import { isWindows, isMacintosh } from '../../base/common/platform.js';
|
||||
import { IProductService } from '../../platform/product/common/productService.js';
|
||||
import { INotificationService, NeverShowAgainScope, NotificationPriority, Severity } from '../../platform/notification/common/notification.js';
|
||||
import { IKeybindingService } from '../../platform/keybinding/common/keybinding.js';
|
||||
@ -80,7 +80,6 @@ import { ThemeIcon } from '../../base/common/themables.js';
|
||||
import { getWorkbenchContribution } from '../common/contributions.js';
|
||||
import { DynamicWorkbenchSecurityConfiguration } from '../common/configuration.js';
|
||||
import { nativeHoverDelegate } from '../../platform/hover/browser/hover.js';
|
||||
import { isESM } from '../../base/common/amd.js';
|
||||
|
||||
export class NativeWindow extends BaseWindow {
|
||||
|
||||
@ -708,17 +707,6 @@ export class NativeWindow extends BaseWindow {
|
||||
|
||||
private async handleWarnings(): Promise<void> {
|
||||
|
||||
// Check for cyclic dependencies
|
||||
if (!isESM && typeof require.hasDependencyCycle === 'function' && require.hasDependencyCycle()) {
|
||||
if (isCI) {
|
||||
this.logService.error('Error: There is a dependency cycle in the AMD modules that needs to be resolved!');
|
||||
this.nativeHostService.exit(37); // running on a build machine, just exit without showing a dialog
|
||||
} else {
|
||||
this.dialogService.error(localize('loaderCycle', "There is a dependency cycle in the AMD modules that needs to be resolved!"));
|
||||
this.nativeHostService.openDevTools();
|
||||
}
|
||||
}
|
||||
|
||||
// After restored phase is fine for the following ones
|
||||
await this.lifecycleService.when(LifecyclePhase.Restored);
|
||||
|
||||
|
||||
@ -6,7 +6,6 @@
|
||||
import * as dom from '../../../../base/browser/dom.js';
|
||||
import { parentOriginHash } from '../../../../base/browser/iframe.js';
|
||||
import { mainWindow } from '../../../../base/browser/window.js';
|
||||
import { isESM } from '../../../../base/common/amd.js';
|
||||
import { Barrier } from '../../../../base/common/async.js';
|
||||
import { VSBuffer } from '../../../../base/common/buffer.js';
|
||||
import { canceled, onUnexpectedError } from '../../../../base/common/errors.js';
|
||||
@ -87,7 +86,7 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
|
||||
|
||||
const suffix = `?${suffixSearchParams.toString()}`;
|
||||
|
||||
const iframeModulePath: AppResourcePath = `vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.${isESM ? 'esm.' : ''}html`;
|
||||
const iframeModulePath: AppResourcePath = `vs/workbench/services/extensions/worker/webWorkerExtensionHostIframe.html`;
|
||||
if (platform.isWeb) {
|
||||
const webEndpointUrlTemplate = this._productService.webEndpointUrlTemplate;
|
||||
const commit = this._productService.commit;
|
||||
@ -184,13 +183,10 @@ export class WebWorkerExtensionHost extends Disposable implements IExtensionHost
|
||||
return rejectBarrier(ExtensionHostExitCode.UnexpectedError, err);
|
||||
}
|
||||
if (event.data.type === 'vscode.bootstrap.nls') {
|
||||
const factoryModuleId = 'vs/base/worker/workerMain.js';
|
||||
const baseUrl = isESM ? undefined : require.toUrl(factoryModuleId).slice(0, -factoryModuleId.length);
|
||||
iframe.contentWindow!.postMessage({
|
||||
type: event.data.type,
|
||||
data: {
|
||||
baseUrl,
|
||||
workerUrl: isESM ? FileAccess.asBrowserUri('vs/workbench/api/worker/extensionHostWorker.esm.js').toString(true) : require.toUrl(factoryModuleId),
|
||||
workerUrl: FileAccess.asBrowserUri('vs/workbench/api/worker/extensionHostWorker.esm.js').toString(true),
|
||||
fileRoot: globalThis._VSCODE_FILE_ROOT,
|
||||
nls: {
|
||||
messages: getNLSMessages(),
|
||||
|
||||
@ -1,168 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Security-Policy" content="
|
||||
default-src 'none';
|
||||
child-src 'self' data: blob:;
|
||||
script-src 'self' 'unsafe-eval' 'sha256-YVBiNCLDtlDv8TpTuATV/fJ9rcBWIq9O9zBL2ndqAgw=' https: http://localhost:* blob:;
|
||||
connect-src 'self' https: wss: http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*;"/>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
(function () {
|
||||
const searchParams = new URL(document.location.href).searchParams;
|
||||
const vscodeWebWorkerExtHostId = searchParams.get('vscodeWebWorkerExtHostId') || '';
|
||||
const name = searchParams.get('debugged') ? 'DebugExtensionHostWorker' : 'ExtensionHostWorker';
|
||||
const parentOrigin = searchParams.get('parentOrigin') || window.origin;
|
||||
const salt = searchParams.get('salt');
|
||||
|
||||
(async function () {
|
||||
const hostnameValidationMarker = 'v--';
|
||||
const hostname = location.hostname;
|
||||
if (!hostname.startsWith(hostnameValidationMarker)) {
|
||||
// validation not requested
|
||||
return start();
|
||||
}
|
||||
if (!crypto.subtle) {
|
||||
// cannot validate, not running in a secure context
|
||||
return sendError(new Error(`Cannot validate in current context!`));
|
||||
}
|
||||
|
||||
// Here the `parentOriginHash()` function from `src/vs/base/browser/iframe.ts` is inlined
|
||||
// compute a sha-256 composed of `parentOrigin` and `salt` converted to base 32
|
||||
/** @type {string} */
|
||||
let parentOriginHash;
|
||||
try {
|
||||
const strData = JSON.stringify({ parentOrigin, salt });
|
||||
const encoder = new TextEncoder();
|
||||
const arrData = encoder.encode(strData);
|
||||
const hash = await crypto.subtle.digest('sha-256', arrData);
|
||||
const hashArray = Array.from(new Uint8Array(hash));
|
||||
const hashHex = hashArray.map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
// sha256 has 256 bits, so we need at most ceil(lg(2^256-1)/lg(32)) = 52 chars to represent it in base 32
|
||||
parentOriginHash = BigInt(`0x${hashHex}`).toString(32).padStart(52, '0');
|
||||
} catch (err) {
|
||||
return sendError(err instanceof Error ? err : new Error(String(err)));
|
||||
}
|
||||
|
||||
const requiredSubdomain = `${hostnameValidationMarker}${parentOriginHash}.`;
|
||||
if (hostname.substring(0, requiredSubdomain.length) === requiredSubdomain) {
|
||||
// validation succeeded!
|
||||
return start();
|
||||
}
|
||||
|
||||
return sendError(new Error(`Expected '${requiredSubdomain}' as subdomain!`));
|
||||
})();
|
||||
|
||||
function sendError(error) {
|
||||
window.parent.postMessage({
|
||||
vscodeWebWorkerExtHostId,
|
||||
error: {
|
||||
name: error ? error.name : '',
|
||||
message: error ? error.message : '',
|
||||
stack: error ? error.stack : []
|
||||
}
|
||||
}, '*');
|
||||
}
|
||||
|
||||
function start() {
|
||||
|
||||
// Before we can load the worker, we need to get the current set of NLS
|
||||
// configuration into this iframe. We ask the parent window to send it
|
||||
// together with the necessary information to load the worker via Blob.
|
||||
|
||||
const bootstrapNlsType = 'vscode.bootstrap.nls';
|
||||
|
||||
self.onmessage = (event) => {
|
||||
if (event.origin !== parentOrigin || event.data.type !== bootstrapNlsType) {
|
||||
return;
|
||||
}
|
||||
const { data } = event.data;
|
||||
createWorker(data.baseUrl, data.workerUrl, data.fileRoot, data.nls.messages, data.nls.language);
|
||||
};
|
||||
|
||||
window.parent.postMessage({
|
||||
vscodeWebWorkerExtHostId,
|
||||
type: bootstrapNlsType
|
||||
}, '*');
|
||||
}
|
||||
|
||||
function createWorker(baseUrl, workerUrl, fileRoot, nlsMessages, nlsLanguage) {
|
||||
try {
|
||||
if (globalThis.crossOriginIsolated) {
|
||||
workerUrl += '?vscode-coi=2'; // COEP
|
||||
}
|
||||
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
|
||||
// In below blob code, we are using JSON.stringify to ensure the passed
|
||||
// in values are not breaking our script. The values may contain string
|
||||
// terminating characters (such as ' or ").
|
||||
|
||||
const blob = new Blob([[
|
||||
`/*extensionHostWorker*/`,
|
||||
`globalThis.MonacoEnvironment = { baseUrl: ${JSON.stringify(baseUrl)} };`,
|
||||
`globalThis._VSCODE_NLS_MESSAGES = ${JSON.stringify(nlsMessages)};`,
|
||||
`globalThis._VSCODE_NLS_LANGUAGE = ${JSON.stringify(nlsLanguage)};`,
|
||||
`globalThis._VSCODE_FILE_ROOT = ${JSON.stringify(fileRoot)};`,
|
||||
isESM ? `await import(${JSON.stringify(workerUrl)});` : `importScripts(${JSON.stringify(workerUrl)});`,
|
||||
`/*extensionHostWorker*/`
|
||||
].join('')], { type: 'application/javascript' });
|
||||
|
||||
const worker = new Worker(URL.createObjectURL(blob), { name, type: isESM ? 'module' : undefined });
|
||||
if (!isESM) {
|
||||
// Note: cannot postMessage into a worker that is ESM because imports are async
|
||||
worker.postMessage('vs/workbench/api/worker/extensionHostWorker');
|
||||
}
|
||||
const nestedWorkers = new Map();
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
const { data } = event;
|
||||
|
||||
if (data?.type === '_newWorker') {
|
||||
const { id, port, url, options } = data;
|
||||
const newWorker = new Worker(url, options);
|
||||
newWorker.postMessage(port, [port]);
|
||||
newWorker.onerror = console.error.bind(console);
|
||||
nestedWorkers.set(id, newWorker);
|
||||
|
||||
} else if (data?.type === '_terminateWorker') {
|
||||
const { id } = data;
|
||||
if (nestedWorkers.has(id)) {
|
||||
nestedWorkers.get(id).terminate();
|
||||
nestedWorkers.delete(id);
|
||||
}
|
||||
} else {
|
||||
worker.onerror = console.error.bind(console);
|
||||
window.parent.postMessage({
|
||||
vscodeWebWorkerExtHostId,
|
||||
data
|
||||
}, parentOrigin, [data]);
|
||||
}
|
||||
};
|
||||
|
||||
worker.onerror = (event) => {
|
||||
console.error(event.message, event.error);
|
||||
sendError(event.error);
|
||||
};
|
||||
|
||||
self.onmessage = (event) => {
|
||||
if (event.origin !== parentOrigin) {
|
||||
return;
|
||||
}
|
||||
worker.postMessage(event.data, event.ports);
|
||||
};
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
sendError(err);
|
||||
}
|
||||
}
|
||||
})();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@ -4,7 +4,7 @@
|
||||
<meta http-equiv="Content-Security-Policy" content="
|
||||
default-src 'none';
|
||||
child-src 'self' data: blob:;
|
||||
script-src 'self' 'unsafe-eval' 'sha256-++yLFGtZAMsPOtftkIktNKpSEupSQGmZufZGVEWmSu4=' https: http://localhost:* blob:;
|
||||
script-src 'self' 'unsafe-eval' 'sha256-p4xRHmWlJbvrRA1GaJNOE1piFno4zCQWj+53Qkt8PF8=' https: http://localhost:* blob:;
|
||||
connect-src 'self' https: wss: http://localhost:* http://127.0.0.1:* ws://localhost:* ws://127.0.0.1:*;"/>
|
||||
</head>
|
||||
<body>
|
||||
@ -12,7 +12,7 @@
|
||||
(function () {
|
||||
const searchParams = new URL(document.location.href).searchParams;
|
||||
const vscodeWebWorkerExtHostId = searchParams.get('vscodeWebWorkerExtHostId') || '';
|
||||
const name = searchParams.get('debugged') ? 'DebugWorkerExtensionHost' : 'WorkerExtensionHost';
|
||||
const name = searchParams.get('debugged') ? 'DebugExtensionHostWorker' : 'ExtensionHostWorker';
|
||||
const parentOrigin = searchParams.get('parentOrigin') || window.origin;
|
||||
const salt = searchParams.get('salt');
|
||||
|
||||
@ -93,29 +93,21 @@
|
||||
workerUrl += '?vscode-coi=2'; // COEP
|
||||
}
|
||||
|
||||
// ESM-comment-begin
|
||||
// const isESM = false;
|
||||
// ESM-comment-end
|
||||
// ESM-uncomment-begin
|
||||
const isESM = true;
|
||||
// ESM-uncomment-end
|
||||
// In below blob code, we are using JSON.stringify to ensure the passed
|
||||
// in values are not breaking our script. The values may contain string
|
||||
// terminating characters (such as ' or ").
|
||||
|
||||
const blob = new Blob([[
|
||||
`/*extensionHostWorker*/`,
|
||||
`globalThis.MonacoEnvironment = { baseUrl: '${baseUrl}' };`,
|
||||
`globalThis.MonacoEnvironment = { baseUrl: ${JSON.stringify(baseUrl)} };`,
|
||||
`globalThis._VSCODE_NLS_MESSAGES = ${JSON.stringify(nlsMessages)};`,
|
||||
`globalThis._VSCODE_NLS_LANGUAGE = ${JSON.stringify(nlsLanguage)};`,
|
||||
`globalThis._VSCODE_FILE_ROOT = '${fileRoot}';`,
|
||||
isESM ? `await import('${workerUrl}');` : `importScripts('${workerUrl}');`,
|
||||
isESM ? `globalThis.onmessage({ data: 'vs/workbench/api/worker/extensionHostWorker' });` : undefined, // important to start loading after the ESM async import has finished
|
||||
`globalThis._VSCODE_FILE_ROOT = ${JSON.stringify(fileRoot)};`,
|
||||
`await import(${JSON.stringify(workerUrl)});`,
|
||||
`/*extensionHostWorker*/`
|
||||
].join('')], { type: 'application/javascript' });
|
||||
|
||||
const worker = new Worker(URL.createObjectURL(blob), { name, type: isESM ? 'module' : undefined });
|
||||
if (!isESM) {
|
||||
// Note: cannot postMessage into a worker that is ESM because imports are async
|
||||
worker.postMessage('vs/workbench/api/worker/extensionHostWorker');
|
||||
}
|
||||
const worker = new Worker(URL.createObjectURL(blob), { name, type: 'module' });
|
||||
const nestedWorkers = new Map();
|
||||
|
||||
worker.onmessage = (event) => {
|
||||
|
||||
@ -5,7 +5,6 @@
|
||||
|
||||
import * as nls from '../../../../nls.js';
|
||||
import { Emitter, Event } from '../../../../base/common/event.js';
|
||||
import { isESM } from '../../../../base/common/amd.js';
|
||||
import { AppResourcePath, FileAccess } from '../../../../base/common/network.js';
|
||||
import { Disposable } from '../../../../base/common/lifecycle.js';
|
||||
import { KeymapInfo, IRawMixedKeyboardMapping, IKeymapInfo } from '../common/keymapInfo.js';
|
||||
@ -457,10 +456,7 @@ export class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBa
|
||||
|
||||
const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
|
||||
|
||||
import(isESM ?
|
||||
FileAccess.asBrowserUri(`vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.${platform}.js` satisfies AppResourcePath).path :
|
||||
`vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.${platform}`
|
||||
).then((m) => {
|
||||
import(FileAccess.asBrowserUri(`vs/workbench/services/keybinding/browser/keyboardLayouts/layout.contribution.${platform}.js` satisfies AppResourcePath).path).then((m) => {
|
||||
const keymapInfos: IKeymapInfo[] = m.KeyboardLayoutContribution.INSTANCE.layoutInfos;
|
||||
this._keymapInfos.push(...keymapInfos.map(info => (new KeymapInfo(info.layout, info.secondaryLayouts, info.mapping, info.isUserKeyboardLayout))));
|
||||
this._mru = this._keymapInfos;
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { importAMDNodeModule, resolveAmdNodeModulePath } from '../../../../amdX.js';
|
||||
import { canASAR, isESM } from '../../../../base/common/amd.js';
|
||||
import { canASAR } from '../../../../base/common/amd.js';
|
||||
import * as dom from '../../../../base/browser/dom.js';
|
||||
import { equals as equalArray } from '../../../../base/common/arrays.js';
|
||||
import { Color } from '../../../../base/common/color.js';
|
||||
@ -372,9 +372,7 @@ export class TextMateTokenizationFeature extends Disposable implements ITextMate
|
||||
|
||||
private async _loadVSCodeOnigurumaWASM(): Promise<Response | ArrayBuffer> {
|
||||
if (isWeb) {
|
||||
const response = await fetch(isESM
|
||||
? resolveAmdNodeModulePath('vscode-oniguruma', 'release/onig.wasm')
|
||||
: FileAccess.asBrowserUri('vscode-oniguruma/../onig.wasm').toString(true));
|
||||
const response = await fetch(resolveAmdNodeModulePath('vscode-oniguruma', 'release/onig.wasm'));
|
||||
// Using the response directly only works if the server sets the MIME type 'application/wasm'.
|
||||
// Otherwise, a TypeError is thrown when using the streaming compiler.
|
||||
// We therefore use the non-streaming compiler :(.
|
||||
|
||||
@ -8,7 +8,6 @@ import { VSBuffer, VSBufferReadable, VSBufferReadableStream } from '../../../../
|
||||
import { importAMDNodeModule } from '../../../../amdX.js';
|
||||
import { CancellationTokenSource } from '../../../../base/common/cancellation.js';
|
||||
import { coalesce } from '../../../../base/common/arrays.js';
|
||||
import { isESM } from '../../../../base/common/amd.js';
|
||||
|
||||
export const UTF8 = 'utf8';
|
||||
export const UTF8_with_bom = 'utf8bom';
|
||||
@ -325,7 +324,7 @@ async function guessEncodingByBuffer(buffer: VSBuffer, candidateGuessEncodings?:
|
||||
// TODO@bpasero TODO@esm: this used to be `dist/jschardet.min.js`, but we are running into an issue that
|
||||
// https://github.com/aadsm/jschardet/pull/96 mitigates. Long-term we should just add minification
|
||||
// of dependencies into our build process so that we do not depend on how others are doing it.
|
||||
const jschardet = await importAMDNodeModule<typeof import('jschardet')>('jschardet', isESM ? 'dist/jschardet.js' : 'dist/jschardet.min.js');
|
||||
const jschardet = await importAMDNodeModule<typeof import('jschardet')>('jschardet', 'dist/jschardet.js');
|
||||
|
||||
// ensure to limit buffer for guessing due to https://github.com/aadsm/jschardet/issues/53
|
||||
const limitedBuffer = buffer.slice(0, AUTO_ENCODING_GUESS_MAX_BYTES);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user