@hocuspocus/extension-database
Advanced tools
Comparing version 2.2.3 to 2.3.0
@@ -72,3 +72,3 @@ import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'; | ||
/** | ||
* Once a document is laoded, subscribe to the channel in Redis. | ||
* Once a document is loaded, subscribe to the channel in Redis. | ||
*/ | ||
@@ -75,0 +75,0 @@ afterLoadDocument({ documentName, document }: afterLoadDocumentPayload): Promise<unknown>; |
@@ -1,13 +0,13 @@ | ||
import * as Y from 'yjs'; | ||
import { Awareness } from 'y-protocols/awareness'; | ||
import * as mutex from 'lib0/mutex'; | ||
import type { CloseEvent, Event, MessageEvent } from 'ws'; | ||
import { Awareness } from 'y-protocols/awareness'; | ||
import * as Y from 'yjs'; | ||
import EventEmitter from './EventEmitter.js'; | ||
import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters, WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters } from './types.js'; | ||
import { CompleteHocuspocusProviderWebsocketConfiguration, HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.js'; | ||
import { ConstructableOutgoingMessage, WebSocketStatus, 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'>>); | ||
export interface CompleteHocuspocusProviderConfiguration { | ||
/** | ||
* The identifier/name of your document | ||
*/ | ||
* The identifier/name of your document | ||
*/ | ||
name: string; | ||
@@ -62,2 +62,10 @@ /** | ||
quiet: boolean; | ||
/** | ||
* Pass `false` to start the connection manually. | ||
*/ | ||
connect: boolean; | ||
/** | ||
* Pass `false` to close the connection manually. | ||
*/ | ||
preserveConnection: boolean; | ||
} | ||
@@ -77,3 +85,3 @@ export declare class HocuspocusProvider extends EventEmitter { | ||
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void; | ||
boundBeforeUnload: () => void; | ||
boundPageUnload: () => void; | ||
boundOnOpen: (event: Event) => Promise<void>; | ||
@@ -93,5 +101,6 @@ boundOnMessage: (event: MessageEvent) => void; | ||
get hasUnsyncedChanges(): boolean; | ||
updateUnsyncedChanges(unsyncedChanges?: number): void; | ||
incrementUnsyncedChanges(): void; | ||
decrementUnsyncedChanges(): void; | ||
forceSync(): void; | ||
beforeUnload(): void; | ||
pageUnload(): void; | ||
registerEventListeners(): void; | ||
@@ -101,2 +110,8 @@ sendStateless(payload: string): void; | ||
awarenessUpdateHandler({ added, updated, removed }: any, origin: any): void; | ||
/** | ||
* Indicates whether a first handshake with the server has been established | ||
* | ||
* Note: this does not mean all updates from the client have been persisted to the backend. For this, | ||
* use `hasUnsyncedChanges`. | ||
*/ | ||
get synced(): boolean; | ||
@@ -103,0 +118,0 @@ set synced(state: boolean); |
@@ -5,4 +5,4 @@ import * as mutex from 'lib0/mutex'; | ||
import EventEmitter from './EventEmitter.js'; | ||
import { onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters } from './types.js'; | ||
import { HocuspocusProvider } from './HocuspocusProvider.js'; | ||
import { WebSocketStatus, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.js'; | ||
export type HocuspocusProviderWebsocketConfiguration = Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> & Partial<CompleteHocuspocusProviderWebsocketConfiguration>; | ||
@@ -80,2 +80,3 @@ export interface CompleteHocuspocusProviderWebsocketConfiguration { | ||
export declare class HocuspocusProviderWebsocket extends EventEmitter { | ||
private messageQueue; | ||
configuration: CompleteHocuspocusProviderWebsocketConfiguration; | ||
@@ -82,0 +83,0 @@ subscribedToBroadcastChannel: boolean; |
@@ -8,4 +8,5 @@ import { HocuspocusProvider } from './HocuspocusProvider.js'; | ||
setBroadcasted(value: boolean): this; | ||
apply(provider: HocuspocusProvider, emitSynced?: boolean): void; | ||
apply(provider: HocuspocusProvider, emitSynced: boolean): void; | ||
private applySyncMessage; | ||
applySyncStatusMessage(provider: HocuspocusProvider, applied: boolean): void; | ||
private applyAwarenessMessage; | ||
@@ -12,0 +13,0 @@ private applyAuthMessage; |
@@ -26,4 +26,4 @@ import type { AbstractType, YArrayEvent } from 'yjs'; | ||
isAutoVersioning(): boolean; | ||
enableAutoVersioning(): number; | ||
disableAutoVersioning(): number; | ||
enableAutoVersioning(): 1; | ||
disableAutoVersioning(): 0; | ||
} |
@@ -8,3 +8,3 @@ /// <reference types="node" /> | ||
import Document from './Document.js'; | ||
import { Configuration, ConnectionConfiguration, HookName, HookPayload, onListenPayload, onStoreDocumentPayload } from './types.js'; | ||
import { Configuration, ConnectionConfiguration, HookName, HookPayloadByName, onListenPayload, onStoreDocumentPayload } from './types.js'; | ||
export declare const defaultConfiguration: { | ||
@@ -95,3 +95,4 @@ name: null; | ||
*/ | ||
hooks(name: HookName, payload: HookPayload, callback?: Function | null): Promise<any>; | ||
hooks<T extends HookName>(name: T, payload: HookPayloadByName[T], callback?: Function | null): Promise<any>; | ||
unloadDocument(document: Document): void; | ||
enableDebugging(): void; | ||
@@ -98,0 +99,0 @@ enableMessageLogging(): void; |
import Connection from './Connection.js'; | ||
import { IncomingMessage } from './IncomingMessage.js'; | ||
import { Debugger } from './Debugger.js'; | ||
import Document from './Document.js'; | ||
import { IncomingMessage } from './IncomingMessage.js'; | ||
export declare class MessageReceiver { | ||
@@ -6,0 +6,0 @@ message: IncomingMessage; |
@@ -19,3 +19,4 @@ import { Encoder } from 'lib0/encoding'; | ||
writeBroadcastStateless(payload: string): OutgoingMessage; | ||
writeSyncStatus(updateSaved: boolean): OutgoingMessage; | ||
toUint8Array(): Uint8Array; | ||
} |
@@ -7,5 +7,5 @@ /// <reference types="node" /> | ||
import { Awareness } from 'y-protocols/awareness'; | ||
import Connection from './Connection.js'; | ||
import Document from './Document.js'; | ||
import { Hocuspocus } from './Hocuspocus.js'; | ||
import Connection from './Connection.js'; | ||
export declare enum MessageType { | ||
@@ -20,3 +20,4 @@ Unknown = -1, | ||
BroadcastStateless = 6, | ||
CLOSE = 7 | ||
CLOSE = 7, | ||
SyncStatus = 8 | ||
} | ||
@@ -52,6 +53,27 @@ export interface AwarenessUpdate { | ||
onDisconnect?(data: onDisconnectPayload): Promise<any>; | ||
afterUnloadDocument?(data: onLoadDocumentPayload): Promise<any>; | ||
onDestroy?(data: onDestroyPayload): Promise<any>; | ||
} | ||
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy'; | ||
export type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onStatelessPayload | beforeHandleMessagePayload | beforeBroadcastStatelessPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload; | ||
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy'; | ||
export type HookPayloadByName = { | ||
onConfigure: onConfigurePayload; | ||
onListen: onListenPayload; | ||
onUpgrade: onUpgradePayload; | ||
onConnect: onConnectPayload; | ||
connected: connectedPayload; | ||
onAuthenticate: onAuthenticatePayload; | ||
onLoadDocument: onLoadDocumentPayload; | ||
afterLoadDocument: onLoadDocumentPayload; | ||
beforeHandleMessage: beforeHandleMessagePayload; | ||
beforeBroadcastStateless: beforeBroadcastStatelessPayload; | ||
onStateless: onStatelessPayload; | ||
onChange: onChangePayload; | ||
onStoreDocument: onStoreDocumentPayload; | ||
afterStoreDocument: afterStoreDocumentPayload; | ||
onAwarenessUpdate: onAwarenessUpdatePayload; | ||
onRequest: onRequestPayload; | ||
onDisconnect: onDisconnectPayload; | ||
afterUnloadDocument: afterUnloadDocumentPayload; | ||
onDestroy: onDestroyPayload; | ||
}; | ||
export interface Configuration extends Extension { | ||
@@ -204,3 +226,2 @@ /** | ||
export interface onAwarenessUpdatePayload { | ||
clientsCount: number; | ||
context: any; | ||
@@ -212,3 +233,2 @@ document: Document; | ||
requestParameters: URLSearchParams; | ||
update: Uint8Array; | ||
socketId: string; | ||
@@ -272,2 +292,6 @@ added: number[]; | ||
} | ||
export interface afterUnloadDocumentPayload { | ||
instance: Hocuspocus; | ||
documentName: string; | ||
} | ||
export interface DirectConnection { | ||
@@ -274,0 +298,0 @@ transact(transaction: (document: Document) => void): Promise<void>; |
{ | ||
"name": "@hocuspocus/extension-database", | ||
"description": "a generic Hocuspocus persistence driver for the database", | ||
"version": "2.2.3", | ||
"version": "2.3.0", | ||
"homepage": "https://hocuspocus.dev", | ||
@@ -30,6 +30,6 @@ "keywords": [ | ||
"dependencies": { | ||
"@hocuspocus/server": "^2.2.3" | ||
"@hocuspocus/server": "^2.3.0" | ||
}, | ||
"peerDependencies": { | ||
"yjs": "^13.5.29" | ||
"yjs": "^13.6.4" | ||
}, | ||
@@ -36,0 +36,0 @@ "publishConfig": { |
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
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
71518
133
1880
Updated@hocuspocus/server@^2.3.0