mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Pull out collaboration package into a separate repo
This commit is contained in:
@@ -70,6 +70,7 @@
|
||||
"autoflow": "0.1.0",
|
||||
"bookmarks": "0.1.0",
|
||||
"bracket-matcher": "0.1.0",
|
||||
"collaboration": "0.1.0",
|
||||
"command-logger": "0.1.0",
|
||||
"command-panel": "0.1.0",
|
||||
"command-palette": "0.1.0",
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
'body':
|
||||
'meta-C': 'collaboration:copy-session-id'
|
||||
'meta-H': 'collaboration:start-session'
|
||||
'meta-K': 'collaboration:join-session'
|
||||
@@ -1,27 +0,0 @@
|
||||
require 'atom'
|
||||
require 'window'
|
||||
$ = require 'jquery'
|
||||
{$$} = require 'space-pen'
|
||||
{createPeer, connectDocument} = require './session-utils'
|
||||
{createSite, Document} = require 'telepath'
|
||||
|
||||
window.setDimensions(width: 350, height: 100)
|
||||
window.setUpEnvironment('editor')
|
||||
{sessionId} = atom.getLoadSettings()
|
||||
|
||||
loadingView = $$ ->
|
||||
@div style: 'margin: 10px; text-align: center', =>
|
||||
@div "Joining session #{sessionId}"
|
||||
$(window.rootViewParentSelector).append(loadingView)
|
||||
atom.show()
|
||||
|
||||
peer = createPeer()
|
||||
connection = peer.connect(sessionId, reliable: true)
|
||||
connection.on 'open', ->
|
||||
console.log 'connection opened'
|
||||
connection.once 'data', (data) ->
|
||||
loadingView.remove()
|
||||
console.log 'received document'
|
||||
atom.windowState = Document.deserialize(createSite(peer.id), data)
|
||||
connectDocument(atom.windowState, connection)
|
||||
window.startEditorWindow()
|
||||
@@ -1,32 +0,0 @@
|
||||
JoinPromptView = require './join-prompt-view'
|
||||
{createSite, Document} = require 'telepath'
|
||||
{createPeer, connectDocument} = require './session-utils'
|
||||
|
||||
startSession = ->
|
||||
peer = createPeer()
|
||||
peer.on 'connection', (connection) ->
|
||||
connection.on 'open', ->
|
||||
console.log 'sending document'
|
||||
windowState = atom.getWindowState()
|
||||
connection.send(windowState.serialize())
|
||||
connectDocument(windowState, connection)
|
||||
peer.id
|
||||
|
||||
module.exports =
|
||||
activate: ->
|
||||
sessionId = null
|
||||
|
||||
rootView.command 'collaboration:copy-session-id', ->
|
||||
pasteboard.write(sessionId) if sessionId
|
||||
|
||||
rootView.command 'collaboration:start-session', ->
|
||||
if sessionId = startSession()
|
||||
pasteboard.write(sessionId)
|
||||
|
||||
rootView.command 'collaboration:join-session', ->
|
||||
new JoinPromptView (id) ->
|
||||
windowSettings =
|
||||
bootstrapScript: require.resolve('collaboration/lib/bootstrap')
|
||||
resourcePath: window.resourcePath
|
||||
sessionId: id
|
||||
atom.openWindow(windowSettings)
|
||||
@@ -1,39 +0,0 @@
|
||||
{View} = require 'space-pen'
|
||||
Editor = require 'editor'
|
||||
$ = require 'jquery'
|
||||
Point = require 'point'
|
||||
_ = require 'underscore'
|
||||
Guid = require 'guid'
|
||||
|
||||
module.exports =
|
||||
class JoinPromptView extends View
|
||||
@activate: -> new Prompt
|
||||
|
||||
@content: ->
|
||||
@div class: 'overlay from-top', =>
|
||||
@subview 'miniEditor', new Editor(mini: true)
|
||||
@div class: 'message', outlet: 'message', 'Enter a session id to join'
|
||||
|
||||
initialize: (@confirmed) ->
|
||||
@miniEditor.on 'focusout', => @remove()
|
||||
@on 'core:confirm', => @confirm()
|
||||
@on 'core:cancel', => @remove()
|
||||
|
||||
clipboard = pasteboard.read()[0]
|
||||
if Guid.isGuid(clipboard)
|
||||
@miniEditor.setText(clipboard)
|
||||
|
||||
@attach()
|
||||
|
||||
beforeRemove: ->
|
||||
@previouslyFocusedElement?.focus()
|
||||
@miniEditor.setText('')
|
||||
|
||||
confirm: ->
|
||||
@confirmed(@miniEditor.getText())
|
||||
@remove()
|
||||
|
||||
attach: ->
|
||||
@previouslyFocusedElement = $(':focus')
|
||||
rootView.append(this)
|
||||
@miniEditor.focus()
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,45 +0,0 @@
|
||||
Peer = require './peer'
|
||||
Guid = require 'guid'
|
||||
|
||||
module.exports =
|
||||
createPeer: ->
|
||||
id = Guid.create().toString()
|
||||
new Peer(id, host: 'ec2-54-218-51-127.us-west-2.compute.amazonaws.com', port: 8080)
|
||||
|
||||
connectDocument: (doc, connection) ->
|
||||
nextOutputEventId = 1
|
||||
outputListener = (event) ->
|
||||
event.id = nextOutputEventId++
|
||||
console.log 'sending event', event.id, event
|
||||
connection.send(event)
|
||||
doc.outputEvents.on('changed', outputListener)
|
||||
|
||||
queuedEvents = []
|
||||
nextInputEventId = 1
|
||||
handleInputEvent = (event) ->
|
||||
console.log 'received event', event.id, event
|
||||
doc.handleInputEvent(event)
|
||||
nextInputEventId = event.id + 1
|
||||
flushQueuedEvents = ->
|
||||
loop
|
||||
eventHandled = false
|
||||
for event, index in queuedEvents when event.id is nextInputEventId
|
||||
handleInputEvent(event)
|
||||
queuedEvents.splice(index, 1)
|
||||
eventHandled = true
|
||||
break
|
||||
break unless eventHandled
|
||||
|
||||
connection.on 'data', (event) ->
|
||||
if event.id is nextInputEventId
|
||||
handleInputEvent(event)
|
||||
flushQueuedEvents()
|
||||
else
|
||||
console.log 'enqueing event', event.id, event
|
||||
queuedEvents.push(event)
|
||||
|
||||
connection.on 'close', ->
|
||||
doc.outputEvents.removeListener('changed', outputListener)
|
||||
|
||||
connection.on 'error', (error) ->
|
||||
console.error 'connection error', error.stack ? error
|
||||
@@ -1 +0,0 @@
|
||||
'main': './lib/collaboration'
|
||||
Reference in New Issue
Block a user