@hocuspocus/provider 3.4.1 → 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 +6 -3
- package/src/HocuspocusProvider.ts +16 -9
- package/src/HocuspocusProviderWebsocket.ts +16 -4
- package/src/MessageReceiver.ts +2 -2
- package/src/types.ts +3 -1
|
@@ -1212,6 +1212,7 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1212
1212
|
this.configuration = {
|
|
1213
1213
|
url: "",
|
|
1214
1214
|
autoConnect: true,
|
|
1215
|
+
preserveTrailingSlash: false,
|
|
1215
1216
|
// @ts-ignore
|
|
1216
1217
|
document: undefined,
|
|
1217
1218
|
WebSocketPolyfill: undefined,
|
|
@@ -1475,12 +1476,16 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
1475
1476
|
this.messageQueue = [];
|
|
1476
1477
|
}
|
|
1477
1478
|
}
|
|
1478
|
-
// Ensure that the URL never ends with /
|
|
1479
1479
|
get serverUrl() {
|
|
1480
|
-
|
|
1481
|
-
return this.configuration.url
|
|
1480
|
+
if (this.configuration.preserveTrailingSlash) {
|
|
1481
|
+
return this.configuration.url;
|
|
1482
1482
|
}
|
|
1483
|
-
|
|
1483
|
+
// By default, ensure that the URL never ends with /
|
|
1484
|
+
let url = this.configuration.url;
|
|
1485
|
+
while (url[url.length - 1] === "/") {
|
|
1486
|
+
url = url.slice(0, url.length - 1);
|
|
1487
|
+
}
|
|
1488
|
+
return url;
|
|
1484
1489
|
}
|
|
1485
1490
|
get url() {
|
|
1486
1491
|
return this.serverUrl;
|
|
@@ -1704,7 +1709,7 @@ class MessageReceiver {
|
|
|
1704
1709
|
};
|
|
1705
1710
|
provider.onClose();
|
|
1706
1711
|
provider.configuration.onClose({ event });
|
|
1707
|
-
provider.forwardClose(event);
|
|
1712
|
+
provider.forwardClose({ event });
|
|
1708
1713
|
break;
|
|
1709
1714
|
default:
|
|
1710
1715
|
throw new Error(`Can’t apply message of unknown type: ${type}`);
|
|
@@ -1949,11 +1954,8 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1949
1954
|
}
|
|
1950
1955
|
setConfiguration(configuration = {}) {
|
|
1951
1956
|
if (!configuration.websocketProvider) {
|
|
1952
|
-
const websocketProviderConfig = configuration;
|
|
1953
1957
|
this.manageSocket = true;
|
|
1954
|
-
this.configuration.websocketProvider = new HocuspocusProviderWebsocket(
|
|
1955
|
-
url: websocketProviderConfig.url,
|
|
1956
|
-
});
|
|
1958
|
+
this.configuration.websocketProvider = new HocuspocusProviderWebsocket(configuration);
|
|
1957
1959
|
}
|
|
1958
1960
|
this.configuration = { ...this.configuration, ...configuration };
|
|
1959
1961
|
}
|