@hocuspocus/provider 3.2.2 → 3.2.4
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 +14 -5
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +14 -5
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-s3/src/S3.d.ts +44 -0
- package/dist/packages/extension-s3/src/index.d.ts +1 -0
- package/dist/packages/extension-webhook/src/index.d.ts +1 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +7 -5
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +6 -1
- package/dist/playground/backend/src/s3-redis.d.ts +1 -0
- package/dist/playground/backend/src/s3.d.ts +1 -0
- package/dist/tests/extension-s3/fetch.d.ts +1 -0
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +22 -4
- package/src/HocuspocusProviderWebsocket.ts +14 -5
|
@@ -1232,6 +1232,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1232
1232
|
this.messageQueue = [];
|
|
1233
1233
|
this.configuration = {
|
|
1234
1234
|
url: "",
|
|
1235
|
+
autoConnect: true,
|
|
1235
1236
|
// @ts-ignore
|
|
1236
1237
|
document: undefined,
|
|
1237
1238
|
WebSocketPolyfill: undefined,
|
|
@@ -1296,10 +1297,9 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1296
1297
|
this.on("close", this.onClose.bind(this));
|
|
1297
1298
|
this.on("message", this.onMessage.bind(this));
|
|
1298
1299
|
this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.configuration.messageReconnectTimeout / 10);
|
|
1299
|
-
if (
|
|
1300
|
-
|
|
1300
|
+
if (this.shouldConnect) {
|
|
1301
|
+
this.connect();
|
|
1301
1302
|
}
|
|
1302
|
-
this.connect();
|
|
1303
1303
|
}
|
|
1304
1304
|
async onOpen(event) {
|
|
1305
1305
|
this.status = exports.WebSocketStatus.Connected;
|
|
@@ -1326,6 +1326,9 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1326
1326
|
}
|
|
1327
1327
|
setConfiguration(configuration = {}) {
|
|
1328
1328
|
this.configuration = { ...this.configuration, ...configuration };
|
|
1329
|
+
if (!this.configuration.autoConnect) {
|
|
1330
|
+
this.shouldConnect = false;
|
|
1331
|
+
}
|
|
1329
1332
|
}
|
|
1330
1333
|
async connect() {
|
|
1331
1334
|
if (this.status === exports.WebSocketStatus.Connected) {
|
|
@@ -1895,6 +1898,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1895
1898
|
onMessage: () => null,
|
|
1896
1899
|
onOutgoingMessage: () => null,
|
|
1897
1900
|
onSynced: () => null,
|
|
1901
|
+
onStatus: () => null,
|
|
1898
1902
|
onDisconnect: () => null,
|
|
1899
1903
|
onClose: () => null,
|
|
1900
1904
|
onDestroy: () => null,
|
|
@@ -1918,10 +1922,11 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1918
1922
|
this.boundPageHide = this.pageHide.bind(this);
|
|
1919
1923
|
this.boundOnOpen = this.onOpen.bind(this);
|
|
1920
1924
|
this.boundOnClose = this.onClose.bind(this);
|
|
1921
|
-
this.forwardConnect = (
|
|
1925
|
+
this.forwardConnect = () => this.emit("connect");
|
|
1926
|
+
this.forwardStatus = (e) => this.emit("status", e);
|
|
1922
1927
|
this.forwardClose = (e) => this.emit("close", e);
|
|
1923
1928
|
this.forwardDisconnect = (e) => this.emit("disconnect", e);
|
|
1924
|
-
this.forwardDestroy = (
|
|
1929
|
+
this.forwardDestroy = () => this.emit("destroy");
|
|
1925
1930
|
this.setConfiguration(configuration);
|
|
1926
1931
|
this.configuration.document = configuration.document
|
|
1927
1932
|
? configuration.document
|
|
@@ -2158,6 +2163,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2158
2163
|
detach() {
|
|
2159
2164
|
this.configuration.websocketProvider.off("connect", this.configuration.onConnect);
|
|
2160
2165
|
this.configuration.websocketProvider.off("connect", this.forwardConnect);
|
|
2166
|
+
this.configuration.websocketProvider.off("status", this.forwardStatus);
|
|
2167
|
+
this.configuration.websocketProvider.off("status", this.configuration.onStatus);
|
|
2161
2168
|
this.configuration.websocketProvider.off("open", this.boundOnOpen);
|
|
2162
2169
|
this.configuration.websocketProvider.off("close", this.boundOnClose);
|
|
2163
2170
|
this.configuration.websocketProvider.off("close", this.configuration.onClose);
|
|
@@ -2174,6 +2181,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2174
2181
|
return;
|
|
2175
2182
|
this.configuration.websocketProvider.on("connect", this.configuration.onConnect);
|
|
2176
2183
|
this.configuration.websocketProvider.on("connect", this.forwardConnect);
|
|
2184
|
+
this.configuration.websocketProvider.on("status", this.configuration.onStatus);
|
|
2185
|
+
this.configuration.websocketProvider.on("status", this.forwardStatus);
|
|
2177
2186
|
this.configuration.websocketProvider.on("open", this.boundOnOpen);
|
|
2178
2187
|
this.configuration.websocketProvider.on("close", this.boundOnClose);
|
|
2179
2188
|
this.configuration.websocketProvider.on("close", this.configuration.onClose);
|