@hocuspocus/server
Advanced tools
Comparing version 2.12.0-rc.0 to 2.12.1-rc.0
@@ -1,2 +0,3 @@ | ||
import { type MessageEvent, Event } from 'ws'; | ||
import type { MessageEvent } from 'ws'; | ||
import { Event } from 'ws'; | ||
import EventEmitter from './EventEmitter.js'; | ||
@@ -3,0 +4,0 @@ import { HocuspocusProvider } from './HocuspocusProvider.js'; |
@@ -41,2 +41,3 @@ /// <reference types="node" /> | ||
onAuthenticate?(data: onAuthenticatePayload): Promise<any>; | ||
onCreateDocument?(data: onCreateDocumentPayload): Promise<any>; | ||
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>; | ||
@@ -56,3 +57,3 @@ afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>; | ||
} | ||
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy'; | ||
export type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'afterUnloadDocument' | 'onDestroy'; | ||
export type HookPayloadByName = { | ||
@@ -65,2 +66,3 @@ onConfigure: onConfigurePayload; | ||
onAuthenticate: onAuthenticatePayload; | ||
onCreateDocument: onCreateDocumentPayload; | ||
onLoadDocument: onLoadDocumentPayload; | ||
@@ -148,2 +150,3 @@ afterLoadDocument: afterLoadDocumentPayload; | ||
requestParameters: URLSearchParams; | ||
request: IncomingMessage; | ||
socketId: string; | ||
@@ -153,2 +156,11 @@ token: string; | ||
} | ||
export interface onCreateDocumentPayload { | ||
context: any; | ||
documentName: string; | ||
instance: Hocuspocus; | ||
requestHeaders: IncomingHttpHeaders; | ||
requestParameters: URLSearchParams; | ||
socketId: string; | ||
connection: ConnectionConfiguration; | ||
} | ||
export interface onConnectPayload { | ||
@@ -155,0 +167,0 @@ context: any; |
{ | ||
"name": "@hocuspocus/server", | ||
"description": "plug & play collaboration backend", | ||
"version": "2.12.0-rc.0", | ||
"version": "2.12.1-rc.0", | ||
"homepage": "https://hocuspocus.dev", | ||
@@ -32,3 +32,3 @@ "keywords": [ | ||
"dependencies": { | ||
"@hocuspocus/common": "^2.12.0-rc.0", | ||
"@hocuspocus/common": "^2.12.1-rc.0", | ||
"async-lock": "^1.3.1", | ||
@@ -35,0 +35,0 @@ "kleur": "^4.1.4", |
@@ -65,2 +65,3 @@ import { IncomingMessage } from 'http' | ||
onChange: () => new Promise(r => r(null)), | ||
onCreateDocument: () => new Promise(r => r(null)), | ||
onLoadDocument: () => new Promise(r => r(null)), | ||
@@ -426,3 +427,19 @@ onStoreDocument: () => new Promise(r => r(null)), | ||
const document = new Document(documentName, this.debugger, this.configuration.yDocOptions) | ||
const requestHeaders = request.headers ?? {} | ||
const requestParameters = getParameters(request) | ||
const yDocOptions = await this.hooks('onCreateDocument', { | ||
documentName, | ||
requestHeaders, | ||
requestParameters, | ||
connection, | ||
context, | ||
socketId, | ||
instance: this, | ||
}) | ||
const document = new Document(documentName, this.debugger, { | ||
...this.configuration.yDocOptions, | ||
...yDocOptions, | ||
}) | ||
this.documents.set(documentName, document) | ||
@@ -437,4 +454,4 @@ | ||
socketId, | ||
requestHeaders: request.headers ?? {}, | ||
requestParameters: getParameters(request), | ||
requestHeaders, | ||
requestParameters, | ||
} | ||
@@ -441,0 +458,0 @@ |
@@ -44,2 +44,3 @@ import { | ||
onAuthenticate?(data: onAuthenticatePayload): Promise<any>; | ||
onCreateDocument?(data: onCreateDocumentPayload): Promise<any>; | ||
onLoadDocument?(data: onLoadDocumentPayload): Promise<any>; | ||
@@ -67,2 +68,3 @@ afterLoadDocument?(data: afterLoadDocumentPayload): Promise<any>; | ||
'onAuthenticate' | | ||
'onCreateDocument' | | ||
'onLoadDocument' | | ||
@@ -89,2 +91,3 @@ 'afterLoadDocument' | | ||
onAuthenticate: onAuthenticatePayload, | ||
onCreateDocument: onCreateDocumentPayload | ||
onLoadDocument: onLoadDocumentPayload, | ||
@@ -179,2 +182,3 @@ afterLoadDocument: afterLoadDocumentPayload, | ||
requestParameters: URLSearchParams, | ||
request: IncomingMessage, | ||
socketId: string, | ||
@@ -187,2 +191,14 @@ token: string, | ||
// see https://github.com/ueberdosis/hocuspocus/pull/607#issuecomment-1553559805 | ||
export interface onCreateDocumentPayload { | ||
context: any | ||
documentName: string | ||
instance: Hocuspocus | ||
requestHeaders: IncomingHttpHeaders | ||
requestParameters: URLSearchParams | ||
socketId: string | ||
connection: ConnectionConfiguration | ||
} | ||
// @todo Change 'connection' to 'connectionConfig' in next major release | ||
// see https://github.com/ueberdosis/hocuspocus/pull/607#issuecomment-1553559805 | ||
export interface onConnectPayload { | ||
@@ -189,0 +205,0 @@ context: 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 too big to display
Sorry, the diff of this file is not supported yet
815905
9647