@hocuspocus/extension-database 3.0.0-rc.0 → 3.0.6-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-database.cjs +17 -10603
- package/dist/hocuspocus-database.cjs.map +1 -1
- package/dist/hocuspocus-database.esm.js +3 -10608
- package/dist/hocuspocus-database.esm.js.map +1 -1
- package/dist/packages/common/src/index.d.ts +4 -4
- package/dist/packages/extension-database/src/index.d.ts +1 -1
- package/dist/packages/extension-logger/src/index.d.ts +1 -1
- package/dist/packages/extension-redis/src/Redis.d.ts +6 -2
- package/dist/packages/extension-redis/src/index.d.ts +1 -1
- package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +14 -36
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +4 -8
- package/dist/packages/provider/src/IncomingMessage.d.ts +2 -2
- package/dist/packages/provider/src/MessageReceiver.d.ts +2 -4
- package/dist/packages/provider/src/MessageSender.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
- package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +3 -3
- package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
- package/dist/packages/provider/src/index.d.ts +3 -5
- package/dist/packages/provider/src/types.d.ts +50 -10
- package/dist/packages/server/src/ClientConnection.d.ts +16 -8
- package/dist/packages/server/src/Connection.d.ts +14 -20
- package/dist/packages/server/src/DirectConnection.d.ts +4 -4
- package/dist/packages/server/src/Document.d.ts +2 -6
- package/dist/packages/server/src/Hocuspocus.d.ts +6 -15
- package/dist/packages/server/src/IncomingMessage.d.ts +4 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +6 -8
- package/dist/packages/server/src/OutgoingMessage.d.ts +2 -1
- package/dist/packages/server/src/Server.d.ts +3 -3
- package/dist/packages/server/src/index.d.ts +9 -10
- package/dist/packages/server/src/types.d.ts +41 -13
- package/dist/packages/transformer/src/Prosemirror.d.ts +1 -1
- package/dist/packages/transformer/src/Tiptap.d.ts +1 -1
- package/dist/packages/transformer/src/index.d.ts +3 -3
- package/dist/playground/frontend/app/SocketContext.d.ts +2 -0
- package/dist/playground/frontend/next.config.d.ts +3 -0
- package/dist/tests/utils/index.d.ts +9 -9
- package/dist/tests/utils/newHocuspocusProvider.d.ts +2 -2
- package/package.json +3 -3
- package/src/index.ts +1 -1
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +0 -64
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +0 -20
- package/dist/packages/server/src/Debugger.d.ts +0 -14
- package/dist/playground/frontend/vite.config.d.ts +0 -2
- package/dist/tests/server/getMessageLogs.d.ts +0 -1
- package/dist/tests/server/requiresAuthentication.d.ts +0 -1
- /package/dist/{playground/frontend/src/main.d.ts → tests/server/beforeSync.d.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './auth.
|
|
2
|
-
export * from './CloseEvents.
|
|
3
|
-
export * from './awarenessStatesToArray.
|
|
4
|
-
export * from './types.
|
|
1
|
+
export * from './auth.ts';
|
|
2
|
+
export * from './CloseEvents.ts';
|
|
3
|
+
export * from './awarenessStatesToArray.ts';
|
|
4
|
+
export * from './types.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Database.
|
|
1
|
+
export * from './Database.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Logger.
|
|
1
|
+
export * from './Logger.ts';
|
|
@@ -2,7 +2,6 @@ import type { ClusterNode, ClusterOptions, RedisOptions } from 'ioredis';
|
|
|
2
2
|
import RedisClient from 'ioredis';
|
|
3
3
|
import Redlock from 'redlock';
|
|
4
4
|
import type { Extension, afterLoadDocumentPayload, afterStoreDocumentPayload, onDisconnectPayload, onStoreDocumentPayload, onAwarenessUpdatePayload, onChangePayload, onConfigurePayload, beforeBroadcastStatelessPayload, Hocuspocus } from '@hocuspocus/server';
|
|
5
|
-
import { Debugger } from '@hocuspocus/server';
|
|
6
5
|
export type RedisInstance = RedisClient.Cluster | RedisClient.Redis;
|
|
7
6
|
export interface Configuration {
|
|
8
7
|
/**
|
|
@@ -64,8 +63,13 @@ export declare class Redis implements Extension {
|
|
|
64
63
|
instance: Hocuspocus;
|
|
65
64
|
redlock: Redlock;
|
|
66
65
|
locks: Map<string, Redlock.Lock>;
|
|
67
|
-
logger: Debugger;
|
|
68
66
|
messagePrefix: Buffer;
|
|
67
|
+
/**
|
|
68
|
+
* When we have a high frequency of updates to a document we don't need tons of setTimeouts
|
|
69
|
+
* piling up, so we'll track them to keep it to the most recent per document.
|
|
70
|
+
*/
|
|
71
|
+
private pendingDisconnects;
|
|
72
|
+
private pendingAfterStoreDocumentResolves;
|
|
69
73
|
constructor(configuration: Partial<Configuration>);
|
|
70
74
|
onConfigure({ instance }: onConfigurePayload): Promise<void>;
|
|
71
75
|
private getKey;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './Redis.
|
|
1
|
+
export * from './Redis.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export * from './SQLite.
|
|
1
|
+
export * from './SQLite.ts';
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { CloseEvent, Event, MessageEvent } from 'ws';
|
|
1
|
+
import type { Event, MessageEvent } from 'ws';
|
|
3
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
4
3
|
import * as Y from 'yjs';
|
|
5
|
-
import EventEmitter from './EventEmitter.
|
|
6
|
-
import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.
|
|
7
|
-
import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.
|
|
8
|
-
import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters,
|
|
4
|
+
import EventEmitter from './EventEmitter.ts';
|
|
5
|
+
import type { CompleteHocuspocusProviderWebsocketConfiguration } from './HocuspocusProviderWebsocket.ts';
|
|
6
|
+
import { HocuspocusProviderWebsocket } from './HocuspocusProviderWebsocket.ts';
|
|
7
|
+
import type { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onSyncedParameters } from './types.ts';
|
|
9
8
|
export type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'name'>> & Partial<CompleteHocuspocusProviderConfiguration> & (Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, 'url'>> | Required<Pick<CompleteHocuspocusProviderConfiguration, 'websocketProvider'>>);
|
|
10
9
|
export interface CompleteHocuspocusProviderConfiguration {
|
|
11
10
|
/**
|
|
@@ -16,10 +15,6 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
16
15
|
* The actual Y.js document
|
|
17
16
|
*/
|
|
18
17
|
document: Y.Doc;
|
|
19
|
-
/**
|
|
20
|
-
* Pass false to disable broadcasting between browser tabs.
|
|
21
|
-
*/
|
|
22
|
-
broadcast: boolean;
|
|
23
18
|
/**
|
|
24
19
|
* An Awareness instance to keep the presence state of all clients.
|
|
25
20
|
*
|
|
@@ -33,12 +28,6 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
33
28
|
* A token that’s sent to the backend for authentication purposes.
|
|
34
29
|
*/
|
|
35
30
|
token: string | (() => string) | (() => Promise<string>) | null;
|
|
36
|
-
/**
|
|
37
|
-
* URL parameters that should be added.
|
|
38
|
-
*/
|
|
39
|
-
parameters: {
|
|
40
|
-
[key: string]: any;
|
|
41
|
-
};
|
|
42
31
|
/**
|
|
43
32
|
* Hocuspocus websocket provider
|
|
44
33
|
*/
|
|
@@ -53,7 +42,6 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
53
42
|
onConnect: () => void;
|
|
54
43
|
onMessage: (data: onMessageParameters) => void;
|
|
55
44
|
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
56
|
-
onStatus: (data: onStatusParameters) => void;
|
|
57
45
|
onSynced: (data: onSyncedParameters) => void;
|
|
58
46
|
onDisconnect: (data: onDisconnectParameters) => void;
|
|
59
47
|
onClose: (data: onCloseParameters) => void;
|
|
@@ -61,37 +49,26 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
61
49
|
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
|
|
62
50
|
onAwarenessChange: (data: onAwarenessChangeParameters) => void;
|
|
63
51
|
onStateless: (data: onStatelessParameters) => void;
|
|
64
|
-
/**
|
|
65
|
-
* Don’t output any warnings.
|
|
66
|
-
*/
|
|
67
|
-
quiet: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* Pass `false` to start the connection manually.
|
|
70
|
-
*/
|
|
71
|
-
connect: boolean;
|
|
72
|
-
/**
|
|
73
|
-
* Pass `false` to close the connection manually.
|
|
74
|
-
*/
|
|
75
|
-
preserveConnection: boolean;
|
|
76
52
|
}
|
|
77
53
|
export declare class AwarenessError extends Error {
|
|
78
54
|
code: number;
|
|
79
55
|
}
|
|
80
56
|
export declare class HocuspocusProvider extends EventEmitter {
|
|
81
57
|
configuration: CompleteHocuspocusProviderConfiguration;
|
|
82
|
-
subscribedToBroadcastChannel: boolean;
|
|
83
58
|
isSynced: boolean;
|
|
84
59
|
unsyncedChanges: number;
|
|
85
60
|
isAuthenticated: boolean;
|
|
86
61
|
authorizedScope: string | undefined;
|
|
87
|
-
|
|
62
|
+
manageSocket: boolean;
|
|
63
|
+
private isAttached;
|
|
88
64
|
intervals: any;
|
|
89
65
|
constructor(configuration: HocuspocusProviderConfiguration);
|
|
66
|
+
boundDocumentUpdateHandler: (update: Uint8Array, origin: any) => void;
|
|
67
|
+
boundAwarenessUpdateHandler: ({ added, updated, removed }: any, origin: any) => void;
|
|
90
68
|
boundPageHide: () => void;
|
|
91
69
|
boundOnOpen: (event: Event) => Promise<void>;
|
|
92
|
-
boundOnClose: (
|
|
70
|
+
boundOnClose: () => void;
|
|
93
71
|
forwardConnect: (e: any) => this;
|
|
94
|
-
forwardOpen: (e: any) => this;
|
|
95
72
|
forwardClose: (e: any) => this;
|
|
96
73
|
forwardDisconnect: (e: any) => this;
|
|
97
74
|
forwardDestroy: (e: any) => this;
|
|
@@ -117,16 +94,17 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
117
94
|
get synced(): boolean;
|
|
118
95
|
set synced(state: boolean);
|
|
119
96
|
receiveStateless(payload: string): void;
|
|
120
|
-
get isAuthenticationRequired(): boolean;
|
|
121
97
|
connect(): Promise<void>;
|
|
122
98
|
disconnect(): void;
|
|
123
99
|
onOpen(event: Event): Promise<void>;
|
|
124
100
|
getToken(): Promise<string | null>;
|
|
125
101
|
startSync(): void;
|
|
126
|
-
send(message: ConstructableOutgoingMessage, args: any
|
|
102
|
+
send(message: ConstructableOutgoingMessage, args: any): void;
|
|
127
103
|
onMessage(event: MessageEvent): void;
|
|
128
|
-
onClose(
|
|
104
|
+
onClose(): void;
|
|
129
105
|
destroy(): void;
|
|
106
|
+
detach(): void;
|
|
107
|
+
attach(): void;
|
|
130
108
|
permissionDeniedHandler(reason: string): void;
|
|
131
109
|
authenticatedHandler(scope: string): void;
|
|
132
110
|
setAwarenessField(key: string, value: any): void;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MessageEvent, Event } from 'ws';
|
|
2
|
-
import EventEmitter from './EventEmitter.
|
|
3
|
-
import type { HocuspocusProvider } from './HocuspocusProvider.
|
|
4
|
-
import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.
|
|
5
|
-
import { WebSocketStatus } from './types.
|
|
2
|
+
import EventEmitter from './EventEmitter.ts';
|
|
3
|
+
import type { HocuspocusProvider } from './HocuspocusProvider.ts';
|
|
4
|
+
import type { onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters } from './types.ts';
|
|
5
|
+
import { WebSocketStatus } from './types.ts';
|
|
6
6
|
export type HocusPocusWebSocket = WebSocket & {
|
|
7
7
|
identifier: string;
|
|
8
8
|
};
|
|
@@ -72,10 +72,6 @@ export interface CompleteHocuspocusProviderWebsocketConfiguration {
|
|
|
72
72
|
onDestroy: () => void;
|
|
73
73
|
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
|
|
74
74
|
onAwarenessChange: (data: onAwarenessChangeParameters) => void;
|
|
75
|
-
/**
|
|
76
|
-
* Don’t output any warnings.
|
|
77
|
-
*/
|
|
78
|
-
quiet: boolean;
|
|
79
75
|
/**
|
|
80
76
|
* Map of attached providers keyed by documentName.
|
|
81
77
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Decoder } from 'lib0/decoding';
|
|
2
2
|
import type { Encoder } from 'lib0/encoding';
|
|
3
|
-
import type { MessageType } from './types.
|
|
3
|
+
import type { MessageType } from './types.ts';
|
|
4
4
|
export declare class IncomingMessage {
|
|
5
5
|
data: any;
|
|
6
6
|
encoder: Encoder;
|
|
@@ -9,7 +9,7 @@ export declare class IncomingMessage {
|
|
|
9
9
|
peekVarString(): string;
|
|
10
10
|
readVarUint(): MessageType;
|
|
11
11
|
readVarString(): string;
|
|
12
|
-
readVarUint8Array(): Uint8Array
|
|
12
|
+
readVarUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
13
13
|
writeVarUint(type: MessageType): void;
|
|
14
14
|
writeVarString(string: string): void;
|
|
15
15
|
writeVarUint8Array(data: Uint8Array): void;
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import type { HocuspocusProvider } from './HocuspocusProvider.
|
|
2
|
-
import type { IncomingMessage } from './IncomingMessage.
|
|
1
|
+
import type { HocuspocusProvider } from './HocuspocusProvider.ts';
|
|
2
|
+
import type { IncomingMessage } from './IncomingMessage.ts';
|
|
3
3
|
export declare class MessageReceiver {
|
|
4
4
|
message: IncomingMessage;
|
|
5
|
-
broadcasted: boolean;
|
|
6
5
|
constructor(message: IncomingMessage);
|
|
7
|
-
setBroadcasted(value: boolean): this;
|
|
8
6
|
apply(provider: HocuspocusProvider, emitSynced: boolean): void;
|
|
9
7
|
private applySyncMessage;
|
|
10
8
|
applySyncStatusMessage(provider: HocuspocusProvider, applied: boolean): void;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { Encoder } from 'lib0/encoding';
|
|
2
|
-
import type { ConstructableOutgoingMessage } from './types.
|
|
2
|
+
import type { ConstructableOutgoingMessage } from './types.ts';
|
|
3
3
|
export declare class MessageSender {
|
|
4
4
|
encoder: Encoder;
|
|
5
5
|
message: any;
|
|
6
6
|
constructor(Message: ConstructableOutgoingMessage, args?: any);
|
|
7
|
-
create(): Uint8Array
|
|
7
|
+
create(): Uint8Array<ArrayBufferLike>;
|
|
8
8
|
send(webSocket: any): void;
|
|
9
9
|
broadcast(channel: string): void;
|
|
10
10
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { Encoder } from 'lib0/encoding';
|
|
2
|
-
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.
|
|
2
|
+
import type { MessageType, OutgoingMessageArguments, OutgoingMessageInterface } from './types.ts';
|
|
3
3
|
export declare class OutgoingMessage implements OutgoingMessageInterface {
|
|
4
4
|
encoder: Encoder;
|
|
5
5
|
type?: MessageType;
|
|
6
6
|
constructor();
|
|
7
7
|
get(args: Partial<OutgoingMessageArguments>): Encoder | undefined;
|
|
8
|
-
toUint8Array(): Uint8Array
|
|
8
|
+
toUint8Array(): Uint8Array<ArrayBufferLike>;
|
|
9
9
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
2
|
-
import { MessageType } from '../types.
|
|
3
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
1
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
2
|
+
import { MessageType } from '../types.ts';
|
|
3
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
4
4
|
export declare class AuthenticationMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class AwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class CloseMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class QueryAwarenessMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
2
|
-
import { MessageType } from '../types.
|
|
3
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
1
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
2
|
+
import { MessageType } from '../types.ts';
|
|
3
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
4
4
|
export declare class StatelessMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class SyncStepOneMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as encoding from 'lib0/encoding';
|
|
2
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
3
|
-
import { MessageType } from '../types.
|
|
4
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
2
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
3
|
+
import { MessageType } from '../types.ts';
|
|
4
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
5
5
|
export declare class SyncStepTwoMessage extends OutgoingMessage {
|
|
6
6
|
type: MessageType;
|
|
7
7
|
description: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { OutgoingMessageArguments } from '../types.
|
|
2
|
-
import { MessageType } from '../types.
|
|
3
|
-
import { OutgoingMessage } from '../OutgoingMessage.
|
|
1
|
+
import type { OutgoingMessageArguments } from '../types.ts';
|
|
2
|
+
import { MessageType } from '../types.ts';
|
|
3
|
+
import { OutgoingMessage } from '../OutgoingMessage.ts';
|
|
4
4
|
export declare class UpdateMessage extends OutgoingMessage {
|
|
5
5
|
type: MessageType;
|
|
6
6
|
description: string;
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
export * from './HocuspocusProvider.
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
4
|
-
export * from './HocuspocusProviderWebsocket.js';
|
|
5
|
-
export * from './types.js';
|
|
1
|
+
export * from './HocuspocusProvider.ts';
|
|
2
|
+
export * from './HocuspocusProviderWebsocket.ts';
|
|
3
|
+
export * from './types.ts';
|
|
@@ -3,14 +3,14 @@ import type { Event, MessageEvent } from 'ws';
|
|
|
3
3
|
import type { Awareness } from 'y-protocols/awareness';
|
|
4
4
|
import type * as Y from 'yjs';
|
|
5
5
|
import type { CloseEvent } from '@hocuspocus/common';
|
|
6
|
-
import type { IncomingMessage } from './IncomingMessage.
|
|
7
|
-
import type { OutgoingMessage } from './OutgoingMessage.
|
|
8
|
-
import type { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage.
|
|
9
|
-
import type { AwarenessMessage } from './OutgoingMessages/AwarenessMessage.
|
|
10
|
-
import type { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage.
|
|
11
|
-
import type { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage.
|
|
12
|
-
import type { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage.
|
|
13
|
-
import type { UpdateMessage } from './OutgoingMessages/UpdateMessage.
|
|
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
14
|
export declare enum MessageType {
|
|
15
15
|
Sync = 0,
|
|
16
16
|
Awareness = 1,
|
|
@@ -88,14 +88,17 @@ export type TCollabThread<Data = any, CommentData = any> = {
|
|
|
88
88
|
id: string;
|
|
89
89
|
createdAt: number;
|
|
90
90
|
updatedAt: number;
|
|
91
|
+
deletedAt: number | null;
|
|
91
92
|
resolvedAt?: string;
|
|
92
93
|
comments: TCollabComment<CommentData>[];
|
|
94
|
+
deletedComments: TCollabComment<CommentData>[];
|
|
93
95
|
data: Data;
|
|
94
96
|
};
|
|
95
97
|
export type TCollabComment<Data = any> = {
|
|
96
98
|
id: string;
|
|
97
|
-
createdAt:
|
|
98
|
-
updatedAt:
|
|
99
|
+
createdAt: string;
|
|
100
|
+
updatedAt: string;
|
|
101
|
+
deletedAt?: string;
|
|
99
102
|
data: Data;
|
|
100
103
|
content: any;
|
|
101
104
|
};
|
|
@@ -144,3 +147,40 @@ export type THistoryDocumentRevertedEvent = {
|
|
|
144
147
|
event: 'document.reverted';
|
|
145
148
|
version: number;
|
|
146
149
|
};
|
|
150
|
+
export type DeleteCommentOptions = {
|
|
151
|
+
/**
|
|
152
|
+
* If `true`, the thread will also be deleted if the deleted comment was the first comment in the thread.
|
|
153
|
+
*/
|
|
154
|
+
deleteThread?: boolean;
|
|
155
|
+
/**
|
|
156
|
+
* If `true`, will remove the content of the deleted comment
|
|
157
|
+
*/
|
|
158
|
+
deleteContent?: boolean;
|
|
159
|
+
};
|
|
160
|
+
export type DeleteThreadOptions = {
|
|
161
|
+
/**
|
|
162
|
+
* If `true`, will remove the comments on the thread,
|
|
163
|
+
* otherwise will only mark the thread as deleted
|
|
164
|
+
* and keep the comments
|
|
165
|
+
* @default false
|
|
166
|
+
*/
|
|
167
|
+
deleteComments?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* If `true`, will forcefully remove the thread and all comments,
|
|
170
|
+
* otherwise will only mark the thread as deleted
|
|
171
|
+
* and keep the comments
|
|
172
|
+
* @default false
|
|
173
|
+
*/
|
|
174
|
+
force?: boolean;
|
|
175
|
+
};
|
|
176
|
+
/**
|
|
177
|
+
* The type of thread
|
|
178
|
+
*/
|
|
179
|
+
export type ThreadType = 'archived' | 'unarchived';
|
|
180
|
+
export type GetThreadsOptions = {
|
|
181
|
+
/**
|
|
182
|
+
* The types of threads to get
|
|
183
|
+
* @default ['unarchived']
|
|
184
|
+
*/
|
|
185
|
+
types?: Array<ThreadType>;
|
|
186
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { IncomingMessage } from 'http';
|
|
2
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
2
3
|
import type WebSocket from 'ws';
|
|
3
|
-
import type
|
|
4
|
-
import type
|
|
5
|
-
import type {
|
|
6
|
-
import type { onDisconnectPayload } from './types.js';
|
|
4
|
+
import type Document from './Document.ts';
|
|
5
|
+
import type { Hocuspocus } from './Hocuspocus.ts';
|
|
6
|
+
import type { onDisconnectPayload } from './types.ts';
|
|
7
7
|
/**
|
|
8
8
|
* The `ClientConnection` class is responsible for handling an incoming WebSocket
|
|
9
9
|
*
|
|
@@ -15,7 +15,6 @@ export declare class ClientConnection {
|
|
|
15
15
|
private readonly request;
|
|
16
16
|
private readonly documentProvider;
|
|
17
17
|
private readonly hooks;
|
|
18
|
-
private readonly debuggerTool;
|
|
19
18
|
private readonly opts;
|
|
20
19
|
private readonly defaultContext;
|
|
21
20
|
private readonly documentConnections;
|
|
@@ -23,8 +22,10 @@ export declare class ClientConnection {
|
|
|
23
22
|
private readonly documentConnectionsEstablished;
|
|
24
23
|
private readonly hookPayloads;
|
|
25
24
|
private readonly callbacks;
|
|
26
|
-
private readonly closeIdleConnectionTimeout;
|
|
27
25
|
private readonly socketId;
|
|
26
|
+
timeout: number;
|
|
27
|
+
pingInterval: NodeJS.Timeout;
|
|
28
|
+
pongReceived: boolean;
|
|
28
29
|
/**
|
|
29
30
|
* The `ClientConnection` class receives incoming WebSocket connections,
|
|
30
31
|
* runs all hooks:
|
|
@@ -37,10 +38,17 @@ export declare class ClientConnection {
|
|
|
37
38
|
*/
|
|
38
39
|
constructor(websocket: WebSocket, request: IncomingMessage, documentProvider: {
|
|
39
40
|
createDocument: Hocuspocus['createDocument'];
|
|
40
|
-
}, hooks: Hocuspocus['hooks'],
|
|
41
|
-
requiresAuthentication: boolean;
|
|
41
|
+
}, hooks: Hocuspocus['hooks'], opts: {
|
|
42
42
|
timeout: number;
|
|
43
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;
|
|
44
52
|
/**
|
|
45
53
|
* Set a callback that will be triggered when the connection is closed
|
|
46
54
|
*/
|
|
@@ -1,30 +1,25 @@
|
|
|
1
1
|
import type { IncomingMessage as HTTPIncomingMessage } from 'http';
|
|
2
|
-
import
|
|
2
|
+
import { type CloseEvent } from '@hocuspocus/common';
|
|
3
3
|
import type WebSocket from 'ws';
|
|
4
|
-
import type
|
|
5
|
-
import type
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
7
|
-
import type { onStatelessPayload } from './types.js';
|
|
4
|
+
import type Document from './Document.ts';
|
|
5
|
+
import type { beforeSyncPayload, onStatelessPayload } from './types.ts';
|
|
8
6
|
export declare class Connection {
|
|
9
7
|
webSocket: WebSocket;
|
|
10
8
|
context: any;
|
|
11
9
|
document: Document;
|
|
12
|
-
pingInterval: NodeJS.Timeout;
|
|
13
|
-
pongReceived: boolean;
|
|
14
10
|
request: HTTPIncomingMessage;
|
|
15
|
-
|
|
16
|
-
|
|
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
|
+
};
|
|
17
17
|
socketId: string;
|
|
18
|
-
lock: AsyncLock;
|
|
19
18
|
readOnly: boolean;
|
|
20
|
-
logger: Debugger;
|
|
21
19
|
/**
|
|
22
20
|
* Constructor.
|
|
23
21
|
*/
|
|
24
|
-
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document,
|
|
25
|
-
boundClose: (event?: CloseEvent) => void;
|
|
26
|
-
boundHandlePong: () => void;
|
|
27
|
-
handlePong(): void;
|
|
22
|
+
constructor(connection: WebSocket, request: HTTPIncomingMessage, document: Document, socketId: string, context: any, readOnly?: boolean);
|
|
28
23
|
/**
|
|
29
24
|
* Set a callback that will be triggered when the connection is closed
|
|
30
25
|
*/
|
|
@@ -37,6 +32,10 @@ export declare class Connection {
|
|
|
37
32
|
* Set a callback that will be triggered before an message is handled
|
|
38
33
|
*/
|
|
39
34
|
beforeHandleMessage(callback: (connection: Connection, update: Uint8Array) => Promise<any>): Connection;
|
|
35
|
+
/**
|
|
36
|
+
* Set a callback that will be triggered before a sync message is handled
|
|
37
|
+
*/
|
|
38
|
+
beforeSync(callback: (connection: Connection, payload: Pick<beforeSyncPayload, 'type' | 'payload'>) => Promise<any>): Connection;
|
|
40
39
|
/**
|
|
41
40
|
* Send the given message
|
|
42
41
|
*/
|
|
@@ -49,11 +48,6 @@ export declare class Connection {
|
|
|
49
48
|
* Graceful wrapper around the WebSocket close method.
|
|
50
49
|
*/
|
|
51
50
|
close(event?: CloseEvent): void;
|
|
52
|
-
/**
|
|
53
|
-
* Check if pong was received and close the connection otherwise
|
|
54
|
-
* @private
|
|
55
|
-
*/
|
|
56
|
-
private check;
|
|
57
51
|
/**
|
|
58
52
|
* Send the current document awareness to the client, if any
|
|
59
53
|
* @private
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type Document from './Document.
|
|
2
|
-
import type { Hocuspocus } from './Hocuspocus.
|
|
3
|
-
import type { DirectConnection as DirectConnectionInterface } from './types.
|
|
1
|
+
import type Document from './Document.ts';
|
|
2
|
+
import type { Hocuspocus } from './Hocuspocus.ts';
|
|
3
|
+
import type { DirectConnection as DirectConnectionInterface } from './types.ts';
|
|
4
4
|
export declare class DirectConnection implements DirectConnectionInterface {
|
|
5
5
|
document: Document | null;
|
|
6
6
|
instance: Hocuspocus;
|
|
@@ -9,6 +9,6 @@ export declare class DirectConnection implements DirectConnectionInterface {
|
|
|
9
9
|
* Constructor.
|
|
10
10
|
*/
|
|
11
11
|
constructor(document: Document, instance: Hocuspocus, context?: any);
|
|
12
|
-
transact(transaction: (document: Document) => void
|
|
12
|
+
transact(transaction: (document: Document) => void): Promise<void>;
|
|
13
13
|
disconnect(): Promise<void>;
|
|
14
14
|
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type WebSocket from 'ws';
|
|
2
2
|
import { Awareness } from 'y-protocols/awareness';
|
|
3
3
|
import { Doc } from 'yjs';
|
|
4
|
-
import type
|
|
5
|
-
import type Connection from './Connection.js';
|
|
6
|
-
import type { Debugger } from './Debugger.js';
|
|
4
|
+
import type Connection from './Connection.ts';
|
|
7
5
|
export declare class Document extends Doc {
|
|
8
6
|
awareness: Awareness;
|
|
9
7
|
callbacks: {
|
|
@@ -16,14 +14,12 @@ export declare class Document extends Doc {
|
|
|
16
14
|
}>;
|
|
17
15
|
directConnectionsCount: number;
|
|
18
16
|
name: string;
|
|
19
|
-
mux: mutex;
|
|
20
|
-
logger?: Debugger;
|
|
21
17
|
isLoading: boolean;
|
|
22
18
|
isDestroyed: boolean;
|
|
23
19
|
/**
|
|
24
20
|
* Constructor.
|
|
25
21
|
*/
|
|
26
|
-
constructor(name: string,
|
|
22
|
+
constructor(name: string, yDocOptions?: object);
|
|
27
23
|
/**
|
|
28
24
|
* Check if the Document (XMLFragment or Map) is empty
|
|
29
25
|
*/
|