@hocuspocus/provider 1.0.0-alpha.19 → 1.0.0-alpha.23
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/demos/backend/src/{create-document.d.ts → load-document.d.ts} +0 -0
- package/dist/hocuspocus-provider.cjs +14 -12
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +14 -12
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/extension-logger/src/Logger.d.ts +68 -0
- package/dist/packages/extension-logger/src/index.d.ts +1 -0
- package/dist/packages/{monitor → extension-monitor}/src/Collector.d.ts +2 -2
- package/dist/packages/{monitor → extension-monitor}/src/Dashboard.d.ts +0 -0
- package/dist/packages/{monitor → extension-monitor}/src/Storage.d.ts +0 -0
- package/dist/packages/{monitor → extension-monitor}/src/index.d.ts +2 -2
- package/dist/packages/{redis → extension-redis}/src/Redis.d.ts +2 -2
- package/dist/packages/{redis → extension-redis}/src/RedisCluster.d.ts +0 -0
- package/dist/packages/{redis → extension-redis}/src/index.d.ts +0 -0
- package/dist/packages/{rocksdb → extension-rocksdb}/src/index.d.ts +3 -3
- package/dist/packages/{throttle → extension-throttle}/src/index.d.ts +0 -0
- package/dist/packages/{webhook → extension-webhook}/src/index.d.ts +3 -3
- package/dist/packages/provider/src/HocuspocusProvider.d.ts +1 -1
- package/dist/packages/server/src/Hocuspocus.d.ts +1 -0
- package/dist/packages/server/src/types.d.ts +15 -2
- package/package.json +10 -5
- package/src/HocuspocusProvider.ts +15 -14
- package/dist/packages/logger/src/index.d.ts +0 -13
|
@@ -1885,25 +1885,26 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1885
1885
|
},
|
|
1886
1886
|
});
|
|
1887
1887
|
}
|
|
1888
|
-
catch (
|
|
1889
|
-
// If we aborted the connection attempt then don
|
|
1888
|
+
catch (error) {
|
|
1889
|
+
// If we aborted the connection attempt then don’t throw an error
|
|
1890
1890
|
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
|
|
1891
|
-
if (
|
|
1892
|
-
throw
|
|
1891
|
+
if (error && error.code !== 'ATTEMPT_ABORTED') {
|
|
1892
|
+
throw error;
|
|
1893
1893
|
}
|
|
1894
1894
|
}
|
|
1895
1895
|
}
|
|
1896
1896
|
createWebSocketConnection() {
|
|
1897
1897
|
return new Promise((resolve, reject) => {
|
|
1898
1898
|
// Init the WebSocket connection
|
|
1899
|
-
|
|
1900
|
-
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1899
|
+
const ws = new this.options.WebSocketPolyfill(this.url);
|
|
1900
|
+
ws.binaryType = 'arraybuffer';
|
|
1901
|
+
ws.onmessage = this.onMessage.bind(this);
|
|
1902
|
+
ws.onclose = this.onClose.bind(this);
|
|
1903
|
+
ws.onopen = this.onOpen.bind(this);
|
|
1904
|
+
ws.onerror = () => {
|
|
1905
1905
|
reject();
|
|
1906
1906
|
};
|
|
1907
|
+
this.webSocket = ws;
|
|
1907
1908
|
// Reset the status
|
|
1908
1909
|
this.synced = false;
|
|
1909
1910
|
this.status = WebSocketStatus.Connecting;
|
|
@@ -1932,6 +1933,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1932
1933
|
return this.options.awareness;
|
|
1933
1934
|
}
|
|
1934
1935
|
checkConnection() {
|
|
1936
|
+
var _a;
|
|
1935
1937
|
// Don’t check the connection when it’s not even established
|
|
1936
1938
|
if (this.status !== WebSocketStatus.Connected) {
|
|
1937
1939
|
return;
|
|
@@ -1946,7 +1948,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1946
1948
|
}
|
|
1947
1949
|
// No message received in a long time, not even your own
|
|
1948
1950
|
// Awareness updates, which are updated every 15 seconds.
|
|
1949
|
-
this.webSocket.close();
|
|
1951
|
+
(_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.close();
|
|
1950
1952
|
}
|
|
1951
1953
|
forceSync() {
|
|
1952
1954
|
if (!this.webSocket) {
|
|
@@ -2047,7 +2049,6 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2047
2049
|
return;
|
|
2048
2050
|
}
|
|
2049
2051
|
this.startSync();
|
|
2050
|
-
this.resolveConnectionAttempt();
|
|
2051
2052
|
}
|
|
2052
2053
|
startSync() {
|
|
2053
2054
|
this.send(SyncStepOneMessage, { document: this.document });
|
|
@@ -2069,6 +2070,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2069
2070
|
}
|
|
2070
2071
|
}
|
|
2071
2072
|
onMessage(event) {
|
|
2073
|
+
this.resolveConnectionAttempt();
|
|
2072
2074
|
this.lastMessageReceived = getUnixTime();
|
|
2073
2075
|
const message = new IncomingMessage(event.data);
|
|
2074
2076
|
this.emit('message', { event, message });
|