bump(electron): 0.34.3 => 0.35.1

Electron 0.35.1 includes the tray fixes we contributed last week but also includes API restructuring and improvements. Most importantly, modules from electron are now imported via `require('electron')`
This commit is contained in:
Ben Gotow 2015-11-23 22:09:17 -08:00
parent 5ee8ffabbc
commit 528c8850ce
65 changed files with 250 additions and 259 deletions

View file

@ -1,4 +1,4 @@
shell = require 'shell'
{shell} = require 'electron'
GithubStore = require './github-store'
{React} = require 'nylas-exports'
{RetinaImg, KeyCommandsRegion} = require 'nylas-component-kit'

View file

@ -12,15 +12,16 @@ class CalendarButton extends React.Component
_onClick: =>
BrowserWindow = require('remote').require('browser-window')
w = new BrowserWindow
'node-integration': false,
'web-preferences': {'web-security':false},
'width': 700,
'height': 600
nodeIntegration: false
webPreferences:
webSecurity:false
width: 700
height: 600
# Here, we load an arbitrary html file into the Composer!
path = require 'path'
url = path.join __dirname, '..', 'calendar.html'
w.loadUrl "file://#{url}?draftClientId=#{@props.draftClientId}"
w.loadURL "file://#{url}?draftClientId=#{@props.draftClientId}"
_getDialog: =>

View file

@ -10,7 +10,7 @@
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To &hellip;</a>
@ -18,46 +18,46 @@
<div id="jump_wrapper">
<div id="jump_page_wrapper">
<div id="jump_page">
<a class="source" href="availability-draft-extension.html">
availability-draft-extension.coffee
</a>
<a class="source" href="calendar-button.html">
calendar-button.coffee
</a>
<a class="source" href="main.html">
main.coffee
</a>
</div>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>calendar-button.coffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">&#182;</a>
</div>
</div>
<div class="content"><div class='highlight'><pre>{Utils, DraftStore, React} = <span class="hljs-built_in">require</span> <span class="hljs-string">'nylas-exports'</span>
{RetinaImg} = <span class="hljs-built_in">require</span> <span class="hljs-string">'nylas-component-kit'</span>
@ -76,23 +76,23 @@
<span class="hljs-string">'web-preferences'</span>: {<span class="hljs-string">'web-security'</span>:<span class="hljs-literal">false</span>},
<span class="hljs-string">'width'</span>: <span class="hljs-number">700</span>,
<span class="hljs-string">'height'</span>: <span class="hljs-number">600</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">&#182;</a>
</div>
<p>Here, we load an arbitrary html file into the Composer!</p>
</div>
<div class="content"><div class='highlight'><pre> path = <span class="hljs-built_in">require</span> <span class="hljs-string">'path'</span>
url = path.join __dirname, <span class="hljs-string">'..'</span>, <span class="hljs-string">'calendar.html'</span>
w.loadUrl <span class="hljs-string">"file://<span class="hljs-subst">#{url}</span>?draftClientId=<span class="hljs-subst">#{<span class="hljs-property">@props</span>.draftClientId}</span>"</span>
w.loadURL <span class="hljs-string">"file://<span class="hljs-subst">#{url}</span>?draftClientId=<span class="hljs-subst">#{<span class="hljs-property">@props</span>.draftClientId}</span>"</span>
<span class="hljs-attribute">_getDialog</span>: <span class="hljs-function">=&gt;</span>
@ -100,9 +100,9 @@
<span class="hljs-built_in">module</span>.exports = CalendarButton</pre></div></div>
</li>
</ul>
</div>
</body>

View file

@ -12,15 +12,16 @@ class CalendarButton extends React.Component
_onClick: =>
BrowserWindow = require('remote').require('browser-window')
w = new BrowserWindow
'node-integration': false,
'web-preferences': {'web-security':false},
'width': 700,
'height': 600
nodeIntegration: false
webPreferences:
webSecurity:false
width: 700
height: 600
# Here, we load an arbitrary html file into the Composer!
path = require 'path'
url = path.join __dirname, '..', 'calendar.html'
w.loadUrl "file://#{url}?draftClientId=#{@props.draftClientId}"
w.loadURL "file://#{url}?draftClientId=#{@props.draftClientId}"
_getDialog: =>

View file

@ -56,9 +56,8 @@ class AccountSidebarItem extends React.Component
_onShowContextMenu: =>
item = @props.item
label = item.name
remote = require 'remote'
Menu = remote.require 'menu'
MenuItem = remote.require 'menu-item'
{remote} = require 'electron'
{Menu, MenuItem} = remote.require 'electron'
menu = new Menu()
menu.append(new MenuItem({

View file

@ -26,10 +26,10 @@ class ImageAttachmentComponent extends AttachmentComponent
_canAbortDownload: -> false
_renderRemoveIcon: ->
<RetinaImg name="image-cancel-button.png"/>
<RetinaImg name="image-cancel-button.png" mode={RetinaImg.Mode.ContentPreserve} />
_renderDownloadButton: ->
<RetinaImg name="image-download-button.png"/>
<RetinaImg name="image-download-button.png" mode={RetinaImg.Mode.ContentPreserve} />
_imgOrLoader: ->
if @props.download

View file

@ -40,7 +40,7 @@ class ComposerView extends React.Component
@containerRequired: false
@propTypes:
draftClientId: React.PropTypes.string.isRequired
draftClientId: React.PropTypes.string
# Either "inline" or "fullwindow"
mode: React.PropTypes.string

View file

@ -19,12 +19,13 @@ class FileUpload extends React.Component
<Flexbox direction="row" style={alignItems: 'center'}>
<RetinaImg className="file-icon"
fallback="file-fallback.png"
mode={RetinaImg.Mode.ContentPreserve}
name="file-#{@_extension()}.png"/>
<span className="file-name">
<span className="uploading">Uploading:</span>&nbsp;{@_basename()}
</span>
<div className="file-action-icon" onClick={@_onClickRemove}>
<RetinaImg name="remove-attachment.png"/>
<RetinaImg name="remove-attachment.png" mode={RetinaImg.Mode.ContentDark} />
</div>
</Flexbox>
</div>

View file

@ -57,7 +57,7 @@ class FeedbackButton extends React.Component
x = Math.min(parentScreen.workAreaSize.width - width, Math.max(0, parentBounds.x + parentBounds.width - 36 - width / 2))
y = Math.max(0, (parentBounds.y + parentBounds.height) - height - 60)
require('ipc').send('show-feedback-window', { x, y, width, height, params })
require('electron').ipcRenderer.send('show-feedback-window', { x, y, width, height, params })
setTimeout =>
@setState(newMessages: false)
, 250

View file

@ -1,5 +1,5 @@
remote = require 'remote'
React = require 'react'
{remote} = require 'electron'
{Actions, NylasAPI, AccountStore} = require 'nylas-exports'
{RetinaImg, ButtonDropdown, Menu} = require 'nylas-component-kit'
@ -131,7 +131,7 @@ class MessageControls extends React.Component
success: (body) =>
fs.writeFile tmpfile, body, =>
window = new BrowserWindow(width: 800, height: 600, title: "#{@props.message.subject} - RFC822")
window.loadUrl('file://'+tmpfile)
window.loadURL('file://'+tmpfile)
_onLogData: =>
console.log @props.message

View file

@ -1,6 +1,5 @@
remote = require 'remote'
{Actions} = require 'nylas-exports'
ipc = require('ipc')
{ipcRenderer, remote} = require('electron')
module.exports =
@ -62,7 +61,7 @@ module.exports =
_onNotificationActionTaken: ({notification, action}) ->
if action.id is 'release-bar:install-update'
ipc.send 'command', 'application:install-update'
ipcRenderer.send 'command', 'application:install-update'
true
if action.id is 'release-bar:view-changelog'
require('shell').openExternal('https://github.com/nylas/N1/blob/master/CHANGELOG.md')

View file

@ -8,14 +8,15 @@ stubUpdaterReleaseVersion = null
ipcSendArgs = null
PackageMain = proxyquire "../lib/main",
"ipc":
send: ->
ipcSendArgs = arguments
"remote":
getGlobal: (global) ->
autoUpdateManager:
releaseVersion: stubUpdaterReleaseVersion
getState: -> stubUpdaterState
"electron":
"ipcRenderer":
send: ->
ipcSendArgs = arguments
"remote":
getGlobal: (global) ->
autoUpdateManager:
releaseVersion: stubUpdaterReleaseVersion
getState: -> stubUpdaterState
describe "NotificationUpdateAvailable", ->
beforeEach ->
@ -33,7 +34,7 @@ describe "NotificationUpdateAvailable", ->
stubUpdaterState = 'update-available'
@package.activate()
expect(@package.displayNotification).toHaveBeenCalled()
it "should not display a notification if no update is avialable", ->
spyOn(@package, 'displayNotification')
stubUpdaterState = 'no-update-available'
@ -63,9 +64,8 @@ describe "NotificationUpdateAvailable", ->
notifOptions = Actions.postNotification.mostRecentCall.args[0]
expect(notifOptions.message.indexOf(version) > 0).toBe(true)
describe "when the action is taken", ->
it "should fire the `application:install-update` IPC event", ->
Actions.notificationActionTaken({notification: {}, action: {id: 'release-bar:install-update'}})
expect(Array.prototype.slice.call(ipcSendArgs)).toEqual(['command', 'application:install-update'])

View file

@ -98,7 +98,7 @@ class AccountChoosePage extends React.Component
https://www.googleapis.com/auth/calendar'
approval_prompt: 'force'
})
shell = require 'shell'
{shell} = require 'electron'
shell.openExternal(googleUrl)
module.exports = AccountChoosePage

View file

@ -1,9 +1,6 @@
React = require 'react'
remote = require 'remote'
dialog = remote.require 'dialog'
Crypto = require 'crypto'
ipc = require 'ipc'
{ipcRenderer, dialog, remote} = require 'electron'
{RetinaImg} = require 'nylas-component-kit'
{EdgehillAPI, NylasAPI, APIError} = require 'nylas-exports'
@ -52,7 +49,7 @@ class AccountSettingsPage extends React.Component
)
setTimeout(_retry,initial_delay)
ipc.on('browser-window-focus', ->
ipcRenderer.on('browser-window-focus', ->
if not done # hack to deactivate this listener when done
pollAttemptId++
poll(pollAttemptId,0)

View file

@ -102,6 +102,6 @@ class InitialPackagesPage extends React.Component
if RunningPackageInstalls > 0
@setState(waitingToGetStarted: true)
else
require('ipc').send('account-setup-successful')
require('electron').ipcRenderer.send('account-setup-successful')
module.exports = InitialPackagesPage

View file

@ -2,8 +2,8 @@ Reflux = require 'reflux'
OnboardingActions = require './onboarding-actions'
TokenAuthAPI = require './token-auth-api'
{AccountStore} = require 'nylas-exports'
{ipcRenderer} = require 'electron'
NylasStore = require 'nylas-store'
ipc = require 'ipc'
url = require 'url'
return unless NylasEnv.getWindowType() is "onboarding"
@ -26,12 +26,12 @@ class PageRouterStore extends NylasStore
_onAccountJSONReceived: (json) =>
isFirstAccount = AccountStore.items().length is 0
AccountStore.addAccountFromJSON(json)
ipc.send('new-account-added')
ipcRenderer.send('new-account-added')
NylasEnv.displayWindow()
if isFirstAccount
@_onMoveToPage('initial-preferences', {account: json})
else
ipc.send('account-setup-successful')
ipcRenderer.send('account-setup-successful')
_onWindowPropsChanged: ({page, pageData}={}) =>
@_onMoveToPage(page, pageData)

View file

@ -1,5 +1,5 @@
React = require 'react'
shell = require 'shell'
{shell} = require 'electron'
classnames = require 'classnames'
{RetinaImg} = require 'nylas-component-kit'
PageRouterStore = require './page-router-store'

View file

@ -1,12 +1,12 @@
_ = require 'underscore'
ipc = require 'ipc'
Reflux = require 'reflux'
path = require 'path'
fs = require 'fs-plus'
shell = require 'shell'
PluginsActions = require './plugins-actions'
{APMWrapper} = require 'nylas-exports'
dialog = require('remote').require('dialog')
{ipcRenderer, shell, remote} = require 'electron'
dialog = remote.require('dialog')
module.exports =
PackagesStore = Reflux.createStore
@ -168,7 +168,7 @@ PackagesStore = Reflux.createStore
else
starterPackagesPath = path.join(resourcePath, "examples")
dialog.showOpenDialog
NylasEnv.showOpenDialog
title: "Choose a Package Directory"
defaultPath: starterPackagesPath
properties: ['openDirectory']
@ -195,13 +195,13 @@ PackagesStore = Reflux.createStore
Developer menu."
buttons: ["OK", "Cancel"]
if btn is 0
ipc.send('command', 'application:toggle-dev')
ipcRenderer.send('command', 'application:toggle-dev')
return
packagesDir = path.join(NylasEnv.getConfigDirPath(), 'dev', 'packages')
fs.makeTreeSync(packagesDir)
dialog.showSaveDialog
NylasEnv.showSaveDialog
title: "Save New Package"
defaultPath: packagesDir
properties: ['createDirectory']

View file

@ -56,7 +56,7 @@ class TabInstalled extends React.Component
</div>
_onEnableDevMode: =>
require('ipc').send('command', 'application:toggle-dev')
require('electron').ipcRenderer.send('command', 'application:toggle-dev')
componentDidMount: =>
@_unsubscribers = []

View file

@ -1,5 +1,4 @@
_ = require 'underscore'
ipc = require 'ipc'
Reflux = require 'reflux'
PluginsActions = require './plugins-actions'

View file

@ -6,7 +6,7 @@
module.exports =
activate: ->
ipc = require 'ipc'
{ipcRenderer} = require 'electron'
React = require 'react'
Cfg = PreferencesSectionStore.SectionConfig
@ -42,7 +42,7 @@ module.exports =
location: WorkspaceStore.Location.Preferences
Actions.openPreferences.listen(@_openPreferences)
ipc.on 'open-preferences', => @_openPreferences()
ipcRenderer.on 'open-preferences', => @_openPreferences()
_openPreferences: ->
Actions.pushSheet(WorkspaceStore.Sheet.Preferences)

View file

@ -87,7 +87,7 @@ class PreferencesAccounts extends React.Component
tokens
_onAddAccount: =>
ipc = require('ipc')
ipc = require('electron').ipcRenderer
ipc.send('command', 'application:add-account')
_onAccountChange: =>

View file

@ -18,8 +18,8 @@ class SystemTray {
}
_addEventListeners() {
this._tray.addListener('clicked', this._onClicked.bind(this));
const unsubClicked = ()=> this._tray.removeListener('clicked', this._onClicked);
this._tray.addListener('click', this._onClicked.bind(this));
const unsubClicked = ()=> this._tray.removeListener('click', this._onClicked);
const unsubStore = this._store.listen(this._onChange.bind(this));
return ()=> {
unsubClicked();

View file

@ -1,7 +1,6 @@
import path from 'path';
import remote from 'remote';
import ipc from 'ipc';
import NylasStore from 'nylas-store';
import {remote, ipcRenderer} from 'electron';
import {UnreadBadgeStore, CanvasUtils} from 'nylas-exports';
const NativeImage = remote.require('native-image');
const Menu = remote.require('menu');
@ -15,25 +14,25 @@ const UNREAD_ICON_PATH = path.join(__dirname, '..', 'assets', process.platform,
const menuTemplate = [
{
label: 'New Message',
click: ()=> ipc.send('command', 'application:new-message'),
click: ()=> ipcRenderer.send('command', 'application:new-message'),
},
{
label: 'Preferences',
click: ()=> ipc.send('command', 'application:open-preferences'),
click: ()=> ipcRenderer.send('command', 'application:open-preferences'),
},
{
type: 'separator',
},
{
label: 'Quit N1',
click: ()=> ipc.send('command', 'application:quit'),
click: ()=> ipcRenderer.send('command', 'application:quit'),
},
];
if (process.platform === 'darwin') {
menuTemplate.unshift({
label: 'Open Inbox',
click: ()=> ipc.send('command', 'application:show-main-window'),
click: ()=> ipcRenderer.send('command', 'application:show-main-window'),
});
}
@ -77,10 +76,10 @@ class TrayStore extends NylasStore {
const img = new Image();
// toDataUrl always returns the @1x image data, so the assets/darwin/
// contains an "@2x" image /without/ the @2x extension
img.src = this._baseIcon.toDataUrl();
img.src = this._baseIcon.toDataURL();
const count = this._unreadCount || '';
const canvas = canvasWithSystemTrayIconAndText(img, count.toString());
const pngData = NativeImage.createFromDataUrl(canvas.toDataURL()).toPng();
const pngData = NativeImage.createFromDataURL(canvas.toDataURL()).toPng();
// creating from a buffer allows us to specify that the image is @2x
const out2x = NativeImage.createFromBuffer(pngData, 2);

View file

@ -40,7 +40,7 @@ class DeveloperBarCurlItem extends React.Component
fs.unlinkSync(curlFile)
fs.writeFileSync(curlFile, @props.item.command)
fs.chmodSync(curlFile, '777')
shell = require 'shell'
{shell} = require 'electron'
shell.openItem(curlFile)

View file

@ -11,7 +11,7 @@
"bugs": {
"url": "https://github.com/nylas/N1/issues"
},
"electronVersion": "0.34.3",
"electronVersion": "0.35.1",
"dependencies": {
"async": "^0.9",
"atom-keymap": "^6.1.1",

View file

@ -18,7 +18,7 @@ describe "AutoUpdateManager", ->
m = new AutoUpdateManager("3.222.1-abc", @config, @specMode)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedUrl, true)
{query} = url.parse(m.feedURL, true)
expect(query.arch).toBe process.arch
expect(query.platform).toBe process.platform
expect(query.version).toBe "3.222.1-abc"
@ -27,7 +27,7 @@ describe "AutoUpdateManager", ->
it "correctly sets the feedURL", ->
m = new AutoUpdateManager("3.222.1", @config, @specMode)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedUrl, true)
{query} = url.parse(m.feedURL, true)
expect(query.arch).toBe process.arch
expect(query.platform).toBe process.platform
expect(query.version).toBe "3.222.1"
@ -36,7 +36,7 @@ describe "AutoUpdateManager", ->
it "should save one to @config and send it", ->
m = new AutoUpdateManager("3.222.1", @config, @specMode)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedUrl, true)
{query} = url.parse(m.feedURL, true)
expect(query.id).toBeDefined()
expect(@config.set).toHaveBeenCalledWith('updateIdentity', query.id)
@ -46,7 +46,7 @@ describe "AutoUpdateManager", ->
@updateIdentity = "test-identity"
m = new AutoUpdateManager("3.222.1", @config, @specMode)
spyOn(m, "setupAutoUpdater")
{query} = url.parse(m.feedUrl, true)
{query} = url.parse(m.feedURL, true)
expect(query.id).toEqual(@updateIdentity)
expect(@config.set).not.toHaveBeenCalled()

View file

@ -1,5 +1,5 @@
fs = require 'fs'
remote = require 'remote'
{remote} = require 'electron'
module.exports.runSpecSuite = (specSuite, logFile, logErrors=true) ->
{$, $$} = require '../src/space-pen-extensions'

View file

@ -82,7 +82,7 @@ class N1SpecReporter extends View
@on 'click', '.stack-trace', ->
$(this).toggleClass('expanded')
@reloadButton.on 'click', -> require('ipc').send('call-window-method', 'restart')
@reloadButton.on 'click', -> require('electron').ipcRenderer.send('call-window-method', 'restart')
reportRunnerResults: (runner) ->
@updateSpecCounts()

View file

@ -17,7 +17,7 @@ KeymapManager = require '../src/keymap-manager'
Config = require '../src/config'
ServiceHub = require 'service-hub'
pathwatcher = require 'pathwatcher'
clipboard = require 'clipboard'
{clipboard} = require 'electron'
Account = require "../src/flux/models/account"
AccountStore = require "../src/flux/stores/account-store"

View file

@ -1,4 +1,3 @@
ipc = require 'ipc'
TestModel = require '../fixtures/db-test-model'
Attributes = require '../../src/flux/attributes'
DatabaseSetupQueryBuilder = require '../../src/flux/stores/database-setup-query-builder'

View file

@ -1,5 +1,4 @@
_ = require 'underscore'
ipc = require 'ipc'
Label = require '../../src/flux/models/label'
Thread = require '../../src/flux/models/thread'

View file

@ -12,7 +12,8 @@ DestroyDraftTask = require '../../src/flux/tasks/destroy-draft'
SoundRegistry = require '../../src/sound-registry'
Actions = require '../../src/flux/actions'
Utils = require '../../src/flux/models/utils'
ipc = require 'ipc'
{ipcRenderer} = require 'electron'
_ = require 'underscore'
fakeThread = null
@ -42,14 +43,14 @@ describe "DraftStore", ->
spyOn(DraftStore, "_sanitizeBody").andCallThrough()
spyOn(DraftStore, "_onInlineStylesResult").andCallThrough()
spyOn(DraftStore, "_convertToInlineStyles").andCallThrough()
spyOn(ipc, "send").andCallFake (message, body) ->
spyOn(ipcRenderer, "send").andCallFake (message, body) ->
if message is "inline-style-parse"
# There needs to be a defer block in here so the promise
# responsible for handling the `inline-style-parse` can be
# properly set. If the whole path is synchronous instead of
# asynchrounous, the promise is not cleared properly. Doing this
# requires us to add `advanceClock` blocks.
_.defer -> DraftStore._onInlineStylesResult(body)
_.defer -> DraftStore._onInlineStylesResult({}, body)
fakeThread = new Thread
id: 'fake-thread-id'
@ -863,7 +864,7 @@ describe "DraftStore", ->
received = draft
Promise.resolve()
waitsForPromise ->
DraftStore._onHandleMailtoLink('mailto:bengotow@gmail.com').then ->
DraftStore._onHandleMailtoLink({}, 'mailto:bengotow@gmail.com').then ->
expect(received.body.indexOf("Edited by TestExtension!")).toBe(0)
describe "when testing subject keys", ->
@ -875,19 +876,19 @@ describe "DraftStore", ->
it "works for lowercase", ->
waitsForPromise =>
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?subject=' + @expected).then =>
DraftStore._onHandleMailtoLink({}, 'mailto:asdf@asdf.com?subject=' + @expected).then =>
received = DraftStore._finalizeAndPersistNewMessage.mostRecentCall.args[0]
expect(received.subject).toBe(@expected)
it "works for title case", ->
waitsForPromise =>
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?Subject=' + @expected).then =>
DraftStore._onHandleMailtoLink({}, 'mailto:asdf@asdf.com?Subject=' + @expected).then =>
received = DraftStore._finalizeAndPersistNewMessage.mostRecentCall.args[0]
expect(received.subject).toBe(@expected)
it "works for uppercase", ->
waitsForPromise =>
DraftStore._onHandleMailtoLink('mailto:asdf@asdf.com?SUBJECT=' + @expected).then =>
DraftStore._onHandleMailtoLink({}, 'mailto:asdf@asdf.com?SUBJECT=' + @expected).then =>
received = DraftStore._finalizeAndPersistNewMessage.mostRecentCall.args[0]
expect(received.subject).toBe(@expected)
@ -977,7 +978,7 @@ describe "DraftStore", ->
links.forEach (link, idx) ->
it "works for #{link}", ->
waitsForPromise ->
DraftStore._onHandleMailtoLink(link).then ->
DraftStore._onHandleMailtoLink({}, link).then ->
expectedDraft = expected[idx]
received = DatabaseStore.persistModel.mostRecentCall.args[0]
expect(received['subject']).toEqual(expectedDraft['subject'])

View file

@ -1,5 +1,5 @@
fs = require 'fs'
shell = require 'shell'
{shell} = require 'electron'
NylasAPI = require '../../src/flux/nylas-api'
File = require '../../src/flux/models/file'
FileDownloadStore = require '../../src/flux/stores/file-download-store'

View file

@ -1,9 +1,6 @@
app = require 'app'
ipc = require 'ipc'
Menu = require 'menu'
{BrowserWindow, Menu, app} = require 'electron'
_ = require 'underscore'
Utils = require '../flux/models/utils'
BrowserWindow = require 'browser-window'
# Used to manage the global application menu.
#

View file

@ -1,22 +1,19 @@
NylasWindow = require './nylas-window'
BrowserWindow = require 'browser-window'
WindowManager = require './window-manager'
ApplicationMenu = require './application-menu'
AutoUpdateManager = require './auto-update-manager'
NylasProtocolHandler = require './nylas-protocol-handler'
SharedFileManager = require './shared-file-manager'
{BrowserWindow, Menu, app, ipcMain, dialog} = require 'electron'
_ = require 'underscore'
fs = require 'fs-plus'
os = require 'os'
app = require 'app'
ipc = require 'ipc'
net = require 'net'
url = require 'url'
exec = require('child_process').exec
Menu = require 'menu'
path = require 'path'
dialog = require 'dialog'
querystring = require 'querystring'
{EventEmitter} = require 'events'
@ -310,28 +307,28 @@ class Application
@openUrl(urlToOpen)
event.preventDefault()
ipc.on 'set-badge-value', (event, value) =>
ipcMain.on 'set-badge-value', (event, value) =>
app.dock?.setBadge?(value)
ipc.on 'new-window', (event, options) =>
ipcMain.on 'new-window', (event, options) =>
@windowManager.newWindow(options)
ipc.on 'show-feedback-window', (event, options) =>
ipcMain.on 'show-feedback-window', (event, options) =>
@windowManager.showFeedbackWindow(options)
ipc.on 'register-hot-window', (event, options) =>
ipcMain.on 'register-hot-window', (event, options) =>
@windowManager.registerHotWindow(options)
ipc.on 'unregister-hot-window', (event, windowType) =>
ipcMain.on 'unregister-hot-window', (event, windowType) =>
@windowManager.unregisterHotWindow(windowType)
ipc.on 'from-react-remote-window', (event, json) =>
ipcMain.on 'from-react-remote-window', (event, json) =>
@windowManager.sendToMainWindow('from-react-remote-window', json)
ipc.on 'from-react-remote-window-selection', (event, json) =>
ipcMain.on 'from-react-remote-window-selection', (event, json) =>
@windowManager.sendToMainWindow('from-react-remote-window-selection', json)
ipc.on 'inline-style-parse', (event, {body, clientId}) =>
ipcMain.on 'inline-style-parse', (event, {body, clientId}) =>
juice = require 'juice'
try
body = juice(body)
@ -348,48 +345,51 @@ class Application
@openWindowsForTokenState()
event.preventDefault()
ipc.on 'update-application-menu', (event, template, keystrokesByCommand) =>
ipcMain.on 'update-application-menu', (event, template, keystrokesByCommand) =>
win = BrowserWindow.fromWebContents(event.sender)
@applicationMenu.update(win, template, keystrokesByCommand)
ipc.on 'command', (event, command) =>
ipcMain.on 'command', (event, command) =>
@emit(command)
ipc.on 'window-command', (event, command, args...) ->
ipcMain.on 'window-command', (event, command, args...) ->
win = BrowserWindow.fromWebContents(event.sender)
win.emit(command, args...)
ipc.on 'call-window-method', (event, method, args...) ->
ipcMain.on 'call-window-method', (event, method, args...) ->
win = BrowserWindow.fromWebContents(event.sender)
win[method](args...)
ipc.on 'action-bridge-rebroadcast-to-all', (event, args...) =>
ipcMain.on 'call-webcontents-method', (event, method, args...) ->
event.sender[method](args...)
ipcMain.on 'action-bridge-rebroadcast-to-all', (event, args...) =>
win = BrowserWindow.fromWebContents(event.sender)
@windowManager.windows().forEach (nylasWindow) ->
return if nylasWindow.browserWindow == win
return unless nylasWindow.browserWindow.webContents
nylasWindow.browserWindow.webContents.send('action-bridge-message', args...)
ipc.on 'action-bridge-rebroadcast-to-work', (event, args...) =>
ipcMain.on 'action-bridge-rebroadcast-to-work', (event, args...) =>
workWindow = @windowManager.workWindow()
return if not workWindow or not workWindow.browserWindow.webContents
return if BrowserWindow.fromWebContents(event.sender) is workWindow
workWindow.browserWindow.webContents.send('action-bridge-message', args...)
clipboard = null
ipc.on 'write-text-to-selection-clipboard', (event, selectedText) ->
clipboard ?= require 'clipboard'
ipcMain.on 'write-text-to-selection-clipboard', (event, selectedText) ->
clipboard ?= require('electron').clipboard
clipboard.writeText(selectedText, 'selection')
ipc.on 'account-setup-successful', (event) =>
ipcMain.on 'account-setup-successful', (event) =>
@windowManager.showMainWindow()
@windowManager.ensureWorkWindow()
@windowManager.onboardingWindow()?.close()
ipc.on 'new-account-added', (event) =>
ipcMain.on 'new-account-added', (event) =>
@windowManager.ensureWorkWindow()
ipc.on 'run-in-window', (event, params) =>
ipcMain.on 'run-in-window', (event, params) =>
@_sourceWindows ?= {}
sourceWindow = BrowserWindow.fromWebContents(event.sender)
@_sourceWindows[params.taskId] = sourceWindow
@ -401,7 +401,7 @@ class Application
return if not targetWindow or not targetWindow.browserWindow.webContents
targetWindow.browserWindow.webContents.send('run-in-window', params)
ipc.on 'remote-run-results', (event, params) =>
ipcMain.on 'remote-run-results', (event, params) =>
sourceWindow = @_sourceWindows[params.taskId]
sourceWindow.webContents.send('remote-run-results', params)
delete @_sourceWindows[params.taskId]

View file

@ -35,9 +35,9 @@ class AutoUpdateManager
if process.platform is 'win32'
# Squirrel for Windows can't handle query params
# https://github.com/Squirrel/Squirrel.Windows/issues/132
@feedUrl = "https://edgehill.nylas.com/update-check/win32/#{process.arch}/#{@version}/#{updaterId}/#{updaterEmails}"
@feedURL = "https://edgehill.nylas.com/update-check/win32/#{process.arch}/#{@version}/#{updaterId}/#{updaterEmails}"
else
@feedUrl = "https://edgehill.nylas.com/update-check?platform=#{process.platform}&arch=#{process.arch}&version=#{@version}&id=#{updaterId}&emails=#{updaterEmails}"
@feedURL = "https://edgehill.nylas.com/update-check?platform=#{process.platform}&arch=#{process.arch}&version=#{@version}&id=#{updaterId}&emails=#{updaterEmails}"
if not @specMode
process.nextTick => @setupAutoUpdater()
@ -46,13 +46,13 @@ class AutoUpdateManager
if process.platform is 'win32'
autoUpdater = require './auto-updater-win32'
else
autoUpdater = require 'auto-updater'
autoUpdater = require('electron').autoUpdater
autoUpdater.on 'error', (event, message) =>
console.error "Error Downloading Update: #{message}"
@setState(ErrorState)
autoUpdater.setFeedUrl(@feedUrl)
autoUpdater.setFeedURL(@feedURL)
autoUpdater.on 'checking-for-update', =>
@setState(CheckingState)
@ -110,7 +110,7 @@ class AutoUpdateManager
onUpdateNotAvailable: =>
autoUpdater.removeListener 'error', @onUpdateError
dialog = require 'dialog'
{dialog} = require 'electron'
dialog.showMessageBox
type: 'info'
buttons: ['OK']
@ -121,7 +121,7 @@ class AutoUpdateManager
onUpdateError: (event, message) =>
autoUpdater.removeListener 'update-not-available', @onUpdateNotAvailable
dialog = require 'dialog'
{dialog} = require 'electron'
dialog.showMessageBox
type: 'warning'
buttons: ['OK']

View file

@ -5,7 +5,7 @@ SquirrelUpdate = require './squirrel-update'
class AutoUpdater
_.extend @prototype, EventEmitter.prototype
setFeedUrl: (@updateUrl) ->
setFeedURL: (@updateUrl) ->
quitAndInstall: ->
if SquirrelUpdate.existsSync()

View file

@ -1,4 +1,4 @@
Menu = require 'menu'
{Menu} = require 'electron'
module.exports =
class ContextMenu

View file

@ -4,7 +4,7 @@ process.on 'uncaughtException', (error={}) ->
console.log(error.message) if error.message?
console.log(error.stack) if error.stack?
app = require 'app'
{app} = require 'electron'
fs = require 'fs-plus'
path = require 'path'
optimist = require 'optimist'
@ -44,7 +44,7 @@ start = ->
setupNylasHome = ->
return if process.env.NYLAS_HOME
atomHome = path.join(app.getHomeDir(), '.nylas')
atomHome = path.join(app.getPath('home'), '.nylas')
process.env.NYLAS_HOME = atomHome
normalizeDriveLetterName = (filePath) ->

View file

@ -64,7 +64,7 @@
if (process.env.NYLAS_HOME) {
return;
}
atomHome = path.join(app.getHomeDir(), '.nylas');
atomHome = path.join(app.getPath('home'), '.nylas');
return process.env.NYLAS_HOME = atomHome;
};

View file

@ -1,4 +1,4 @@
# ipc = require 'ipc'
# ipcMain = require 'ipcMain'
# BrowserWindow = require 'browser-window'
#
# class NativeNotificationManagerUnavailable
@ -27,7 +27,7 @@
# global.__nativeNotificationManagerMacOSXDelegate = Delegate
# global.__nativeNotificationManagerMacOSX = @
#
# ipc.on('fire-native-notification', @onFireNotification)
# ipcMain.on('fire-native-notification', @onFireNotification)
#
# shouldPresentNotification: (self, _cmd, center, notif) =>
# return true

View file

@ -1,7 +1,6 @@
app = require 'app'
{app, protocol} = require 'electron'
fs = require 'fs'
path = require 'path'
protocol = require 'protocol'
# Handles requests with 'nylas' protocol.
#
@ -18,7 +17,7 @@ module.exports =
class NylasProtocolHandler
constructor: (resourcePath, safeMode) ->
@loadPaths = []
@dotNylasDirectory = path.join(app.getHomeDir(), '.nylas')
@dotNylasDirectory = path.join(app.getPath('home'), '.nylas')
unless safeMode
@loadPaths.push(path.join(@dotNylasDirectory, 'dev', 'packages'))

View file

@ -1,5 +1,4 @@
BrowserWindow = require 'browser-window'
app = require 'app'
{BrowserWindow, app} = require 'electron'
path = require 'path'
fs = require 'fs'
url = require 'url'
@ -55,26 +54,24 @@ class NylasWindow
show: false
title: title ? 'Nylas'
frame: frame
'standard-window': frame
width: width
height: height
resizable: resizable ? true
icon: @constructor.iconPath
'web-preferences':
'direct-write': true
'subpixel-font-scaling': true
webPreferences:
directWrite: true
if @mainWindow
# Prevents DOM timers from being suspended when the main window is hidden.
# Means there's not an awkward catch-up when you re-show the main window.
options['web-preferences']['page-visibility'] = true
options.webPreferences.pageVisibility = true
# Don't set icon on Windows so the exe's ico will be used as window and
# taskbar's icon. See https://github.com/atom/atom/issues/4811 for more.
if process.platform is 'linux'
options.icon = @constructor.iconPath
@browserWindow = new BrowserWindow options
@browserWindow = new BrowserWindow(options)
global.application.windowManager.addWindow(this)
@handleEvents()
@ -108,7 +105,7 @@ class NylasWindow
if @browserWindow.loadSettingsChangedSinceGetURL
@browserWindow.webContents.send('load-settings-changed', @browserWindow.loadSettings)
@browserWindow.loadUrl(@getUrl(loadSettings))
@browserWindow.loadURL(@getURL(loadSettings))
@browserWindow.focusOnWebView() if @isSpec
loadSettings: ->
@ -120,7 +117,7 @@ class NylasWindow
if @loaded
@browserWindow.webContents.send('load-settings-changed', loadSettings)
getUrl: (loadSettingsObj) ->
getURL: (loadSettingsObj) ->
# Ignore the windowState when passing loadSettings via URL, since it could
# be quite large.
loadSettings = _.clone(loadSettingsObj)
@ -172,7 +169,7 @@ class NylasWindow
return if @isSpec
return if not @loaded
dialog = require 'dialog'
{dialog} = require 'electron'
chosen = dialog.showMessageBox @browserWindow,
type: 'warning'
buttons: ['Close', 'Keep Waiting']
@ -184,9 +181,9 @@ class NylasWindow
global.application.exit(100) if @exitWhenDone
if @neverClose
@browserWindow.restart()
@browserWindow.reload()
else
dialog = require 'dialog'
{dialog} = require 'electron'
chosen = dialog.showMessageBox @browserWindow,
type: 'warning'
buttons: ['Close Window', 'Reload', 'Keep It Open']
@ -194,7 +191,7 @@ class NylasWindow
detail: 'Please report this issue to us at support@nylas.com.'
switch chosen
when 0 then @browserWindow.destroy()
when 1 then @browserWindow.restart()
when 1 then @browserWindow.reload()
@setupContextMenu()
@ -271,6 +268,6 @@ class NylasWindow
isSpecWindow: -> @isSpec
reload: -> @browserWindow.restart()
reload: -> @browserWindow.reload()
toggleDevTools: -> @browserWindow.toggleDevTools()

View file

@ -1,8 +1,8 @@
_ = require 'underscore'
fs = require 'fs-plus'
NylasWindow = require './nylas-window'
BrowserWindow = require 'browser-window'
app = require 'app'
{BrowserWindow, app} = require 'electron'
class WindowManager
@ -164,16 +164,17 @@ class WindowManager
@feedbackWindow.show()
else
@feedbackWindow = w = new BrowserWindow
'node-integration': false,
'web-preferences': {'web-security':false},
'x': x
'y': y
'width': width,
'height': height,
'title': 'Feedback'
nodeIntegration: false
webPreferences:
webSecurity:false
x: x
y: y
width: width,
height: height,
title: 'Feedback'
onOpenURL = (event, href) ->
shell = require 'shell'
{shell} = require 'electron'
shell.openExternal(href)
event.preventDefault()
@ -190,7 +191,7 @@ class WindowManager
w.webContents.on('will-navigate', onOpenURL)
url = require('path').join(@resourcePath, 'static', 'feedback.html')
w.loadUrl("file://#{url}?#{params}")
w.loadURL("file://#{url}?#{params}")
w.show()
# Makes a new window appear of a certain `windowType`.

View file

@ -1,4 +1,4 @@
clipboard = require 'clipboard'
{clipboard} = require 'electron'
crypto = require 'crypto'
# Extended: Represents the clipboard used for copying and pasting in Nylas N1.

View file

@ -169,7 +169,7 @@ class EventedIFrame extends React.Component
menu.append(new MenuItem({
label: "Save Image...",
click: ->
NylasEnv.showSaveDialog srcFilename, (path) ->
NylasEnv.showSaveDialog {defaultPath: srcFilename}, (path) ->
return unless path
oReq = new XMLHttpRequest()
oReq.open("GET", src, true)
@ -190,7 +190,7 @@ class EventedIFrame extends React.Component
canvas.height = img.height
canvas.getContext("2d").drawImage(imageTarget, 0, 0)
imageDataURL = canvas.toDataURL("image/png")
img = NativeImage.createFromDataUrl(imageDataURL)
img = NativeImage.createFromDataURL(imageDataURL)
clipboard.writeImage(img)
, false)
img.src = src

View file

@ -1,5 +1,4 @@
_ = require 'underscore'
ipc = require 'ipc'
Model = null
SerializableRegistry = require './serializable-registry'

View file

@ -65,7 +65,7 @@ class ActionBridge
callback = => @onRebroadcast(TargetWindows.WORK, name, arguments)
Actions[name].listen(callback, @)
onIPCMessage: (initiatorId, name, json) =>
onIPCMessage: (event, initiatorId, name, json) =>
# There's something very strange about IPC event handlers. The ReactRemoteParent
# threw React exceptions when calling setState from an IPC callback, and the debugger
# often refuses to stop at breakpoints immediately inside IPC callbacks.

View file

@ -241,8 +241,8 @@ class NylasAPI
unless @_notificationUnlisten
handler = ({notification, action}) ->
if action.id is '401:unlink'
ipc = require 'ipc'
ipc.send('command', 'application:reset-config-and-relaunch')
{ipcRenderer} = require 'electron'
ipcRenderer.send('command', 'application:reset-config-and-relaunch')
@_notificationUnlisten = Actions.notificationActionTaken.listen(handler, @)
return Promise.resolve()

View file

@ -63,7 +63,7 @@ class AccountStore
NylasEnv.menu.update()
_selectAccountByIndex: (index) =>
require('ipc').send('command', 'application:show-main-window')
require('electron').ipcRenderer.send('command', 'application:show-main-window')
index = Math.min(@_accounts.length - 1, Math.max(0, index))
Actions.selectAccountId(@_accounts[index].id)
@ -103,7 +103,7 @@ class AccountStore
@_save()
if @_accounts.length is 0
ipc = require('ipc')
ipc = require('electron').ipcRenderer
ipc.send('command', 'application:reset-config-and-relaunch')
else
if @_index is idx

View file

@ -1,5 +1,4 @@
_ = require 'underscore'
ipc = require 'ipc'
async = require 'async'
path = require 'path'
sqlite3 = require 'sqlite3'
@ -13,6 +12,8 @@ DatabaseSetupQueryBuilder = require './database-setup-query-builder'
DatabaseChangeRecord = require './database-change-record'
PriorityUICoordinator = require '../../priority-ui-coordinator'
{ipcRenderer} = require 'electron'
{AttributeCollection, AttributeJoinedData} = require '../attributes'
{tableNameForJoin,
@ -94,7 +95,7 @@ class DatabaseStore extends NylasStore
# Listen to events from the application telling us when the database is ready,
# should be closed so it can be deleted, etc.
ipc.on('database-phase-change', @_onPhaseChange)
ipcRenderer.on('database-phase-change', @_onPhaseChange)
_.defer => @_onPhaseChange()
_onPhaseChange: (event) =>

View file

@ -1,9 +1,10 @@
_ = require 'underscore'
ipc = require 'ipc'
crypto = require 'crypto'
moment = require 'moment'
sanitizeHtml = require 'sanitize-html'
{ipcRenderer} = require 'electron'
DraftStoreProxy = require './draft-store-proxy'
DatabaseStore = require './database-store'
AccountStore = require './account-store'
@ -58,7 +59,7 @@ class DraftStore
@listenTo Actions.sendQuickReply, @_onSendQuickReply
if NylasEnv.isMainWindow()
ipc.on 'new-message', => @_onPopoutBlankDraft()
ipcRenderer.on 'new-message', => @_onPopoutBlankDraft()
# Remember that these two actions only fire in the current window and
# are picked up by the instance of the DraftStore in the current
@ -92,9 +93,9 @@ class DraftStore
# request to queue something, and when it appears on the queue.
@_draftsSending = {}
ipc.on 'mailto', @_onHandleMailtoLink
ipcRenderer.on 'mailto', @_onHandleMailtoLink
ipc.on 'inline-styles-result', @_onInlineStylesResult
ipcRenderer.on 'inline-styles-result', @_onInlineStylesResult
######### PUBLIC #######################################################
@ -371,7 +372,7 @@ class DraftStore
body = @_injectUserAgentStyles(body)
@_inlineStylePromises[clientId] ?= new Promise (resolve, reject) =>
@_inlineStyleResolvers[clientId] = resolve
ipc.send('inline-style-parse', {body, clientId})
ipcRenderer.send('inline-style-parse', {body, clientId})
return @_inlineStylePromises[clientId]
# This will prepend the user agent stylesheet so we can apply it to the
@ -383,7 +384,7 @@ class DraftStore
userAgentDefault = require '../../chrome-user-agent-stylesheet-string'
return "#{body[0...i]}<style>#{userAgentDefault}</style>#{body[i..-1]}"
_onInlineStylesResult: ({body, clientId}) =>
_onInlineStylesResult: (event, {body, clientId}) =>
delete @_inlineStylePromises[clientId]
@_inlineStyleResolvers[clientId](body)
delete @_inlineStyleResolvers[clientId]
@ -422,19 +423,23 @@ class DraftStore
title = if options.newDraft then "New Message" else "Message"
console.log('starting save')
save.then =>
console.log('finished save')
app = require('remote').getGlobal('application')
existing = app.windowManager.windowWithPropsMatching({draftClientId})
console.log('discovered existing')
if existing
existing.restore() if existing.isMinimized()
existing.focus()
else
console.log('NylasEnv.newWindow')
NylasEnv.newWindow
title: title
windowType: "composer"
windowProps: _.extend(options, {draftClientId})
_onHandleMailtoLink: (urlString) =>
_onHandleMailtoLink: (event, urlString) =>
account = AccountStore.current()
return unless account

View file

@ -1,8 +1,7 @@
os = require 'os'
fs = require 'fs'
ipc = require 'ipc'
path = require 'path'
shell = require 'shell'
{shell} = require 'electron'
mkdirp = require 'mkdirp'
Utils = require '../models/utils'
Reflux = require 'reflux'
@ -211,7 +210,7 @@ FileDownloadStore = Reflux.createStore
@_presentError(file)
_fetchAndSave: (file) ->
NylasEnv.showSaveDialog @_defaultSavePath(file), (savePath) =>
NylasEnv.showSaveDialog {defaultPath: @_defaultSavePath(file)}, (savePath) =>
return unless savePath
@_runDownload(file).then (download) ->
stream = fs.createReadStream(download.targetPath)

View file

@ -1,5 +1,4 @@
_ = require 'underscore'
ipc = require 'ipc'
fs = require 'fs'
Reflux = require 'reflux'
Actions = require '../actions'

View file

@ -61,6 +61,6 @@ class UnreadBadgeStore extends NylasStore
# NOTE: Do not underestimate how long this can take. It's a synchronous
# remote call and can take ~50+msec.
return if NylasEnv.config.get('core.showUnreadBadge') is false
require('ipc').send('set-badge-value', val)
require('electron').ipcRenderer.send('set-badge-value', val)
module.exports = new UnreadBadgeStore()

View file

@ -1,9 +1,9 @@
path = require 'path'
_ = require 'underscore'
ipc = require 'ipc'
CSON = require 'season'
fs = require 'fs-plus'
{ipcRenderer} = require 'electron'
{Disposable} = require 'event-kit'
Utils = require './flux/models/utils'
@ -170,7 +170,7 @@ class MenuManager
sendToBrowserProcess: (template, keystrokesByCommand) ->
keystrokesByCommand = @filterMultipleKeystroke(keystrokesByCommand)
ipc.send 'update-application-menu', template, keystrokesByCommand
ipcRenderer.send 'update-application-menu', template, keystrokesByCommand
# Get an {Array} of {String} classes for the given element.
classesForElement: (element) ->

View file

@ -1,9 +1,8 @@
crypto = require 'crypto'
ipc = require 'ipc'
os = require 'os'
path = require 'path'
remote = require 'remote'
shell = require 'shell'
{ipcRenderer, remote, shell} = require 'electron'
_ = require 'underscore'
{deprecate} = require 'grim'
@ -194,10 +193,10 @@ class NylasEnvConstructor extends Model
# from needing this crap, which has to be updated every time a new
# application: command is added:
if event.binding.command.indexOf('application:') is 0 and event.binding.selector.indexOf("body") is 0
ipc.send('command', event.binding.command)
ipcRenderer.send('command', event.binding.command)
unless @inSpecMode()
@actionBridge = new ActionBridge(ipc)
@actionBridge = new ActionBridge(ipcRenderer)
@commands = new CommandRegistry
specMode = @inSpecMode()
@ -490,7 +489,7 @@ class NylasEnvConstructor extends Model
setPosition: (x, y) ->
x = ensureInteger(x, 0)
y = ensureInteger(y, 0)
ipc.send('call-window-method', 'setPosition', x, y)
ipcRenderer.send('call-window-method', 'setPosition', x, y)
# Extended: Get the current window
getCurrentWindow: ->
@ -498,32 +497,32 @@ class NylasEnvConstructor extends Model
# Extended: Move current window to the center of the screen.
center: ->
ipc.send('call-window-method', 'center')
ipcRenderer.send('call-window-method', 'center')
# Extended: Focus the current window.
focus: ->
ipc.send('call-window-method', 'focus')
ipcRenderer.send('call-window-method', 'focus')
window.focus()
# Extended: Show the current window.
show: ->
ipc.send('call-window-method', 'show')
ipcRenderer.send('call-window-method', 'show')
isVisible: ->
@getCurrentWindow().isVisible()
# Extended: Hide the current window.
hide: ->
ipc.send('call-window-method', 'hide')
ipcRenderer.send('call-window-method', 'hide')
# Extended: Reload the current window.
reload: ->
ipc.send('call-window-method', 'restart')
ipcRenderer.send('call-window-method', 'restart')
# Updates the window load settings - called when the app is ready to display
# a hot-loaded window. Causes listeners registered with `onWindowPropsReceived`
# to receive new window props.
loadSettingsChanged: (loadSettings) =>
loadSettingsChanged: (event, loadSettings) =>
@loadSettings = loadSettings
@constructor.loadSettings = loadSettings
{width, height, windowProps} = loadSettings
@ -553,10 +552,10 @@ class NylasEnvConstructor extends Model
@getCurrentWindow().isMaximized()
maximize: ->
ipc.send('call-window-method', 'maximize')
ipcRenderer.send('call-window-method', 'maximize')
minimize: ->
ipc.send('call-window-method', 'minimize')
ipcRenderer.send('call-window-method', 'minimize')
# Extended: Is the current window in full screen mode?
isFullScreen: ->
@ -564,7 +563,7 @@ class NylasEnvConstructor extends Model
# Extended: Set the full screen state of the current window.
setFullScreen: (fullScreen=false) ->
ipc.send('call-window-method', 'setFullScreen', fullScreen)
ipcRenderer.send('call-window-method', 'setFullScreen', fullScreen)
if fullScreen then document.body.classList.add("fullscreen") else document.body.classList.remove("fullscreen")
# Extended: Toggle the full screen state of the current window.
@ -658,7 +657,7 @@ class NylasEnvConstructor extends Model
@showRootWindow()
ipc.sendChannel('window-command', 'window:loaded')
ipcRenderer.send('window-command', 'window:loaded')
showRootWindow: ->
cover = document.getElementById("application-loading-cover")
@ -697,27 +696,27 @@ class NylasEnvConstructor extends Model
@packages.activate()
@keymaps.loadUserKeymap()
ipc.on("load-settings-changed", @loadSettingsChanged)
ipcRenderer.on("load-settings-changed", @loadSettingsChanged)
@setWindowDimensions({width, height}) if width and height
@menu.update()
ipc.sendChannel('window-command', 'window:loaded')
ipcRenderer.send('window-command', 'window:loaded')
# Requests that the backend browser bootup a new window with the given
# options.
# See the valid option types in Application::newWindow in
# src/browser/application.coffee
newWindow: (options={}) -> ipc.send('new-window', options)
newWindow: (options={}) -> ipcRenderer.send('new-window', options)
# Registers a hot window for certain packages
# See the valid option types in Application::registerHotWindow in
# src/browser/application.coffee
registerHotWindow: (options={}) -> ipc.send('register-hot-window', options)
registerHotWindow: (options={}) -> ipcRenderer.send('register-hot-window', options)
# Unregisters a hot window with the given windowType
unregisterHotWindow: (windowType) -> ipc.send('unregister-hot-window', windowType)
unregisterHotWindow: (windowType) -> ipcRenderer.send('unregister-hot-window', windowType)
saveStateAndUnloadWindow: ->
@packages.deactivatePackages()
@ -785,15 +784,15 @@ class NylasEnvConstructor extends Model
# Extended: Open the dev tools for the current window.
openDevTools: ->
ipc.send('call-window-method', 'openDevTools')
ipcRenderer.send('call-window-method', 'openDevTools')
# Extended: Toggle the visibility of the dev tools for the current window.
toggleDevTools: ->
ipc.send('call-window-method', 'toggleDevTools')
ipcRenderer.send('call-window-method', 'toggleDevTools')
# Extended: Execute code in dev tools.
executeJavaScriptInDevTools: (code) ->
ipc.send('call-window-method', 'executeJavaScriptInDevTools', code)
ipcRenderer.send('call-webcontents-method', 'executeJavaScriptInDevTools', code)
###
Section: Private
@ -837,11 +836,12 @@ class NylasEnvConstructor extends Model
showOpenDialog: (options, callback) ->
dialog = remote.require('dialog')
dialog.showOpenDialog(@getCurrentWindow(), options, callback)
callback(dialog.showOpenDialog(@getCurrentWindow(), options))
showSaveDialog: (defaultPath, callback) ->
showSaveDialog: (options, callback) ->
options.title ?= 'Save File'
dialog = remote.require('dialog')
dialog.showSaveDialog(@getCurrentWindow(), {title: 'Save File', defaultPath}, callback)
callback(dialog.showSaveDialog(@getCurrentWindow(), options))
showErrorDialog: (message) ->
dialog = remote.require('dialog')
@ -941,4 +941,3 @@ class NylasEnvConstructor extends Model
overriddenStop.apply(@, arguments)
Event::isPropagationStopped = ->
@propagationStopped

View file

@ -1,6 +1,6 @@
var _ = require('underscore')
var container = document.getElementById("container");
var ipc = require('ipc');
var ipc = require('electron').ipcRenderer;
var lastSelectionData = {}
document.body.classList.add("platform-"+process.platform);

View file

@ -1,4 +1,4 @@
var ipc = require("ipc");
var ipcRenderer = require("electron").ipcRenderer;
var React = require('react');
var _ = require('underscore');
var LinkedValueUtils = require('react/lib/LinkedValueUtils');
@ -117,7 +117,7 @@ setTimeout(function(){
observeMethod('ReactDOMSelect', 'componentDidMount', Custom.sendSelectCurrentValue);
}, 10);
ipc.on('from-react-remote-window', function(json) {
ipcRenderer.on('from-react-remote-window', function(event, json) {
var container = null;
for (var ii = 0; ii < invocationTargets.length; ii ++) {
if (invocationTargets[ii].windowId == json.windowId) {
@ -175,7 +175,7 @@ selectionChange = function() {
}
// document.addEventListener("selectionchange", selectionChange);
ipc.on('from-react-remote-window-selection', function(selectionData){
ipcRenderer.on('from-react-remote-window-selection', function(event, selectionData){
document.removeEventListener("selectionchange", selectionChange)
restoreSelection(selectionData)
document.addEventListener("selectionchange", selectionChange);
@ -248,7 +248,7 @@ var openWindowForComponent = function(Component, options) {
resizable: options.resizable,
show: false
});
thinWindow.loadUrl(thinWindowUrl);
thinWindow.loadURL(thinWindowUrl);
if (process.platform !== 'darwin') {
thinWindow.setMenu(null);
}

View file

@ -28,7 +28,8 @@ class WindowTitle extends React.Component
@unlisten = NylasEnv.onWindowPropsReceived (windowProps) =>
@setState NylasEnv.getLoadSettings()
componentWillUnmount: -> @unlisten()
componentWillUnmount: ->
@unlisten?()
render: ->
<div className="window-title">{@state.title}</div>

View file

@ -1,12 +1,12 @@
_ = require 'underscore'
ipc = require 'ipc'
{ipcRenderer} = require 'electron'
Utils = require './flux/models/utils'
class WindowBridge
constructor: ->
@_tasks = {}
ipc.on("remote-run-results", @_onResults)
ipc.on("run-in-window", @_onRunInWindow)
ipcRenderer.on("remote-run-results", @_onResults)
ipcRenderer.on("run-in-window", @_onRunInWindow)
runInWindow: (window, objectName, methodName, args) ->
taskId = Utils.generateTempId()
@ -14,7 +14,7 @@ class WindowBridge
@_tasks[taskId] = {resolve, reject}
args = Utils.serializeRegisteredObjects(args)
params = {window, objectName, methodName, args, taskId}
ipc.send("run-in-window", params)
ipcRenderer.send("run-in-window", params)
runInMainWindow: (args...) ->
@runInWindow("main", args...)
@ -22,22 +22,22 @@ class WindowBridge
runInWorkWindow: ->
@runInWindow("work", args...)
_onResults: ({returnValue, taskId}={}) =>
_onResults: (event, {returnValue, taskId}={}) =>
returnValue = Utils.deserializeRegisteredObjects(returnValue)
@_tasks[taskId].resolve(returnValue)
delete @_tasks[taskId]
_onRunInWindow: ({objectName, methodName, args, taskId}={}) =>
_onRunInWindow: (event, {objectName, methodName, args, taskId}={}) =>
args = Utils.deserializeRegisteredObjects(args)
exports = require 'nylas-exports'
result = exports[objectName][methodName].apply(null, args)
if _.isFunction(result.then)
result.then (returnValue) ->
returnValue = Utils.serializeRegisteredObjects(returnValue)
ipc.send('remote-run-results', {returnValue, taskId})
ipcRenderer.send('remote-run-results', {returnValue, taskId})
else
returnValue = result
returnValue = Utils.serializeRegisteredObjects(returnValue)
ipc.send('remote-run-results', {returnValue, taskId})
ipcRenderer.send('remote-run-results', {returnValue, taskId})
module.exports = new WindowBridge

View file

@ -2,8 +2,7 @@ path = require 'path'
{$} = require './space-pen-extensions'
_ = require 'underscore'
{Disposable} = require 'event-kit'
ipc = require 'ipc'
shell = require 'shell'
{shell, ipcRenderer} = require 'electron'
{Subscriber} = require 'emissary'
fs = require 'fs-plus'
url = require 'url'
@ -19,7 +18,7 @@ class WindowEventHandler
_.defer =>
@showDevModeMessages()
@subscribe ipc, 'open-path', (pathToOpen) ->
@subscribe ipcRenderer, 'open-path', (event, pathToOpen) ->
unless NylasEnv.project?.getPaths().length
if fs.existsSync(pathToOpen) or fs.existsSync(path.dirname(pathToOpen))
NylasEnv.project?.setPaths([pathToOpen])
@ -27,20 +26,20 @@ class WindowEventHandler
unless fs.isDirectorySync(pathToOpen)
NylasEnv.workspace?.open(pathToOpen, {})
@subscribe ipc, 'update-available', (detail) ->
@subscribe ipcRenderer, 'update-available', (event, detail) ->
NylasEnv.updateAvailable(detail)
@subscribe ipc, 'send-feedback', (detail) ->
@subscribe ipcRenderer, 'send-feedback', (detail) ->
Actions = require './flux/actions'
Actions.sendFeedback()
@subscribe ipc, 'browser-window-focus', ->
@subscribe ipcRenderer, 'browser-window-focus', ->
document.body.classList.remove('is-blurred')
@subscribe ipc, 'browser-window-blur', ->
@subscribe ipcRenderer, 'browser-window-blur', ->
document.body.classList.add('is-blurred')
@subscribe ipc, 'command', (command, args...) ->
@subscribe ipcRenderer, 'command', (event, command, args...) ->
activeElement = document.activeElement
# Use the workspace element view if body has focus
if activeElement is document.body and workspaceElement = document.getElementById("nylas-workspace")

View file

@ -1,6 +1,6 @@
path = require('path')
fs = require('fs-plus')
ipc = require('ipc')
ipc = require('electron').ipcRenderer
require('module').globalPaths.push(path.resolve('exports'))

View file

@ -44,7 +44,7 @@ function setupWindow (loadSettings) {
setupCsonCache(CompileCache.getCacheDirectory())
require(loadSettings.bootstrapScript)
require('ipc').sendChannel('window-command', 'window:loaded')
require('electron').ipcRenderer.send('window-command', 'window:loaded')
}
function setupCsonCache (cacheDir) {