@hocuspocus/transformer
Advanced tools
Comparing version 1.0.0-alpha.23 to 1.0.0-beta.2
@@ -1,2 +0,2 @@ | ||
import { Extension, onChangePayload, onLoadDocumentPayload, storePayload } from '@hocuspocus/server'; | ||
import { Extension, onChangePayload, onLoadDocumentPayload, storePayload, fetchPayload } from '@hocuspocus/server'; | ||
export interface DatabaseConfiguration { | ||
@@ -7,5 +7,3 @@ /** | ||
*/ | ||
fetch: ({ documentName }: { | ||
documentName: string; | ||
}) => Promise<Uint8Array | null>; | ||
fetch: (data: fetchPayload) => Promise<Uint8Array | null>; | ||
/** | ||
@@ -28,3 +26,3 @@ * Pass a function to store updates in your database. | ||
*/ | ||
onLoadDocument({ document, documentName }: onLoadDocumentPayload): Promise<any>; | ||
onLoadDocument(data: onLoadDocumentPayload): Promise<any>; | ||
/** | ||
@@ -31,0 +29,0 @@ * Store new updates in the database. |
import RedisClient from 'ioredis'; | ||
import Redlock from 'redlock'; | ||
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, Debugger, onConfigurePayload, onListenPayload } from '@hocuspocus/server'; | ||
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, onListenPayload } from '@hocuspocus/server'; | ||
export interface Configuration { | ||
@@ -78,3 +78,3 @@ /** | ||
*/ | ||
onAwarenessUpdate({ documentName, awareness }: onAwarenessUpdatePayload): Promise<number>; | ||
onAwarenessUpdate({ documentName, awareness, added, updated, removed, }: onAwarenessUpdatePayload): Promise<number>; | ||
/** | ||
@@ -87,2 +87,6 @@ * Handle incoming messages published on all subscribed document channels. | ||
/** | ||
* if the ydoc changed, we'll need to inform other Hocuspocus servers about it. | ||
*/ | ||
onChange(data: onChangePayload): Promise<any>; | ||
/** | ||
* Make sure to *not* listen for further changes, when there’s | ||
@@ -89,0 +93,0 @@ * noone connected anymore. |
@@ -113,2 +113,3 @@ import * as Y from 'yjs'; | ||
isSynced: boolean; | ||
unsyncedChanges: number; | ||
isAuthenticated: boolean; | ||
@@ -124,3 +125,5 @@ lastMessageReceived: number; | ||
setConfiguration(configuration?: Partial<HocuspocusProviderConfiguration>): void; | ||
connect(): Promise<void>; | ||
boundConnect: () => Promise<unknown>; | ||
cancelWebsocketRetry?: () => void; | ||
connect(): Promise<unknown>; | ||
createWebSocketConnection(): Promise<unknown>; | ||
@@ -132,4 +135,7 @@ resolveConnectionAttempt(): void; | ||
get awareness(): Awareness; | ||
get hasUnsyncedChanges(): boolean; | ||
checkConnection(): void; | ||
forceSync(): void; | ||
boundBeforeUnload: () => void; | ||
beforeUnload(): void; | ||
registerEventListeners(): void; | ||
@@ -154,2 +160,3 @@ documentUpdateHandler(update: Uint8Array, origin: any): void; | ||
get broadcastChannel(): string; | ||
boundBroadcastChannelSubscriber: (data: ArrayBuffer) => void; | ||
broadcastChannelSubscriber(data: ArrayBuffer): void; | ||
@@ -156,0 +163,0 @@ subscribeToBroadcastChannel(): void; |
@@ -30,2 +30,6 @@ /// <reference types="node" /> | ||
/** | ||
* Set a callback that will be triggered before an message is handled | ||
*/ | ||
beforeHandleMessage(callback: (payload: Document, update: Uint8Array) => Promise<any>): Connection; | ||
/** | ||
* Send the given message | ||
@@ -54,2 +58,9 @@ */ | ||
/** | ||
* Handle a ws instance error, which is required to prevent | ||
* the server from crashing when one happens | ||
* See https://github.com/websockets/ws/issues/1777#issuecomment-660803472 | ||
* @private | ||
*/ | ||
private handleError; | ||
/** | ||
* Get the underlying connection instance | ||
@@ -56,0 +67,0 @@ * @deprecated |
@@ -19,6 +19,7 @@ import WebSocket from 'ws'; | ||
logger: Debugger; | ||
isLoading: boolean; | ||
/** | ||
* Constructor. | ||
*/ | ||
constructor(name: string, logger: Debugger); | ||
constructor(name: string, logger: Debugger, yDocOptions: {}); | ||
/** | ||
@@ -25,0 +26,0 @@ * Check if the Document is empty |
@@ -15,2 +15,6 @@ /// <reference types="node" /> | ||
quiet: boolean; | ||
yDocOptions: { | ||
gc: boolean; | ||
gcFilter: () => boolean; | ||
}; | ||
}; | ||
@@ -17,0 +21,0 @@ /** |
@@ -11,4 +11,4 @@ import { Awareness } from 'y-protocols/awareness'; | ||
apply(document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): void; | ||
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void): 0 | 2 | 1; | ||
readSyncMessage(message: IncomingMessage, document: Document, connection?: Connection, reply?: (message: Uint8Array) => void, requestFirstSync?: boolean): 0 | 2 | 1; | ||
applyQueryAwarenessMessage(awareness: Awareness, reply?: (message: Uint8Array) => void): void; | ||
} |
@@ -10,2 +10,3 @@ import { Encoder } from 'lib0/encoding'; | ||
createSyncMessage(): OutgoingMessage; | ||
createSyncReplyMessage(): OutgoingMessage; | ||
createAwarenessUpdateMessage(awareness: Awareness, changedClients?: Array<any>): OutgoingMessage; | ||
@@ -12,0 +13,0 @@ writeQueryAwareness(): OutgoingMessage; |
@@ -12,3 +12,4 @@ /// <reference types="node" /> | ||
Auth = 2, | ||
QueryAwareness = 3 | ||
QueryAwareness = 3, | ||
SyncReply = 4 | ||
} | ||
@@ -39,2 +40,3 @@ export interface AwarenessUpdate { | ||
afterLoadDocument?(data: onLoadDocumentPayload): Promise<any>; | ||
beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>; | ||
onChange?(data: onChangePayload): Promise<any>; | ||
@@ -52,4 +54,4 @@ onStoreDocument?(data: onStoreDocumentPayload): Promise<any>; | ||
*/ | ||
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy'; | ||
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onLoadDocumentPayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload; | ||
'onCreateDocument' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy'; | ||
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload; | ||
export interface Configuration extends Extension { | ||
@@ -86,2 +88,9 @@ /** | ||
/** | ||
* options to pass to the ydoc document | ||
*/ | ||
yDocOptions: { | ||
gc: boolean; | ||
gcFilter: () => boolean; | ||
}; | ||
/** | ||
* Function which returns the (customized) document name based on the request | ||
@@ -154,2 +163,13 @@ */ | ||
} | ||
export interface beforeHandleMessagePayload { | ||
clientsCount: number; | ||
context: any; | ||
document: Document; | ||
documentName: string; | ||
instance: Hocuspocus; | ||
requestHeaders: IncomingHttpHeaders; | ||
requestParameters: URLSearchParams; | ||
update: Uint8Array; | ||
socketId: string; | ||
} | ||
export interface onStoreDocumentPayload { | ||
@@ -187,2 +207,12 @@ clientsCount: number; | ||
}[]; | ||
export interface fetchPayload { | ||
context: any; | ||
document: Document; | ||
documentName: string; | ||
instance: Hocuspocus; | ||
requestHeaders: IncomingHttpHeaders; | ||
requestParameters: URLSearchParams; | ||
socketId: string; | ||
connection: ConnectionConfiguration; | ||
} | ||
export interface storePayload extends onStoreDocumentPayload { | ||
@@ -189,0 +219,0 @@ state: Buffer; |
{ | ||
"name": "@hocuspocus/transformer", | ||
"version": "1.0.0-alpha.23", | ||
"version": "1.0.0-beta.2", | ||
"description": "hocuspocus transformation utilities", | ||
@@ -36,3 +36,3 @@ "homepage": "https://hocuspocus.dev", | ||
}, | ||
"gitHead": "b0a04ffe8d56cfa6b269a2c8ad7f64c92b108de0" | ||
"gitHead": "8f2e9df95de9968d70622ea8697c303a333b6cb3" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
73449
120
1795
1