update modules and lint
This commit is contained in:
parent
08d164dc26
commit
ea176e2b6a
6 changed files with 860 additions and 520 deletions
|
@ -1,9 +1,9 @@
|
|||
# WebRTC Connector for [Yjs](https://github.com/yjs/yjs)
|
||||
# WebRTC connector for [Yjs](https://github.com/yjs/yjs)
|
||||
|
||||
It propagates document updates directly to all users via WebRTC.
|
||||
Propagates document updates peer-to-peer to all users using WebRTC.
|
||||
|
||||
* Fast message propagation
|
||||
* Encryption and authorization over untrusted signaling server
|
||||
* Encryption and authorization over untrusted signaling servers
|
||||
* No setup required, public signaling servers are available
|
||||
* Very little server load
|
||||
* Not suited for a large amount of collaborators on a single document (each peer is connected to each other)
|
||||
|
@ -89,7 +89,7 @@ The following default values of `opts` can be overwritten:
|
|||
}
|
||||
```
|
||||
|
||||
### Logging
|
||||
## Logging
|
||||
|
||||
`y-webrtc` uses the `lib0/logging.js` logging library. By default this library disables logging. You can enable it by specifying the `log` environment / localStorage variable:
|
||||
|
||||
|
|
1340
package-lock.json
generated
1340
package-lock.json
generated
File diff suppressed because it is too large
Load diff
16
package.json
16
package.json
|
@ -44,22 +44,22 @@
|
|||
]
|
||||
},
|
||||
"dependencies": {
|
||||
"lib0": "^0.2.20",
|
||||
"lib0": "^0.2.24",
|
||||
"simple-peer": "^9.6.2",
|
||||
"y-protocols": "^0.2.1"
|
||||
"y-protocols": "^0.2.3"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@rollup/plugin-commonjs": "^11.0.1",
|
||||
"@rollup/plugin-node-resolve": "^7.0.0",
|
||||
"@rollup/plugin-commonjs": "^11.0.2",
|
||||
"@rollup/plugin-node-resolve": "^7.1.1",
|
||||
"@types/simple-peer": "^9.6.0",
|
||||
"concurrently": "^5.1.0",
|
||||
"http-server": "^0.12.1",
|
||||
"rollup": "^1.30.1",
|
||||
"rollup": "^1.32.1",
|
||||
"rollup-cli": "^1.0.9",
|
||||
"rollup-plugin-terser": "^5.2.0",
|
||||
"standard": "^12.0.1",
|
||||
"rollup-plugin-terser": "^5.3.0",
|
||||
"standard": "^14.3.3",
|
||||
"typescript": "^3.8.3",
|
||||
"yjs": "^13.0.4"
|
||||
"yjs": "^13.0.5"
|
||||
},
|
||||
"peerDependenies": {
|
||||
"yjs": "^13.0.0"
|
||||
|
|
|
@ -34,7 +34,7 @@ export const deriveKey = (secret, roomName) => {
|
|||
length: 256
|
||||
},
|
||||
true,
|
||||
[ 'encrypt', 'decrypt' ]
|
||||
['encrypt', 'decrypt']
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -71,7 +71,7 @@ const readMessage = (room, buf, syncedCallback) => {
|
|||
const doc = room.doc
|
||||
let sendReply = false
|
||||
switch (messageType) {
|
||||
case messageSync:
|
||||
case messageSync: {
|
||||
encoding.writeVarUint(encoder, messageSync)
|
||||
const syncMessageType = syncProtocol.readSyncMessage(decoder, encoder, doc, room)
|
||||
if (syncMessageType === syncProtocol.messageYjsSyncStep2 && !room.synced) {
|
||||
|
@ -81,6 +81,7 @@ const readMessage = (room, buf, syncedCallback) => {
|
|||
sendReply = true
|
||||
}
|
||||
break
|
||||
}
|
||||
case messageQueryAwareness:
|
||||
encoding.writeVarUint(encoder, messageAwareness)
|
||||
encoding.writeVarUint8Array(encoder, awarenessProtocol.encodeAwarenessUpdate(awareness, Array.from(awareness.getStates().keys())))
|
||||
|
@ -229,6 +230,7 @@ export class WebrtcConn {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.peer.destroy()
|
||||
}
|
||||
|
@ -366,6 +368,7 @@ export class Room {
|
|||
})
|
||||
})
|
||||
}
|
||||
|
||||
connect () {
|
||||
// signal through all available signaling connections
|
||||
announceSignalingInfo(this)
|
||||
|
@ -394,6 +397,7 @@ export class Room {
|
|||
encoding.writeVarUint8Array(encoderAwarenessState, awarenessProtocol.encodeAwarenessUpdate(this.awareness, [this.doc.clientID]))
|
||||
broadcastBcMessage(this, encoding.toUint8Array(encoderAwarenessState))
|
||||
}
|
||||
|
||||
disconnect () {
|
||||
// signal through all available signaling connections
|
||||
signalingConns.forEach(conn => {
|
||||
|
@ -415,6 +419,7 @@ export class Room {
|
|||
this.awareness.off('change', this._awarenessUpdateHandler)
|
||||
this.webrtcConns.forEach(conn => conn.destroy())
|
||||
}
|
||||
|
||||
destroy () {
|
||||
this.disconnect()
|
||||
}
|
||||
|
@ -576,12 +581,14 @@ export class WebrtcProvider extends Observable {
|
|||
})
|
||||
this.connect()
|
||||
}
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
get connected () {
|
||||
return this.room !== null && this.shouldConnect
|
||||
}
|
||||
|
||||
connect () {
|
||||
this.shouldConnect = true
|
||||
this.signalingUrls.forEach(url => {
|
||||
|
@ -593,6 +600,7 @@ export class WebrtcProvider extends Observable {
|
|||
this.room.connect()
|
||||
}
|
||||
}
|
||||
|
||||
disconnect () {
|
||||
this.shouldConnect = false
|
||||
this.signalingConns.forEach(conn => {
|
||||
|
@ -606,6 +614,7 @@ export class WebrtcProvider extends Observable {
|
|||
this.room.disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
destroy () {
|
||||
// need to wait for key before deleting room
|
||||
this.key.then(() => {
|
||||
|
|
|
@ -13,8 +13,7 @@
|
|||
"moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */
|
||||
"baseUrl": "./", /* Base directory to resolve non-absolute module names. */
|
||||
"paths": {
|
||||
},
|
||||
"maxNodeModuleJsDepth": 0
|
||||
}
|
||||
},
|
||||
"include": ["./src/y-webrtc.js"],
|
||||
"exclude": ["./node_modules/simple-peer/*"]
|
||||
|
|
Loading…
Reference in a new issue