@hocuspocus/provider 1.0.0-alpha.32 → 1.0.0-alpha.35
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-provider.cjs +27 -28
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +28 -29
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/common/src/index.d.ts +1 -0
- package/dist/packages/common/src/types.d.ts +10 -0
- package/dist/packages/extension-monitor/src/Collector.d.ts +0 -2
- package/dist/packages/extension-monitor/src/index.d.ts +2 -2
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +13 -23
- package/dist/packages/provider/src/types.d.ts +33 -0
- package/dist/packages/server/src/types.d.ts +0 -11
- package/package.json +5 -5
- package/src/HocuspocusProvider.ts +38 -43
- package/src/types.ts +42 -0
|
@@ -3,7 +3,6 @@ import { Configuration, onConnectPayload, onDisconnectPayload, onLoadDocumentPay
|
|
|
3
3
|
export declare class Collector {
|
|
4
4
|
serverConfiguration: Partial<Configuration>;
|
|
5
5
|
version: string;
|
|
6
|
-
yjsVersion: string;
|
|
7
6
|
connections: {};
|
|
8
7
|
messages: {};
|
|
9
8
|
messageCounter: number;
|
|
@@ -56,7 +55,6 @@ export declare class Collector {
|
|
|
56
55
|
platform: NodeJS.Platform;
|
|
57
56
|
started: string;
|
|
58
57
|
version: string;
|
|
59
|
-
yjsVersion: string;
|
|
60
58
|
}>;
|
|
61
59
|
private static readableYDoc;
|
|
62
60
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
import { Extension, onChangePayload, onConfigurePayload,
|
|
2
|
+
import { Extension, onChangePayload, onConfigurePayload, onLoadDocumentPayload, onDisconnectPayload, onRequestPayload, onUpgradePayload, connectedPayload } from '@hocuspocus/server';
|
|
3
3
|
import { IncomingMessage, ServerResponse } from 'http';
|
|
4
4
|
import WebSocket from 'ws';
|
|
5
5
|
import { Storage } from './Storage';
|
|
@@ -30,7 +30,7 @@ export declare class Monitor implements Extension {
|
|
|
30
30
|
handleConnection(websocket: WebSocket, request: IncomingMessage): void | undefined;
|
|
31
31
|
onRequest({ request, response }: onRequestPayload): Promise<void>;
|
|
32
32
|
onUpgrade({ request, socket, head }: onUpgradePayload): Promise<void>;
|
|
33
|
-
|
|
33
|
+
connected(data: connectedPayload): Promise<void>;
|
|
34
34
|
onDisconnect(data: onDisconnectPayload): Promise<void>;
|
|
35
35
|
onLoadDocument(data: onLoadDocumentPayload): Promise<void>;
|
|
36
36
|
onChange(data: onChangePayload): Promise<void>;
|
|
@@ -3,14 +3,8 @@ import { Awareness } from 'y-protocols/awareness';
|
|
|
3
3
|
import * as mutex from 'lib0/mutex';
|
|
4
4
|
import type { Event, CloseEvent, MessageEvent } from 'ws';
|
|
5
5
|
import EventEmitter from './EventEmitter';
|
|
6
|
-
import {
|
|
7
|
-
import { ConstructableOutgoingMessage } from './types';
|
|
6
|
+
import { ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus } from './types';
|
|
8
7
|
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.';
|
|
9
|
-
export declare enum WebSocketStatus {
|
|
10
|
-
Connecting = "connecting",
|
|
11
|
-
Connected = "connected",
|
|
12
|
-
Disconnected = "disconnected"
|
|
13
|
-
}
|
|
14
8
|
export declare type HocuspocusProviderConfiguration = Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>> & Partial<CompleteHocuspocusProviderConfiguration>;
|
|
15
9
|
export interface CompleteHocuspocusProviderConfiguration {
|
|
16
10
|
/**
|
|
@@ -92,22 +86,18 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
92
86
|
*/
|
|
93
87
|
timeout: number;
|
|
94
88
|
onAuthenticated: () => void;
|
|
95
|
-
onAuthenticationFailed: (
|
|
96
|
-
|
|
97
|
-
}) => void;
|
|
98
|
-
onOpen: (event: Event) => void;
|
|
89
|
+
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void;
|
|
90
|
+
onOpen: (data: onOpenParameters) => void;
|
|
99
91
|
onConnect: () => void;
|
|
100
|
-
onMessage: (
|
|
101
|
-
onOutgoingMessage: (
|
|
102
|
-
onStatus: (
|
|
103
|
-
onSynced: (
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
onDisconnect: (event: CloseEvent) => void;
|
|
107
|
-
onClose: (event: CloseEvent) => void;
|
|
92
|
+
onMessage: (data: onMessageParameters) => void;
|
|
93
|
+
onOutgoingMessage: (data: onOutgoingMessageParameters) => void;
|
|
94
|
+
onStatus: (data: onStatusParameters) => void;
|
|
95
|
+
onSynced: (data: onSyncedParameters) => void;
|
|
96
|
+
onDisconnect: (data: onDisconnectParameters) => void;
|
|
97
|
+
onClose: (data: onCloseParameters) => void;
|
|
108
98
|
onDestroy: () => void;
|
|
109
|
-
onAwarenessUpdate: (
|
|
110
|
-
onAwarenessChange: (
|
|
99
|
+
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void;
|
|
100
|
+
onAwarenessChange: (data: onAwarenessChangeParameters) => void;
|
|
111
101
|
/**
|
|
112
102
|
* Don’t output any warnings.
|
|
113
103
|
*/
|
|
@@ -133,6 +123,7 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
133
123
|
connect(): Promise<void>;
|
|
134
124
|
createWebSocketConnection(): Promise<unknown>;
|
|
135
125
|
resolveConnectionAttempt(): void;
|
|
126
|
+
stopConnectionAttempt(): void;
|
|
136
127
|
rejectConnectionAttempt(): void;
|
|
137
128
|
get document(): Y.Doc;
|
|
138
129
|
get awareness(): Awareness;
|
|
@@ -149,9 +140,8 @@ export declare class HocuspocusProvider extends EventEmitter {
|
|
|
149
140
|
set synced(state: boolean);
|
|
150
141
|
get isAuthenticationRequired(): boolean;
|
|
151
142
|
disconnect(): void;
|
|
152
|
-
onOpen(event: Event): void
|
|
143
|
+
onOpen(event: Event): Promise<void>;
|
|
153
144
|
getToken(): Promise<string | null>;
|
|
154
|
-
webSocketConnectionEstablished(): Promise<void>;
|
|
155
145
|
startSync(): void;
|
|
156
146
|
send(Message: ConstructableOutgoingMessage, args: any, broadcast?: boolean): void;
|
|
157
147
|
onMessage(event: MessageEvent): void;
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
import { Awareness } from 'y-protocols/awareness';
|
|
2
2
|
import * as Y from 'yjs';
|
|
3
3
|
import { Encoder } from 'lib0/encoding';
|
|
4
|
+
import type { Event, CloseEvent, MessageEvent } from 'ws';
|
|
4
5
|
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage';
|
|
5
6
|
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage';
|
|
6
7
|
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage';
|
|
7
8
|
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage';
|
|
8
9
|
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage';
|
|
9
10
|
import { UpdateMessage } from './OutgoingMessages/UpdateMessage';
|
|
11
|
+
import { IncomingMessage } from './IncomingMessage';
|
|
12
|
+
import { OutgoingMessage } from './OutgoingMessage';
|
|
10
13
|
export declare enum MessageType {
|
|
11
14
|
Sync = 0,
|
|
12
15
|
Awareness = 1,
|
|
13
16
|
Auth = 2,
|
|
14
17
|
QueryAwareness = 3
|
|
15
18
|
}
|
|
19
|
+
export declare enum WebSocketStatus {
|
|
20
|
+
Connecting = "connecting",
|
|
21
|
+
Connected = "connected",
|
|
22
|
+
Disconnected = "disconnected"
|
|
23
|
+
}
|
|
16
24
|
export interface OutgoingMessageInterface {
|
|
17
25
|
encoder: Encoder;
|
|
18
26
|
type?: MessageType;
|
|
@@ -32,6 +40,31 @@ export interface Constructable<T> {
|
|
|
32
40
|
new (...args: any): T;
|
|
33
41
|
}
|
|
34
42
|
export declare type ConstructableOutgoingMessage = Constructable<AuthenticationMessage> | Constructable<AwarenessMessage> | Constructable<QueryAwarenessMessage> | Constructable<SyncStepOneMessage> | Constructable<SyncStepTwoMessage> | Constructable<UpdateMessage>;
|
|
43
|
+
export declare type onAuthenticationFailedParameters = {
|
|
44
|
+
reason: string;
|
|
45
|
+
};
|
|
46
|
+
export declare type onOpenParameters = {
|
|
47
|
+
event: Event;
|
|
48
|
+
};
|
|
49
|
+
export declare type onMessageParameters = {
|
|
50
|
+
event: MessageEvent;
|
|
51
|
+
message: IncomingMessage;
|
|
52
|
+
};
|
|
53
|
+
export declare type onOutgoingMessageParameters = {
|
|
54
|
+
message: OutgoingMessage;
|
|
55
|
+
};
|
|
56
|
+
export declare type onStatusParameters = {
|
|
57
|
+
status: WebSocketStatus;
|
|
58
|
+
};
|
|
59
|
+
export declare type onSyncedParameters = {
|
|
60
|
+
state: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare type onDisconnectParameters = {
|
|
63
|
+
event: CloseEvent;
|
|
64
|
+
};
|
|
65
|
+
export declare type onCloseParameters = {
|
|
66
|
+
event: CloseEvent;
|
|
67
|
+
};
|
|
35
68
|
export declare type onAwarenessUpdateParameters = {
|
|
36
69
|
states: StatesArray;
|
|
37
70
|
};
|
|
@@ -12,16 +12,6 @@ export declare enum MessageType {
|
|
|
12
12
|
Auth = 2,
|
|
13
13
|
QueryAwareness = 3
|
|
14
14
|
}
|
|
15
|
-
/**
|
|
16
|
-
* State of the WebSocket connection.
|
|
17
|
-
* https://developer.mozilla.org/de/docs/Web/API/WebSocket/readyState
|
|
18
|
-
*/
|
|
19
|
-
export declare enum WsReadyStates {
|
|
20
|
-
Connecting = 0,
|
|
21
|
-
Open = 1,
|
|
22
|
-
Closing = 2,
|
|
23
|
-
Closed = 3
|
|
24
|
-
}
|
|
25
15
|
export interface AwarenessUpdate {
|
|
26
16
|
added: Array<any>;
|
|
27
17
|
updated: Array<any>;
|
|
@@ -222,6 +212,5 @@ export interface onDestroyPayload {
|
|
|
222
212
|
export interface onConfigurePayload {
|
|
223
213
|
configuration: Configuration;
|
|
224
214
|
version: string;
|
|
225
|
-
yjsVersion: string;
|
|
226
215
|
instance: Hocuspocus;
|
|
227
216
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.35",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"dist"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@hocuspocus/common": "^1.0.0-alpha.
|
|
31
|
+
"@hocuspocus/common": "^1.0.0-alpha.10",
|
|
32
32
|
"@lifeomic/attempt": "^3.0.2",
|
|
33
|
-
"lib0": "^0.2.
|
|
33
|
+
"lib0": "^0.2.46",
|
|
34
34
|
"y-protocols": "^1.0.5",
|
|
35
|
-
"yjs": "^13.5.
|
|
35
|
+
"yjs": "^13.5.29"
|
|
36
36
|
},
|
|
37
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "1fc2a6cff1b5fd626b8dd7c486755111965da20d"
|
|
38
38
|
}
|
|
@@ -6,7 +6,9 @@ import * as mutex from 'lib0/mutex'
|
|
|
6
6
|
import * as url from 'lib0/url'
|
|
7
7
|
import type { Event, CloseEvent, MessageEvent } from 'ws'
|
|
8
8
|
import { retry } from '@lifeomic/attempt'
|
|
9
|
-
import {
|
|
9
|
+
import {
|
|
10
|
+
awarenessStatesToArray, Forbidden, Unauthorized, WsReadyStates,
|
|
11
|
+
} from '@hocuspocus/common'
|
|
10
12
|
import EventEmitter from './EventEmitter'
|
|
11
13
|
import { IncomingMessage } from './IncomingMessage'
|
|
12
14
|
import { MessageReceiver } from './MessageReceiver'
|
|
@@ -17,16 +19,11 @@ import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage'
|
|
|
17
19
|
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage'
|
|
18
20
|
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage'
|
|
19
21
|
import { UpdateMessage } from './OutgoingMessages/UpdateMessage'
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
+
import {
|
|
23
|
+
ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus,
|
|
24
|
+
} from './types'
|
|
22
25
|
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.'
|
|
23
26
|
|
|
24
|
-
export enum WebSocketStatus {
|
|
25
|
-
Connecting = 'connecting',
|
|
26
|
-
Connected = 'connected',
|
|
27
|
-
Disconnected = 'disconnected',
|
|
28
|
-
}
|
|
29
|
-
|
|
30
27
|
export type HocuspocusProviderConfiguration =
|
|
31
28
|
Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>>
|
|
32
29
|
& Partial<CompleteHocuspocusProviderConfiguration>
|
|
@@ -109,18 +106,18 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
109
106
|
*/
|
|
110
107
|
timeout: number,
|
|
111
108
|
onAuthenticated: () => void,
|
|
112
|
-
onAuthenticationFailed: (
|
|
113
|
-
onOpen: (
|
|
109
|
+
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void,
|
|
110
|
+
onOpen: (data: onOpenParameters) => void,
|
|
114
111
|
onConnect: () => void,
|
|
115
|
-
onMessage: (
|
|
116
|
-
onOutgoingMessage: (
|
|
117
|
-
onStatus: (
|
|
118
|
-
onSynced: (
|
|
119
|
-
onDisconnect: (
|
|
120
|
-
onClose: (
|
|
112
|
+
onMessage: (data: onMessageParameters) => void,
|
|
113
|
+
onOutgoingMessage: (data: onOutgoingMessageParameters) => void,
|
|
114
|
+
onStatus: (data: onStatusParameters) => void,
|
|
115
|
+
onSynced: (data: onSyncedParameters) => void,
|
|
116
|
+
onDisconnect: (data: onDisconnectParameters) => void,
|
|
117
|
+
onClose: (data: onCloseParameters) => void,
|
|
121
118
|
onDestroy: () => void,
|
|
122
|
-
onAwarenessUpdate: (
|
|
123
|
-
onAwarenessChange: (
|
|
119
|
+
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void,
|
|
120
|
+
onAwarenessChange: (data: onAwarenessChangeParameters) => void,
|
|
124
121
|
/**
|
|
125
122
|
* Don’t output any warnings.
|
|
126
123
|
*/
|
|
@@ -311,7 +308,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
311
308
|
// Reset the status
|
|
312
309
|
this.synced = false
|
|
313
310
|
this.status = WebSocketStatus.Connecting
|
|
314
|
-
this.emit('status', { status:
|
|
311
|
+
this.emit('status', { status: WebSocketStatus.Connecting })
|
|
315
312
|
|
|
316
313
|
// Store resolve/reject for later use
|
|
317
314
|
this.connectionAttempt = {
|
|
@@ -324,6 +321,14 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
324
321
|
resolveConnectionAttempt() {
|
|
325
322
|
this.connectionAttempt?.resolve()
|
|
326
323
|
this.connectionAttempt = null
|
|
324
|
+
|
|
325
|
+
this.status = WebSocketStatus.Connected
|
|
326
|
+
this.emit('status', { status: WebSocketStatus.Connected })
|
|
327
|
+
this.emit('connect')
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
stopConnectionAttempt() {
|
|
331
|
+
this.connectionAttempt = null
|
|
327
332
|
}
|
|
328
333
|
|
|
329
334
|
rejectConnectionAttempt() {
|
|
@@ -457,12 +462,17 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
457
462
|
}
|
|
458
463
|
}
|
|
459
464
|
|
|
460
|
-
onOpen(event: Event) {
|
|
465
|
+
async onOpen(event: Event) {
|
|
461
466
|
this.emit('open', { event })
|
|
462
467
|
|
|
463
|
-
if (this.
|
|
464
|
-
this.
|
|
468
|
+
if (this.isAuthenticationRequired) {
|
|
469
|
+
this.send(AuthenticationMessage, {
|
|
470
|
+
token: await this.getToken(),
|
|
471
|
+
})
|
|
472
|
+
return
|
|
465
473
|
}
|
|
474
|
+
|
|
475
|
+
this.startSync()
|
|
466
476
|
}
|
|
467
477
|
|
|
468
478
|
async getToken() {
|
|
@@ -474,21 +484,6 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
474
484
|
return this.configuration.token
|
|
475
485
|
}
|
|
476
486
|
|
|
477
|
-
async webSocketConnectionEstablished() {
|
|
478
|
-
this.status = WebSocketStatus.Connected
|
|
479
|
-
this.emit('status', { status: 'connected' })
|
|
480
|
-
this.emit('connect')
|
|
481
|
-
|
|
482
|
-
if (this.isAuthenticationRequired) {
|
|
483
|
-
this.send(AuthenticationMessage, {
|
|
484
|
-
token: await this.getToken(),
|
|
485
|
-
})
|
|
486
|
-
return
|
|
487
|
-
}
|
|
488
|
-
|
|
489
|
-
this.startSync()
|
|
490
|
-
}
|
|
491
|
-
|
|
492
487
|
startSync() {
|
|
493
488
|
this.send(SyncStepOneMessage, { document: this.document })
|
|
494
489
|
|
|
@@ -505,7 +500,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
505
500
|
this.mux(() => { this.broadcast(Message, args) })
|
|
506
501
|
}
|
|
507
502
|
|
|
508
|
-
if (this.
|
|
503
|
+
if (this.webSocket?.readyState === WsReadyStates.Open) {
|
|
509
504
|
const messageSender = new MessageSender(Message, args)
|
|
510
505
|
|
|
511
506
|
this.emit('outgoingMessage', { message: messageSender.message })
|
|
@@ -541,7 +536,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
541
536
|
)
|
|
542
537
|
|
|
543
538
|
this.status = WebSocketStatus.Disconnected
|
|
544
|
-
this.emit('status', { status:
|
|
539
|
+
this.emit('status', { status: WebSocketStatus.Disconnected })
|
|
545
540
|
this.emit('disconnect', { event })
|
|
546
541
|
}
|
|
547
542
|
|
|
@@ -579,7 +574,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
579
574
|
|
|
580
575
|
// Let’s update the connection status.
|
|
581
576
|
this.status = WebSocketStatus.Disconnected
|
|
582
|
-
this.emit('status', { status:
|
|
577
|
+
this.emit('status', { status: WebSocketStatus.Disconnected })
|
|
583
578
|
this.emit('disconnect', { event })
|
|
584
579
|
}
|
|
585
580
|
|
|
@@ -594,10 +589,10 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
594
589
|
|
|
595
590
|
removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy')
|
|
596
591
|
|
|
597
|
-
// If there is still a connection attempt outstanding then we should
|
|
592
|
+
// If there is still a connection attempt outstanding then we should stop
|
|
598
593
|
// it before calling disconnect, otherwise it will be rejected in the onClose
|
|
599
594
|
// handler and trigger a retry
|
|
600
|
-
this.
|
|
595
|
+
this.stopConnectionAttempt()
|
|
601
596
|
|
|
602
597
|
this.disconnect()
|
|
603
598
|
|
package/src/types.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import { Awareness } from 'y-protocols/awareness'
|
|
2
2
|
import * as Y from 'yjs'
|
|
3
3
|
import { Encoder } from 'lib0/encoding'
|
|
4
|
+
import type { Event, CloseEvent, MessageEvent } from 'ws'
|
|
4
5
|
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage'
|
|
5
6
|
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage'
|
|
6
7
|
import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage'
|
|
7
8
|
import { SyncStepOneMessage } from './OutgoingMessages/SyncStepOneMessage'
|
|
8
9
|
import { SyncStepTwoMessage } from './OutgoingMessages/SyncStepTwoMessage'
|
|
9
10
|
import { UpdateMessage } from './OutgoingMessages/UpdateMessage'
|
|
11
|
+
import { IncomingMessage } from './IncomingMessage'
|
|
12
|
+
import { OutgoingMessage } from './OutgoingMessage'
|
|
10
13
|
|
|
11
14
|
export enum MessageType {
|
|
12
15
|
Sync = 0,
|
|
@@ -15,6 +18,12 @@ export enum MessageType {
|
|
|
15
18
|
QueryAwareness = 3,
|
|
16
19
|
}
|
|
17
20
|
|
|
21
|
+
export enum WebSocketStatus {
|
|
22
|
+
Connecting = 'connecting',
|
|
23
|
+
Connected = 'connected',
|
|
24
|
+
Disconnected = 'disconnected',
|
|
25
|
+
}
|
|
26
|
+
|
|
18
27
|
export interface OutgoingMessageInterface {
|
|
19
28
|
encoder: Encoder
|
|
20
29
|
type?: MessageType
|
|
@@ -42,6 +51,39 @@ export type ConstructableOutgoingMessage =
|
|
|
42
51
|
Constructable<SyncStepTwoMessage> |
|
|
43
52
|
Constructable<UpdateMessage>
|
|
44
53
|
|
|
54
|
+
export type onAuthenticationFailedParameters = {
|
|
55
|
+
reason: string,
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type onOpenParameters = {
|
|
59
|
+
event: Event,
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export type onMessageParameters = {
|
|
63
|
+
event: MessageEvent,
|
|
64
|
+
message: IncomingMessage,
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type onOutgoingMessageParameters = {
|
|
68
|
+
message: OutgoingMessage,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export type onStatusParameters = {
|
|
72
|
+
status: WebSocketStatus,
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export type onSyncedParameters = {
|
|
76
|
+
state: boolean,
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export type onDisconnectParameters = {
|
|
80
|
+
event: CloseEvent,
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export type onCloseParameters = {
|
|
84
|
+
event: CloseEvent,
|
|
85
|
+
}
|
|
86
|
+
|
|
45
87
|
export type onAwarenessUpdateParameters = {
|
|
46
88
|
states: StatesArray
|
|
47
89
|
}
|