Socket
Socket
Sign inDemoInstall

@hocuspocus/server

Package Overview
Dependencies
Maintainers
4
Versions
115
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 2.0.4 to 2.0.5

6

dist/packages/extension-redis/src/Redis.d.ts
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
import Redlock from 'redlock';
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, onListenPayload, beforeBroadcastStatelessPayload } from '@hocuspocus/server';
import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, onListenPayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;

@@ -61,3 +61,3 @@ export interface Configuration {

sub: RedisInstance;
documents: Map<string, Document>;
instance: Hocuspocus;
redlock: Redlock;

@@ -112,3 +112,3 @@ locks: Map<string, Redlock.Lock>;

*/
onDisconnect: ({ document, documentName }: onDisconnectPayload) => Promise<void>;
onDisconnect: ({ documentName }: onDisconnectPayload) => Promise<void>;
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>;

@@ -115,0 +115,0 @@ /**

{
"name": "@hocuspocus/server",
"description": "plug & play collaboration backend",
"version": "2.0.4",
"version": "2.0.5",
"homepage": "https://hocuspocus.dev",

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

"dependencies": {
"@hocuspocus/common": "^2.0.4",
"@hocuspocus/common": "^2.0.5",
"async-lock": "^1.3.1",

@@ -34,0 +34,0 @@ "kleur": "^4.1.4",

@@ -754,44 +754,45 @@ import { createServer, IncomingMessage, Server as HTTPServer } from 'http'

this.hooks('onDisconnect', hookPayload)
this.hooks('onDisconnect', hookPayload).then(() => {
// Check if there are still no connections to the document, as these hooks
// may take some time to resolve (e.g. database queries). If a
// new connection were to come in during that time it would rely on the
// document in the map that we remove now.
if (document.getConnectionsCount() > 0) {
return
}
// Check if there are still no connections to the document, as these hooks
// may take some time to resolve (e.g. database queries). If a
// new connection were to come in during that time it would rely on the
// document in the map that we remove now.
if (document.getConnectionsCount() > 0) {
return
}
// If it’s the last connection, we need to make sure to store the
// document. Use the debounce helper, to clear running timers,
// but make it run immediately (`true`).
// Only run this if the document has finished loading earlier (i.e. not to persist the empty
// ydoc if the onLoadDocument hook returned an error)
if (!document.isLoading) {
this.debounce(`onStoreDocument-${document.name}`, () => {
this.hooks('onStoreDocument', hookPayload)
.catch(error => {
if (error?.message) {
throw error
}
})
.then(() => {
this.hooks('afterStoreDocument', hookPayload).then(() => {
// If it’s the last connection, we need to make sure to store the
// document. Use the debounce helper, to clear running timers,
// but make it run immediately (`true`).
// Only run this if the document has finished loading earlier (i.e. not to persist the empty
// ydoc if the onLoadDocument hook returned an error)
if (!document.isLoading) {
this.debounce(`onStoreDocument-${document.name}`, () => {
this.hooks('onStoreDocument', hookPayload)
.catch(error => {
if (error?.message) {
throw error
}
})
.then(() => {
this.hooks('afterStoreDocument', hookPayload).then(() => {
// Remove document from memory.
if (document.getConnectionsCount() > 0) {
return
}
if (document.getConnectionsCount() > 0) {
return
}
this.documents.delete(document.name)
document.destroy()
this.documents.delete(document.name)
document.destroy()
})
})
})
}, true)
}, true)
} else {
} else {
// Remove document from memory immediately
this.documents.delete(document.name)
document.destroy()
}
this.documents.delete(document.name)
document.destroy()
}
})
})

@@ -798,0 +799,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 too big to display

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