-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
initialize-application-window.js
63 lines (53 loc) · 2.01 KB
/
initialize-application-window.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const AtomEnvironment = require('./atom-environment');
const ApplicationDelegate = require('./application-delegate');
const Clipboard = require('./clipboard');
const TextEditor = require('./text-editor');
require('./text-editor-component');
require('./file-system-blob-store');
require('./native-compile-cache');
require('./compile-cache');
require('./module-cache');
const clipboard = new Clipboard();
TextEditor.setClipboard(clipboard);
TextEditor.viewForItem = item => atom.views.getView(item);
global.atom = new AtomEnvironment({
clipboard,
applicationDelegate: new ApplicationDelegate(),
enablePersistence: true
});
TextEditor.setScheduler(global.atom.views);
global.atom.preloadPackages();
// Like sands through the hourglass, so are the days of our lives.
module.exports = function({ blobStore }) {
const { updateProcessEnv } = require('./update-process-env');
const path = require('path');
require('./window');
const getWindowLoadSettings = require('./get-window-load-settings');
const { ipcRenderer } = require('electron');
const { resourcePath, devMode } = getWindowLoadSettings();
require('./electron-shims');
// Add application-specific exports to module search path.
const exportsPath = path.join(resourcePath, 'exports');
require('module').globalPaths.push(exportsPath);
process.env.NODE_PATH = exportsPath;
// Make React faster
if (!devMode && process.env.NODE_ENV == null) {
process.env.NODE_ENV = 'production';
}
global.atom.initialize({
window,
document,
blobStore,
configDirPath: process.env.ATOM_HOME,
env: process.env
});
return global.atom.startEditorWindow().then(function() {
// Workaround for focus getting cleared upon window creation
const windowFocused = function() {
window.removeEventListener('focus', windowFocused);
setTimeout(() => document.querySelector('atom-workspace').focus(), 0);
};
window.addEventListener('focus', windowFocused);
ipcRenderer.on('environment', (event, env) => updateProcessEnv(env));
});
};