y-websocket
Advanced tools
Comparing version 1.3.11 to 1.3.12
{ | ||
"name": "y-websocket", | ||
"version": "1.3.11", | ||
"version": "1.3.12", | ||
"description": "Websockets provider for Yjs", | ||
@@ -50,3 +50,3 @@ "main": "./dist/y-websocket.cjs", | ||
"lodash.debounce": "^4.0.8", | ||
"y-protocols": "^1.0.3" | ||
"y-protocols": "^1.0.4" | ||
}, | ||
@@ -57,7 +57,7 @@ "devDependencies": { | ||
"standard": "^12.0.1", | ||
"typescript": "^3.9.7", | ||
"yjs": "^13.4.14" | ||
"typescript": "^3.9.9", | ||
"yjs": "^13.5.0" | ||
}, | ||
"peerDependenies": { | ||
"yjs": "^13.0.0" | ||
"peerDependencies": { | ||
"yjs": "^13.5.0" | ||
}, | ||
@@ -64,0 +64,0 @@ "optionalDependencies": { |
@@ -14,2 +14,18 @@ | ||
### Install dependencies | ||
```sh | ||
npm i y-websocket | ||
``` | ||
### Start a y-websocket server | ||
This repository implements a basic server that you can adopt to your specific use-case. [(source code)](./bin/) | ||
Start a y-websocket server: | ||
```sh | ||
HOST=localhost PORT=1234 npx y-websocket-server | ||
``` | ||
### Client Code: | ||
@@ -73,3 +89,3 @@ | ||
<b><code>wsProvider.synced: boolean</code></b> | ||
<dd>True if this instance is currently connected and synced with the server./dd> | ||
<dd>True if this instance is currently connected and synced with the server.</dd> | ||
<b><code>wsProvider.disconnect()</code></b> | ||
@@ -76,0 +92,0 @@ <dd>Disconnect from the server and don't try to reconnect.</dd> |
@@ -159,4 +159,3 @@ /* | ||
if (provider.wsconnected) { | ||
// @ts-ignore We know that wsconnected = true | ||
provider.ws.send(buf) | ||
/** @type {WebSocket} */ (provider.ws).send(buf) | ||
} | ||
@@ -262,3 +261,3 @@ if (provider.bcconnected) { | ||
this._updateHandler = (update, origin) => { | ||
if (origin !== this || origin === null) { | ||
if (origin !== this) { | ||
const encoder = encoding.createEncoder() | ||
@@ -282,5 +281,7 @@ encoding.writeVarUint(encoder, messageSync) | ||
} | ||
window.addEventListener('beforeunload', () => { | ||
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload') | ||
}) | ||
if (typeof window !== 'undefined') { | ||
window.addEventListener('beforeunload', () => { | ||
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload') | ||
}) | ||
} | ||
awareness.on('update', this._awarenessUpdateHandler) | ||
@@ -287,0 +288,0 @@ this._checkInterval = /** @type {any} */ (setInterval(() => { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
76664
1166
139
6
Updatedy-protocols@^1.0.4