Add site global used to create all telepath documents

This commit is contained in:
Kevin Sawicki & Nathan Sobo 2013-07-22 19:58:27 -07:00
parent 0370eb9236
commit 501a6b7d11
14 changed files with 18 additions and 18 deletions

View File

@ -275,8 +275,7 @@ window.atom =
console.warn "Error parsing window state: #{windowStatePath}", error.stack, error
windowState ?= {}
site = telepath.createSite(1)
telepath.Document.deserialize(windowState, {site}) ? telepath.Document.create({}, {site})
site.deserializeDocument(windowState) ? site.createDocument({})
saveWindowState: ->
windowStateJson = JSON.stringify(@getWindowState().serialize())

View File

@ -36,7 +36,7 @@ class DisplayBuffer
{@buffer, softWrapColumn} = optionsOrState
@id = guid.create().toString()
@tokenizedBuffer = new TokenizedBuffer(optionsOrState)
@state = telepath.create
@state = site.createDocument
deserializer: @constructor.name
id: @id
tokenizedBuffer: @tokenizedBuffer.getState()

View File

@ -52,7 +52,7 @@ class EditSession
{buffer, displayBuffer, tabLength, softTabs, softWrap, suppressCursorCreation} = optionsOrState
@id = guid.create().toString()
displayBuffer ?= new DisplayBuffer({buffer, tabLength})
@state = telepath.Document.create
@state = site.createDocument
deserializer: 'EditSession'
version: @constructor.version
id: @id

View File

@ -15,7 +15,7 @@ class PaneAxis extends View
@state = args[0]
@state.get('children').each (child, index) => @addChild(deserialize(child), index, updateState: false)
else
@state = telepath.create(deserializer: @className(), children: [])
@state = site.createDocument(deserializer: @className(), children: [])
@addChild(child) for child in args
@state.get('children').on 'changed', ({index, inserted, removed, site}) =>

View File

@ -23,7 +23,7 @@ class PaneContainer extends View
@state = state
@setRoot(deserialize(@state.get('root')))
else
@state = telepath.create(deserializer: 'PaneContainer')
@state = site.createDocument(deserializer: 'PaneContainer')
@state.on 'changed', ({key, newValue, site}) =>
return if site is @state.site.id

View File

@ -32,7 +32,7 @@ class Pane extends View
@items = _.compact(@state.get('items').map (item) -> deserialize(item))
else
@items = args
@state = telepath.Document.create
@state = site.createDocument
deserializer: 'Pane'
items: @items.map (item) -> item.getState?() ? item.serialize()

View File

@ -69,7 +69,7 @@ class Project
if buffer = deserialize(bufferState, project: this)
@addBuffer(buffer, updateState: false)
else
@state = telepath.Document.create(deserializer: @constructor.name, version: @constructor.version, buffers: [])
@state = site.createDocument(deserializer: @constructor.name, version: @constructor.version, buffers: [])
@setPath(pathOrState)
@state.get('buffers').on 'changed', ({inserted, removed, index, site}) =>

View File

@ -45,7 +45,7 @@ class RootView extends View
panes = deserialize(state.get('panes'))
else
panes = new PaneContainer
@state = telepath.create
@state = site.createDocument
deserializer: @constructor.name
version: @constructor.version
panes: panes.getState()

View File

@ -43,9 +43,9 @@ class TextBuffer
@id = @state.get('id')
else
{@project, filePath, initialText} = optionsOrState
@text = telepath.Document.create(initialText, shareStrings: true) if initialText
@text = site.createDocument(initialText, shareStrings: true) if initialText
@id = guid.create().toString()
@state = telepath.Document.create
@state = site.createDocument
id: @id
deserializer: @constructor.name
version: @constructor.version
@ -55,10 +55,10 @@ class TextBuffer
if @text
@updateCachedDiskContents()
else
@text = telepath.Document.create('', shareStrings: true)
@text = site.createDocument('', shareStrings: true)
@reload() if fsUtils.exists(filePath)
else
@text ?= telepath.Document.create('', shareStrings: true)
@text ?= site.createDocument('', shareStrings: true)
@state.set('text', @text)
@text.on 'changed', @handleTextChange

View File

@ -31,7 +31,7 @@ class TokenizedBuffer
@buffer = project.bufferForId(optionsOrState.get('bufferId'))
else
{ @buffer, tabLength } = optionsOrState
@state = telepath.create
@state = site.createDocument
deserializer: @constructor.name
bufferId: @buffer.id
tabLength: tabLength ? 2

View File

@ -20,6 +20,7 @@ windowEventHandler = null
# This method is called in any window needing a general environment, including specs
window.setUpEnvironment = (windowMode) ->
window.site = new telepath.Site(1)
atom.windowMode = windowMode
window.resourcePath = remote.getCurrentWindow().loadSettings.resourcePath

View File

@ -31,8 +31,8 @@ class GuestSession
@createTelepathDocument(data, connection)
createTelepathDocument: (data, connection) ->
doc = telepath.Document.deserialize(data.doc, site: telepath.createSite(@getId()))
window.site = new telepath.Site(@getId())
doc = window.site.deserializeDocument(data.doc)
servers = null
mediaConnection = new webkitRTCPeerConnection(servers)

View File

@ -35,7 +35,7 @@ class HostSession
navigator.webkitGetUserMedia constraints, success, console.error
@peer = createPeer()
@doc = telepath.Document.create({}, site: telepath.createSite(@getId()))
@doc = site.createDocument({})
@doc.set('windowState', atom.windowState)
patrick.snapshot project.getPath(), (error, repoSnapshot) =>
if error?

2
vendor/telepath vendored

@ -1 +1 @@
Subproject commit c1b07c50444a3e5f617ae45699b2140db74b3537
Subproject commit 8ce1bbfaa3a65650dad5e750bd465b9f96a2f43e