@hocuspocus/provider 2.8.0 → 2.9.0-rc.0
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 +15 -13
- package/dist/hocuspocus-provider.cjs.map +1 -1
- package/dist/hocuspocus-provider.esm.js +15 -13
- package/dist/hocuspocus-provider.esm.js.map +1 -1
- package/dist/packages/provider/src/TiptapCollabProvider.d.ts +1 -1
- package/dist/packages/provider/src/TiptapCollabProviderWebsocket.d.ts +1 -1
- package/dist/packages/server/src/Hocuspocus.d.ts +5 -1
- package/dist/packages/server/src/util/debounce.d.ts +5 -1
- package/package.json +5 -5
- package/src/HocuspocusProvider.ts +2 -2
- package/src/TiptapCollabProvider.ts +1 -1
- package/src/TiptapCollabProviderWebsocket.ts +1 -1
|
@@ -221,7 +221,7 @@ let usePolyfill = true;
|
|
|
221
221
|
/* c8 ignore start */
|
|
222
222
|
try {
|
|
223
223
|
// if the same-origin rule is violated, accessing localStorage might thrown an error
|
|
224
|
-
if (typeof localStorage !== 'undefined') {
|
|
224
|
+
if (typeof localStorage !== 'undefined' && localStorage) {
|
|
225
225
|
_localStorage = localStorage;
|
|
226
226
|
usePolyfill = false;
|
|
227
227
|
}
|
|
@@ -406,10 +406,10 @@ const isOneOf = (value, options) => options.includes(value);
|
|
|
406
406
|
* @module map
|
|
407
407
|
*/
|
|
408
408
|
|
|
409
|
-
/* c8 ignore next */
|
|
409
|
+
/* c8 ignore next 2 */
|
|
410
410
|
// @ts-ignore
|
|
411
|
-
const isNode = typeof process !== 'undefined' && process.release &&
|
|
412
|
-
|
|
411
|
+
const isNode = typeof process !== 'undefined' && process.release && /node|io\.js/.test(process.release.name) && Object.prototype.toString.call(typeof process !== 'undefined' ? process : 0) === '[object process]';
|
|
412
|
+
|
|
413
413
|
/* c8 ignore next */
|
|
414
414
|
const isBrowser = typeof window !== 'undefined' && typeof document !== 'undefined' && !isNode;
|
|
415
415
|
/* c8 ignore next 3 */
|
|
@@ -621,7 +621,7 @@ const toUint8Array = encoder => {
|
|
|
621
621
|
uint8arr.set(d, curPos);
|
|
622
622
|
curPos += d.length;
|
|
623
623
|
}
|
|
624
|
-
uint8arr.set(
|
|
624
|
+
uint8arr.set(new Uint8Array(encoder.cbuf.buffer, 0, encoder.cpos), curPos);
|
|
625
625
|
return uint8arr
|
|
626
626
|
};
|
|
627
627
|
|
|
@@ -834,7 +834,7 @@ const createDecoder = uint8Array => new Decoder(uint8Array);
|
|
|
834
834
|
* @return {Uint8Array}
|
|
835
835
|
*/
|
|
836
836
|
const readUint8Array = (decoder, len) => {
|
|
837
|
-
const view =
|
|
837
|
+
const view = new Uint8Array(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
|
|
838
838
|
decoder.pos += len;
|
|
839
839
|
return view
|
|
840
840
|
};
|
|
@@ -1071,7 +1071,7 @@ const fromBase64Browser = s => {
|
|
|
1071
1071
|
*/
|
|
1072
1072
|
const fromBase64Node = s => {
|
|
1073
1073
|
const buf = Buffer.from(s, 'base64');
|
|
1074
|
-
return
|
|
1074
|
+
return createUint8ArrayViewFromArrayBuffer(buf.buffer, buf.byteOffset, buf.byteLength)
|
|
1075
1075
|
};
|
|
1076
1076
|
|
|
1077
1077
|
/* c8 ignore next */
|
|
@@ -1252,9 +1252,11 @@ const getUnixTime = Date.now;
|
|
|
1252
1252
|
* @module observable
|
|
1253
1253
|
*/
|
|
1254
1254
|
|
|
1255
|
+
/* c8 ignore start */
|
|
1255
1256
|
/**
|
|
1256
1257
|
* Handles named events.
|
|
1257
1258
|
*
|
|
1259
|
+
* @deprecated
|
|
1258
1260
|
* @template N
|
|
1259
1261
|
*/
|
|
1260
1262
|
class Observable {
|
|
@@ -1321,6 +1323,7 @@ class Observable {
|
|
|
1321
1323
|
this._observers = create$2();
|
|
1322
1324
|
}
|
|
1323
1325
|
}
|
|
1326
|
+
/* c8 ignore end */
|
|
1324
1327
|
|
|
1325
1328
|
/**
|
|
1326
1329
|
* @module awareness-protocol
|
|
@@ -2072,8 +2075,8 @@ class HocuspocusProviderWebsocket extends EventEmitter {
|
|
|
2072
2075
|
* When the server receives SyncStep1, it should reply with SyncStep2 immediately followed by SyncStep1. The client replies
|
|
2073
2076
|
* with SyncStep2 when it receives SyncStep1. Optionally the server may send a SyncDone after it received SyncStep2, so the
|
|
2074
2077
|
* client knows that the sync is finished. There are two reasons for this more elaborated sync model: 1. This protocol can
|
|
2075
|
-
* easily be implemented on top of http and websockets. 2. The server
|
|
2076
|
-
* Therefore it is
|
|
2078
|
+
* easily be implemented on top of http and websockets. 2. The server should only reply to requests, and not initiate them.
|
|
2079
|
+
* Therefore it is necessary that the client initiates the sync.
|
|
2077
2080
|
*
|
|
2078
2081
|
* Construction of a message:
|
|
2079
2082
|
* [messageType : varUint, message definition..]
|
|
@@ -2155,7 +2158,7 @@ const readUpdate = readSyncStep2;
|
|
|
2155
2158
|
|
|
2156
2159
|
/**
|
|
2157
2160
|
* @param {decoding.Decoder} decoder A message received from another client
|
|
2158
|
-
* @param {encoding.Encoder} encoder The reply message.
|
|
2161
|
+
* @param {encoding.Encoder} encoder The reply message. Does not need to be sent if empty.
|
|
2159
2162
|
* @param {Y.Doc} doc
|
|
2160
2163
|
* @param {any} transactionOrigin
|
|
2161
2164
|
*/
|
|
@@ -2690,15 +2693,15 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2690
2693
|
}
|
|
2691
2694
|
}
|
|
2692
2695
|
destroy() {
|
|
2693
|
-
var _a;
|
|
2694
2696
|
this.emit('destroy');
|
|
2695
2697
|
if (this.intervals.forceSync) {
|
|
2696
2698
|
clearInterval(this.intervals.forceSync);
|
|
2697
2699
|
}
|
|
2698
2700
|
if (this.awareness) {
|
|
2699
2701
|
removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy');
|
|
2702
|
+
this.awareness.off('update', this.awarenessUpdateHandler);
|
|
2703
|
+
this.awareness.destroy();
|
|
2700
2704
|
}
|
|
2701
|
-
(_a = this.awareness) === null || _a === void 0 ? void 0 : _a.off('update', this.awarenessUpdateHandler);
|
|
2702
2705
|
this.document.off('update', this.documentUpdateHandler);
|
|
2703
2706
|
this.removeAllListeners();
|
|
2704
2707
|
this.configuration.websocketProvider.off('connect', this.configuration.onConnect);
|
|
@@ -2730,7 +2733,6 @@ class HocuspocusProvider extends EventEmitter {
|
|
|
2730
2733
|
this.isAuthenticated = true;
|
|
2731
2734
|
this.authorizedScope = scope;
|
|
2732
2735
|
this.emit('authenticated');
|
|
2733
|
-
this.startSync();
|
|
2734
2736
|
}
|
|
2735
2737
|
get broadcastChannel() {
|
|
2736
2738
|
return `${this.configuration.name}`;
|