New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@hocuspocus/extension-redis

Package Overview
Dependencies
Maintainers
4
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/extension-redis - npm Package Compare versions

Comparing version 2.0.4 to 2.0.5

12

dist/hocuspocus-redis.esm.js

@@ -23,3 +23,2 @@ import RedisClient from 'ioredis';

};
this.documents = new Map();
this.locks = new Map();

@@ -38,3 +37,3 @@ /**

const [_, documentName, identifier] = channelName.split(':');
const document = this.documents.get(documentName);
const document = this.instance.documents.get(documentName);
if (identifier === this.configuration.identifier) {

@@ -54,10 +53,9 @@ return;

*/
this.onDisconnect = async ({ document, documentName }) => {
this.onDisconnect = async ({ documentName }) => {
const disconnect = () => {
const document = this.instance.documents.get(documentName);
// Do nothing, when other users are still connected to the document.
if (document.getConnectionsCount() > 0) {
if (document && document.getConnectionsCount() > 0) {
return;
}
// It was indeed the last connected user.
this.documents.delete(documentName);
// Time to end the subscription on the document channel.

@@ -102,2 +100,3 @@ this.sub.punsubscribe(this.subKey(documentName), (error) => {

this.logger = instance.debugger;
this.instance = instance;
}

@@ -127,3 +126,2 @@ async onListen({ configuration }) {

async afterLoadDocument({ documentName, document }) {
this.documents.set(documentName, document);
return new Promise((resolve, reject) => {

@@ -130,0 +128,0 @@ // On document creation the node will connect to pub and sub channels

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/extension-redis",
"version": "2.0.4",
"version": "2.0.5",
"description": "Scale Hocuspocus horizontally with Redis",

@@ -35,3 +35,3 @@ "homepage": "https://hocuspocus.dev",

"dependencies": {
"@hocuspocus/server": "^2.0.4",
"@hocuspocus/server": "^2.0.5",
"ioredis": "^4.28.2",

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

@@ -19,3 +19,3 @@ import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'

onListenPayload,
beforeBroadcastStatelessPayload,
beforeBroadcastStatelessPayload, Hocuspocus,
} from '@hocuspocus/server'

@@ -94,3 +94,3 @@ import kleur from 'kleur'

documents: Map<string, Document> = new Map()
instance!: Hocuspocus

@@ -142,2 +142,3 @@ redlock: Redlock

this.logger = instance.debugger
this.instance = instance
}

@@ -174,4 +175,2 @@

public async afterLoadDocument({ documentName, document }: afterLoadDocumentPayload) {
this.documents.set(documentName, document)
return new Promise((resolve, reject) => {

@@ -284,3 +283,3 @@ // On document creation the node will connect to pub and sub channels

const [_, documentName, identifier] = channelName.split(':')
const document = this.documents.get(documentName)
const document = this.instance.documents.get(documentName)

@@ -317,12 +316,11 @@ if (identifier === this.configuration.identifier) {

*/
public onDisconnect = async ({ document, documentName }: onDisconnectPayload) => {
public onDisconnect = async ({ documentName }: onDisconnectPayload) => {
const disconnect = () => {
const document = this.instance.documents.get(documentName)
// Do nothing, when other users are still connected to the document.
if (document.getConnectionsCount() > 0) {
if (document && document.getConnectionsCount() > 0) {
return
}
// It was indeed the last connected user.
this.documents.delete(documentName)
// Time to end the subscription on the document channel.

@@ -329,0 +327,0 @@ this.sub.punsubscribe(this.subKey(documentName), (error: any) => {

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