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

View file

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

View file

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

View file

@ -11,19 +11,19 @@ var slice = [].slice;
process.argv.splice(1, 1); process.argv.splice(1, 1);
// Clear search paths. // Clear search paths.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'reset-search-paths')); require('../common/reset-search-paths');
// Import common settings. // Import common settings.
require(path.resolve(__dirname, '..', '..', 'common', 'lib', 'init')); require('../common/init');
var globalPaths = Module.globalPaths; var globalPaths = Module.globalPaths;
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) { if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib')); globalPaths.push(path.join(__dirname, 'api'));
} }
// Expose public APIs. // Expose public APIs.
globalPaths.push(path.resolve(__dirname, '..', 'api', 'lib', 'exports')); globalPaths.push(path.join(__dirname, 'api', 'exports'));
if (process.platform === 'win32') { if (process.platform === 'win32') {
// Redirect node's console to use our own implementations, since node can not // 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) { if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
// Add common/api/lib to module search paths. // 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. // Import common modules.
common.defineProperties(exports); 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. // 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. // And add a helper receiver for each one.
var fn = function(name) { var fn = function(name) {

View file

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

View file

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

View file

@ -17,7 +17,7 @@ describe('asar package', function() {
it('does not leak fd', function() { it('does not leak fd', function() {
var readCalls = 1; var readCalls = 1;
while(readCalls <= 10000) { 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++; readCalls++;
} }
}); });

View file

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