diff --git a/.vscode/launch.json b/.vscode/launch.json index 11c578b992d5e58436717b5407163675f641d3af..c82071657d393b4cf7fd434ede961a306800f696 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -192,6 +192,15 @@ "order": 6 } }, + { + "name": "Attach", + "port": 9229, + "request": "attach", + "skipFiles": [ + "/**" + ], + "type": "pwa-node" + }, { "type": "pwa-chrome", "request": "attach", diff --git a/build/esbuild.js b/build/esbuild.js new file mode 100644 index 0000000000000000000000000000000000000000..0e859ce67f3ae4dfab82d9bea12c4876d2cd75c2 --- /dev/null +++ b/build/esbuild.js @@ -0,0 +1,69 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +const esbuild = require("esbuild"); +const buildfile = require("../src/buildfile"); +const _ = require("underscore"); +const pkg = require("../package.json"); +const dependencies = Object.keys(pkg.dependencies); +const entryPoints = _.flatten([ + buildfile.entrypoint('vs/workbench/workbench.desktop.main'), + buildfile.base, + buildfile.workerExtensionHost, + buildfile.workerNotebook, + buildfile.workbenchDesktop, + buildfile.code +]).map(entrypoint => `src/${entrypoint.name}.ts`); +async function main() { + await esbuild.build({ + entryPoints: [ + ...entryPoints, + 'src/main.js', + 'src/vs/base/parts/sandbox/electron-browser/preload.js', + 'src/vs/code/electron-sandbox/workbench/workbench.html' + ], + outdir: 'out', + outbase: 'src', + // format: 'iife', + platform: 'node', + target: 'node12.18', + bundle: true, + tsconfig: 'src/tsconfig.json', + logLevel: 'info', + sourcemap: true, + // minify: true, + loader: { + '.png': 'file', + '.ttf': 'file', + '.svg': 'file', + '.html': 'file' + }, + inject: [ + 'src/vs/dummyloader.js' + ], + external: [ + ...dependencies, + 'vs/css!*', + // 'vs/nls', + '*/sqlite', + 'electron*', + 'vscode-windows-registry', + 'windows-process-tree', + 'windows-mutex', + 'windows-foreground-love', + 'vscode-windows-ca-certs', + '*.node', + '*keymapping', + '*pty.node' + ] + }); +} +if (require.main === module) { + main().catch(err => { + // console.error(err); + process.exit(1); + }); +} diff --git a/build/esbuild.ts b/build/esbuild.ts new file mode 100644 index 0000000000000000000000000000000000000000..c724bd9bd8927824ccaf8870cc57024a65d2fb81 --- /dev/null +++ b/build/esbuild.ts @@ -0,0 +1,72 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import * as esbuild from 'esbuild'; +import * as buildfile from '../src/buildfile'; +import * as _ from 'underscore'; +import * as pkg from '../package.json'; + +const dependencies = Object.keys(pkg.dependencies); + +const entryPoints = _.flatten([ + buildfile.entrypoint('vs/workbench/workbench.desktop.main'), + buildfile.base, + buildfile.workerExtensionHost, + buildfile.workerNotebook, + buildfile.workbenchDesktop, + buildfile.code +]).map(entrypoint => `src/${entrypoint.name}.ts`); + +async function main() { + await esbuild.build({ + entryPoints: [ + ...entryPoints, + 'src/main.js', + 'src/vs/base/parts/sandbox/electron-browser/preload.js', + 'src/vs/code/electron-sandbox/workbench/workbench.html' + ], + outdir: 'out', + outbase: 'src', + // format: 'iife', + platform: 'node', + target: 'node12.18', + bundle: true, + tsconfig: 'src/tsconfig.json', + logLevel: 'info', + sourcemap: true, + // minify: true, + loader: { + '.png': 'file', + '.ttf': 'file', + '.svg': 'file', + '.html': 'file' + }, + inject: [ + 'src/vs/dummyloader.js' + ], + external: [ + ...dependencies, + 'vs/css!*', + // 'vs/nls', + '*/sqlite', + 'electron*', + 'vscode-windows-registry', + 'windows-process-tree', + 'windows-mutex', + 'windows-foreground-love', + 'vscode-windows-ca-certs', + '*.node', + '*keymapping', + '*pty.node' + ] + }); +} + +if (require.main === module) { + main().catch(err => { + // console.error(err); + process.exit(1); + }); +} diff --git a/src/bootstrap-window.js b/src/bootstrap-window.js index cf3d3bfbac52e5ec68be46dd0ec486e2bf72e4a9..5ad6a69514811183b3c4ad97823d74b801363394 100644 --- a/src/bootstrap-window.js +++ b/src/bootstrap-window.js @@ -84,7 +84,7 @@ // replace the patched electron fs with the original node fs for all AMD code (TODO@sandbox non-sandboxed only) if (!sandbox) { - require.define('fs', [], function () { return require.__$__nodeRequire('original-fs'); }); + // require.define('fs', [], function () { return require.__$__nodeRequire('original-fs'); }); } window['MonacoEnvironment'] = {}; @@ -93,66 +93,66 @@ `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32', scheme: 'vscode-file', fallbackAuthority: 'vscode-app' })}/out` : `${bootstrapLib.fileUriFromPath(configuration.appRoot, { isWindows: safeProcess.platform === 'win32' })}/out`; - const loaderConfig = { - baseUrl, - 'vs/nls': nlsConfig, - preferScriptTags: useCustomProtocol - }; - - // use a trusted types policy when loading via script tags - if (loaderConfig.preferScriptTags) { - loaderConfig.trustedTypesPolicy = window.trustedTypes?.createPolicy('amdLoader', { - createScriptURL(value) { - if (value.startsWith(window.location.origin)) { - return value; - } - throw new Error(`Invalid script url: ${value}`); - } - }); - } - - // Enable loading of node modules: - // - sandbox: we list paths of webpacked modules to help the loader - // - non-sandbox: we signal that any module that does not begin with - // `vs/` should be loaded using node.js require() - if (sandbox) { - loaderConfig.paths = { - 'vscode-textmate': `../node_modules/vscode-textmate/release/main`, - 'vscode-oniguruma': `../node_modules/vscode-oniguruma/release/main`, - 'xterm': `../node_modules/xterm/lib/xterm.js`, - 'xterm-addon-search': `../node_modules/xterm-addon-search/lib/xterm-addon-search.js`, - 'xterm-addon-unicode11': `../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, - 'xterm-addon-webgl': `../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, - 'iconv-lite-umd': `../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`, - 'jschardet': `../node_modules/jschardet/dist/jschardet.min.js`, - }; - } else { - loaderConfig.amdModulesPattern = /^vs\//; - } - - // cached data config - if (configuration.nodeCachedDataDir) { - loaderConfig.nodeCachedData = { - path: configuration.nodeCachedDataDir, - seed: modulePaths.join('') - }; - } - - if (options && typeof options.beforeLoaderConfig === 'function') { - options.beforeLoaderConfig(configuration, loaderConfig); - } - - require.config(loaderConfig); - - if (nlsConfig.pseudo) { - require(['vs/nls'], function (nlsPlugin) { - nlsPlugin.setPseudoTranslation(nlsConfig.pseudo); - }); - } - - if (options && typeof options.beforeRequire === 'function') { - options.beforeRequire(); - } + // const loaderConfig = { + // baseUrl, + // 'vs/nls': nlsConfig, + // preferScriptTags: useCustomProtocol + // }; + + // // use a trusted types policy when loading via script tags + // if (loaderConfig.preferScriptTags) { + // loaderConfig.trustedTypesPolicy = window.trustedTypes?.createPolicy('amdLoader', { + // createScriptURL(value) { + // if (value.startsWith(window.location.origin)) { + // return value; + // } + // throw new Error(`Invalid script url: ${value}`); + // } + // }); + // } + + // // Enable loading of node modules: + // // - sandbox: we list paths of webpacked modules to help the loader + // // - non-sandbox: we signal that any module that does not begin with + // // `vs/` should be loaded using node.js require() + // if (sandbox) { + // loaderConfig.paths = { + // 'vscode-textmate': `../node_modules/vscode-textmate/release/main`, + // 'vscode-oniguruma': `../node_modules/vscode-oniguruma/release/main`, + // 'xterm': `../node_modules/xterm/lib/xterm.js`, + // 'xterm-addon-search': `../node_modules/xterm-addon-search/lib/xterm-addon-search.js`, + // 'xterm-addon-unicode11': `../node_modules/xterm-addon-unicode11/lib/xterm-addon-unicode11.js`, + // 'xterm-addon-webgl': `../node_modules/xterm-addon-webgl/lib/xterm-addon-webgl.js`, + // 'iconv-lite-umd': `../node_modules/iconv-lite-umd/lib/iconv-lite-umd.js`, + // 'jschardet': `../node_modules/jschardet/dist/jschardet.min.js`, + // }; + // } else { + // loaderConfig.amdModulesPattern = /^vs\//; + // } + + // // cached data config + // if (configuration.nodeCachedDataDir) { + // loaderConfig.nodeCachedData = { + // path: configuration.nodeCachedDataDir, + // seed: modulePaths.join('') + // }; + // } + + // if (options && typeof options.beforeLoaderConfig === 'function') { + // options.beforeLoaderConfig(configuration, loaderConfig); + // } + + // require.config(loaderConfig); + + // if (nlsConfig.pseudo) { + // require(['vs/nls'], function (nlsPlugin) { + // nlsPlugin.setPseudoTranslation(nlsConfig.pseudo); + // }); + // } + + // if (options && typeof options.beforeRequire === 'function') { + // options.beforeRequire(); + // } require(modulePaths, async result => { try { diff --git a/src/main.js b/src/main.js index 618c45bbf3cdd1c2e441f5587eb3ae89ac1a3206..c44a88983eefdff0def7203509eca690d1d3b527 100644 --- a/src/main.js +++ b/src/main.js @@ -194,9 +194,10 @@ function startup(cachedDataDir, nlsConfig) { // Load main in AMD perf.mark('code/willLoadMainBundle'); - require('./bootstrap-amd').load('vs/code/electron-main/main', () => { - perf.mark('code/didLoadMainBundle'); - }); + require('./vs/code/electron-main/main'); + // require('./bootstrap-amd').load('vs/code/electron-main/main', () => { + perf.mark('code/didLoadMainBundle'); + // }); } async function onReady() { diff --git a/src/vs/base/common/insane/insane.js b/src/vs/base/common/insane/insane.js index cedeb883165dd25ff7f3c48ec04a22497be364eb..aba63965f15498384192218a049cffb4644f6798 100644 --- a/src/vs/base/common/insane/insane.js +++ b/src/vs/base/common/insane/insane.js @@ -466,9 +466,9 @@ let __insane_func; }, {}, [4]); // ESM-comment-begin -define(function() { return { insane: __insane_func }; }); +// define(function () { return { insane: __insane_func }; }); // ESM-comment-end // ESM-uncomment-begin -// export var insane = __insane_func; +export var insane = __insane_func; // ESM-uncomment-end diff --git a/src/vs/base/common/network.ts b/src/vs/base/common/network.ts index 75e1a0c603f65d34f7db97c50ed4029d0e0cea18..3a64f1d030d5004a859358dc83cce5587abaf22b 100644 --- a/src/vs/base/common/network.ts +++ b/src/vs/base/common/network.ts @@ -204,7 +204,10 @@ class FileAccessImpl { return uriOrModule; } - return URI.parse(moduleIdToUrl!.toUrl(uriOrModule)); + console.log(uriOrModule); + + return URI.parse(`file:///home/joao/Work/vscode/out/${uriOrModule}`); + // return URI.parse(moduleIdToUrl!.toUrl(uriOrModule)); } } diff --git a/src/vs/base/common/performance.js b/src/vs/base/common/performance.js index ac8c2cdb71431513ec938285d1734e714d920864..a8aca7902ddc82bf13b2785a2986ea090f8a94a8 100644 --- a/src/vs/base/common/performance.js +++ b/src/vs/base/common/performance.js @@ -107,13 +107,13 @@ if (typeof global === 'object') { sharedObj = {}; } -if (typeof define === 'function') { - // amd - define([], function () { return _factory(sharedObj); }); -} else if (typeof module === 'object' && typeof module.exports === 'object') { - // commonjs - module.exports = _factory(sharedObj); -} else { - console.trace('perf-util defined in UNKNOWN context (neither requirejs or commonjs)'); - sharedObj.perf = _factory(sharedObj); -} +// if (typeof define === 'function') { +// // amd +// define([], function () { return _factory(sharedObj); }); +// } else if (typeof module === 'object' && typeof module.exports === 'object') { +// commonjs +module.exports = _factory(sharedObj); +// } else { +// console.trace('perf-util defined in UNKNOWN context (neither requirejs or commonjs)'); +// sharedObj.perf = _factory(sharedObj); +// } diff --git a/src/vs/base/node/languagePacks.js b/src/vs/base/node/languagePacks.js index be9ca50b1bf5996681140bc18c5179ba455543fc..cd36b95e19237c1f234ad018353f644f5bbac4ea 100644 --- a/src/vs/base/node/languagePacks.js +++ b/src/vs/base/node/languagePacks.js @@ -301,14 +301,14 @@ function factory(nodeRequire, path, fs, perf) { } -if (typeof define === 'function') { - // amd - define(['path', 'fs', 'vs/base/common/performance'], function (path, fs, perf) { return factory(require.__$__nodeRequire, path, fs, perf); }); -} else if (typeof module === 'object' && typeof module.exports === 'object') { +// if (typeof define === 'function') { +// // amd +// define(['path', 'fs', 'vs/base/common/performance'], function (path, fs, perf) { return factory(require.__$__nodeRequire, path, fs, perf); }); +// } else if (typeof module === 'object' && typeof module.exports === 'object') { const path = require('path'); const fs = require('fs'); const perf = require('../common/performance'); module.exports = factory(require, path, fs, perf); -} else { - throw new Error('Unknown context'); -} +// } else { +// throw new Error('Unknown context'); +// } diff --git a/src/vs/base/node/paths.ts b/src/vs/base/node/paths.ts index eaf03e6e4008b8a0e399286761f55abc7ccc2bb9..aef43e575bc5b72160247c02254f15cea6ee08c6 100644 --- a/src/vs/base/node/paths.ts +++ b/src/vs/base/node/paths.ts @@ -3,9 +3,10 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { FileAccess } from 'vs/base/common/network'; +// import { FileAccess } from 'vs/base/common/network'; -const pathsPath = FileAccess.asFileUri('paths', require).fsPath; -const paths = require.__$__nodeRequire<{ getDefaultUserDataPath(): string }>(pathsPath); +// const pathsPath = FileAccess.asFileUri('paths', require).fsPath; +// const paths = require.__$__nodeRequire<{ getDefaultUserDataPath(): string }>(pathsPath); +const paths = require('../../../paths.js'); export const getDefaultUserDataPath = paths.getDefaultUserDataPath; diff --git a/src/vs/code/electron-browser/workbench/workbench.html b/src/vs/code/electron-browser/workbench/workbench.html index 25ea4acfa0e2ceba423848bfcd59eda28b5dfe98..044fcbdc96e47e3a59d3aa66694141ee35c5e494 100644 --- a/src/vs/code/electron-browser/workbench/workbench.html +++ b/src/vs/code/electron-browser/workbench/workbench.html @@ -11,7 +11,7 @@ - + diff --git a/src/vs/code/electron-main/window.ts b/src/vs/code/electron-main/window.ts index c27b128c227fb9b87a23a7c63fe7d69c1842cebb..34e0bf1b52d69493cda3bb96c1f0caf25a8ffae2 100644 --- a/src/vs/code/electron-main/window.ts +++ b/src/vs/code/electron-main/window.ts @@ -856,8 +856,9 @@ export class CodeWindow extends Disposable implements ICodeWindow { workbench = 'vs/code/electron-browser/workbench/workbench.html'; } - return FileAccess - .asBrowserUri(workbench, require) + // return FileAccess + // .asBrowserUri(workbench, require) + return URI.file(`/home/joao/Work/vscode/src/${workbench}`) .with({ query: `config=${encodeURIComponent(JSON.stringify(config))}` }) .toString(true); } diff --git a/src/vs/code/electron-sandbox/workbench/workbench.html b/src/vs/code/electron-sandbox/workbench/workbench.html index 40737461d2930079c8466a044b13bf11d4459f9c..428bef0fe79593813da8874309e815447f4bbcce 100644 --- a/src/vs/code/electron-sandbox/workbench/workbench.html +++ b/src/vs/code/electron-sandbox/workbench/workbench.html @@ -1,18 +1,22 @@ - - - - - - - - - - + + + + + + + + + + + + + + + - - diff --git a/src/vs/dummyloader.js b/src/vs/dummyloader.js new file mode 100644 index 0000000000000000000000000000000000000000..2325cb693ad9c28f3657fde5064b8a046e7b02ab --- /dev/null +++ b/src/vs/dummyloader.js @@ -0,0 +1,5 @@ +export function define() { + +} + +require.__$__nodeRequire = () => { } diff --git a/src/vs/nls.js b/src/vs/nls.js index 03f781a17a9d3181c525b1f25150e1036094b1ea..bdf17b5e6d5080208406ff2e1b8ce4a20bd1b0a8 100644 --- a/src/vs/nls.js +++ b/src/vs/nls.js @@ -158,3 +158,5 @@ var NLSLoaderPlugin; NLSLoaderPlugin.NLSPlugin = NLSPlugin; define('vs/nls', new NLSPlugin(new Environment())); })(NLSLoaderPlugin || (NLSLoaderPlugin = {})); + +module.exports.localize = (_, msg) => msg; diff --git a/src/vs/platform/environment/node/argv.ts b/src/vs/platform/environment/node/argv.ts index 1ec40eea8f0543e6629620f95f7358c88f57131f..85c57f1678dca6be3fa9776518f691f01d77e6df 100644 --- a/src/vs/platform/environment/node/argv.ts +++ b/src/vs/platform/environment/node/argv.ts @@ -3,7 +3,7 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as minimist from 'minimist'; +const minimist = require('minimist'); import { localize } from 'vs/nls'; import { isWindows } from 'vs/base/common/platform'; import { NativeParsedArgs } from 'vs/platform/environment/common/argv'; diff --git a/src/vs/platform/instantiation/common/instantiation.ts b/src/vs/platform/instantiation/common/instantiation.ts index dbde5f6332cfd8aa25ccf2d9f6920c8a14f6652d..7a367ef34b3f9fa0b1d0409288f1bc36394ceaec 100644 --- a/src/vs/platform/instantiation/common/instantiation.ts +++ b/src/vs/platform/instantiation/common/instantiation.ts @@ -16,7 +16,7 @@ export namespace _util { export const DI_DEPENDENCIES = '$di$dependencies'; export function getServiceDependencies(ctor: any): { id: ServiceIdentifier, index: number, optional: boolean }[] { - return ctor[DI_DEPENDENCIES] || []; + return ctor.prototype[DI_DEPENDENCIES] || []; } } diff --git a/src/vs/platform/product/common/product.ts b/src/vs/platform/product/common/product.ts index 537db557d87c5708ecf3a15d33cf0804fb1b18d7..980618a41e9785c2f69aec110c621625bb295f6f 100644 --- a/src/vs/platform/product/common/product.ts +++ b/src/vs/platform/product/common/product.ts @@ -42,10 +42,13 @@ if (isWeb || typeof require === 'undefined' || typeof require.__$__nodeRequire ! else { // Obtain values from product.json and package.json - const rootPath = dirname(FileAccess.asFileUri('', require)); + // const rootPath = dirname(FileAccess.asFileUri('', require)); - product = require.__$__nodeRequire(joinPath(rootPath, 'product.json').fsPath); - const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string; }; + // product = require.__$__nodeRequire(joinPath(rootPath, 'product.json').fsPath); + // const pkg = require.__$__nodeRequire(joinPath(rootPath, 'package.json').fsPath) as { version: string; }; + + product = require('../../../../../product.json'); + const pkg = require('../../../../../package.json'); // Running out of sources if (env['VSCODE_DEV']) { diff --git a/src/vs/workbench/electron-browser/desktop.main.ts b/src/vs/workbench/electron-browser/desktop.main.ts index 9c7c566c600811ac09f932bdec8bada560e39960..e97515e4eead1096f4a3e344aafd436ec3a384d6 100644 --- a/src/vs/workbench/electron-browser/desktop.main.ts +++ b/src/vs/workbench/electron-browser/desktop.main.ts @@ -3,8 +3,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as fs from 'fs'; -import * as gracefulFs from 'graceful-fs'; +// import * as fs from 'fs'; +// import * as gracefulFs from 'graceful-fs'; import { createHash } from 'crypto'; import { exists, stat } from 'vs/base/node/pfs'; import { isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; @@ -70,7 +70,7 @@ class DesktopMain extends Disposable { private init(): void { // Enable gracefulFs - gracefulFs.gracefulify(fs); + // gracefulFs.gracefulify(fs); // Massage configuration file URIs this.reviveUris();