Socket
Socket
Sign inDemoInstall

@hocuspocus/server

Package Overview
Dependencies
Maintainers
3
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/server - npm Package Compare versions

Comparing version 1.0.0-alpha.59 to 1.0.0-alpha.60

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [1.0.0-alpha.60](https://github.com/ueberdosis/hocuspocus/compare/@hocuspocus/server@1.0.0-alpha.59...@hocuspocus/server@1.0.0-alpha.60) (2021-07-13)
**Note:** Version bump only for package @hocuspocus/server
# [1.0.0-alpha.59](https://github.com/ueberdosis/hocuspocus/compare/@hocuspocus/server@1.0.0-alpha.58...@hocuspocus/server@1.0.0-alpha.59) (2021-06-22)

@@ -8,0 +16,0 @@

75

dist/hocuspocus-server.esm.js

@@ -1417,3 +1417,3 @@ import WebSocket from 'ws';

var description = "plug & play collaboration backend";
var version = "1.0.0-alpha.58";
var version = "1.0.0-alpha.59";
var homepage = "https://hocuspocus.dev";

@@ -1605,9 +1605,10 @@ var keywords = [

// if no hook interrupts create a document and connection
const document = this.createDocument(documentName, request, socketId, context);
this.createConnection(incoming, request, document, socketId, connection.readOnly, context);
// Remove the queue listener
incoming.off('message', queueIncomingMessageListener);
// Work through queued messages
incomingMessageQueue.forEach(input => {
incoming.emit('message', input);
this.createDocument(documentName, request, socketId, context).then(document => {
this.createConnection(incoming, request, document, socketId, connection.readOnly, context);
// Remove the queue listener
incoming.off('message', queueIncomingMessageListener);
// Work through queued messages
incomingMessageQueue.forEach(input => {
incoming.emit('message', input);
});
});

@@ -1646,31 +1647,35 @@ })

*/
createDocument(documentName, request, socketId, context) {
if (this.documents.has(documentName)) {
return this.documents.get(documentName);
}
const document = new Document(documentName);
document.onUpdate((document, connection, update) => {
this.handleDocumentUpdate(document, connection, update, request, connection === null || connection === void 0 ? void 0 : connection.socketId);
});
const hookPayload = {
context,
document,
documentName,
socketId,
requestHeaders: request.headers,
requestParameters: Hocuspocus.getParameters(request),
};
this.hooks('onCreateDocument', hookPayload, (loadedDocument) => {
// if a hook returns a Y-Doc, encode the document state as update
// and apply it to the newly created document
// 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) === 'Document'
|| (loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') {
applyUpdate(document, encodeStateAsUpdate(loadedDocument));
async createDocument(documentName, request, socketId, context) {
return new Promise(resolve => {
if (this.documents.has(documentName)) {
const document = this.documents.get(documentName);
return resolve(document);
}
}).catch(e => {
throw e;
const document = new Document(documentName);
document.onUpdate((document, connection, update) => {
this.handleDocumentUpdate(document, connection, update, request, connection === null || connection === void 0 ? void 0 : connection.socketId);
});
const hookPayload = {
context,
document,
documentName,
socketId,
requestHeaders: request.headers,
requestParameters: Hocuspocus.getParameters(request),
};
this.hooks('onCreateDocument', hookPayload, (loadedDocument) => {
// if a hook returns a Y-Doc, encode the document state as update
// and apply it to the newly created document
// 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) === 'Document'
|| (loadedDocument === null || loadedDocument === void 0 ? void 0 : loadedDocument.constructor.name) === 'Doc') {
applyUpdate(document, encodeStateAsUpdate(loadedDocument));
}
}).then(() => {
resolve(document);
}).catch(e => {
throw e;
});
this.documents.set(documentName, document);
});
this.documents.set(documentName, document);
return document;
}

@@ -1677,0 +1682,0 @@ /**

@@ -8,3 +8,3 @@ import { RedisPersistence } from 'y-redis';

cluster: boolean;
persistence: RedisPersistence;
persistence: RedisPersistence | undefined;
/**

@@ -14,3 +14,3 @@ * Constructor

constructor(configuration?: Partial<Configuration>);
onCreateDocument(data: onCreateDocumentPayload): Promise<void>;
onCreateDocument(data: onCreateDocumentPayload): Promise<import("yjs").Doc | undefined>;
onConnect(data: onConnectPayload): Promise<void>;

@@ -17,0 +17,0 @@ onChange(data: onChangePayload): Promise<void>;

{
"name": "@hocuspocus/server",
"description": "plug & play collaboration backend",
"version": "1.0.0-alpha.59",
"version": "1.0.0-alpha.60",
"homepage": "https://hocuspocus.dev",

@@ -35,3 +35,3 @@ "keywords": [

},
"gitHead": "5056505ff8ac1a82433c66e0fa42140aab0aace4"
"gitHead": "5c4003bf38b4bb81799e1d0da0cf8ca38bcd511e"
}

@@ -177,10 +177,11 @@ import WebSocket from 'ws'

// if no hook interrupts create a document and connection
const document = this.createDocument(documentName, request, socketId, context)
this.createConnection(incoming, request, document, socketId, connection.readOnly, context)
this.createDocument(documentName, request, socketId, context).then(document => {
this.createConnection(incoming, request, document, socketId, connection.readOnly, context)
// Remove the queue listener
incoming.off('message', queueIncomingMessageListener)
// Work through queued messages
incomingMessageQueue.forEach(input => {
incoming.emit('message', input)
// Remove the queue listener
incoming.off('message', queueIncomingMessageListener)
// Work through queued messages
incomingMessageQueue.forEach(input => {
incoming.emit('message', input)
})
})

@@ -226,40 +227,42 @@ })

*/
private createDocument(documentName: string, request: IncomingMessage, socketId: string, context?: any): Document {
private async createDocument(documentName: string, request: IncomingMessage, socketId: string, context?: any): Promise<Document> {
return new Promise(resolve => {
if (this.documents.has(documentName)) {
const document = this.documents.get(documentName)
return resolve(document)
}
if (this.documents.has(documentName)) {
return this.documents.get(documentName)
}
const document = new Document(documentName)
const document = new Document(documentName)
document.onUpdate((document, connection, update) => {
this.handleDocumentUpdate(document, connection, update, request, connection?.socketId)
})
document.onUpdate((document, connection, update) => {
this.handleDocumentUpdate(document, connection, update, request, connection?.socketId)
})
const hookPayload = {
context,
document,
documentName,
socketId,
requestHeaders: request.headers,
requestParameters: Hocuspocus.getParameters(request),
}
const hookPayload = {
context,
document,
documentName,
socketId,
requestHeaders: request.headers,
requestParameters: Hocuspocus.getParameters(request),
}
this.hooks('onCreateDocument', hookPayload, (loadedDocument: Doc | undefined) => {
this.hooks('onCreateDocument', hookPayload, (loadedDocument: Doc | undefined) => {
// if a hook returns a Y-Doc, encode the document state as update
// and apply it to the newly created document
// Note: instanceof doesn't work, because Doc !== Doc for some reason I don't understand
if (
loadedDocument?.constructor.name === 'Document'
if (
loadedDocument?.constructor.name === 'Document'
|| loadedDocument?.constructor.name === 'Doc'
) {
applyUpdate(document, encodeStateAsUpdate(loadedDocument))
}
}).catch(e => {
throw e
) {
applyUpdate(document, encodeStateAsUpdate(loadedDocument))
}
}).then(() => {
resolve(document)
}).catch(e => {
throw e
})
this.documents.set(documentName, document)
})
this.documents.set(documentName, document)
return document
}

@@ -266,0 +269,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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