@hocuspocus/provider 3.2.2 → 3.2.3
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 +6 -3
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +6 -3
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +6 -1
- package/package.json +2 -2
- package/src/HocuspocusProviderWebsocket.ts +14 -5
|
@@ -2,11 +2,16 @@ import type { Event, MessageEvent } from "ws";
|
|
|
2
2
|
import EventEmitter from "./EventEmitter.ts";
|
|
3
3
|
import type { HocuspocusProvider } from "./HocuspocusProvider.ts";
|
|
4
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
|
|
5
|
+
export type HocuspocusWebSocket = WebSocket & {
|
|
6
6
|
identifier: string;
|
|
7
7
|
};
|
|
8
|
+
export type HocusPocusWebSocket = HocuspocusWebSocket;
|
|
8
9
|
export type HocuspocusProviderWebsocketConfiguration = Required<Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">> & Partial<CompleteHocuspocusProviderWebsocketConfiguration>;
|
|
9
10
|
export interface CompleteHocuspocusProviderWebsocketConfiguration {
|
|
11
|
+
/**
|
|
12
|
+
* Whether to connect automatically when creating the provider instance. Default=true
|
|
13
|
+
*/
|
|
14
|
+
autoConnect: boolean;
|
|
10
15
|
/**
|
|
11
16
|
* URL of your @hocuspocus/server instance
|
|
12
17
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hocuspocus/provider",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.3",
|
|
4
4
|
"description": "hocuspocus provider",
|
|
5
5
|
"homepage": "https://hocuspocus.dev",
|
|
6
6
|
"keywords": [
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dist"
|
|
30
30
|
],
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@hocuspocus/common": "^3.2.
|
|
32
|
+
"@hocuspocus/common": "^3.2.3",
|
|
33
33
|
"@lifeomic/attempt": "^3.0.2",
|
|
34
34
|
"lib0": "^0.2.87",
|
|
35
35
|
"ws": "^8.17.1"
|
|
@@ -18,7 +18,8 @@ import {
|
|
|
18
18
|
type onStatusParameters,
|
|
19
19
|
} from "./types.ts";
|
|
20
20
|
|
|
21
|
-
export type
|
|
21
|
+
export type HocuspocusWebSocket = WebSocket & { identifier: string };
|
|
22
|
+
export type HocusPocusWebSocket = HocuspocusWebSocket;
|
|
22
23
|
|
|
23
24
|
export type HocuspocusProviderWebsocketConfiguration = Required<
|
|
24
25
|
Pick<CompleteHocuspocusProviderWebsocketConfiguration, "url">
|
|
@@ -26,6 +27,11 @@ export type HocuspocusProviderWebsocketConfiguration = Required<
|
|
|
26
27
|
Partial<CompleteHocuspocusProviderWebsocketConfiguration>;
|
|
27
28
|
|
|
28
29
|
export interface CompleteHocuspocusProviderWebsocketConfiguration {
|
|
30
|
+
/**
|
|
31
|
+
* Whether to connect automatically when creating the provider instance. Default=true
|
|
32
|
+
*/
|
|
33
|
+
autoConnect: boolean;
|
|
34
|
+
|
|
29
35
|
/**
|
|
30
36
|
* URL of your @hocuspocus/server instance
|
|
31
37
|
*/
|
|
@@ -95,6 +101,7 @@ export class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
95
101
|
|
|
96
102
|
public configuration: CompleteHocuspocusProviderWebsocketConfiguration = {
|
|
97
103
|
url: "",
|
|
104
|
+
autoConnect: true,
|
|
98
105
|
// @ts-ignore
|
|
99
106
|
document: undefined,
|
|
100
107
|
WebSocketPolyfill: undefined,
|
|
@@ -179,11 +186,9 @@ export class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
179
186
|
this.configuration.messageReconnectTimeout / 10,
|
|
180
187
|
);
|
|
181
188
|
|
|
182
|
-
if (
|
|
183
|
-
|
|
189
|
+
if (this.shouldConnect) {
|
|
190
|
+
this.connect();
|
|
184
191
|
}
|
|
185
|
-
|
|
186
|
-
this.connect();
|
|
187
192
|
}
|
|
188
193
|
|
|
189
194
|
receivedOnOpenPayload?: Event | undefined = undefined;
|
|
@@ -222,6 +227,10 @@ export class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
222
227
|
configuration: Partial<HocuspocusProviderWebsocketConfiguration> = {},
|
|
223
228
|
): void {
|
|
224
229
|
this.configuration = { ...this.configuration, ...configuration };
|
|
230
|
+
|
|
231
|
+
if (!this.configuration.autoConnect) {
|
|
232
|
+
this.shouldConnect = false;
|
|
233
|
+
}
|
|
225
234
|
}
|
|
226
235
|
|
|
227
236
|
cancelWebsocketRetry?: () => void;
|