Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@atom/teletype-client

Package Overview
Dependencies
Maintainers
15
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@atom/teletype-client - npm Package Compare versions

Comparing version 0.36.1 to 0.37.0

57

lib/buffer-proxy.js

@@ -74,6 +74,12 @@ const assert = require('assert')

const operations = this.document.setTextInRange(oldStart, oldEnd, newText)
this.broadcastUpdate(operations)
this.broadcastOperations(operations)
this.emitter.emit('did-update-text', {remote: false})
}
setURI (uri) {
assert(this.isHost, 'Only hosts can change the URI')
this.uri = uri
this.broadcastURIChange(uri)
}
getMarkers () {

@@ -83,5 +89,5 @@ return this.document.getMarkers()

updateMarkers (markerUpdatesByLayerId, broadcastUpdate = true) {
updateMarkers (markerUpdatesByLayerId, broadcastOperations = true) {
const operations = this.document.updateMarkers(markerUpdatesByLayerId)
if (broadcastUpdate) this.broadcastUpdate(operations)
if (broadcastOperations) this.broadcastOperations(operations)
return operations

@@ -102,3 +108,3 @@ }

const {operations, textUpdates, markers} = undoEntry
this.broadcastUpdate(operations)
this.broadcastOperations(operations)
if (textUpdates.length > 0) {

@@ -117,3 +123,3 @@ this.emitter.emit('did-update-text', {remote: false})

const {operations, textUpdates, markers} = redoEntry
this.broadcastUpdate(operations)
this.broadcastOperations(operations)
if (textUpdates.length > 0) {

@@ -148,3 +154,3 @@ this.emitter.emit('did-update-text', {remote: false})

const {operations, textUpdates, markers} = result
this.broadcastUpdate(operations)
this.broadcastOperations(operations)
if (textUpdates.length > 0) {

@@ -178,6 +184,21 @@ this.emitter.emit('did-update-text', {remote: false})

const updateMessage = Messages.BufferProxyUpdate.deserializeBinary(body)
const operations = updateMessage.getOperationsList().map(deserializeOperation)
if (updateMessage.hasOperationsUpdate()) {
this.receiveOperationsUpdate(updateMessage.getOperationsUpdate())
} else if (updateMessage.hasUriUpdate()) {
this.receiveURIUpdate(updateMessage.getUriUpdate())
} else {
throw new Error('Received unknown update message')
}
}
receiveOperationsUpdate (operationsUpdateMessage) {
const operations = operationsUpdateMessage.getOperationsList().map(deserializeOperation)
this.integrateOperations(operations)
}
receiveURIUpdate (uriUpdateMessage) {
this.uri = uriUpdateMessage.getUri()
this.delegate.didChangeURI(this.uri)
}
receiveSave () {

@@ -187,6 +208,9 @@ this.delegate.save()

broadcastUpdate (operations) {
broadcastOperations (operations) {
const operationsUpdateMessage = new Messages.BufferProxyUpdate.OperationsUpdate()
operationsUpdateMessage.setOperationsList(operations.map(serializeOperation))
const updateMessage = new Messages.BufferProxyUpdate()
updateMessage.setOperationsList(operations.map(serializeOperation))
this.router.notify({channelId: `/buffers/${this.id}`, body: updateMessage.serializeBinary()})
updateMessage.setOperationsUpdate(operationsUpdateMessage)
this.broadcastUpdate(updateMessage)
}

@@ -202,2 +226,15 @@

}
broadcastURIChange (uri) {
const uriUpdateMessage = new Messages.BufferProxyUpdate.URIUpdate()
uriUpdateMessage.setUri(uri)
const updateMessage = new Messages.BufferProxyUpdate()
updateMessage.setUriUpdate(uriUpdateMessage)
this.broadcastUpdate(updateMessage)
}
broadcastUpdate (updateMessage) {
this.router.notify({channelId: `/buffers/${this.id}`, body: updateMessage.serializeBinary()})
}
}

@@ -23,2 +23,5 @@ const Messages = require('./teletype-client_pb')

this.subscriptions.add(
router.onNotification(`/buffers/${id}`, this.receiveBufferUpdate.bind(this))
)
this.subscriptions.add(
router.onNotification(`/editors/${id}/disposal`, this.dispose.bind(this))

@@ -41,2 +44,9 @@ )

}
receiveBufferUpdate ({body}) {
const updateMessage = Messages.BufferProxyUpdate.deserializeBinary(body)
if (updateMessage.hasUriUpdate()) {
this.bufferProxyURI = updateMessage.getUriUpdate().getUri()
}
}
}

@@ -302,2 +302,11 @@ const assert = require('assert')

getEditorProxyMetadata (editorProxyId) {
const editorProxy = this.editorProxiesById.get(editorProxyId)
if (editorProxy) {
return editorProxy.getMetadata()
} else {
return this.editorProxiesMetadataById.get(editorProxyId)
}
}
getActiveSiteIds () {

@@ -304,0 +313,0 @@ return this.network.getMemberIds().map((id) => this.siteIdsByPeerId.get(id))

2

lib/teletype-client.js

@@ -12,3 +12,3 @@ const os = require('os')

const DEFAULT_TETHER_DISCONNECT_WINDOW = 1000
const LOCAL_PROTOCOL_VERSION = 8
const LOCAL_PROTOCOL_VERSION = 9

@@ -15,0 +15,0 @@ module.exports =

{
"name": "@atom/teletype-client",
"version": "0.36.1",
"version": "0.37.0",
"description": "",

@@ -15,3 +15,3 @@ "main": "index.js",

"event-kit": "^2.3.0",
"google-protobuf": "^3.4.0",
"google-protobuf": "^3.5.0",
"pusher-js": "^4.1.0",

@@ -18,0 +18,0 @@ "uuid": "^3.1.0",

@@ -9,2 +9,3 @@ const assert = require('assert')

this.saveRequestCount = 0
this.uriChangeCount = 0
}

@@ -57,2 +58,6 @@

didChangeURI () {
this.uriChangeCount++
}
save () {

@@ -59,0 +64,0 @@ this.saveRequestCount++

@@ -912,2 +912,28 @@ require('./setup')

test('changing buffer proxy uri', async () => {
const host = await buildClient()
const hostPortal = await host.createPortal()
const guest = await buildClient()
const guestPortal = await guest.joinPortal(hostPortal.id)
const hostBuffer1Proxy = await hostPortal.createBufferProxy({uri: 'buffer1-a', text: ''})
const hostEditor1Proxy = await hostPortal.createEditorProxy({bufferProxy: hostBuffer1Proxy, selections: {}})
const hostBuffer2Proxy = await hostPortal.createBufferProxy({uri: 'buffer2-a', text: ''})
const hostEditor2Proxy = await hostPortal.createEditorProxy({bufferProxy: hostBuffer2Proxy, selections: {}})
const guestEditor1Proxy = await guestPortal.findOrFetchEditorProxy(hostEditor1Proxy.id)
const guestBuffer1Proxy = guestEditor1Proxy.bufferProxy
guestBuffer1Proxy.setDelegate(new FakeBufferDelegate())
assert.equal(guestBuffer1Proxy.uri, 'buffer1-a')
assert.equal(guestPortal.getEditorProxyMetadata(hostEditor1Proxy.id).bufferProxyURI, 'buffer1-a')
assert.equal(guestPortal.getEditorProxyMetadata(hostEditor2Proxy.id).bufferProxyURI, 'buffer2-a')
hostBuffer1Proxy.setURI('buffer1-b')
hostBuffer2Proxy.setURI('buffer2-b')
await condition(() => guestBuffer1Proxy.delegate.uriChangeCount === 1)
assert.equal(guestBuffer1Proxy.uri, 'buffer1-b')
assert.equal(guestPortal.getEditorProxyMetadata(hostEditor1Proxy.id).bufferProxyURI, 'buffer1-b')
assert.equal(guestPortal.getEditorProxyMetadata(hostEditor2Proxy.id).bufferProxyURI, 'buffer2-b')
})
test('save requests', async () => {

@@ -914,0 +940,0 @@ const host = await buildClient()

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc