@hocuspocus/provider 1.0.0-alpha.34 → 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 +11 -11
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +11 -11
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-monitor/src/Collector.d.ts +0 -2
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +11 -21
- package/dist/packages/provider/src/types.d.ts +33 -0
- package/dist/packages/server/src/types.d.ts +0 -1
- package/package.json +4 -4
- package/src/HocuspocusProvider.ts +17 -22
- 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
|
}
|
|
@@ -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
|
*/
|
|
@@ -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
|
};
|
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
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
|
}
|
|
@@ -19,16 +19,11 @@ import { QueryAwarenessMessage } from './OutgoingMessages/QueryAwarenessMessage'
|
|
|
19
19
|
import { AuthenticationMessage } from './OutgoingMessages/AuthenticationMessage'
|
|
20
20
|
import { AwarenessMessage } from './OutgoingMessages/AwarenessMessage'
|
|
21
21
|
import { UpdateMessage } from './OutgoingMessages/UpdateMessage'
|
|
22
|
-
import {
|
|
23
|
-
|
|
22
|
+
import {
|
|
23
|
+
ConstructableOutgoingMessage, onAuthenticationFailedParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatusParameters, onSyncedParameters, WebSocketStatus,
|
|
24
|
+
} from './types'
|
|
24
25
|
import { onAwarenessChangeParameters, onAwarenessUpdateParameters } from '.'
|
|
25
26
|
|
|
26
|
-
export enum WebSocketStatus {
|
|
27
|
-
Connecting = 'connecting',
|
|
28
|
-
Connected = 'connected',
|
|
29
|
-
Disconnected = 'disconnected',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
27
|
export type HocuspocusProviderConfiguration =
|
|
33
28
|
Required<Pick<CompleteHocuspocusProviderConfiguration, 'url' | 'name'>>
|
|
34
29
|
& Partial<CompleteHocuspocusProviderConfiguration>
|
|
@@ -111,18 +106,18 @@ export interface CompleteHocuspocusProviderConfiguration {
|
|
|
111
106
|
*/
|
|
112
107
|
timeout: number,
|
|
113
108
|
onAuthenticated: () => void,
|
|
114
|
-
onAuthenticationFailed: (
|
|
115
|
-
onOpen: (
|
|
109
|
+
onAuthenticationFailed: (data: onAuthenticationFailedParameters) => void,
|
|
110
|
+
onOpen: (data: onOpenParameters) => void,
|
|
116
111
|
onConnect: () => void,
|
|
117
|
-
onMessage: (
|
|
118
|
-
onOutgoingMessage: (
|
|
119
|
-
onStatus: (
|
|
120
|
-
onSynced: (
|
|
121
|
-
onDisconnect: (
|
|
122
|
-
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,
|
|
123
118
|
onDestroy: () => void,
|
|
124
|
-
onAwarenessUpdate: (
|
|
125
|
-
onAwarenessChange: (
|
|
119
|
+
onAwarenessUpdate: (data: onAwarenessUpdateParameters) => void,
|
|
120
|
+
onAwarenessChange: (data: onAwarenessChangeParameters) => void,
|
|
126
121
|
/**
|
|
127
122
|
* Don’t output any warnings.
|
|
128
123
|
*/
|
|
@@ -313,7 +308,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
313
308
|
// Reset the status
|
|
314
309
|
this.synced = false
|
|
315
310
|
this.status = WebSocketStatus.Connecting
|
|
316
|
-
this.emit('status', { status:
|
|
311
|
+
this.emit('status', { status: WebSocketStatus.Connecting })
|
|
317
312
|
|
|
318
313
|
// Store resolve/reject for later use
|
|
319
314
|
this.connectionAttempt = {
|
|
@@ -328,7 +323,7 @@ export class HocuspocusProvider extends EventEmitter {
|
|
|
328
323
|
this.connectionAttempt = null
|
|
329
324
|
|
|
330
325
|
this.status = WebSocketStatus.Connected
|
|
331
|
-
this.emit('status', { status:
|
|
326
|
+
this.emit('status', { status: WebSocketStatus.Connected })
|
|
332
327
|
this.emit('connect')
|
|
333
328
|
}
|
|
334
329
|
|
|
@@ -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
|
|
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
|
}
|