@hocuspocus/provider 2.8.0 → 2.8.1

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.
@@ -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
- /node|io\.js/.test(process.release.name);
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(createUint8ArrayViewFromArrayBuffer(encoder.cbuf.buffer, 0, encoder.cpos), curPos);
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 = createUint8ArrayViewFromArrayBuffer(decoder.arr.buffer, decoder.pos + decoder.arr.byteOffset, len);
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 new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)
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 shoul only reply to requests, and not initiate them.
2076
- * Therefore it is necesarry that the client initiates the sync.
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. Will not be sent if empty.
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
  */