@hocuspocus/extension-webhook 3.4.4 → 3.4.5-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hocuspocus-webhook.cjs +169 -168
- package/dist/hocuspocus-webhook.cjs.map +1 -1
- package/dist/hocuspocus-webhook.esm.js +140 -167
- package/dist/hocuspocus-webhook.esm.js.map +1 -1
- package/dist/index.d.ts +61 -0
- package/dist/index.js +142 -0
- package/package.json +6 -6
- package/dist/node_modules/@tiptap/pm/model/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/state/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/transform/index.d.ts +0 -1
- package/dist/node_modules/@tiptap/pm/view/index.d.ts +0 -1
- package/dist/packages/common/src/CloseEvents.d.ts +0 -29
- package/dist/packages/common/src/auth.d.ts +0 -13
- package/dist/packages/common/src/awarenessStatesToArray.d.ts +0 -3
- package/dist/packages/common/src/index.d.ts +0 -4
- package/dist/packages/common/src/types.d.ts +0 -10
- package/dist/packages/extension-database/src/Database.d.ts +0 -30
- package/dist/packages/extension-database/src/index.d.ts +0 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +0 -67
- package/dist/packages/extension-logger/src/index.d.ts +0 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +0 -124
- package/dist/packages/extension-redis/src/index.d.ts +0 -1
- package/dist/packages/extension-s3/src/S3.d.ts +0 -44
- package/dist/packages/extension-s3/src/index.d.ts +0 -1
- package/dist/packages/extension-sqlite/src/SQLite.d.ts +0 -27
- package/dist/packages/extension-sqlite/src/index.d.ts +0 -1
- package/dist/packages/extension-throttle/src/index.d.ts +0 -30
- package/dist/packages/extension-webhook/src/index.d.ts +0 -56
- package/dist/packages/provider/src/EventEmitter.d.ts +0 -9
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +0 -116
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +0 -119
- package/dist/packages/provider/src/IncomingMessage.d.ts +0 -17
- package/dist/packages/provider/src/MessageReceiver.d.ts +0 -12
- package/dist/packages/provider/src/MessageSender.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +0 -8
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +0 -9
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +0 -8
- package/dist/packages/provider/src/index.d.ts +0 -3
- package/dist/packages/provider/src/types.d.ts +0 -93
- package/dist/packages/server/src/ClientConnection.d.ts +0 -63
- package/dist/packages/server/src/Connection.d.ts +0 -75
- package/dist/packages/server/src/DirectConnection.d.ts +0 -14
- package/dist/packages/server/src/Document.d.ts +0 -92
- package/dist/packages/server/src/Hocuspocus.d.ts +0 -80
- package/dist/packages/server/src/IncomingMessage.d.ts +0 -25
- package/dist/packages/server/src/MessageReceiver.d.ts +0 -11
- package/dist/packages/server/src/OutgoingMessage.d.ts +0 -23
- package/dist/packages/server/src/Server.d.ts +0 -32
- package/dist/packages/server/src/index.d.ts +0 -9
- package/dist/packages/server/src/types.d.ts +0 -342
- package/dist/packages/server/src/util/debounce.d.ts +0 -6
- package/dist/packages/server/src/util/getParameters.d.ts +0 -6
- package/dist/packages/transformer/src/Prosemirror.d.ts +0 -11
- package/dist/packages/transformer/src/Tiptap.d.ts +0 -10
- package/dist/packages/transformer/src/index.d.ts +0 -3
- package/dist/packages/transformer/src/types.d.ts +0 -5
- package/dist/playground/backend/src/default.d.ts +0 -1
- package/dist/playground/backend/src/deno.d.ts +0 -1
- package/dist/playground/backend/src/express.d.ts +0 -1
- package/dist/playground/backend/src/hono.d.ts +0 -1
- package/dist/playground/backend/src/koa.d.ts +0 -1
- package/dist/playground/backend/src/load-document.d.ts +0 -1
- package/dist/playground/backend/src/redis.d.ts +0 -1
- package/dist/playground/backend/src/s3-redis.d.ts +0 -1
- package/dist/playground/backend/src/s3.d.ts +0 -1
- package/dist/playground/backend/src/slow.d.ts +0 -1
- package/dist/playground/backend/src/tiptapcollab.d.ts +0 -1
- package/dist/playground/backend/src/webhook.d.ts +0 -1
- package/dist/playground/frontend/app/SocketContext1.d.ts +0 -2
- package/dist/playground/frontend/app/SocketContext2.d.ts +0 -2
- package/dist/playground/frontend/next.config.d.ts +0 -3
- package/dist/tests/extension-database/fetch.d.ts +0 -1
- package/dist/tests/extension-logger/onListen.d.ts +0 -1
- package/dist/tests/extension-redis/onAwarenessChange.d.ts +0 -1
- package/dist/tests/extension-redis/onChange.d.ts +0 -1
- package/dist/tests/extension-redis/onStateless.d.ts +0 -1
- package/dist/tests/extension-redis/onStoreDocument.d.ts +0 -1
- package/dist/tests/extension-s3/fetch.d.ts +0 -1
- package/dist/tests/extension-throttle/banning.d.ts +0 -1
- package/dist/tests/extension-throttle/configuration.d.ts +0 -1
- package/dist/tests/provider/hasUnsyncedChanges.d.ts +0 -1
- package/dist/tests/provider/observe.d.ts +0 -1
- package/dist/tests/provider/observeDeep.d.ts +0 -1
- package/dist/tests/provider/onAuthenticated.d.ts +0 -1
- package/dist/tests/provider/onAuthenticationFailed.d.ts +0 -1
- package/dist/tests/provider/onAwarenessChange.d.ts +0 -1
- package/dist/tests/provider/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/provider/onClose.d.ts +0 -1
- package/dist/tests/provider/onConnect.d.ts +0 -1
- package/dist/tests/provider/onDisconnect.d.ts +0 -1
- package/dist/tests/provider/onMessage.d.ts +0 -1
- package/dist/tests/provider/onOpen.d.ts +0 -1
- package/dist/tests/provider/onStateless.d.ts +0 -1
- package/dist/tests/provider/onSynced.d.ts +0 -1
- package/dist/tests/providerwebsocket/configuration.d.ts +0 -1
- package/dist/tests/server/address.d.ts +0 -1
- package/dist/tests/server/afterLoadDocument.d.ts +0 -1
- package/dist/tests/server/afterStoreDocument.d.ts +0 -1
- package/dist/tests/server/afterUnloadDocument.d.ts +0 -1
- package/dist/tests/server/beforeBroadcastStateless.d.ts +0 -1
- package/dist/tests/server/beforeHandleMessage.d.ts +0 -1
- package/dist/tests/server/beforeSync.d.ts +0 -1
- package/dist/tests/server/beforeUnloadDocument.d.ts +0 -1
- package/dist/tests/server/closeConnections.d.ts +0 -1
- package/dist/tests/server/getConnectionsCount.d.ts +0 -1
- package/dist/tests/server/getDocumentsCount.d.ts +0 -1
- package/dist/tests/server/listen.d.ts +0 -1
- package/dist/tests/server/onAuthenticate.d.ts +0 -1
- package/dist/tests/server/onAwarenessUpdate.d.ts +0 -1
- package/dist/tests/server/onChange.d.ts +0 -1
- package/dist/tests/server/onClose.d.ts +0 -1
- package/dist/tests/server/onConfigure.d.ts +0 -1
- package/dist/tests/server/onConnect.d.ts +0 -1
- package/dist/tests/server/onDestroy.d.ts +0 -1
- package/dist/tests/server/onDisconnect.d.ts +0 -1
- package/dist/tests/server/onListen.d.ts +0 -1
- package/dist/tests/server/onLoadDocument.d.ts +0 -1
- package/dist/tests/server/onRequest.d.ts +0 -1
- package/dist/tests/server/onStateless.d.ts +0 -1
- package/dist/tests/server/onStoreDocument.d.ts +0 -1
- package/dist/tests/server/onTokenSync.d.ts +0 -1
- package/dist/tests/server/onUpgrade.d.ts +0 -1
- package/dist/tests/server/openDirectConnection.d.ts +0 -1
- package/dist/tests/server/websocketError.d.ts +0 -1
- package/dist/tests/transformer/TiptapTransformer.d.ts +0 -1
- package/dist/tests/utils/createDirectory.d.ts +0 -1
- package/dist/tests/utils/flushRedis.d.ts +0 -1
- package/dist/tests/utils/index.d.ts +0 -9
- package/dist/tests/utils/newHocuspocus.d.ts +0 -2
- package/dist/tests/utils/newHocuspocusProvider.d.ts +0 -3
- package/dist/tests/utils/newHocuspocusProviderWebsocket.d.ts +0 -4
- package/dist/tests/utils/randomInteger.d.ts +0 -1
- package/dist/tests/utils/redisConnectionSettings.d.ts +0 -4
- package/dist/tests/utils/removeDirectory.d.ts +0 -1
- package/dist/tests/utils/retryableAssertion.d.ts +0 -2
- package/dist/tests/utils/sleep.d.ts +0 -1
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import type { Event, MessageEvent } from "ws";
|
|
2
|
-
import EventEmitter from "./EventEmitter.ts";
|
|
3
|
-
import type { HocuspocusProvider } from "./HocuspocusProvider.ts";
|
|
4
|
-
import { WebSocketStatus, type onAwarenessChangeParameters, type onAwarenessUpdateParameters, type onCloseParameters, type onDisconnectParameters, type onMessageParameters, type onOpenParameters, type onOutgoingMessageParameters, type onStatusParameters } from "./types.ts";
|
|
5
|
-
export type HocuspocusWebSocket = WebSocket & {
|
|
6
|
-
identifier: string;
|
|
7
|
-
};
|
|
8
|
-
export type HocusPocusWebSocket = HocuspocusWebSocket;
|
|
9
|
-
export type HocuspocusProviderWebsocketConfiguration = Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> & Partial<CompleteHocuspocusProviderWebsocketConfiguration>;
|
|
10
|
-
export interface CompleteHocuspocusProviderWebsocketConfiguration {
|
|
11
|
-
/**
|
|
12
|
-
* Whether to connect automatically when creating the provider instance. Default=true
|
|
13
|
-
*/
|
|
14
|
-
autoConnect: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* URL of your @hocuspocus/server instance
|
|
17
|
-
*/
|
|
18
|
-
url: string;
|
|
19
|
-
/**
|
|
20
|
-
* By default, trailing slashes are removed from the URL. Set this to true
|
|
21
|
-
* to preserve trailing slashes if your server configuration requires them.
|
|
22
|
-
*/
|
|
23
|
-
preserveTrailingSlash: boolean;
|
|
24
|
-
/**
|
|
25
|
-
* An optional WebSocket polyfill, for example for Node.js
|
|
26
|
-
*/
|
|
27
|
-
WebSocketPolyfill: any;
|
|
28
|
-
/**
|
|
29
|
-
* Disconnect when no message is received for the defined amount of milliseconds.
|
|
30
|
-
*/
|
|
31
|
-
messageReconnectTimeout: number;
|
|
32
|
-
/**
|
|
33
|
-
* The delay between each attempt in milliseconds. You can provide a factor to have the delay grow exponentially.
|
|
34
|
-
*/
|
|
35
|
-
delay: number;
|
|
36
|
-
/**
|
|
37
|
-
* The initialDelay is the amount of time to wait before making the first attempt. This option should typically be 0 since you typically want the first attempt to happen immediately.
|
|
38
|
-
*/
|
|
39
|
-
initialDelay: number;
|
|
40
|
-
/**
|
|
41
|
-
* The factor option is used to grow the delay exponentially.
|
|
42
|
-
*/
|
|
43
|
-
factor: number;
|
|
44
|
-
/**
|
|
45
|
-
* The maximum number of attempts or 0 if there is no limit on number of attempts.
|
|
46
|
-
*/
|
|
47
|
-
maxAttempts: number;
|
|
48
|
-
/**
|
|
49
|
-
* minDelay is used to set a lower bound of delay when jitter is enabled. This property has no effect if jitter is disabled.
|
|
50
|
-
*/
|
|
51
|
-
minDelay: number;
|
|
52
|
-
/**
|
|
53
|
-
* The maxDelay option is used to set an upper bound for the delay when factor is enabled. A value of 0 can be provided if there should be no upper bound when calculating delay.
|
|
54
|
-
*/
|
|
55
|
-
maxDelay: number;
|
|
56
|
-
/**
|
|
57
|
-
* If jitter is true then the calculated delay will be a random integer value between minDelay and the calculated delay for the current iteration.
|
|
58
|
-
*/
|
|
59
|
-
jitter: boolean;
|
|
60
|
-
/**
|
|
61
|
-
* A timeout in milliseconds. If timeout is non-zero then a timer is set using setTimeout. If the timeout is triggered then future attempts will be aborted.
|
|
62
|
-
*/
|
|
63
|
-
timeout: number;
|
|
64
|
-
handleTimeout: (() => Promise<unknown>) | null;
|
|
65
|
-
onOpen: (data: onOpenParameters) => void;
|
|
66
|
-
onConnect: () => void;
|
|
67
|
-
onMessage: (data: onMessageParameters) => void;
|
|
68
|
-
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
69
|
-
onStatus: (data: onStatusParameters) => void;
|
|
70
|
-
onDisconnect: (data: onDisconnectParameters) => void;
|
|
71
|
-
onClose: (data: onCloseParameters) => void;
|
|
72
|
-
onDestroy: () => void;
|
|
73
|
-
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
|
|
74
|
-
onAwarenessChange: (data: onAwarenessChangeParameters) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Map of attached providers keyed by documentName.
|
|
77
|
-
*/
|
|
78
|
-
providerMap: Map<string, HocuspocusProvider>;
|
|
79
|
-
}
|
|
80
|
-
export declare class HocuspocusProviderWebsocket extends EventEmitter {
|
|
81
|
-
private messageQueue;
|
|
82
|
-
configuration: CompleteHocuspocusProviderWebsocketConfiguration;
|
|
83
|
-
webSocket: HocusPocusWebSocket | null;
|
|
84
|
-
webSocketHandlers: {
|
|
85
|
-
[key: string]: any;
|
|
86
|
-
};
|
|
87
|
-
shouldConnect: boolean;
|
|
88
|
-
status: WebSocketStatus;
|
|
89
|
-
lastMessageReceived: number;
|
|
90
|
-
identifier: number;
|
|
91
|
-
intervals: any;
|
|
92
|
-
connectionAttempt: {
|
|
93
|
-
resolve: (value?: any) => void;
|
|
94
|
-
reject: (reason?: any) => void;
|
|
95
|
-
} | null;
|
|
96
|
-
constructor(configuration: HocuspocusProviderWebsocketConfiguration);
|
|
97
|
-
receivedOnOpenPayload?: Event | undefined;
|
|
98
|
-
onOpen(event: Event): Promise<void>;
|
|
99
|
-
attach(provider: HocuspocusProvider): void;
|
|
100
|
-
detach(provider: HocuspocusProvider): void;
|
|
101
|
-
setConfiguration(configuration?: Partial<HocuspocusProviderWebsocketConfiguration>): void;
|
|
102
|
-
cancelWebsocketRetry?: () => void;
|
|
103
|
-
connect(): Promise<unknown>;
|
|
104
|
-
attachWebSocketListeners(ws: HocusPocusWebSocket, reject: Function): void;
|
|
105
|
-
cleanupWebSocket(): void;
|
|
106
|
-
createWebSocketConnection(): Promise<unknown>;
|
|
107
|
-
onMessage(event: MessageEvent): void;
|
|
108
|
-
resolveConnectionAttempt(): void;
|
|
109
|
-
stopConnectionAttempt(): void;
|
|
110
|
-
rejectConnectionAttempt(): void;
|
|
111
|
-
closeTries: number;
|
|
112
|
-
checkConnection(): void;
|
|
113
|
-
get serverUrl(): string;
|
|
114
|
-
get url(): string;
|
|
115
|
-
disconnect(): void;
|
|
116
|
-
send(message: any): void;
|
|
117
|
-
onClose({ event }: onCloseParameters): void;
|
|
118
|
-
destroy(): void;
|
|
119
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { Decoder } from "lib0/decoding";
|
|
2
|
-
import type { Encoder } from "lib0/encoding";
|
|
3
|
-
import type { MessageType } from "./types.ts";
|
|
4
|
-
export declare class IncomingMessage {
|
|
5
|
-
data: any;
|
|
6
|
-
encoder: Encoder;
|
|
7
|
-
decoder: Decoder;
|
|
8
|
-
constructor(data: any);
|
|
9
|
-
peekVarString(): string;
|
|
10
|
-
readVarUint(): MessageType;
|
|
11
|
-
readVarString(): string;
|
|
12
|
-
readVarUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
13
|
-
writeVarUint(type: MessageType): void;
|
|
14
|
-
writeVarString(string: string): void;
|
|
15
|
-
writeVarUint8Array(data: Uint8Array): void;
|
|
16
|
-
length(): number;
|
|
17
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type { HocuspocusProvider } from "./HocuspocusProvider.ts";
|
|
2
|
-
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
3
|
-
export declare class MessageReceiver {
|
|
4
|
-
message: IncomingMessage;
|
|
5
|
-
constructor(message: IncomingMessage);
|
|
6
|
-
apply(provider: HocuspocusProvider, emitSynced: boolean): void;
|
|
7
|
-
private applySyncMessage;
|
|
8
|
-
applySyncStatusMessage(provider: HocuspocusProvider, applied: boolean): void;
|
|
9
|
-
private applyAwarenessMessage;
|
|
10
|
-
private applyAuthMessage;
|
|
11
|
-
private applyQueryAwarenessMessage;
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Encoder } from "lib0/encoding";
|
|
2
|
-
import type { ConstructableOutgoingMessage } from "./types.ts";
|
|
3
|
-
export declare class MessageSender {
|
|
4
|
-
encoder: Encoder;
|
|
5
|
-
message: any;
|
|
6
|
-
constructor(Message: ConstructableOutgoingMessage, args?: any);
|
|
7
|
-
create(): Uint8Array<ArrayBufferLike>;
|
|
8
|
-
send(webSocket: any): void;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Encoder } from "lib0/encoding";
|
|
2
|
-
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from "./types.ts";
|
|
3
|
-
export declare class OutgoingMessage implements OutgoingMessageInterface {
|
|
4
|
-
encoder: Encoder;
|
|
5
|
-
type?: MessageType;
|
|
6
|
-
constructor();
|
|
7
|
-
get(args: Partial<OutgoingMessageArguments>): Encoder | undefined;
|
|
8
|
-
toUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
9
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
-
import { MessageType } from "../types.ts";
|
|
3
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
|
-
export declare class AuthenticationMessage extends OutgoingMessage {
|
|
5
|
-
type: MessageType;
|
|
6
|
-
description: string;
|
|
7
|
-
get(args: Partial<OutgoingMessageArguments>): import("lib0/encoding").Encoder;
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
-
import { MessageType } from "../types.ts";
|
|
4
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
|
-
export declare class AwarenessMessage extends OutgoingMessage {
|
|
6
|
-
type: MessageType;
|
|
7
|
-
description: string;
|
|
8
|
-
get(args: Partial<OutgoingMessageArguments>): encoding.Encoder;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
-
import { MessageType } from "../types.ts";
|
|
4
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
|
-
export declare class CloseMessage extends OutgoingMessage {
|
|
6
|
-
type: MessageType;
|
|
7
|
-
description: string;
|
|
8
|
-
get(args: Partial<OutgoingMessageArguments>): encoding.Encoder;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
-
import { MessageType } from "../types.ts";
|
|
4
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
|
-
export declare class QueryAwarenessMessage extends OutgoingMessage {
|
|
6
|
-
type: MessageType;
|
|
7
|
-
description: string;
|
|
8
|
-
get(args: Partial<OutgoingMessageArguments>): encoding.Encoder;
|
|
9
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
-
import { MessageType } from "../types.ts";
|
|
3
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
|
-
export declare class StatelessMessage extends OutgoingMessage {
|
|
5
|
-
type: MessageType;
|
|
6
|
-
description: string;
|
|
7
|
-
get(args: Partial<OutgoingMessageArguments>): import("lib0/encoding").Encoder;
|
|
8
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
-
import { MessageType } from "../types.ts";
|
|
4
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
|
-
export declare class SyncStepOneMessage extends OutgoingMessage {
|
|
6
|
-
type: MessageType;
|
|
7
|
-
description: string;
|
|
8
|
-
get(args: Partial<OutgoingMessageArguments>): encoding.Encoder;
|
|
9
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import * as encoding from "lib0/encoding";
|
|
2
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
3
|
-
import { MessageType } from "../types.ts";
|
|
4
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
5
|
-
export declare class SyncStepTwoMessage extends OutgoingMessage {
|
|
6
|
-
type: MessageType;
|
|
7
|
-
description: string;
|
|
8
|
-
get(args: Partial<OutgoingMessageArguments>): encoding.Encoder;
|
|
9
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from "../types.ts";
|
|
2
|
-
import { MessageType } from "../types.ts";
|
|
3
|
-
import { OutgoingMessage } from "../OutgoingMessage.ts";
|
|
4
|
-
export declare class UpdateMessage extends OutgoingMessage {
|
|
5
|
-
type: MessageType;
|
|
6
|
-
description: string;
|
|
7
|
-
get(args: Partial<OutgoingMessageArguments>): import("lib0/encoding").Encoder;
|
|
8
|
-
}
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import type { Encoder } from "lib0/encoding";
|
|
2
|
-
import type { Event, MessageEvent } from "ws";
|
|
3
|
-
import type { Awareness } from "y-protocols/awareness";
|
|
4
|
-
import type * as Y from "yjs";
|
|
5
|
-
import type { CloseEvent } from "@hocuspocus/common";
|
|
6
|
-
import type { IncomingMessage } from "./IncomingMessage.ts";
|
|
7
|
-
import type { OutgoingMessage } from "./OutgoingMessage.ts";
|
|
8
|
-
import type { AuthenticationMessage } from "./OutgoingMessages/AuthenticationMessage.ts";
|
|
9
|
-
import type { AwarenessMessage } from "./OutgoingMessages/AwarenessMessage.ts";
|
|
10
|
-
import type { QueryAwarenessMessage } from "./OutgoingMessages/QueryAwarenessMessage.ts";
|
|
11
|
-
import type { SyncStepOneMessage } from "./OutgoingMessages/SyncStepOneMessage.ts";
|
|
12
|
-
import type { SyncStepTwoMessage } from "./OutgoingMessages/SyncStepTwoMessage.ts";
|
|
13
|
-
import type { UpdateMessage } from "./OutgoingMessages/UpdateMessage.ts";
|
|
14
|
-
export declare enum MessageType {
|
|
15
|
-
Sync = 0,
|
|
16
|
-
Awareness = 1,
|
|
17
|
-
Auth = 2,
|
|
18
|
-
QueryAwareness = 3,
|
|
19
|
-
Stateless = 5,
|
|
20
|
-
CLOSE = 7,
|
|
21
|
-
SyncStatus = 8
|
|
22
|
-
}
|
|
23
|
-
export declare enum WebSocketStatus {
|
|
24
|
-
Connecting = "connecting",
|
|
25
|
-
Connected = "connected",
|
|
26
|
-
Disconnected = "disconnected"
|
|
27
|
-
}
|
|
28
|
-
export type AuthorizedScope = "read-write" | "readonly";
|
|
29
|
-
export interface OutgoingMessageInterface {
|
|
30
|
-
encoder: Encoder;
|
|
31
|
-
type?: MessageType;
|
|
32
|
-
}
|
|
33
|
-
export interface OutgoingMessageArguments {
|
|
34
|
-
documentName: string;
|
|
35
|
-
token: string;
|
|
36
|
-
document: Y.Doc;
|
|
37
|
-
awareness: Awareness;
|
|
38
|
-
clients: number[];
|
|
39
|
-
states: Map<number, {
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
}>;
|
|
42
|
-
update: any;
|
|
43
|
-
payload: string;
|
|
44
|
-
encoder: Encoder;
|
|
45
|
-
}
|
|
46
|
-
export interface Constructable<T> {
|
|
47
|
-
new (...args: any): T;
|
|
48
|
-
}
|
|
49
|
-
export type ConstructableOutgoingMessage = Constructable<AuthenticationMessage> | Constructable<AwarenessMessage> | Constructable<QueryAwarenessMessage> | Constructable<SyncStepOneMessage> | Constructable<SyncStepTwoMessage> | Constructable<UpdateMessage>;
|
|
50
|
-
export type onAuthenticationFailedParameters = {
|
|
51
|
-
reason: string;
|
|
52
|
-
};
|
|
53
|
-
export type onAuthenticatedParameters = {
|
|
54
|
-
scope: AuthorizedScope;
|
|
55
|
-
};
|
|
56
|
-
export type onOpenParameters = {
|
|
57
|
-
event: Event;
|
|
58
|
-
};
|
|
59
|
-
export type onMessageParameters = {
|
|
60
|
-
event: MessageEvent;
|
|
61
|
-
message: IncomingMessage;
|
|
62
|
-
};
|
|
63
|
-
export type onOutgoingMessageParameters = {
|
|
64
|
-
message: OutgoingMessage;
|
|
65
|
-
};
|
|
66
|
-
export type onStatusParameters = {
|
|
67
|
-
status: WebSocketStatus;
|
|
68
|
-
};
|
|
69
|
-
export type onSyncedParameters = {
|
|
70
|
-
state: boolean;
|
|
71
|
-
};
|
|
72
|
-
export type onUnsyncedChangesParameters = {
|
|
73
|
-
number: number;
|
|
74
|
-
};
|
|
75
|
-
export type onDisconnectParameters = {
|
|
76
|
-
event: CloseEvent;
|
|
77
|
-
};
|
|
78
|
-
export type onCloseParameters = {
|
|
79
|
-
event: CloseEvent;
|
|
80
|
-
};
|
|
81
|
-
export type onAwarenessUpdateParameters = {
|
|
82
|
-
states: StatesArray;
|
|
83
|
-
};
|
|
84
|
-
export type onAwarenessChangeParameters = {
|
|
85
|
-
states: StatesArray;
|
|
86
|
-
};
|
|
87
|
-
export type onStatelessParameters = {
|
|
88
|
-
payload: string;
|
|
89
|
-
};
|
|
90
|
-
export type StatesArray = {
|
|
91
|
-
clientId: number;
|
|
92
|
-
[key: string | number]: any;
|
|
93
|
-
}[];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage } from "node:http";
|
|
2
|
-
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
-
import type WebSocket from "ws";
|
|
4
|
-
import type Document from "./Document.ts";
|
|
5
|
-
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
6
|
-
import type { onDisconnectPayload } from "./types.ts";
|
|
7
|
-
/**
|
|
8
|
-
* The `ClientConnection` class is responsible for handling an incoming WebSocket
|
|
9
|
-
*
|
|
10
|
-
* TODO-refactor:
|
|
11
|
-
* - use event handlers instead of calling hooks directly, hooks should probably be called from Hocuspocus.ts
|
|
12
|
-
*/
|
|
13
|
-
export declare class ClientConnection {
|
|
14
|
-
private readonly websocket;
|
|
15
|
-
private readonly request;
|
|
16
|
-
private readonly documentProvider;
|
|
17
|
-
private readonly hooks;
|
|
18
|
-
private readonly opts;
|
|
19
|
-
private readonly defaultContext;
|
|
20
|
-
private readonly documentConnections;
|
|
21
|
-
private readonly incomingMessageQueue;
|
|
22
|
-
private readonly documentConnectionsEstablished;
|
|
23
|
-
private readonly hookPayloads;
|
|
24
|
-
private readonly callbacks;
|
|
25
|
-
private readonly socketId;
|
|
26
|
-
timeout: number;
|
|
27
|
-
pingInterval: NodeJS.Timeout;
|
|
28
|
-
pongReceived: boolean;
|
|
29
|
-
/**
|
|
30
|
-
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
31
|
-
* runs all hooks:
|
|
32
|
-
*
|
|
33
|
-
* - onConnect for all connections
|
|
34
|
-
* - onAuthenticate only if required
|
|
35
|
-
*
|
|
36
|
-
* … and if nothings fails it’ll fully establish the connection and
|
|
37
|
-
* load the Document then.
|
|
38
|
-
*/
|
|
39
|
-
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
40
|
-
createDocument: Hocuspocus["createDocument"];
|
|
41
|
-
}, hooks: Hocuspocus["hooks"], opts: {
|
|
42
|
-
timeout: number;
|
|
43
|
-
}, defaultContext?: any);
|
|
44
|
-
private handleWebsocketClose;
|
|
45
|
-
close(event?: CloseEvent): void;
|
|
46
|
-
handlePong: () => void;
|
|
47
|
-
/**
|
|
48
|
-
* Check if pong was received and close the connection otherwise
|
|
49
|
-
* @private
|
|
50
|
-
*/
|
|
51
|
-
private check;
|
|
52
|
-
/**
|
|
53
|
-
* Set a callback that will be triggered when the connection is closed
|
|
54
|
-
*/
|
|
55
|
-
onClose(callback: (document: Document, payload: onDisconnectPayload) => void): ClientConnection;
|
|
56
|
-
/**
|
|
57
|
-
* Create a new connection by the given request and document
|
|
58
|
-
*/
|
|
59
|
-
private createConnection;
|
|
60
|
-
private setUpNewConnection;
|
|
61
|
-
private handleQueueingMessage;
|
|
62
|
-
private messageHandler;
|
|
63
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage as HTTPIncomingMessage } from "node:http";
|
|
2
|
-
import { type CloseEvent } from "@hocuspocus/common";
|
|
3
|
-
import type WebSocket from "ws";
|
|
4
|
-
import type Document from "./Document.ts";
|
|
5
|
-
import type { beforeSyncPayload, onStatelessPayload } from "./types.ts";
|
|
6
|
-
export declare class Connection {
|
|
7
|
-
webSocket: WebSocket;
|
|
8
|
-
context: any;
|
|
9
|
-
document: Document;
|
|
10
|
-
request: HTTPIncomingMessage;
|
|
11
|
-
callbacks: {
|
|
12
|
-
onClose: ((document: Document, event?: CloseEvent) => void)[];
|
|
13
|
-
beforeHandleMessage: (connection: Connection, update: Uint8Array) => Promise<void>;
|
|
14
|
-
beforeSync: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<void>;
|
|
15
|
-
statelessCallback: (payload: onStatelessPayload) => Promise<void>;
|
|
16
|
-
onTokenSyncCallback: (payload: {
|
|
17
|
-
token: string;
|
|
18
|
-
}) => Promise<void>;
|
|
19
|
-
};
|
|
20
|
-
socketId: string;
|
|
21
|
-
readOnly: boolean;
|
|
22
|
-
/**
|
|
23
|
-
* Constructor.
|
|
24
|
-
*/
|
|
25
|
-
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
|
|
26
|
-
/**
|
|
27
|
-
* Set a callback that will be triggered when the connection is closed
|
|
28
|
-
*/
|
|
29
|
-
onClose(callback: (document: Document, event?: CloseEvent) => void): Connection;
|
|
30
|
-
/**
|
|
31
|
-
* Set a callback that will be triggered when an stateless message is received
|
|
32
|
-
*/
|
|
33
|
-
onStatelessCallback(callback: (payload: onStatelessPayload) => Promise<void>): Connection;
|
|
34
|
-
/**
|
|
35
|
-
* Set a callback that will be triggered before an message is handled
|
|
36
|
-
*/
|
|
37
|
-
beforeHandleMessage(callback: (connection: Connection, update: Uint8Array) => Promise<any>): Connection;
|
|
38
|
-
/**
|
|
39
|
-
* Set a callback that will be triggered before a sync message is handled
|
|
40
|
-
*/
|
|
41
|
-
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, "type" | "payload">) => Promise<any>): Connection;
|
|
42
|
-
/**
|
|
43
|
-
* Set a callback that will be triggered when on token sync message is received
|
|
44
|
-
*/
|
|
45
|
-
onTokenSyncCallback(callback: (payload: {
|
|
46
|
-
token: string;
|
|
47
|
-
}) => Promise<void>): Connection;
|
|
48
|
-
/**
|
|
49
|
-
* Send the given message
|
|
50
|
-
*/
|
|
51
|
-
send(message: any): void;
|
|
52
|
-
/**
|
|
53
|
-
* Send a stateless message with payload
|
|
54
|
-
*/
|
|
55
|
-
sendStateless(payload: string): void;
|
|
56
|
-
/**
|
|
57
|
-
* Request current token from the client
|
|
58
|
-
*/
|
|
59
|
-
requestToken(): void;
|
|
60
|
-
/**
|
|
61
|
-
* Graceful wrapper around the WebSocket close method.
|
|
62
|
-
*/
|
|
63
|
-
close(event?: CloseEvent): void;
|
|
64
|
-
/**
|
|
65
|
-
* Send the current document awareness to the client, if any
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
private sendCurrentAwareness;
|
|
69
|
-
/**
|
|
70
|
-
* Handle an incoming message
|
|
71
|
-
* @public
|
|
72
|
-
*/
|
|
73
|
-
handleMessage(data: Uint8Array): void;
|
|
74
|
-
}
|
|
75
|
-
export default Connection;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type Document from "./Document.ts";
|
|
2
|
-
import type { Hocuspocus } from "./Hocuspocus.ts";
|
|
3
|
-
import type { DirectConnection as DirectConnectionInterface } from "./types.ts";
|
|
4
|
-
export declare class DirectConnection implements DirectConnectionInterface {
|
|
5
|
-
document: Document | null;
|
|
6
|
-
instance: Hocuspocus;
|
|
7
|
-
context: any;
|
|
8
|
-
/**
|
|
9
|
-
* Constructor.
|
|
10
|
-
*/
|
|
11
|
-
constructor(document: Document, instance: Hocuspocus, context?: any);
|
|
12
|
-
transact(transaction: (document: Document) => void): Promise<void>;
|
|
13
|
-
disconnect(): Promise<void>;
|
|
14
|
-
}
|
|
@@ -1,92 +0,0 @@
|
|
|
1
|
-
import { Mutex } from "async-mutex";
|
|
2
|
-
import type WebSocket from "ws";
|
|
3
|
-
import { Awareness } from "y-protocols/awareness";
|
|
4
|
-
import { Doc } from "yjs";
|
|
5
|
-
import type Connection from "./Connection.ts";
|
|
6
|
-
export declare class Document extends Doc {
|
|
7
|
-
awareness: Awareness;
|
|
8
|
-
callbacks: {
|
|
9
|
-
onUpdate: (document: Document, connection: Connection, update: Uint8Array) => void;
|
|
10
|
-
beforeBroadcastStateless: (document: Document, stateless: string) => void;
|
|
11
|
-
};
|
|
12
|
-
connections: Map<WebSocket, {
|
|
13
|
-
clients: Set<any>;
|
|
14
|
-
connection: Connection;
|
|
15
|
-
}>;
|
|
16
|
-
directConnectionsCount: number;
|
|
17
|
-
name: string;
|
|
18
|
-
isLoading: boolean;
|
|
19
|
-
isDestroyed: boolean;
|
|
20
|
-
saveMutex: Mutex;
|
|
21
|
-
lastChangeTime: number;
|
|
22
|
-
/**
|
|
23
|
-
* Constructor.
|
|
24
|
-
*/
|
|
25
|
-
constructor(name: string, yDocOptions?: object);
|
|
26
|
-
/**
|
|
27
|
-
* Check if the Document (XMLFragment or Map) is empty
|
|
28
|
-
*/
|
|
29
|
-
isEmpty(fieldName: string): boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Merge the given document(s) into this one
|
|
32
|
-
*/
|
|
33
|
-
merge(documents: Doc | Array<Doc>): Document;
|
|
34
|
-
/**
|
|
35
|
-
* Set a callback that will be triggered when the document is updated
|
|
36
|
-
*/
|
|
37
|
-
onUpdate(callback: (document: Document, connection: Connection, update: Uint8Array) => void): Document;
|
|
38
|
-
/**
|
|
39
|
-
* Set a callback that will be triggered before a stateless message is broadcasted
|
|
40
|
-
*/
|
|
41
|
-
beforeBroadcastStateless(callback: (document: Document, stateless: string) => void): Document;
|
|
42
|
-
/**
|
|
43
|
-
* Register a connection and a set of clients on this document keyed by the
|
|
44
|
-
* underlying websocket connection
|
|
45
|
-
*/
|
|
46
|
-
addConnection(connection: Connection): Document;
|
|
47
|
-
/**
|
|
48
|
-
* Is the given connection registered on this document
|
|
49
|
-
*/
|
|
50
|
-
hasConnection(connection: Connection): boolean;
|
|
51
|
-
/**
|
|
52
|
-
* Remove the given connection from this document
|
|
53
|
-
*/
|
|
54
|
-
removeConnection(connection: Connection): Document;
|
|
55
|
-
addDirectConnection(): Document;
|
|
56
|
-
removeDirectConnection(): Document;
|
|
57
|
-
/**
|
|
58
|
-
* Get the number of active connections for this document
|
|
59
|
-
*/
|
|
60
|
-
getConnectionsCount(): number;
|
|
61
|
-
/**
|
|
62
|
-
* Get an array of registered connections
|
|
63
|
-
*/
|
|
64
|
-
getConnections(): Array<Connection>;
|
|
65
|
-
/**
|
|
66
|
-
* Get the client ids for the given connection instance
|
|
67
|
-
*/
|
|
68
|
-
getClients(connectionInstance: WebSocket): Set<any>;
|
|
69
|
-
/**
|
|
70
|
-
* Has the document awareness states
|
|
71
|
-
*/
|
|
72
|
-
hasAwarenessStates(): boolean;
|
|
73
|
-
/**
|
|
74
|
-
* Apply the given awareness update
|
|
75
|
-
*/
|
|
76
|
-
applyAwarenessUpdate(connection: Connection, update: Uint8Array): Document;
|
|
77
|
-
/**
|
|
78
|
-
* Handle an awareness update and sync changes to clients
|
|
79
|
-
* @private
|
|
80
|
-
*/
|
|
81
|
-
private handleAwarenessUpdate;
|
|
82
|
-
/**
|
|
83
|
-
* Handle an updated document and sync changes to clients
|
|
84
|
-
*/
|
|
85
|
-
private handleUpdate;
|
|
86
|
-
/**
|
|
87
|
-
* Broadcast stateless message to all connections
|
|
88
|
-
*/
|
|
89
|
-
broadcastStateless(payload: string, filter?: (conn: Connection) => boolean): void;
|
|
90
|
-
destroy(): void;
|
|
91
|
-
}
|
|
92
|
-
export default Document;
|