-
Notifications
You must be signed in to change notification settings - Fork 30.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Rachel Macfarlane
authored
Apr 10, 2018
1 parent
ab5e5d0
commit 609c4ba
Showing
15 changed files
with
585 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
src/vs/code/electron-browser/processExplorer/media/processExplorer.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
html, | ||
body { | ||
margin: 0; | ||
padding: 0; | ||
height: 100%; | ||
width: 100%; | ||
-webkit-touch-callout: none; | ||
-webkit-user-select: none; | ||
user-select: none; | ||
font-family: -apple-system, BlinkMacSystemFont, "Segoe WPC", "Segoe UI", "HelveticaNeue-Light", "Ubuntu", "Droid Sans", sans-serif; | ||
font-size: 13px; | ||
color: #cccccc; | ||
} | ||
|
||
.cpu { | ||
width: 45px; | ||
} | ||
|
||
.pid { | ||
width: 50px | ||
} | ||
|
||
.memory { | ||
width: 90px; | ||
} | ||
|
||
.process-item { | ||
line-height: 22px; | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
table-layout: fixed; | ||
} | ||
th { | ||
vertical-align: bottom; | ||
border-bottom: 1px solid #cccccc; | ||
padding: .5rem; | ||
border-top: 1px solid #cccccc; | ||
text-align: center; | ||
} | ||
td { | ||
padding: .25rem; | ||
vertical-align: top; | ||
} | ||
|
||
.centered { | ||
text-align: center; | ||
} | ||
|
||
.data { | ||
white-space: pre; | ||
} | ||
|
||
tbody > tr:hover { | ||
background-color: #2A2D2E; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/vs/code/electron-browser/processExplorer/processExplorer.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<!-- 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' https: data:; media-src 'none'; child-src 'self'; object-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; connect-src 'self' https:; font-src 'self' https:;"> | ||
</head> | ||
|
||
<body aria-label=""> | ||
<div id="process-list"></div> | ||
</body> | ||
|
||
<!-- Startup via processExplorer.js --> | ||
<script src="processExplorer.js"></script> | ||
|
||
</html> |
175 changes: 175 additions & 0 deletions
175
src/vs/code/electron-browser/processExplorer/processExplorer.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
const path = require('path'); | ||
const fs = require('fs'); | ||
const remote = require('electron').remote; | ||
|
||
function assign(destination, source) { | ||
return Object.keys(source) | ||
.reduce(function (r, key) { r[key] = source[key]; return r; }, destination); | ||
} | ||
|
||
function parseURLQueryArgs() { | ||
const search = window.location.search || ''; | ||
|
||
return search.split(/[?&]/) | ||
.filter(function (param) { return !!param; }) | ||
.map(function (param) { return param.split('='); }) | ||
.filter(function (param) { return param.length === 2; }) | ||
.reduce(function (r, param) { r[param[0]] = decodeURIComponent(param[1]); return r; }, {}); | ||
} | ||
|
||
function uriFromPath(_path) { | ||
var pathName = path.resolve(_path).replace(/\\/g, '/'); | ||
if (pathName.length > 0 && pathName.charAt(0) !== '/') { | ||
pathName = '/' + pathName; | ||
} | ||
|
||
return encodeURI('file://' + pathName); | ||
} | ||
|
||
function readFile(file) { | ||
return new Promise(function(resolve, reject) { | ||
fs.readFile(file, 'utf8', function(err, data) { | ||
if (err) { | ||
reject(err); | ||
return; | ||
} | ||
resolve(data); | ||
}); | ||
}); | ||
} | ||
|
||
function main() { | ||
const args = parseURLQueryArgs(); | ||
const configuration = JSON.parse(args['config'] || '{}') || {}; | ||
|
||
assign(process.env, configuration.userEnv); | ||
|
||
//#region Add support for using node_modules.asar | ||
(function () { | ||
const path = require('path'); | ||
const Module = require('module'); | ||
let NODE_MODULES_PATH = path.join(configuration.appRoot, 'node_modules'); | ||
if (/[a-z]\:/.test(NODE_MODULES_PATH)) { | ||
// Make drive letter uppercase | ||
NODE_MODULES_PATH = NODE_MODULES_PATH.charAt(0).toUpperCase() + NODE_MODULES_PATH.substr(1); | ||
} | ||
const NODE_MODULES_ASAR_PATH = NODE_MODULES_PATH + '.asar'; | ||
|
||
const originalResolveLookupPaths = Module._resolveLookupPaths; | ||
Module._resolveLookupPaths = function (request, parent, newReturn) { | ||
const result = originalResolveLookupPaths(request, parent, newReturn); | ||
|
||
const paths = newReturn ? result : result[1]; | ||
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 result; | ||
}; | ||
})(); | ||
//#endregion | ||
|
||
// Get the nls configuration into the process.env as early as possible. | ||
var nlsConfig = { availableLanguages: {} }; | ||
const config = process.env['VSCODE_NLS_CONFIG']; | ||
if (config) { | ||
process.env['VSCODE_NLS_CONFIG'] = config; | ||
try { | ||
nlsConfig = JSON.parse(config); | ||
} catch (e) { /*noop*/ } | ||
} | ||
|
||
if (nlsConfig._resolvedLanguagePackCoreLocation) { | ||
let bundles = Object.create(null); | ||
nlsConfig.loadBundle = function(bundle, language, cb) { | ||
let result = bundles[bundle]; | ||
if (result) { | ||
cb(undefined, result); | ||
return; | ||
} | ||
let bundleFile = path.join(nlsConfig._resolvedLanguagePackCoreLocation, bundle.replace(/\//g, '!') + '.nls.json'); | ||
readFile(bundleFile).then(function (content) { | ||
let json = JSON.parse(content); | ||
bundles[bundle] = json; | ||
cb(undefined, json); | ||
}) | ||
.catch(cb); | ||
}; | ||
} | ||
|
||
var locale = nlsConfig.availableLanguages['*'] || 'en'; | ||
if (locale === 'zh-tw') { | ||
locale = 'zh-Hant'; | ||
} else if (locale === 'zh-cn') { | ||
locale = 'zh-Hans'; | ||
} | ||
|
||
window.document.documentElement.setAttribute('lang', locale); | ||
|
||
const extractKey = function (e) { | ||
return [ | ||
e.ctrlKey ? 'ctrl-' : '', | ||
e.metaKey ? 'meta-' : '', | ||
e.altKey ? 'alt-' : '', | ||
e.shiftKey ? 'shift-' : '', | ||
e.keyCode | ||
].join(''); | ||
}; | ||
|
||
const TOGGLE_DEV_TOOLS_KB = (process.platform === 'darwin' ? 'meta-alt-73' : 'ctrl-shift-73'); // mac: Cmd-Alt-I, rest: Ctrl-Shift-I | ||
const RELOAD_KB = (process.platform === 'darwin' ? 'meta-82' : 'ctrl-82'); // mac: Cmd-R, rest: Ctrl-R | ||
|
||
window.addEventListener('keydown', function (e) { | ||
const key = extractKey(e); | ||
if (key === TOGGLE_DEV_TOOLS_KB) { | ||
remote.getCurrentWebContents().toggleDevTools(); | ||
} else if (key === RELOAD_KB) { | ||
remote.getCurrentWindow().reload(); | ||
} | ||
}); | ||
|
||
// Load the loader | ||
const loaderFilename = configuration.appRoot + '/out/vs/loader.js'; | ||
const loaderSource = fs.readFileSync(loaderFilename); | ||
require('vm').runInThisContext(loaderSource, { filename: loaderFilename }); | ||
var define = global.define; | ||
global.define = undefined; | ||
|
||
window.nodeRequire = require.__$__nodeRequire; | ||
|
||
define('fs', ['original-fs'], function (originalFS) { return originalFS; }); // replace the patched electron fs with the original node fs for all AMD code | ||
|
||
window.MonacoEnvironment = {}; | ||
const rootUrl = uriFromPath(configuration.appRoot) + '/out'; | ||
|
||
require.config({ | ||
baseUrl: rootUrl, | ||
'vs/nls': nlsConfig, | ||
nodeCachedDataDir: configuration.nodeCachedDataDir, | ||
nodeModules: [/*BUILD->INSERT_NODE_MODULES*/] | ||
}); | ||
|
||
if (nlsConfig.pseudo) { | ||
require(['vs/nls'], function (nlsPlugin) { | ||
nlsPlugin.setPseudoTranslation(nlsConfig.pseudo); | ||
}); | ||
} | ||
|
||
require([ | ||
'vs/code/electron-browser/processExplorer/processExplorerMain' | ||
], function (processExplorer) { | ||
processExplorer.startup(configuration.data); | ||
}); | ||
} | ||
|
||
main(); |
Oops, something went wrong.