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

y-websocket

Package Overview
Dependencies
Maintainers
1
Versions
59
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

y-websocket - npm Package Compare versions

Comparing version 0.0.0 to 1.0.0-0

bin/server.js

73

dist/y-websocket.js

@@ -42,9 +42,9 @@ 'use strict';

encoding.writeVarUint(encoder, messageSync);
syncProtocol.readSyncMessage(decoder, encoder, doc, doc.ws);
break
case messageAwareness:
doc.mux(() =>
syncProtocol.readSyncMessage(decoder, encoder, doc)
awarenessProtocol.readAwarenessMessage(decoder, doc)
);
break
case messageAwareness:
awarenessProtocol.readAwarenessMessage(decoder, doc);
break
case messageAuth:

@@ -88,3 +88,5 @@ authProtocol.readAuthMessage(decoder, doc, permissionDeniedHandler);

}]);
setTimeout(setupWS, reconnectTimeout, doc, url);
if (doc.shouldReconnect) {
setTimeout(setupWS, reconnectTimeout, doc, url);
}
};

@@ -111,17 +113,15 @@ websocket.onopen = () => {

const broadcastUpdate = (transaction, y) => {
if (transaction.updateMessage !== null) {
y.mux(() => {
const updateMessage = transaction.updateMessage;
if (updateMessage !== null) {
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, messageSync);
syncProtocol.writeUpdate(encoder, updateMessage);
const buf = encoding.toBuffer(encoder);
if (y.wsconnected) {
// @ts-ignore We know that wsconnected = true
y.ws.send(buf);
}
bc.publish(y.url, buf);
if (transaction.origin !== y.ws && transaction.updateMessage !== null) {
const updateMessage = transaction.updateMessage;
if (updateMessage !== null) {
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, messageSync);
syncProtocol.writeUpdate(encoder, updateMessage);
const buf = encoding.toBuffer(encoder);
if (y.wsconnected) {
// @ts-ignore We know that wsconnected = true
y.ws.send(buf);
}
});
bc.publish(y.url, buf);
}
}

@@ -150,4 +150,3 @@ };

this.ws = null;
setupWS(this, url);
this.on('afterTransaction', broadcastUpdate);
this.shouldReconnect = true;
/**

@@ -164,11 +163,27 @@ * @param {ArrayBuffer} data

};
bc.subscribe(url, this._bcSubscriber);
// send sync step1 to bc
this.mux(() => {
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, messageSync);
syncProtocol.writeSyncStep1(encoder, this.store);
bc.publish(url, encoding.toBuffer(encoder));
});
this.connect();
}
disconnect () {
this.shouldReconnect = false;
if (this.ws !== null) {
this.ws.close();
bc.unsubscribe(this.url, this._bcSubscriber);
this.off('afterTransaction', broadcastUpdate);
}
}
connect () {
this.shouldReconnect = true;
if (!this.wsconnected && this.ws === null) {
setupWS(this, this.url);
bc.subscribe(this.url, this._bcSubscriber);
// send sync step1 to bc
this.mux(() => {
const encoder = encoding.createEncoder();
encoding.writeVarUint(encoder, messageSync);
syncProtocol.writeSyncStep1(encoder, this.store);
bc.publish(this.url, encoding.toBuffer(encoder));
});
this.on('afterTransaction', broadcastUpdate);
}
}
getLocalAwarenessInfo () {

@@ -175,0 +190,0 @@ return this._localAwarenessState

{
"name": "y-websocket",
"version": "0.0.0",
"version": "1.0.0-0",
"description": "Websockets provider for Yjs",

@@ -20,3 +20,4 @@ "main": "./dist/y-websocket.js",

"files": [
"dist/*"
"dist/*",
"bin/*"
],

@@ -23,0 +24,0 @@ "repository": {

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