remove node types from client code

This commit is contained in:
Kevin Jahns 2021-02-06 14:00:39 +01:00
parent a516319e80
commit e929a3a11e
3 changed files with 10 additions and 10 deletions

6
package-lock.json generated
View File

@ -1988,9 +1988,9 @@
} }
}, },
"y-protocols": { "y-protocols": {
"version": "1.0.2", "version": "1.0.3",
"resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.2.tgz", "resolved": "https://registry.npmjs.org/y-protocols/-/y-protocols-1.0.3.tgz",
"integrity": "sha512-V6ZAmokdogW52+VsIg/YC0R6CHWgG8/hjO3rYL10hAzeT5j464kDiRki31O+GzTj+dMgNYZNd6IDP9X35FLXrw==", "integrity": "sha512-2hSl0dqrD8Kph0SpvyakVYpKEnTLOLGIf7yvwmloQ4qS6RSvl6fUYHy6YocCvTvcd9MBuNeO4EqlmBcONJsvtw==",
"requires": { "requires": {
"lib0": "^0.2.35" "lib0": "^0.2.35"
} }

View File

@ -47,7 +47,7 @@
"dependencies": { "dependencies": {
"lib0": "^0.2.35", "lib0": "^0.2.35",
"lodash.debounce": "^4.0.8", "lodash.debounce": "^4.0.8",
"y-protocols": "^1.0.2" "y-protocols": "^1.0.3"
}, },
"devDependencies": { "devDependencies": {
"rollup": "^1.32.1", "rollup": "^1.32.1",

View File

@ -226,11 +226,11 @@ export class WebsocketProvider extends Observable {
this.shouldConnect = connect this.shouldConnect = connect
/** /**
* @type {NodeJS.Timeout | number} * @type {number}
*/ */
this._resyncInterval = 0 this._resyncInterval = 0
if (resyncInterval > 0) { if (resyncInterval > 0) {
this._resyncInterval = setInterval(() => { this._resyncInterval = /** @type {any} */ (setInterval(() => {
if (this.ws) { if (this.ws) {
// resend sync step 1 // resend sync step 1
const encoder = encoding.createEncoder() const encoder = encoding.createEncoder()
@ -238,7 +238,7 @@ export class WebsocketProvider extends Observable {
syncProtocol.writeSyncStep1(encoder, doc) syncProtocol.writeSyncStep1(encoder, doc)
this.ws.send(encoding.toUint8Array(encoder)) this.ws.send(encoding.toUint8Array(encoder))
} }
}, resyncInterval) }, resyncInterval))
} }
/** /**
@ -281,13 +281,13 @@ export class WebsocketProvider extends Observable {
awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload') awarenessProtocol.removeAwarenessStates(this.awareness, [doc.clientID], 'window unload')
}) })
awareness.on('update', this._awarenessUpdateHandler) awareness.on('update', this._awarenessUpdateHandler)
this._checkInterval = setInterval(() => { this._checkInterval = /** @type {any} */ (setInterval(() => {
if (this.wsconnected && messageReconnectTimeout < time.getUnixTime() - this.wsLastMessageReceived) { if (this.wsconnected && messageReconnectTimeout < time.getUnixTime() - this.wsLastMessageReceived) {
// no message received in a long time - not even your own awareness // no message received in a long time - not even your own awareness
// updates (which are updated every 15 seconds) // updates (which are updated every 15 seconds)
/** @type {WebSocket} */ (this.ws).close() /** @type {WebSocket} */ (this.ws).close()
} }
}, messageReconnectTimeout / 10) }, messageReconnectTimeout / 10))
if (connect) { if (connect) {
this.connect() this.connect()
} }
@ -310,7 +310,7 @@ export class WebsocketProvider extends Observable {
destroy () { destroy () {
if (this._resyncInterval !== 0) { if (this._resyncInterval !== 0) {
clearInterval(/** @type {NodeJS.Timeout} */ (this._resyncInterval)) clearInterval(this._resyncInterval)
} }
clearInterval(this._checkInterval) clearInterval(this._checkInterval)
this.disconnect() this.disconnect()