Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@hocuspocus/provider

Package Overview
Dependencies
Maintainers
0
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@hocuspocus/provider - npm Package Compare versions

Comparing version 2.13.5 to 3.0.0-rc.0

2

dist/packages/common/src/auth.d.ts

@@ -5,3 +5,3 @@ import * as encoding from 'lib0/encoding';

export declare const writePermissionDenied: (encoder: encoding.Encoder, reason: string) => void;
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: 'readonly' | 'read-write') => void;
export declare const writeAuthenticated: (encoder: encoding.Encoder, scope: "readonly" | "read-write") => void;
export declare const readAuthMessage: (decoder: decoding.Decoder, permissionDeniedHandler: (reason: string) => void, authenticatedHandler: (scope: string) => void) => void;

@@ -1,2 +0,2 @@

import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
import type { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server';
export interface DatabaseConfiguration {

@@ -3,0 +3,0 @@ /**

@@ -1,2 +0,2 @@

import { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
import type { Extension, onChangePayload, onConfigurePayload, onConnectPayload, onLoadDocumentPayload, onDestroyPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload } from '@hocuspocus/server';
export interface LoggerConfiguration {

@@ -3,0 +3,0 @@ /**

@@ -1,5 +0,6 @@

/// <reference types="node" />
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
import RedisClient from 'ioredis';
import Redlock from 'redlock';
import { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
import type { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
import { Debugger } from '@hocuspocus/server';
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;

@@ -6,0 +7,0 @@ export interface Configuration {

@@ -1,2 +0,3 @@

import { Database, DatabaseConfiguration } from '@hocuspocus/extension-database';
import type { DatabaseConfiguration } from '@hocuspocus/extension-database';
import { Database } from '@hocuspocus/extension-database';
import sqlite3 from 'sqlite3';

@@ -3,0 +4,0 @@ export declare const schema = "CREATE TABLE IF NOT EXISTS \"documents\" (\n \"name\" varchar(255) NOT NULL,\n \"data\" blob NOT NULL,\n UNIQUE(name)\n)";

@@ -1,3 +0,2 @@

/// <reference types="node" />
import { Extension, onConnectPayload } from '@hocuspocus/server';
import type { Extension, onConnectPayload } from '@hocuspocus/server';
export interface ThrottleConfiguration {

@@ -13,3 +12,3 @@ throttle: number | null | false;

bannedIps: Map<string, number>;
cleanupInterval?: NodeJS.Timer;
cleanupInterval?: NodeJS.Timeout;
/**

@@ -16,0 +15,0 @@ * Constructor

@@ -1,5 +0,4 @@

/// <reference types="node" />
import { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
import { Doc } from 'yjs';
import { Transformer } from '@hocuspocus/transformer';
import type { Extension, onChangePayload, onConnectPayload, onLoadDocumentPayload, onDisconnectPayload } from '@hocuspocus/server';
import type { Doc } from 'yjs';
import type { Transformer } from '@hocuspocus/transformer';
export declare enum Events {

@@ -6,0 +5,0 @@ onChange = "change",

@@ -6,4 +6,5 @@ import * as mutex from 'lib0/mutex';

import EventEmitter from './EventEmitter.js';
import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
import { ConstructableOutgoingMessage, WebSocketStatus, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters } from './types.js';
import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters } from './types.js';
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'name'>> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> | Required<Pick<CompleteHocuspocusProviderConfiguration, 'websocketProvider'>>);

@@ -85,3 +86,2 @@ export interface CompleteHocuspocusProviderConfiguration {

unsyncedChanges: number;
status: WebSocketStatus;
isAuthenticated: boolean;

@@ -91,9 +91,6 @@ authorizedScope: string | undefined;

intervals: any;
isConnected: boolean;
constructor(configuration: HocuspocusProviderConfiguration);
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void;
boundPageHide: () => void;
boundOnOpen: (event: Event) => Promise<void>;
boundOnClose: (event: CloseEvent) => void;
boundOnStatus: ({ status }: onStatusParameters) => void;
forwardConnect: (e: any) => this;

@@ -104,3 +101,2 @@ forwardOpen: (e: any) => this;

forwardDestroy: (e: any) => this;
onStatus({ status }: onStatusParameters): void;
setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void;

@@ -129,3 +125,3 @@ get document(): Y.Doc;

get isAuthenticationRequired(): boolean;
connect(): Promise<any>;
connect(): Promise<void>;
disconnect(): void;

@@ -141,8 +137,3 @@ onOpen(event: Event): Promise<void>;

authenticatedHandler(scope: string): void;
get broadcastChannel(): string;
broadcastChannelSubscriber(data: ArrayBuffer): void;
subscribeToBroadcastChannel(): void;
disconnectBroadcastChannel(): void;
broadcast(Message: ConstructableOutgoingMessage, args?: any): void;
setAwarenessField(key: string, value: any): void;
}

@@ -1,6 +0,6 @@

import type { MessageEvent } from 'ws';
import { Event } from 'ws';
import type { MessageEvent, Event } from 'ws';
import EventEmitter from './EventEmitter.js';
import { HocuspocusProvider } from './HocuspocusProvider.js';
import { WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
import type { HocuspocusProvider } from './HocuspocusProvider.js';
import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js';
import { WebSocketStatus } from './types.js';
export type HocusPocusWebSocket = WebSocket & {

@@ -105,3 +105,3 @@ identifier: string;

onStatus(data: onStatusParameters): Promise<void>;
attach(provider: HocuspocusProvider): Promise<any> | undefined;
attach(provider: HocuspocusProvider): void;
detach(provider: HocuspocusProvider): void;

@@ -108,0 +108,0 @@ setConfiguration(configuration?: Partial<HocuspocusProviderWebsocketConfiguration>): void;

@@ -1,4 +0,4 @@

import { Decoder } from 'lib0/decoding';
import { Encoder } from 'lib0/encoding';
import { MessageType } from './types.js';
import type { Decoder } from 'lib0/decoding';
import type { Encoder } from 'lib0/encoding';
import type { MessageType } from './types.js';
export declare class IncomingMessage {

@@ -5,0 +5,0 @@ data: any;

@@ -1,3 +0,3 @@

import { HocuspocusProvider } from './HocuspocusProvider.js';
import { IncomingMessage } from './IncomingMessage.js';
import type { HocuspocusProvider } from './HocuspocusProvider.js';
import type { IncomingMessage } from './IncomingMessage.js';
export declare class MessageReceiver {

@@ -4,0 +4,0 @@ message: IncomingMessage;

@@ -1,3 +0,3 @@

import { Encoder } from 'lib0/encoding';
import { ConstructableOutgoingMessage } from './types.js';
import type { Encoder } from 'lib0/encoding';
import type { ConstructableOutgoingMessage } from './types.js';
export declare class MessageSender {

@@ -4,0 +4,0 @@ encoder: Encoder;

@@ -1,3 +0,3 @@

import { Encoder } from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js';
import type { Encoder } from 'lib0/encoding';
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js';
export declare class OutgoingMessage implements OutgoingMessageInterface {

@@ -4,0 +4,0 @@ encoder: Encoder;

@@ -1,2 +0,3 @@

import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -3,0 +4,0 @@ export declare class AuthenticationMessage extends OutgoingMessage {

import * as encoding from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -4,0 +5,0 @@ export declare class AwarenessMessage extends OutgoingMessage {

import * as encoding from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -4,0 +5,0 @@ export declare class CloseMessage extends OutgoingMessage {

import * as encoding from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -4,0 +5,0 @@ export declare class QueryAwarenessMessage extends OutgoingMessage {

@@ -1,2 +0,3 @@

import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -3,0 +4,0 @@ export declare class StatelessMessage extends OutgoingMessage {

import * as encoding from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -4,0 +5,0 @@ export declare class SyncStepOneMessage extends OutgoingMessage {

import * as encoding from 'lib0/encoding';
import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -4,0 +5,0 @@ export declare class SyncStepTwoMessage extends OutgoingMessage {

@@ -1,2 +0,3 @@

import { MessageType, OutgoingMessageArguments } from '../types.js';
import type { OutgoingMessageArguments } from '../types.js';
import { MessageType } from '../types.js';
import { OutgoingMessage } from '../OutgoingMessage.js';

@@ -3,0 +4,0 @@ export declare class UpdateMessage extends OutgoingMessage {

import type { AbstractType, YArrayEvent } from 'yjs';
import * as Y from 'yjs';
import { HocuspocusProvider, HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
import type { HocuspocusProviderConfiguration } from './HocuspocusProvider.js';
import { HocuspocusProvider } from './HocuspocusProvider.js';
import { TiptapCollabProviderWebsocket } from './TiptapCollabProviderWebsocket.js';

@@ -5,0 +6,0 @@ import type { TCollabComment, TCollabThread, THistoryVersion } from './types.js';

@@ -1,2 +0,3 @@

import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.js';
import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js';
export type TiptapCollabProviderWebsocketConfiguration = Partial<CompleteHocuspocusProviderWebsocketConfiguration> & AdditionalTiptapCollabProviderWebsocketConfiguration;

@@ -3,0 +4,0 @@ export interface AdditionalTiptapCollabProviderWebsocketConfiguration {

@@ -1,14 +0,14 @@

import { Encoder } from 'lib0/encoding';
import type { Encoder } from 'lib0/encoding';
import type { Event, MessageEvent } from 'ws';
import { Awareness } from 'y-protocols/awareness';
import * as Y from 'yjs';
import { CloseEvent } from '@hocuspocus/common';
import { IncomingMessage } from './IncomingMessage.js';
import { OutgoingMessage } from './OutgoingMessage.js';
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
import type { Awareness } from 'y-protocols/awareness';
import type * as Y from 'yjs';
import type { CloseEvent } from '@hocuspocus/common';
import type { IncomingMessage } from './IncomingMessage.js';
import type { OutgoingMessage } from './OutgoingMessage.js';
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js';
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js';
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js';
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js';
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js';
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js';
export declare enum MessageType {

@@ -15,0 +15,0 @@ Sync = 0,

@@ -1,8 +0,7 @@

/// <reference types="node" />
import { IncomingMessage } from 'http';
import WebSocket from 'ws';
import { Debugger } from './Debugger.js';
import Document from './Document.js';
import { Hocuspocus } from './Hocuspocus.js';
import { onDisconnectPayload } from './types.js';
import type { IncomingMessage } from 'http';
import type WebSocket from 'ws';
import type { Debugger } from './Debugger.js';
import type Document from './Document.js';
import type { Hocuspocus } from './Hocuspocus.js';
import type { onDisconnectPayload } from './types.js';
/**

@@ -9,0 +8,0 @@ * The `ClientConnection` class is responsible for handling an incoming WebSocket

@@ -1,10 +0,8 @@

/// <reference types="node" />
/// <reference types="node" />
import { IncomingMessage as HTTPIncomingMessage } from 'http';
import type { IncomingMessage as HTTPIncomingMessage } from 'http';
import AsyncLock from 'async-lock';
import WebSocket from 'ws';
import { CloseEvent } from '@hocuspocus/common';
import Document from './Document.js';
import { Debugger } from './Debugger.js';
import { onStatelessPayload } from './types.js';
import type WebSocket from 'ws';
import type { CloseEvent } from '@hocuspocus/common';
import type Document from './Document.js';
import type { Debugger } from './Debugger.js';
import type { onStatelessPayload } from './types.js';
export declare class Connection {

@@ -21,3 +19,3 @@ webSocket: WebSocket;

lock: AsyncLock;
readOnly: Boolean;
readOnly: boolean;
logger: Debugger;

@@ -24,0 +22,0 @@ /**

@@ -1,2 +0,2 @@

import Document from './Document.js';
import type Document from './Document.js';
import type { Hocuspocus } from './Hocuspocus.js';

@@ -3,0 +3,0 @@ import type { DirectConnection as DirectConnectionInterface } from './types.js';

@@ -1,7 +0,7 @@

import WebSocket from 'ws';
import type WebSocket from 'ws';
import { Awareness } from 'y-protocols/awareness';
import { Doc } from 'yjs';
import { mutex } from 'lib0/mutex.js';
import Connection from './Connection.js';
import { Debugger } from './Debugger.js';
import type { mutex } from 'lib0/mutex.js';
import type Connection from './Connection.js';
import type { Debugger } from './Debugger.js';
export declare class Document extends Doc {

@@ -26,3 +26,3 @@ awareness: Awareness;

*/
constructor(name: string, logger?: Debugger, yDocOptions?: {});
constructor(name: string, logger?: Debugger, yDocOptions?: object);
/**

@@ -29,0 +29,0 @@ * Check if the Document (XMLFragment or Map) is empty

@@ -1,13 +0,10 @@

/// <reference types="node" />
import { IncomingMessage } from 'http';
import WebSocket, { AddressInfo } from 'ws';
import { Server as HocuspocusServer } from './Server.js';
import type { IncomingMessage } from 'http';
import type WebSocket from 'ws';
import type { Server } from './Server.js';
import { Debugger } from './Debugger.js';
import { DirectConnection } from './DirectConnection.js';
import Document from './Document.js';
import { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onListenPayload, onStoreDocumentPayload } from './types.js';
import type { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onStoreDocumentPayload } from './types.js';
export declare const defaultConfiguration: {
name: null;
port: number;
address: string;
timeout: number;

@@ -22,7 +19,3 @@ debounce: number;

unloadImmediately: boolean;
stopOnSignals: boolean;
};
/**
* Hocuspocus Server
*/
export declare class Hocuspocus {

@@ -32,3 +25,3 @@ configuration: Configuration;

documents: Map<string, Document>;
server?: HocuspocusServer;
server?: Server;
debugger: Debugger;

@@ -42,3 +35,3 @@ debouncer: {

/**
* Configure the server
* Configure Hocuspocus
*/

@@ -48,11 +41,2 @@ configure(configuration: Partial<Configuration>): Hocuspocus;

/**
* Start the server
*/
listen(portOrCallback?: number | ((data: onListenPayload) => Promise<any>) | null, callback?: any): Promise<Hocuspocus>;
get address(): AddressInfo;
get URL(): string;
get webSocketURL(): string;
get httpURL(): string;
private showStartScreen;
/**
* Get the total number of active documents

@@ -70,6 +54,2 @@ */

/**
* Destroy the server
*/
destroy(): Promise<any>;
/**
* The `handleConnection` method receives incoming WebSocket connections,

@@ -112,2 +92,1 @@ * runs all hooks:

}
export declare const Server: Hocuspocus;

@@ -1,4 +0,4 @@

import { Decoder } from 'lib0/decoding';
import { Encoder } from 'lib0/encoding';
import { MessageType } from './types.js';
import type { Decoder } from 'lib0/decoding';
import type { Encoder } from 'lib0/encoding';
import type { MessageType } from './types.js';
export declare class IncomingMessage {

@@ -5,0 +5,0 @@ /**

@@ -8,3 +8,4 @@ export * from './Connection.js';

export * from './OutgoingMessage.js';
export * from './Server.js';
export * from './types.js';
export * from './util/debounce.js';

@@ -1,5 +0,5 @@

import Connection from './Connection.js';
import { Debugger } from './Debugger.js';
import Document from './Document.js';
import { IncomingMessage } from './IncomingMessage.js';
import type Connection from './Connection.js';
import type { Debugger } from './Debugger.js';
import type Document from './Document.js';
import type { IncomingMessage } from './IncomingMessage.js';
export declare class MessageReceiver {

@@ -6,0 +6,0 @@ message: IncomingMessage;

@@ -1,4 +0,4 @@

import { Encoder } from 'lib0/encoding';
import { Awareness } from 'y-protocols/awareness';
import Document from './Document.js';
import type { Encoder } from 'lib0/encoding';
import type { Awareness } from 'y-protocols/awareness';
import type Document from './Document.js';
export declare class OutgoingMessage {

@@ -5,0 +5,0 @@ encoder: Encoder;

@@ -1,5 +0,16 @@

/// <reference types="node" />
import { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
import type { IncomingMessage, Server as HTTPServer, ServerResponse } from 'http';
import type { AddressInfo } from 'ws';
import { WebSocketServer } from 'ws';
import { Hocuspocus } from './Hocuspocus.js';
import type { Configuration } from './types';
export interface ServerConfiguration extends Configuration {
port?: number;
address?: string;
stopOnSignals?: boolean;
}
export declare const defaultServerConfiguration: {
port: number;
address: string;
stopOnSignals: boolean;
};
export declare class Server {

@@ -9,6 +20,14 @@ httpServer: HTTPServer;

hocuspocus: Hocuspocus;
constructor(hocuspocus: Hocuspocus);
configuration: ServerConfiguration;
constructor(configuration?: Partial<ServerConfiguration>);
setupWebsocketConnection: () => void;
setupHttpUpgrade: () => void;
requestHandler: (request: IncomingMessage, response: ServerResponse) => Promise<void>;
listen(port?: number, callback?: any): Promise<Hocuspocus>;
get address(): AddressInfo;
destroy(): Promise<any>;
get URL(): string;
get webSocketURL(): string;
get httpURL(): string;
private showStartScreen;
}

@@ -1,10 +0,7 @@

/// <reference types="node" />
/// <reference types="node" />
/// <reference types="node" />
import { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
import { URLSearchParams } from 'url';
import { Awareness } from 'y-protocols/awareness';
import Connection from './Connection.js';
import Document from './Document.js';
import { Hocuspocus } from './Hocuspocus.js';
import type { IncomingHttpHeaders, IncomingMessage, ServerResponse } from 'http';
import type { URLSearchParams } from 'url';
import type { Awareness } from 'y-protocols/awareness';
import type Connection from './Connection.js';
import type Document from './Document.js';
import type { Hocuspocus } from './Hocuspocus.js';
export declare enum MessageType {

@@ -16,3 +13,3 @@ Unknown = -1,

QueryAwareness = 3,
SyncReply = 4,
SyncReply = 4,// same as Sync, but won't trigger another 'SyncStep1'
Stateless = 5,

@@ -90,10 +87,2 @@ BroadcastStateless = 6,

/**
* The port which the server listens on.
*/
port?: number;
/**
* The address which the server listens on.
*/
address?: string;
/**
* Defines in which interval the server sends a ping, and closes the connection when no pong is sent back.

@@ -124,8 +113,2 @@ */

/**
* the server will gracefully stop if SIGINT, SIGQUIT or SIGTERM is received.
*
* Set this to false if you don't want that.
*/
stopOnSignals: boolean;
/**
* options to pass to the ydoc document

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

@@ -1,4 +0,2 @@

/// <reference types="node" />
/// <reference types="node" />
import { IncomingMessage } from 'http';
import type { IncomingMessage } from 'http';
import { URLSearchParams } from 'url';

@@ -5,0 +3,0 @@ /**

import { Doc } from 'yjs';
import { Schema } from '@tiptap/pm/model';
import { Transformer } from './types.js';
import type { Transformer } from './types.js';
declare class Prosemirror implements Transformer {

@@ -5,0 +5,0 @@ defaultSchema: Schema;

@@ -1,4 +0,4 @@

import { Doc } from 'yjs';
import { Extensions } from '@tiptap/core';
import { Transformer } from './types.js';
import type { Doc } from 'yjs';
import type { Extensions } from '@tiptap/core';
import type { Transformer } from './types.js';
export declare class Tiptap implements Transformer {

@@ -5,0 +5,0 @@ defaultExtensions: Extensions;

@@ -1,2 +0,2 @@

import { Doc } from 'yjs';
import type { Doc } from 'yjs';
export interface Transformer {

@@ -3,0 +3,0 @@ fromYdoc: (document: Doc, fieldName?: string | Array<string>) => any;

@@ -1,2 +0,2 @@

import { Hocuspocus, Configuration } from '@hocuspocus/server';
export declare const newHocuspocus: (options?: Partial<Configuration>) => Promise<Hocuspocus>;
import type { ServerConfiguration } from '@hocuspocus/server';
export declare const newHocuspocus: (options?: Partial<ServerConfiguration>) => Promise<import("@hocuspocus/server").Hocuspocus>;

@@ -1,3 +0,3 @@

import { HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import { Hocuspocus } from '@hocuspocus/server';
import { HocuspocusProvider, type HocuspocusProviderConfiguration, type HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import type { Hocuspocus } from '@hocuspocus/server';
export declare const newHocuspocusProvider: (server: Hocuspocus, options?: Partial<HocuspocusProviderConfiguration>, websocketOptions?: Partial<HocuspocusProviderWebsocketConfiguration>) => HocuspocusProvider;

@@ -1,3 +0,4 @@

import { HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import { Hocuspocus } from '@hocuspocus/server';
export declare const newHocuspocusProviderWebsocket: (server: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, 'url'>>) => HocuspocusProviderWebsocket;
import type { HocuspocusProviderWebsocketConfiguration } from '@hocuspocus/provider';
import { HocuspocusProviderWebsocket } from '@hocuspocus/provider';
import type { Hocuspocus } from '@hocuspocus/server';
export declare const newHocuspocusProviderWebsocket: (hocuspocus: Hocuspocus, options?: Partial<Omit<HocuspocusProviderWebsocketConfiguration, "url">>) => HocuspocusProviderWebsocket;

@@ -1,2 +0,2 @@

import { ExecutionContext } from 'ava';
import type { ExecutionContext } from 'ava';
export declare const retryableAssertion: (t: ExecutionContext, recoverableTry: (tt: ExecutionContext) => void) => Promise<void>;
{
"name": "@hocuspocus/provider",
"version": "2.13.5",
"version": "3.0.0-rc.0",
"description": "hocuspocus provider",

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

"dependencies": {
"@hocuspocus/common": "^2.13.5",
"@hocuspocus/common": "^3.0.0-rc.0",
"@lifeomic/attempt": "^3.0.2",

@@ -35,0 +35,0 @@ "lib0": "^0.2.87",

export default class EventEmitter {
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
public callbacks: { [key: string]: Function[] } = {}
// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
public on(event: string, fn: Function): this {

@@ -25,2 +26,3 @@ if (!this.callbacks[event]) {

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
public off(event: string, fn?: Function): this {

@@ -27,0 +29,0 @@ const callbacks = this.callbacks[event]

import { awarenessStatesToArray } from '@hocuspocus/common'
import * as bc from 'lib0/broadcastchannel'
import * as mutex from 'lib0/mutex'

@@ -8,4 +7,5 @@ import type { CloseEvent, Event, MessageEvent } from 'ws'

import EventEmitter from './EventEmitter.js'
import type {
CompleteHocuspocusProviderWebsocketConfiguration} from './HocuspocusProviderWebsocket.js'
import {
CompleteHocuspocusProviderWebsocketConfiguration,
HocuspocusProviderWebsocket,

@@ -19,10 +19,7 @@ } from './HocuspocusProviderWebsocket.js'

import { CloseMessage } from './OutgoingMessages/CloseMessage.js'
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js'
import { StatelessMessage } from './OutgoingMessages/StatelessMessage.js'
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js'
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js'
import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js'
import {
import type {
ConstructableOutgoingMessage,
WebSocketStatus,
onAuthenticationFailedParameters,

@@ -158,3 +155,3 @@ onAwarenessChangeParameters,

status = WebSocketStatus.Disconnected
// status = WebSocketStatus.Disconnected

@@ -171,3 +168,3 @@ isAuthenticated = false

isConnected = true
// isConnected = true

@@ -203,3 +200,3 @@ constructor(configuration: HocuspocusProviderConfiguration) {

this.configuration.websocketProvider.on('status', this.boundOnStatus)
// this.configuration.websocketProvider.on('status', this.boundOnStatus)

@@ -237,3 +234,3 @@ this.configuration.websocketProvider.on('disconnect', this.configuration.onDisconnect)

boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this)
// boundBroadcastChannelSubscriber = this.broadcastChannelSubscriber.bind(this)

@@ -246,3 +243,3 @@ boundPageHide = this.pageHide.bind(this)

boundOnStatus = this.onStatus.bind(this)
// boundOnStatus = this.onStatus.bind(this)

@@ -259,9 +256,9 @@ forwardConnect = (e: any) => this.emit('connect', e)

public onStatus({ status } : onStatusParameters) {
this.status = status
// public onStatus({ status } : onStatusParameters) {
// this.status = status
//
// this.configuration.onStatus({ status })
// this.emit('status', { status })
// }
this.configuration.onStatus({ status })
this.emit('status', { status })
}
public setConfiguration(configuration: Partial<HocuspocusProviderConfiguration> = {}): void {

@@ -384,20 +381,22 @@ if (!configuration.websocketProvider && (configuration as CompleteHocuspocusProviderWebsocketConfiguration).url) {

async connect() {
if (this.configuration.broadcast) {
this.subscribeToBroadcastChannel()
}
console.warn('HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.')
this.configuration.websocketProvider.shouldConnect = true
return this.configuration.websocketProvider.attach(this)
// if (this.configuration.broadcast) {
// this.subscribeToBroadcastChannel()
// }
//
// return this.configuration.websocketProvider.connect()
}
disconnect() {
this.disconnectBroadcastChannel()
this.configuration.websocketProvider.detach(this)
this.isConnected = false
console.warn('HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.')
if (!this.configuration.preserveConnection) {
this.configuration.websocketProvider.disconnect()
}
// this.disconnectBroadcastChannel()
// this.configuration.websocketProvider.detach(this)
// this.isConnected = false
//
// if (!this.configuration.preserveConnection) {
// this.configuration.websocketProvider.disconnect()
// }
//
}

@@ -407,3 +406,3 @@

this.isAuthenticated = false
this.isConnected = true
// this.isConnected = true

@@ -454,9 +453,9 @@ this.emit('open', { event })

send(message: ConstructableOutgoingMessage, args: any, broadcast = false) {
if (!this.isConnected) {
return
}
// if (!this.isConnected) {
// return
// }
if (broadcast) {
this.mux(() => { this.broadcast(message, args) })
}
// if (broadcast) {
// this.mux(() => { this.broadcast(message, args) })
// }

@@ -519,3 +518,3 @@ const messageSender = new MessageSender(message, args)

this.configuration.websocketProvider.off('close', this.forwardClose)
this.configuration.websocketProvider.off('status', this.boundOnStatus)
// this.configuration.websocketProvider.off('status', this.boundOnStatus)
this.configuration.websocketProvider.off('disconnect', this.configuration.onDisconnect)

@@ -527,2 +526,3 @@ this.configuration.websocketProvider.off('disconnect', this.forwardDisconnect)

this.send(CloseMessage, { documentName: this.configuration.name })
this.configuration.websocketProvider.detach(this)
this.disconnect()

@@ -540,4 +540,4 @@

this.isAuthenticated = false
this.disconnect()
this.status = WebSocketStatus.Disconnected
// this.disconnect()
// this.status = WebSocketStatus.Disconnected
}

@@ -552,70 +552,70 @@

get broadcastChannel() {
return `${this.configuration.name}`
}
// get broadcastChannel() {
// return `${this.configuration.name}`
// }
//
// broadcastChannelSubscriber(data: ArrayBuffer) {
// this.mux(() => {
// const message = new IncomingMessage(data)
//
// const documentName = message.readVarString()
//
// message.writeVarString(documentName)
//
// new MessageReceiver(message)
// .setBroadcasted(true)
// .apply(this, false)
// })
// }
broadcastChannelSubscriber(data: ArrayBuffer) {
this.mux(() => {
const message = new IncomingMessage(data)
// subscribeToBroadcastChannel() {
// if (!this.subscribedToBroadcastChannel) {
// bc.subscribe(this.broadcastChannel, this.boundBroadcastChannelSubscriber)
// this.subscribedToBroadcastChannel = true
// }
//
// this.mux(() => {
// this.broadcast(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name })
// this.broadcast(SyncStepTwoMessage, { document: this.document, documentName: this.configuration.name })
// this.broadcast(QueryAwarenessMessage, { document: this.document, documentName: this.configuration.name })
// if (this.awareness) {
// this.broadcast(AwarenessMessage, {
// awareness: this.awareness,
// clients: [this.document.clientID],
// document: this.document,
// documentName: this.configuration.name,
// })
// }
// })
// }
//
// disconnectBroadcastChannel() {
// // broadcast message with local awareness state set to null (indicating disconnect)
// if (this.awareness) {
// this.send(AwarenessMessage, {
// awareness: this.awareness,
// clients: [this.document.clientID],
// states: new Map(),
// documentName: this.configuration.name,
// }, true)
// }
//
// if (this.subscribedToBroadcastChannel) {
// bc.unsubscribe(this.broadcastChannel, this.boundBroadcastChannelSubscriber)
// this.subscribedToBroadcastChannel = false
// }
// }
const documentName = message.readVarString()
// broadcast(Message: ConstructableOutgoingMessage, args?: any) {
// if (!this.configuration.broadcast) {
// return
// }
//
// if (!this.subscribedToBroadcastChannel) {
// return
// }
//
// new MessageSender(Message, args).broadcast(this.broadcastChannel)
// }
message.writeVarString(documentName)
new MessageReceiver(message)
.setBroadcasted(true)
.apply(this, false)
})
}
subscribeToBroadcastChannel() {
if (!this.subscribedToBroadcastChannel) {
bc.subscribe(this.broadcastChannel, this.boundBroadcastChannelSubscriber)
this.subscribedToBroadcastChannel = true
}
this.mux(() => {
this.broadcast(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name })
this.broadcast(SyncStepTwoMessage, { document: this.document, documentName: this.configuration.name })
this.broadcast(QueryAwarenessMessage, { document: this.document, documentName: this.configuration.name })
if (this.awareness) {
this.broadcast(AwarenessMessage, {
awareness: this.awareness,
clients: [this.document.clientID],
document: this.document,
documentName: this.configuration.name,
})
}
})
}
disconnectBroadcastChannel() {
// broadcast message with local awareness state set to null (indicating disconnect)
if (this.awareness) {
this.send(AwarenessMessage, {
awareness: this.awareness,
clients: [this.document.clientID],
states: new Map(),
documentName: this.configuration.name,
}, true)
}
if (this.subscribedToBroadcastChannel) {
bc.unsubscribe(this.broadcastChannel, this.boundBroadcastChannelSubscriber)
this.subscribedToBroadcastChannel = false
}
}
broadcast(Message: ConstructableOutgoingMessage, args?: any) {
if (!this.configuration.broadcast) {
return
}
if (!this.subscribedToBroadcastChannel) {
return
}
new MessageSender(Message, args).broadcast(this.broadcastChannel)
}
setAwarenessField(key: string, value: any) {

@@ -622,0 +622,0 @@ if (!this.awareness) {

@@ -7,10 +7,10 @@ import {

import * as url from 'lib0/url'
import type { MessageEvent } from 'ws'
import { Event } from 'ws'
import type { MessageEvent , Event } from 'ws'
import EventEmitter from './EventEmitter.js'
import { HocuspocusProvider } from './HocuspocusProvider.js'
import type { HocuspocusProvider } from './HocuspocusProvider.js'
import type {
onAwarenessChangeParameters, onAwarenessUpdateParameters,
onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters} from './types.js'
import {
WebSocketStatus,
onAwarenessChangeParameters, onAwarenessUpdateParameters,
onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters,
} from './types.js'

@@ -232,7 +232,5 @@ import { IncomingMessage } from './IncomingMessage.js'

if (this.receivedOnStatusPayload) {
provider.onStatus(this.receivedOnStatusPayload)
}
return connectPromise
// if (this.receivedOnStatusPayload) {
// provider.onStatus(this.receivedOnStatusPayload)
// }
}

@@ -306,2 +304,3 @@

// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
attachWebSocketListeners(ws: HocusPocusWebSocket, reject: Function) {

@@ -308,0 +307,0 @@ const { identifier } = ws

@@ -0,1 +1,3 @@

import type {
Decoder} from 'lib0/decoding'
import {

@@ -7,6 +9,6 @@ createDecoder,

readVarString,
Decoder,
} from 'lib0/decoding'
import type {
Encoder} from 'lib0/encoding'
import {
Encoder,
createEncoder,

@@ -18,3 +20,3 @@ writeVarUint,

} from 'lib0/encoding'
import { MessageType } from './types.js'
import type { MessageType } from './types.js'

@@ -21,0 +23,0 @@ export class IncomingMessage {

@@ -5,4 +5,4 @@ import { readAuthMessage } from '@hocuspocus/common'

import { messageYjsSyncStep2, readSyncMessage } from 'y-protocols/sync'
import { HocuspocusProvider } from './HocuspocusProvider.js'
import { IncomingMessage } from './IncomingMessage.js'
import type { HocuspocusProvider } from './HocuspocusProvider.js'
import type { IncomingMessage } from './IncomingMessage.js'
import { OutgoingMessage } from './OutgoingMessage.js'

@@ -9,0 +9,0 @@ import { MessageType } from './types.js'

@@ -1,4 +0,5 @@

import { Encoder, toUint8Array } from 'lib0/encoding'
import type { Encoder} from 'lib0/encoding'
import { toUint8Array } from 'lib0/encoding'
import * as bc from 'lib0/broadcastchannel'
import { ConstructableOutgoingMessage } from './types.js'
import type { ConstructableOutgoingMessage } from './types.js'

@@ -5,0 +6,0 @@ export class MessageSender {

@@ -1,3 +0,4 @@

import { Encoder, createEncoder, toUint8Array } from 'lib0/encoding'
import { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js'
import type { Encoder} from 'lib0/encoding'
import { createEncoder, toUint8Array } from 'lib0/encoding'
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.js'

@@ -4,0 +5,0 @@ export class OutgoingMessage implements OutgoingMessageInterface {

import { writeVarString, writeVarUint } from 'lib0/encoding'
import { writeAuthentication } from '@hocuspocus/common'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -5,0 +6,0 @@

import * as encoding from 'lib0/encoding'
import { encodeAwarenessUpdate } from 'y-protocols/awareness'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -5,0 +6,0 @@

import * as encoding from 'lib0/encoding'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -4,0 +5,0 @@

import * as encoding from 'lib0/encoding'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -4,0 +5,0 @@

import { writeVarString, writeVarUint } from 'lib0/encoding'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -4,0 +5,0 @@

import * as encoding from 'lib0/encoding'
import * as syncProtocol from 'y-protocols/sync'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -5,0 +6,0 @@

import * as encoding from 'lib0/encoding'
import * as syncProtocol from 'y-protocols/sync'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -5,0 +6,0 @@

import { writeVarString, writeVarUint } from 'lib0/encoding'
import { writeUpdate } from 'y-protocols/sync'
import { MessageType, OutgoingMessageArguments } from '../types.js'
import type { OutgoingMessageArguments } from '../types.js'
import { MessageType } from '../types.js'
import { OutgoingMessage } from '../OutgoingMessage.js'

@@ -5,0 +6,0 @@

import type { AbstractType, YArrayEvent } from 'yjs'
import * as Y from 'yjs'
import { uuidv4 } from 'lib0/random'
import type {
HocuspocusProviderConfiguration} from './HocuspocusProvider.js'
import {
HocuspocusProvider,
HocuspocusProviderConfiguration,
} from './HocuspocusProvider.js'

@@ -8,0 +9,0 @@

@@ -0,4 +1,5 @@

import type {
CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocketConfiguration} from './HocuspocusProviderWebsocket.js'
import {
CompleteHocuspocusProviderWebsocketConfiguration,
HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration,
HocuspocusProviderWebsocket,
} from './HocuspocusProviderWebsocket.js'

@@ -5,0 +6,0 @@

@@ -1,14 +0,14 @@

import { Encoder } from 'lib0/encoding'
import type { Encoder } from 'lib0/encoding'
import type { Event, MessageEvent } from 'ws'
import { Awareness } from 'y-protocols/awareness'
import * as Y from 'yjs'
import { CloseEvent } from '@hocuspocus/common'
import { IncomingMessage } from './IncomingMessage.js'
import { OutgoingMessage } from './OutgoingMessage.js'
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js'
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js'
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js'
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js'
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js'
import { UpdateMessage } from './OutgoingMessages/UpdateMessage.js'
import type { Awareness } from 'y-protocols/awareness'
import type * as Y from 'yjs'
import type { CloseEvent } from '@hocuspocus/common'
import type { IncomingMessage } from './IncomingMessage.js'
import type { OutgoingMessage } from './OutgoingMessage.js'
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.js'
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.js'
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.js'
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.js'
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.js'
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.js'

@@ -15,0 +15,0 @@ export enum MessageType {

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