Merge pull request #4722 from atom/colocate-js

[WIP] Colocate JavaScript in root lib folder
This commit is contained in:
Cheng Zhao 2016-03-10 17:05:34 +09:00
commit 377a8eefb2
66 changed files with 74 additions and 75 deletions

View file

@ -69,7 +69,7 @@
{
'destination': '<(PRODUCT_DIR)/<(product_name).app/Contents/Resources',
'files': [
'atom/browser/default_app',
'default_app',
],
},
],
@ -171,7 +171,7 @@
{
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'atom/browser/default_app',
'default_app',
]
},
],
@ -212,7 +212,7 @@
{
'destination': '<(PRODUCT_DIR)/resources',
'files': [
'atom/browser/default_app',
'default_app',
]
},
],

View file

@ -165,7 +165,6 @@ node::Environment* NodeBindings::CreateEnvironment(
base::FilePath script_path =
resources_path.Append(FILE_PATH_LITERAL("atom.asar"))
.Append(process_type)
.Append(FILE_PATH_LITERAL("lib"))
.Append(FILE_PATH_LITERAL("init.js"));
std::string script_path_str = script_path.AsUTF8Unsafe();
args.insert(args.begin() + 1, script_path_str.c_str());

View file

@ -8,64 +8,64 @@
'atom/browser/resources/mac/atom.icns',
],
'js_sources': [
'atom/browser/api/lib/app.js',
'atom/browser/api/lib/auto-updater.js',
'atom/browser/api/lib/auto-updater/auto-updater-native.js',
'atom/browser/api/lib/auto-updater/auto-updater-win.js',
'atom/browser/api/lib/auto-updater/squirrel-update-win.js',
'atom/browser/api/lib/browser-window.js',
'atom/browser/api/lib/content-tracing.js',
'atom/browser/api/lib/dialog.js',
'atom/browser/api/lib/exports/electron.js',
'atom/browser/api/lib/global-shortcut.js',
'atom/browser/api/lib/ipc.js',
'atom/browser/api/lib/ipc-main.js',
'atom/browser/api/lib/menu.js',
'atom/browser/api/lib/menu-item.js',
'atom/browser/api/lib/navigation-controller.js',
'atom/browser/api/lib/power-monitor.js',
'atom/browser/api/lib/power-save-blocker.js',
'atom/browser/api/lib/protocol.js',
'atom/browser/api/lib/session.js',
'atom/browser/api/lib/screen.js',
'atom/browser/api/lib/tray.js',
'atom/browser/api/lib/web-contents.js',
'atom/browser/lib/chrome-extension.js',
'atom/browser/lib/desktop-capturer.js',
'atom/browser/lib/guest-view-manager.js',
'atom/browser/lib/guest-window-manager.js',
'atom/browser/lib/init.js',
'atom/browser/lib/objects-registry.js',
'atom/browser/lib/rpc-server.js',
'atom/common/api/lib/callbacks-registry.js',
'atom/common/api/lib/clipboard.js',
'atom/common/api/lib/crash-reporter.js',
'atom/common/api/lib/deprecate.js',
'atom/common/api/lib/deprecations.js',
'atom/common/api/lib/exports/electron.js',
'atom/common/api/lib/native-image.js',
'atom/common/api/lib/shell.js',
'atom/common/lib/init.js',
'atom/common/lib/reset-search-paths.js',
'atom/renderer/lib/chrome-api.js',
'atom/renderer/lib/init.js',
'atom/renderer/lib/inspector.js',
'atom/renderer/lib/override.js',
'atom/renderer/lib/web-view/guest-view-internal.js',
'atom/renderer/lib/web-view/web-view.js',
'atom/renderer/lib/web-view/web-view-attributes.js',
'atom/renderer/lib/web-view/web-view-constants.js',
'atom/renderer/api/lib/desktop-capturer.js',
'atom/renderer/api/lib/exports/electron.js',
'atom/renderer/api/lib/ipc.js',
'atom/renderer/api/lib/ipc-renderer.js',
'atom/renderer/api/lib/remote.js',
'atom/renderer/api/lib/screen.js',
'atom/renderer/api/lib/web-frame.js',
'lib/browser/api/app.js',
'lib/browser/api/auto-updater.js',
'lib/browser/api/auto-updater/auto-updater-native.js',
'lib/browser/api/auto-updater/auto-updater-win.js',
'lib/browser/api/auto-updater/squirrel-update-win.js',
'lib/browser/api/browser-window.js',
'lib/browser/api/content-tracing.js',
'lib/browser/api/dialog.js',
'lib/browser/api/exports/electron.js',
'lib/browser/api/global-shortcut.js',
'lib/browser/api/ipc.js',
'lib/browser/api/ipc-main.js',
'lib/browser/api/menu.js',
'lib/browser/api/menu-item.js',
'lib/browser/api/navigation-controller.js',
'lib/browser/api/power-monitor.js',
'lib/browser/api/power-save-blocker.js',
'lib/browser/api/protocol.js',
'lib/browser/api/session.js',
'lib/browser/api/screen.js',
'lib/browser/api/tray.js',
'lib/browser/api/web-contents.js',
'lib/browser/chrome-extension.js',
'lib/browser/desktop-capturer.js',
'lib/browser/guest-view-manager.js',
'lib/browser/guest-window-manager.js',
'lib/browser/init.js',
'lib/browser/objects-registry.js',
'lib/browser/rpc-server.js',
'lib/common/api/callbacks-registry.js',
'lib/common/api/clipboard.js',
'lib/common/api/crash-reporter.js',
'lib/common/api/deprecate.js',
'lib/common/api/deprecations.js',
'lib/common/api/exports/electron.js',
'lib/common/api/native-image.js',
'lib/common/api/shell.js',
'lib/common/init.js',
'lib/common/reset-search-paths.js',
'lib/renderer/chrome-api.js',
'lib/renderer/init.js',
'lib/renderer/inspector.js',
'lib/renderer/override.js',
'lib/renderer/web-view/guest-view-internal.js',
'lib/renderer/web-view/web-view.js',
'lib/renderer/web-view/web-view-attributes.js',
'lib/renderer/web-view/web-view-constants.js',
'lib/renderer/api/desktop-capturer.js',
'lib/renderer/api/exports/electron.js',
'lib/renderer/api/ipc.js',
'lib/renderer/api/ipc-renderer.js',
'lib/renderer/api/remote.js',
'lib/renderer/api/screen.js',
'lib/renderer/api/web-frame.js',
],
'js2c_sources': [
'atom/common/lib/asar.js',
'atom/common/lib/asar_init.js',
'lib/common/asar.js',
'lib/common/asar_init.js',
],
'lib_sources': [
'atom/app/atom_content_client.cc',

View file

@ -1,4 +1,4 @@
const common = require('../../../../common/api/lib/exports/electron');
const common = require('../../../common/api/exports/electron');
// Import common modules.

View file

@ -11,19 +11,19 @@ var slice = [].slice;
process.argv.splice(1, 1);
// Clear search paths.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
require('../common/reset-search-paths');
// Import common settings.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
require('../common/init');
var globalPaths = Module.globalPaths;
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
globalPaths.push(path.join(__dirname, 'api'));
}
// Expose public APIs.
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
globalPaths.push(path.join(__dirname, 'api', 'exports'));
if (process.platform === 'win32') {
// Redirect node's console to use our own implementations, since node can not

View file

@ -14,7 +14,7 @@ process.atomBinding = function(name) {
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
// Add common/api/lib to module search paths.
Module.globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
Module.globalPaths.push(path.join(__dirname, 'api'));
}

View file

@ -1,4 +1,4 @@
const common = require('../../../../common/api/lib/exports/electron');
const common = require('../../../common/api/exports/electron');
// Import common modules.
common.defineProperties(exports);

View file

@ -244,7 +244,7 @@ ipcRenderer.on('ATOM_RENDERER_RELEASE_CALLBACK', function(event, id) {
});
// List all built-in modules in browser process.
const browserModules = require('../../../browser/api/lib/exports/electron');
const browserModules = require('../../browser/api/exports/electron');
// And add a helper receiver for each one.
var fn = function(name) {

View file

@ -9,19 +9,19 @@ const Module = require('module');
process.argv.splice(1, 1);
// Clear search paths.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths'));
require('../common/reset-search-paths');
// Import common settings.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init'));
require('../common/init');
var globalPaths = Module.globalPaths;
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib'));
globalPaths.push(path.join(__dirname, 'api'));
}
// Expose public APIs.
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports'));
globalPaths.push(path.join(__dirname, 'api', 'exports'));
// The global variable will be used by ipc for event dispatching
var v8Util = process.atomBinding('v8_util');

View file

@ -24,7 +24,7 @@ def main():
settings = ['--quiet', '--config']
sourceConfig = os.path.join('script', 'eslintrc-base.json')
sourceFiles = ['atom']
sourceFiles = ['lib']
execute([eslint] + settings + [sourceConfig] + sourceFiles)
specConfig = os.path.join('script', 'eslintrc-spec.json')

View file

@ -17,7 +17,7 @@ describe('asar package', function() {
it('does not leak fd', function() {
var readCalls = 1;
while(readCalls <= 10000) {
fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'lib', 'ipc.js'));
fs.readFileSync(path.join(process.resourcesPath, 'atom.asar', 'renderer', 'api', 'ipc.js'));
readCalls++;
}
});

View file

@ -29,7 +29,7 @@ def copy_js(js_source_files, output_dir):
def call_asar(archive, output_dir):
js_dir = os.path.join(output_dir, 'atom')
js_dir = os.path.join(output_dir, 'lib')
asar = os.path.join(SOURCE_ROOT, 'node_modules', 'asar', 'bin', 'asar')
subprocess.check_call([find_node(), asar, 'pack', js_dir, archive])