@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
|
File without changes
|
|
@@ -1909,25 +1909,26 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1909
1909
|
},
|
|
1910
1910
|
});
|
|
1911
1911
|
}
|
|
1912
|
-
catch (
|
|
1913
|
-
// If we aborted the connection attempt then don
|
|
1912
|
+
catch (error) {
|
|
1913
|
+
// If we aborted the connection attempt then don’t throw an error
|
|
1914
1914
|
// ref: https://github.com/lifeomic/attempt/blob/master/src/index.ts#L136
|
|
1915
|
-
if (
|
|
1916
|
-
throw
|
|
1915
|
+
if (error && error.code !== 'ATTEMPT_ABORTED') {
|
|
1916
|
+
throw error;
|
|
1917
1917
|
}
|
|
1918
1918
|
}
|
|
1919
1919
|
}
|
|
1920
1920
|
createWebSocketConnection() {
|
|
1921
1921
|
return new Promise((resolve, reject) => {
|
|
1922
1922
|
// Init the WebSocket connection
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
1928
|
-
|
|
1923
|
+
const ws = new this.options.WebSocketPolyfill(this.url);
|
|
1924
|
+
ws.binaryType = 'arraybuffer';
|
|
1925
|
+
ws.onmessage = this.onMessage.bind(this);
|
|
1926
|
+
ws.onclose = this.onClose.bind(this);
|
|
1927
|
+
ws.onopen = this.onOpen.bind(this);
|
|
1928
|
+
ws.onerror = () => {
|
|
1929
1929
|
reject();
|
|
1930
1930
|
};
|
|
1931
|
+
this.webSocket = ws;
|
|
1931
1932
|
// Reset the status
|
|
1932
1933
|
this.synced = false;
|
|
1933
1934
|
this.status = exports.WebSocketStatus.Connecting;
|
|
@@ -1956,6 +1957,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1956
1957
|
return this.options.awareness;
|
|
1957
1958
|
}
|
|
1958
1959
|
checkConnection() {
|
|
1960
|
+
var _a;
|
|
1959
1961
|
// Don’t check the connection when it’s not even established
|
|
1960
1962
|
if (this.status !== exports.WebSocketStatus.Connected) {
|
|
1961
1963
|
return;
|
|
@@ -1970,7 +1972,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
1970
1972
|
}
|
|
1971
1973
|
// No message received in a long time, not even your own
|
|
1972
1974
|
// Awareness updates, which are updated every 15 seconds.
|
|
1973
|
-
this.webSocket.close();
|
|
1975
|
+
(_a = this.webSocket) === null || _a === void 0 ? void 0 : _a.close();
|
|
1974
1976
|
}
|
|
1975
1977
|
forceSync() {
|
|
1976
1978
|
if (!this.webSocket) {
|
|
@@ -2071,7 +2073,6 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2071
2073
|
return;
|
|
2072
2074
|
}
|
|
2073
2075
|
this.startSync();
|
|
2074
|
-
this.resolveConnectionAttempt();
|
|
2075
2076
|
}
|
|
2076
2077
|
startSync() {
|
|
2077
2078
|
this.send(SyncStepOneMessage, { document: this.document });
|
|
@@ -2093,6 +2094,7 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2093
2094
|
}
|
|
2094
2095
|
}
|
|
2095
2096
|
onMessage(event) {
|
|
2097
|
+
this.resolveConnectionAttempt();
|
|
2096
2098
|
this.lastMessageReceived = getUnixTime();
|
|
2097
2099
|
const message = new IncomingMessage(event.data);
|
|
2098
2100
|
this.emit('message', { event, message });
|