@hocuspocus/provider 3.4.3 → 3.4.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 +11 -9
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +11 -9
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/common/src/auth.d.ts +2 -1
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProviderWebsocket.d.ts +5 -0
- package/dist/packages/provider/src/types.d.ts +2 -1
- package/dist/packages/server/src/Connection.d.ts +7 -3
- package/dist/packages/server/src/MessageReceiver.d.ts +1 -1
- package/package.json +2 -2
- package/src/HocuspocusProvider.ts +16 -9
- package/src/HocuspocusProviderWebsocket.ts +16 -4
- package/src/MessageReceiver.ts +2 -2
- package/src/types.ts +3 -1
|
@@ -1233,6 +1233,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1233
1233
|
this.configuration = {
|
|
1234
1234
|
url: "",
|
|
1235
1235
|
autoConnect: true,
|
|
1236
|
+
preserveTrailingSlash: false,
|
|
1236
1237
|
// @ts-ignore
|
|
1237
1238
|
document: undefined,
|
|
1238
1239
|
WebSocketPolyfill: undefined,
|
|
@@ -1496,12 +1497,16 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1496
1497
|
this.messageQueue = [];
|
|
1497
1498
|
}
|
|
1498
1499
|
}
|
|
1499
|
-
// Ensure that the URL never ends with /
|
|
1500
1500
|
get serverUrl() {
|
|
1501
|
-
|
|
1502
|
-
return this.configuration.url
|
|
1501
|
+
if (this.configuration.preserveTrailingSlash) {
|
|
1502
|
+
return this.configuration.url;
|
|
1503
1503
|
}
|
|
1504
|
-
|
|
1504
|
+
// By default, ensure that the URL never ends with /
|
|
1505
|
+
let url = this.configuration.url;
|
|
1506
|
+
while (url[url.length - 1] === "/") {
|
|
1507
|
+
url = url.slice(0, url.length - 1);
|
|
1508
|
+
}
|
|
1509
|
+
return url;
|
|
1505
1510
|
}
|
|
1506
1511
|
get url() {
|
|
1507
1512
|
return this.serverUrl;
|
|
@@ -1725,7 +1730,7 @@ class MessageReceiver {
|
|
|
1725
1730
|
};
|
|
1726
1731
|
provider.onClose();
|
|
1727
1732
|
provider.configuration.onClose({ event });
|
|
1728
|
-
provider.forwardClose(event);
|
|
1733
|
+
provider.forwardClose({ event });
|
|
1729
1734
|
break;
|
|
1730
1735
|
default:
|
|
1731
1736
|
throw new Error(`Can’t apply message of unknown type: ${type}`);
|
|
@@ -1970,11 +1975,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1970
1975
|
}
|
|
1971
1976
|
setConfiguration(configuration = {}) {
|
|
1972
1977
|
if (!configuration.websocketProvider) {
|
|
1973
|
-
const websocketProviderConfig = configuration;
|
|
1974
1978
|
this.manageSocket = true;
|
|
1975
|
-
this.configuration.websocketProvider = new HocuspocusProviderWebsocket(
|
|
1976
|
-
url: websocketProviderConfig.url,
|
|
1977
|
-
});
|
|
1979
|
+
this.configuration.websocketProvider = new HocuspocusProviderWebsocket(configuration);
|
|
1978
1980
|
}
|
|
1979
1981
|
this.configuration = { ...this.configuration, ...configuration };
|
|
1980
1982
|
}
|