mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
Start moving AtomEnvironment instantiation bits inside the snapshot
This commit is contained in:
@@ -131,15 +131,22 @@ class AtomEnvironment extends Model
|
||||
|
||||
# Call .loadOrCreate instead
|
||||
constructor: (params={}) ->
|
||||
{@applicationDelegate, @window, @document, @blobStore, @clipboard, @configDirPath, @enablePersistence, onlyLoadBaseStyleSheets} = params
|
||||
{@applicationDelegate, @clipboard, @enablePersistence, onlyLoadBaseStyleSheets} = params
|
||||
|
||||
@nextProxyRequestId = 0
|
||||
@unloaded = false
|
||||
@loadTime = null
|
||||
{devMode, safeMode, resourcePath, clearWindowState} = @getLoadSettings()
|
||||
|
||||
@emitter = new Emitter
|
||||
@disposables = new CompositeDisposable
|
||||
@deserializers = new DeserializerManager(this)
|
||||
@deserializeTimings = {}
|
||||
@views = new ViewRegistry(this)
|
||||
@notifications = new NotificationManager
|
||||
@config = new Config({notificationManager: @notifications, @enablePersistence})
|
||||
|
||||
initialize: (params={}) ->
|
||||
{@applicationDelegate, @window, @document, @blobStore, @clipboard, @configDirPath, @enablePersistence, onlyLoadBaseStyleSheets} = params
|
||||
{devMode, safeMode, resourcePath, clearWindowState} = @getLoadSettings()
|
||||
|
||||
@stateStore = new StateStore('AtomEnvironments', 1)
|
||||
|
||||
@@ -147,14 +154,9 @@ class AtomEnvironment extends Model
|
||||
@getStorageFolder().clear()
|
||||
@stateStore.clear()
|
||||
|
||||
@deserializers = new DeserializerManager(this)
|
||||
@deserializeTimings = {}
|
||||
@views.initialize()
|
||||
|
||||
@views = new ViewRegistry(this)
|
||||
|
||||
@notifications = new NotificationManager
|
||||
|
||||
@config = new Config({@configDirPath, resourcePath, notificationManager: @notifications, @enablePersistence})
|
||||
@config.initialize({@configDirPath, resourcePath})
|
||||
@setConfigSchema()
|
||||
|
||||
@keymaps = new KeymapManager({@configDirPath, resourcePath, notificationManager: @notifications})
|
||||
|
||||
@@ -398,11 +398,13 @@ class Config
|
||||
value
|
||||
|
||||
# Created during initialization, available as `atom.config`
|
||||
constructor: ({@configDirPath, @resourcePath, @notificationManager, @enablePersistence}={}) ->
|
||||
constructor: ({@notificationManager, @enablePersistence}={}) ->
|
||||
@clear()
|
||||
|
||||
initialize: ({@configDirPath, @resourcePath}) ->
|
||||
if @enablePersistence?
|
||||
@configFilePath = fs.resolve(@configDirPath, 'config', ['json', 'cson'])
|
||||
@configFilePath ?= path.join(@configDirPath, 'config.cson')
|
||||
@clear()
|
||||
|
||||
clear: ->
|
||||
@emitter = new Emitter
|
||||
|
||||
@@ -55,6 +55,15 @@ require('welcome')
|
||||
require('whitespace')
|
||||
require('wrap-guide')
|
||||
|
||||
clipboard = new Clipboard
|
||||
TextEditor.setClipboard(clipboard)
|
||||
|
||||
window.atom = new AtomEnvironment({
|
||||
clipboard,
|
||||
applicationDelegate: new ApplicationDelegate,
|
||||
enablePersistence: true
|
||||
})
|
||||
|
||||
# Like sands through the hourglass, so are the days of our lives.
|
||||
module.exports = ({blobStore}) ->
|
||||
{updateProcessEnv} = require('./update-process-env')
|
||||
@@ -73,14 +82,9 @@ module.exports = ({blobStore}) ->
|
||||
# Make React faster
|
||||
process.env.NODE_ENV ?= 'production' unless devMode
|
||||
|
||||
clipboard = new Clipboard
|
||||
TextEditor.setClipboard(clipboard)
|
||||
|
||||
window.atom = new AtomEnvironment({
|
||||
window, document, clipboard, blobStore,
|
||||
applicationDelegate: new ApplicationDelegate,
|
||||
window.atom.initialize({
|
||||
window, document, blobStore,
|
||||
configDirPath: process.env.ATOM_HOME,
|
||||
enablePersistence: true,
|
||||
env: process.env
|
||||
})
|
||||
|
||||
|
||||
@@ -54,9 +54,12 @@ class ViewRegistry
|
||||
minimumPollInterval: 200
|
||||
|
||||
constructor: (@atomEnvironment) ->
|
||||
@observer = new MutationObserver(@requestDocumentPoll)
|
||||
@polling = false
|
||||
@clear()
|
||||
|
||||
initialize: ->
|
||||
@observer = new MutationObserver(@requestDocumentPoll)
|
||||
|
||||
clear: ->
|
||||
@views = new WeakMap
|
||||
@providers = []
|
||||
@@ -267,10 +270,13 @@ class ViewRegistry
|
||||
startPollingDocument: ->
|
||||
window.addEventListener('resize', @requestDocumentPoll)
|
||||
@observer.observe(document, {subtree: true, childList: true, attributes: true})
|
||||
@polling = true
|
||||
|
||||
stopPollingDocument: ->
|
||||
window.removeEventListener('resize', @requestDocumentPoll)
|
||||
@observer.disconnect()
|
||||
if @polling
|
||||
window.removeEventListener('resize', @requestDocumentPoll)
|
||||
@observer.disconnect()
|
||||
@polling = false
|
||||
|
||||
requestDocumentPoll: =>
|
||||
if @animationFrameRequest?
|
||||
|
||||
Reference in New Issue
Block a user