@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
|
@@ -1211,6 +1211,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1211
1211
|
this.messageQueue = [];
|
|
1212
1212
|
this.configuration = {
|
|
1213
1213
|
url: "",
|
|
1214
|
+
autoConnect: true,
|
|
1214
1215
|
// @ts-ignore
|
|
1215
1216
|
document: undefined,
|
|
1216
1217
|
WebSocketPolyfill: undefined,
|
|
@@ -1275,10 +1276,9 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1275
1276
|
this.on("close", this.onClose.bind(this));
|
|
1276
1277
|
this.on("message", this.onMessage.bind(this));
|
|
1277
1278
|
this.intervals.connectionChecker = setInterval(this.checkConnection.bind(this), this.configuration.messageReconnectTimeout / 10);
|
|
1278
|
-
if (
|
|
1279
|
-
|
|
1279
|
+
if (this.shouldConnect) {
|
|
1280
|
+
this.connect();
|
|
1280
1281
|
}
|
|
1281
|
-
this.connect();
|
|
1282
1282
|
}
|
|
1283
1283
|
async onOpen(event) {
|
|
1284
1284
|
this.status = WebSocketStatus.Connected;
|
|
@@ -1305,6 +1305,9 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1305
1305
|
}
|
|
1306
1306
|
setConfiguration(configuration = {}) {
|
|
1307
1307
|
this.configuration = { ...this.configuration, ...configuration };
|
|
1308
|
+
if (!this.configuration.autoConnect) {
|
|
1309
|
+
this.shouldConnect = false;
|
|
1310
|
+
}
|
|
1308
1311
|
}
|
|
1309
1312
|
async connect() {
|
|
1310
1313
|
if (this.status === WebSocketStatus.Connected) {
|
|
@@ -1874,6 +1877,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1874
1877
|
onMessage: () => null,
|
|
1875
1878
|
onOutgoingMessage: () => null,
|
|
1876
1879
|
onSynced: () => null,
|
|
1880
|
+
onStatus: () => null,
|
|
1877
1881
|
onDisconnect: () => null,
|
|
1878
1882
|
onClose: () => null,
|
|
1879
1883
|
onDestroy: () => null,
|
|
@@ -1897,10 +1901,11 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1897
1901
|
this.boundPageHide = this.pageHide.bind(this);
|
|
1898
1902
|
this.boundOnOpen = this.onOpen.bind(this);
|
|
1899
1903
|
this.boundOnClose = this.onClose.bind(this);
|
|
1900
|
-
this.forwardConnect = (
|
|
1904
|
+
this.forwardConnect = () => this.emit("connect");
|
|
1905
|
+
this.forwardStatus = (e) => this.emit("status", e);
|
|
1901
1906
|
this.forwardClose = (e) => this.emit("close", e);
|
|
1902
1907
|
this.forwardDisconnect = (e) => this.emit("disconnect", e);
|
|
1903
|
-
this.forwardDestroy = (
|
|
1908
|
+
this.forwardDestroy = () => this.emit("destroy");
|
|
1904
1909
|
this.setConfiguration(configuration);
|
|
1905
1910
|
this.configuration.document = configuration.document
|
|
1906
1911
|
? configuration.document
|
|
@@ -2137,6 +2142,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2137
2142
|
detach() {
|
|
2138
2143
|
this.configuration.websocketProvider.off("connect", this.configuration.onConnect);
|
|
2139
2144
|
this.configuration.websocketProvider.off("connect", this.forwardConnect);
|
|
2145
|
+
this.configuration.websocketProvider.off("status", this.forwardStatus);
|
|
2146
|
+
this.configuration.websocketProvider.off("status", this.configuration.onStatus);
|
|
2140
2147
|
this.configuration.websocketProvider.off("open", this.boundOnOpen);
|
|
2141
2148
|
this.configuration.websocketProvider.off("close", this.boundOnClose);
|
|
2142
2149
|
this.configuration.websocketProvider.off("close", this.configuration.onClose);
|
|
@@ -2153,6 +2160,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2153
2160
|
return;
|
|
2154
2161
|
this.configuration.websocketProvider.on("connect", this.configuration.onConnect);
|
|
2155
2162
|
this.configuration.websocketProvider.on("connect", this.forwardConnect);
|
|
2163
|
+
this.configuration.websocketProvider.on("status", this.configuration.onStatus);
|
|
2164
|
+
this.configuration.websocketProvider.on("status", this.forwardStatus);
|
|
2156
2165
|
this.configuration.websocketProvider.on("open", this.boundOnOpen);
|
|
2157
2166
|
this.configuration.websocketProvider.on("close", this.boundOnClose);
|
|
2158
2167
|
this.configuration.websocketProvider.on("close", this.configuration.onClose);
|