@hocuspocus/transformer
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,4 +0,5 @@ | ||
import RedisClient from 'ioredis'; | ||
import RedisClient, { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis'; | ||
import Redlock from 'redlock'; | ||
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, onListenPayload } from '@hocuspocus/server'; | ||
import { Document, Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, Debugger, onConfigurePayload, onListenPayload, beforeBroadcastStatelessPayload } from '@hocuspocus/server'; | ||
export declare type RedisInstance = RedisClient.Cluster | RedisClient.Redis; | ||
export interface Configuration { | ||
@@ -14,2 +15,14 @@ /** | ||
/** | ||
* Redis Cluster | ||
*/ | ||
nodes?: ClusterNode[]; | ||
/** | ||
* Duplicate from an existed Redis instance | ||
*/ | ||
redis?: RedisInstance; | ||
/** | ||
* Redis instance creator | ||
*/ | ||
createClient?: () => RedisInstance; | ||
/** | ||
* Options passed directly to Redis constructor | ||
@@ -19,3 +32,3 @@ * | ||
*/ | ||
options?: RedisClient.RedisOptions; | ||
options?: ClusterOptions | RedisOptions; | ||
/** | ||
@@ -43,4 +56,4 @@ * An unique instance name, required to filter messages in Redis. | ||
configuration: Configuration; | ||
pub: RedisClient.Redis; | ||
sub: RedisClient.Redis; | ||
pub: RedisInstance; | ||
sub: RedisInstance; | ||
documents: Map<string, Document>; | ||
@@ -97,2 +110,3 @@ redlock: Redlock; | ||
onDisconnect: ({ documentName, clientsCount }: onDisconnectPayload) => Promise<void>; | ||
beforeBroadcastStateless(data: beforeBroadcastStatelessPayload): Promise<number>; | ||
/** | ||
@@ -99,0 +113,0 @@ * Kill the Redlock connection immediately. |
@@ -6,3 +6,3 @@ import * as Y from 'yjs'; | ||
import EventEmitter from './EventEmitter'; | ||
import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus } from './types'; | ||
import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSyncedParameters, WebSocketStatus } from './types'; | ||
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.'; | ||
@@ -102,2 +102,3 @@ export declare type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>> & Partial<CompleteHocuspocusProviderConfiguration>; | ||
onAwarenessChange: (data: onAwarenessChangeParameters) => void; | ||
onStateless: (data: onStatelessParameters) => void; | ||
/** | ||
@@ -141,2 +142,3 @@ * Don’t output any warnings. | ||
registerEventListeners(): void; | ||
sendStateless(payload: string): void; | ||
documentUpdateHandler(update: Uint8Array, origin: any): void; | ||
@@ -150,2 +152,3 @@ awarenessUpdateHandler({ added, updated, removed }: any, origin: any): void; | ||
set synced(state: boolean); | ||
receiveStateless(payload: string): void; | ||
get isAuthenticationRequired(): boolean; | ||
@@ -152,0 +155,0 @@ disconnect(): void; |
@@ -17,3 +17,4 @@ import { Awareness } from 'y-protocols/awareness'; | ||
Auth = 2, | ||
QueryAwareness = 3 | ||
QueryAwareness = 3, | ||
Stateless = 5 | ||
} | ||
@@ -38,2 +39,3 @@ export declare enum WebSocketStatus { | ||
update: any; | ||
payload: string; | ||
encoder: Encoder; | ||
@@ -76,2 +78,5 @@ } | ||
}; | ||
export declare type onStatelessParameters = { | ||
payload: string; | ||
}; | ||
export declare type StatesArray = { | ||
@@ -78,0 +83,0 @@ clientId: number; |
@@ -8,2 +8,3 @@ /// <reference types="node" /> | ||
import { Debugger } from './Debugger'; | ||
import { onStatelessPayload } from './types'; | ||
export declare class Connection { | ||
@@ -31,2 +32,6 @@ webSocket: WebSocket; | ||
/** | ||
* Set a callback that will be triggered when an stateless message is received | ||
*/ | ||
onStatelessCallback(callback: (payload: onStatelessPayload) => Promise<void>): Connection; | ||
/** | ||
* Set a callback that will be triggered before an message is handled | ||
@@ -40,2 +45,6 @@ */ | ||
/** | ||
* Send a stateless message with payload | ||
*/ | ||
sendStateless(payload: string): void; | ||
/** | ||
* Graceful wrapper around the WebSocket close method. | ||
@@ -42,0 +51,0 @@ */ |
@@ -11,2 +11,3 @@ import WebSocket from 'ws'; | ||
onUpdate: (document: Document, connection: Connection, update: Uint8Array) => void; | ||
beforeBroadcastStateless: (document: Document, stateless: string) => void; | ||
}; | ||
@@ -38,2 +39,6 @@ connections: Map<WebSocket, { | ||
/** | ||
* Set a callback that will be triggered before a stateless message is broadcasted | ||
*/ | ||
beforeBroadcastStateless(callback: (document: Document, stateless: string) => void): Document; | ||
/** | ||
* Register a connection and a set of clients on this document keyed by the | ||
@@ -80,3 +85,7 @@ * underlying websocket connection | ||
private handleUpdate; | ||
/** | ||
* Broadcast stateless message to all connections | ||
*/ | ||
broadcastStateless(payload: string): void; | ||
} | ||
export default Document; |
@@ -16,2 +16,3 @@ import { Decoder } from 'lib0/decoding'; | ||
readVarUint(): number; | ||
readVarString(): string; | ||
toUint8Array(): Uint8Array; | ||
@@ -18,0 +19,0 @@ writeVarUint(type: MessageType): void; |
@@ -17,3 +17,5 @@ import { Encoder } from 'lib0/encoding'; | ||
writeUpdate(update: Uint8Array): OutgoingMessage; | ||
writeStateless(payload: string): OutgoingMessage; | ||
writeBroadcastStateless(payload: string): OutgoingMessage; | ||
toUint8Array(): Uint8Array; | ||
} |
@@ -7,2 +7,3 @@ /// <reference types="node" /> | ||
import { Hocuspocus } from './Hocuspocus'; | ||
import Connection from './Connection'; | ||
export declare enum MessageType { | ||
@@ -14,3 +15,5 @@ Unknown = -1, | ||
QueryAwareness = 3, | ||
SyncReply = 4 | ||
SyncReply = 4, | ||
Stateless = 5, | ||
BroadcastStateless = 6 | ||
} | ||
@@ -38,2 +41,4 @@ export interface AwarenessUpdate { | ||
beforeHandleMessage?(data: beforeHandleMessagePayload): Promise<any>; | ||
beforeBroadcastStateless?(data: beforeBroadcastStatelessPayload): Promise<any>; | ||
onStateless?(payload: onStatelessPayload): Promise<any>; | ||
onChange?(data: onChangePayload): Promise<any>; | ||
@@ -47,4 +52,4 @@ onStoreDocument?(data: onStoreDocumentPayload): Promise<any>; | ||
} | ||
export declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | '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 declare type HookName = 'onConfigure' | 'onListen' | 'onUpgrade' | 'onConnect' | 'connected' | 'onAuthenticate' | 'onLoadDocument' | 'afterLoadDocument' | 'beforeHandleMessage' | 'beforeBroadcastStateless' | 'onStateless' | 'onChange' | 'onStoreDocument' | 'afterStoreDocument' | 'onAwarenessUpdate' | 'onRequest' | 'onDisconnect' | 'onDestroy'; | ||
export declare type HookPayload = onConfigurePayload | onListenPayload | onUpgradePayload | onConnectPayload | connectedPayload | onAuthenticatePayload | onLoadDocumentPayload | onStatelessPayload | beforeHandleMessagePayload | beforeBroadcastStatelessPayload | onChangePayload | onStoreDocumentPayload | afterStoreDocumentPayload | onAwarenessUpdatePayload | onRequestPayload | onDisconnectPayload | onDestroyPayload; | ||
export interface Configuration extends Extension { | ||
@@ -101,2 +106,8 @@ /** | ||
} | ||
export interface onStatelessPayload { | ||
connection: Connection; | ||
documentName: string; | ||
document: Document; | ||
payload: string; | ||
} | ||
export interface onAuthenticatePayload { | ||
@@ -171,2 +182,7 @@ documentName: string; | ||
} | ||
export interface beforeBroadcastStatelessPayload { | ||
document: Document; | ||
documentName: string; | ||
payload: string; | ||
} | ||
export interface onStoreDocumentPayload { | ||
@@ -173,0 +189,0 @@ clientsCount: number; |
import { Doc } from 'yjs'; | ||
import { Schema } from 'prosemirror-model'; | ||
import { Schema } from '@tiptap/pm/model'; | ||
import { Transformer } from './types'; | ||
@@ -4,0 +4,0 @@ declare class Prosemirror implements Transformer { |
{ | ||
"name": "@hocuspocus/transformer", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "hocuspocus transformation utilities", | ||
@@ -31,10 +31,13 @@ "homepage": "https://hocuspocus.dev", | ||
"@tiptap/core": "^2.0.0-beta.217", | ||
"@tiptap/starter-kit": "^2.0.0-beta.183" | ||
"@tiptap/starter-kit": "^2.0.0-beta.217" | ||
}, | ||
"peerDependencies": { | ||
"prosemirror-model": "^1.16.1", | ||
"@tiptap/pm": "^2.0.0-beta.217", | ||
"y-prosemirror": "^1.0.15", | ||
"yjs": "^13.5.29" | ||
}, | ||
"devDependencies": { | ||
"@tiptap/pm": "^2.0.0-beta.217" | ||
}, | ||
"gitHead": "8f2e9df95de9968d70622ea8697c303a333b6cb3" | ||
} |
import { Doc, applyUpdate, encodeStateAsUpdate } from 'yjs' | ||
import { yDocToProsemirrorJSON, prosemirrorJSONToYDoc } from 'y-prosemirror' | ||
import { Schema } from 'prosemirror-model' | ||
import { Schema } from '@tiptap/pm/model' | ||
import { Transformer } from './types' | ||
@@ -5,0 +5,0 @@ |
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
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
685713
126
7001
1
1