@hocuspocus/server
Advanced tools
Comparing version 1.0.0-alpha.52 to 1.0.0-alpha.53
@@ -6,2 +6,10 @@ # Change Log | ||
# [1.0.0-alpha.53](https://github.com/ueberdosis/hocuspocus/compare/@hocuspocus/server@1.0.0-alpha.52...@hocuspocus/server@1.0.0-alpha.53) (2021-05-15) | ||
**Note:** Version bump only for package @hocuspocus/server | ||
# [1.0.0-alpha.52](https://github.com/ueberdosis/hocuspocus/compare/@hocuspocus/server@1.0.0-alpha.51...@hocuspocus/server@1.0.0-alpha.52) (2021-04-20) | ||
@@ -8,0 +16,0 @@ |
@@ -1402,3 +1402,3 @@ import WebSocket from 'ws'; | ||
var description = "plug & play collaboration backend"; | ||
var version = "1.0.0-alpha.50"; | ||
var version = "1.0.0-alpha.52"; | ||
var homepage = "https://hocuspocus.dev"; | ||
@@ -1474,2 +1474,3 @@ var keywords = [ | ||
this.documents = new Map(); | ||
this.incomingMessageQueue = []; | ||
} | ||
@@ -1578,2 +1579,5 @@ /** | ||
}; | ||
// Queue messages before the connection is established | ||
const queueIncomingMessageListener = this.queueIncomingMessage.bind(this); | ||
incoming.on('message', queueIncomingMessageListener); | ||
this.hooks('onConnect', hookPayload, (contextAdditions) => { | ||
@@ -1587,2 +1591,8 @@ // merge context from all hooks | ||
this.createConnection(incoming, request, document, socketId, connection.readOnly, context); | ||
// Remove the queue listener | ||
incoming.off('message', queueIncomingMessageListener); | ||
// Work through queue messages | ||
this.incomingMessageQueue.forEach(input => { | ||
incoming.emit('message', input); | ||
}); | ||
}) | ||
@@ -1597,2 +1607,10 @@ .catch(e => { | ||
/** | ||
* Queue incoming WebSocket messages before the onConnect hooks are finished | ||
* and the connection is full established | ||
* @private | ||
*/ | ||
queueIncomingMessage(input) { | ||
this.incomingMessageQueue.push(input); | ||
} | ||
/** | ||
* Handle update of the given document | ||
@@ -1640,3 +1658,4 @@ * @private | ||
// Note: instanceof doesn't work, because Doc !== Doc for some reason I don't understand | ||
if ((loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') { | ||
if ((loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Document' | ||
|| (loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') { | ||
applyUpdate(document, encodeStateAsUpdate(loadedDocument)); | ||
@@ -1643,0 +1662,0 @@ } |
@@ -1431,3 +1431,3 @@ 'use strict'; | ||
var description = "plug & play collaboration backend"; | ||
var version = "1.0.0-alpha.50"; | ||
var version = "1.0.0-alpha.52"; | ||
var homepage = "https://hocuspocus.dev"; | ||
@@ -1503,2 +1503,3 @@ var keywords = [ | ||
this.documents = new Map(); | ||
this.incomingMessageQueue = []; | ||
} | ||
@@ -1607,2 +1608,5 @@ /** | ||
}; | ||
// Queue messages before the connection is established | ||
const queueIncomingMessageListener = this.queueIncomingMessage.bind(this); | ||
incoming.on('message', queueIncomingMessageListener); | ||
this.hooks('onConnect', hookPayload, (contextAdditions) => { | ||
@@ -1616,2 +1620,8 @@ // merge context from all hooks | ||
this.createConnection(incoming, request, document, socketId, connection.readOnly, context); | ||
// Remove the queue listener | ||
incoming.off('message', queueIncomingMessageListener); | ||
// Work through queue messages | ||
this.incomingMessageQueue.forEach(input => { | ||
incoming.emit('message', input); | ||
}); | ||
}) | ||
@@ -1626,2 +1636,10 @@ .catch(e => { | ||
/** | ||
* Queue incoming WebSocket messages before the onConnect hooks are finished | ||
* and the connection is full established | ||
* @private | ||
*/ | ||
queueIncomingMessage(input) { | ||
this.incomingMessageQueue.push(input); | ||
} | ||
/** | ||
* Handle update of the given document | ||
@@ -1669,3 +1687,4 @@ * @private | ||
// Note: instanceof doesn't work, because Doc !== Doc for some reason I don't understand | ||
if ((loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') { | ||
if ((loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Document' | ||
|| (loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') { | ||
Y.applyUpdate(document, Y.encodeStateAsUpdate(loadedDocument)); | ||
@@ -1672,0 +1691,0 @@ } |
@@ -17,2 +17,3 @@ /// <reference types="node" /> | ||
websocketServer?: WebSocket.Server; | ||
incomingMessageQueue: Iterable<number>[]; | ||
/** | ||
@@ -35,2 +36,8 @@ * Configure the server | ||
/** | ||
* Queue incoming WebSocket messages before the onConnect hooks are finished | ||
* and the connection is full established | ||
* @private | ||
*/ | ||
private queueIncomingMessage; | ||
/** | ||
* Handle update of the given document | ||
@@ -37,0 +44,0 @@ * @private |
{ | ||
"name": "@hocuspocus/server", | ||
"description": "plug & play collaboration backend", | ||
"version": "1.0.0-alpha.52", | ||
"version": "1.0.0-alpha.53", | ||
"homepage": "https://hocuspocus.dev", | ||
@@ -35,3 +35,3 @@ "keywords": [ | ||
}, | ||
"gitHead": "adc1bacce508102d08fcbe412931192f7ccd1956" | ||
"gitHead": "bb85db1b03f680f706d3f1a7264f0de0d7c6162b" | ||
} |
@@ -42,2 +42,4 @@ import WebSocket from 'ws' | ||
incomingMessageQueue: Iterable<number>[] = [] | ||
/** | ||
@@ -162,2 +164,6 @@ * Configure the server | ||
// Queue messages before the connection is established | ||
const queueIncomingMessageListener = this.queueIncomingMessage.bind(this) | ||
incoming.on('message', queueIncomingMessageListener) | ||
this.hooks('onConnect', hookPayload, (contextAdditions: any) => { | ||
@@ -171,2 +177,9 @@ // merge context from all hooks | ||
this.createConnection(incoming, request, document, socketId, connection.readOnly, context) | ||
// Remove the queue listener | ||
incoming.off('message', queueIncomingMessageListener) | ||
// Work through queue messages | ||
this.incomingMessageQueue.forEach(input => { | ||
incoming.emit('message', input) | ||
}) | ||
}) | ||
@@ -182,2 +195,11 @@ .catch(e => { | ||
/** | ||
* Queue incoming WebSocket messages before the onConnect hooks are finished | ||
* and the connection is full established | ||
* @private | ||
*/ | ||
private queueIncomingMessage(input: Iterable<number>): void { | ||
this.incomingMessageQueue.push(input) | ||
} | ||
/** | ||
* Handle update of the given document | ||
@@ -234,3 +256,6 @@ * @private | ||
// Note: instanceof doesn't work, because Doc !== Doc for some reason I don't understand | ||
if (loadedDocument?.constructor.name === 'Doc') { | ||
if ( | ||
loadedDocument?.constructor.name === 'Document' | ||
|| loadedDocument?.constructor.name === 'Doc' | ||
) { | ||
applyUpdate(document, encodeStateAsUpdate(loadedDocument)) | ||
@@ -237,0 +262,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No License Found
License(Experimental) License information could not be found.
Found 1 instance in 1 package
440152
42
0
4794
3