mirror of
https://github.com/atom/atom.git
synced 2026-01-23 13:58:08 -05:00
Merge pull request #945 from atom/browser-folder
Separate classes that run in the browser process
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "atom",
|
||||
"version": "31.0.0",
|
||||
"main": "./src/main.js",
|
||||
"main": "./src/browser/main.js",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/atom/atom.git"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
AtomWindow = require 'atom-window'
|
||||
ApplicationMenu = require 'application-menu'
|
||||
AtomProtocolHandler = require 'atom-protocol-handler'
|
||||
AtomWindow = require './atom-window'
|
||||
ApplicationMenu = require './application-menu'
|
||||
AtomProtocolHandler = require './atom-protocol-handler'
|
||||
Menu = require 'menu'
|
||||
autoUpdater = require 'auto-updater'
|
||||
app = require 'app'
|
||||
@@ -251,7 +251,7 @@ class AtomApplication
|
||||
bootstrapScript = require.resolve(path.join(global.devResourcePath, 'src', 'window-bootstrap'))
|
||||
else
|
||||
resourcePath = @resourcePath
|
||||
bootstrapScript = require.resolve('./window-bootstrap')
|
||||
bootstrapScript = require.resolve('../window-bootstrap')
|
||||
openedWindow = new AtomWindow({pathToOpen, initialLine, bootstrapScript, resourcePath, devMode, initialSize})
|
||||
|
||||
if pidToKillWhenClosed?
|
||||
@@ -279,8 +279,8 @@ class AtomApplication
|
||||
# Boolean to control the opened window's dev mode.
|
||||
openUrl: ({urlToOpen, devMode}) ->
|
||||
unless @packages?
|
||||
PackageManager = require './package-manager'
|
||||
fsUtils = require './fs-utils'
|
||||
PackageManager = require '../package-manager'
|
||||
fsUtils = require '../fs-utils'
|
||||
@packages = new PackageManager
|
||||
configDirPath: fsUtils.absolute('~/.atom')
|
||||
devMode: devMode
|
||||
@@ -314,7 +314,7 @@ class AtomApplication
|
||||
try
|
||||
bootstrapScript = require.resolve(path.resolve(global.devResourcePath, 'spec', 'spec-bootstrap'))
|
||||
catch error
|
||||
bootstrapScript = require.resolve(path.resolve(__dirname, '..', 'spec', 'spec-bootstrap'))
|
||||
bootstrapScript = require.resolve(path.resolve(__dirname, '..', '..', 'spec', 'spec-bootstrap'))
|
||||
|
||||
isSpec = true
|
||||
devMode = true
|
||||
@@ -324,9 +324,9 @@ class AtomApplication
|
||||
try
|
||||
bootstrapScript = require.resolve(path.resolve(global.devResourcePath, 'benchmark', 'benchmark-bootstrap'))
|
||||
catch error
|
||||
bootstrapScript = require.resolve(path.resolve(__dirname, '..', 'benchmark', 'benchmark-bootstrap'))
|
||||
bootstrapScript = require.resolve(path.resolve(__dirname, '..', '..', 'benchmark', 'benchmark-bootstrap'))
|
||||
|
||||
isSpec = true # Needed because this flag adds the spec directory to the NODE_PATH
|
||||
isSpec = true
|
||||
new AtomWindow({bootstrapScript, @resourcePath, isSpec})
|
||||
|
||||
# Private: Opens a native dialog to prompt the user for a path.
|
||||
@@ -1,7 +1,6 @@
|
||||
BrowserWindow = require 'browser-window'
|
||||
Menu = require 'menu'
|
||||
MenuItem = require 'menu-item'
|
||||
ContextMenu = require 'context-menu'
|
||||
ContextMenu = require './context-menu'
|
||||
dialog = require 'dialog'
|
||||
ipc = require 'ipc'
|
||||
path = require 'path'
|
||||
@@ -84,7 +83,7 @@ class AtomWindow
|
||||
when 1 then @browserWindow.restart()
|
||||
|
||||
@browserWindow.on 'context-menu', (menuTemplate) =>
|
||||
new ContextMenu(menuTemplate)
|
||||
new ContextMenu(menuTemplate, @browserWindow)
|
||||
|
||||
if @isSpec
|
||||
# Spec window's web view should always have focus
|
||||
@@ -1,12 +1,11 @@
|
||||
Menu = require 'menu'
|
||||
BrowserWindow = require 'browser-window'
|
||||
|
||||
module.exports =
|
||||
class ContextMenu
|
||||
constructor: (template) ->
|
||||
constructor: (template, browserWindow) ->
|
||||
template = @createClickHandlers(template)
|
||||
menu = Menu.buildFromTemplate(template)
|
||||
menu.popup(BrowserWindow.getFocusedWindow())
|
||||
menu.popup(browserWindow)
|
||||
|
||||
# Private: It's necessary to build the event handlers in this process, otherwise
|
||||
# closures are drug across processes and failed to be garbage collected
|
||||
@@ -14,6 +14,10 @@ dialog = require 'dialog'
|
||||
console.log = (args...) ->
|
||||
nslog(args.map((arg) -> JSON.stringify(arg)).join(" "))
|
||||
|
||||
process.on 'uncaughtException', (error={}) ->
|
||||
nslog(error.message) if error.message?
|
||||
nslog(error.stack) if error.stack?
|
||||
|
||||
delegate.browserMainParts.preMainMessageLoopRun = ->
|
||||
args = parseCommandLine()
|
||||
|
||||
@@ -47,12 +51,9 @@ delegate.browserMainParts.preMainMessageLoopRun = ->
|
||||
require('coffee-script')
|
||||
if args.devMode
|
||||
require(path.join(args.resourcePath, 'src', 'coffee-cache')).register()
|
||||
module.globalPaths.push(path.join(args.resourcePath, 'src'))
|
||||
AtomApplication = require path.join(args.resourcePath, 'src', 'browser', 'atom-application')
|
||||
else
|
||||
appSrcPath = path.resolve(process.argv[0], "../../Resources/app/src")
|
||||
module.globalPaths.push(appSrcPath)
|
||||
|
||||
AtomApplication = require 'atom-application'
|
||||
AtomApplication = require './atom-application'
|
||||
|
||||
AtomApplication.open(args)
|
||||
console.log("App load time: #{new Date().getTime() - startTime}ms")
|
||||
@@ -112,6 +113,6 @@ parseCommandLine = ->
|
||||
fs.statSync resourcePath
|
||||
catch e
|
||||
devMode = false
|
||||
resourcePath = path.dirname(__dirname)
|
||||
resourcePath = path.dirname(path.dirname(__dirname))
|
||||
|
||||
{resourcePath, pathsToOpen, executedFrom, test, version, pidToKillWhenClosed, devMode, newWindow, specDirectory}
|
||||
Reference in New Issue
Block a user