@hocuspocus/provider 3.1.3 → 3.1.5

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.
Files changed (64) hide show
  1. package/dist/hocuspocus-provider.cjs +111 -92
  2. package/dist/hocuspocus-provider.cjs.map +1 -1
  3. package/dist/hocuspocus-provider.esm.js +111 -92
  4. package/dist/hocuspocus-provider.esm.js.map +1 -1
  5. package/dist/packages/common/src/auth.d.ts +2 -2
  6. package/dist/packages/common/src/index.d.ts +4 -4
  7. package/dist/packages/extension-database/src/Database.d.ts +1 -1
  8. package/dist/packages/extension-database/src/index.d.ts +1 -1
  9. package/dist/packages/extension-logger/src/Logger.d.ts +1 -1
  10. package/dist/packages/extension-logger/src/index.d.ts +1 -1
  11. package/dist/packages/extension-redis/src/index.d.ts +1 -1
  12. package/dist/packages/extension-sqlite/src/SQLite.d.ts +3 -3
  13. package/dist/packages/extension-sqlite/src/index.d.ts +1 -1
  14. package/dist/packages/extension-throttle/src/index.d.ts +1 -1
  15. package/dist/packages/extension-webhook/src/index.d.ts +3 -3
  16. package/dist/packages/provider/src/HocuspocusProvider.d.ts +10 -10
  17. package/dist/packages/provider/src/IncomingMessage.d.ts +3 -3
  18. package/dist/packages/provider/src/MessageReceiver.d.ts +2 -2
  19. package/dist/packages/provider/src/OutgoingMessage.d.ts +2 -2
  20. package/dist/packages/provider/src/OutgoingMessages/AuthenticationMessage.d.ts +3 -3
  21. package/dist/packages/provider/src/OutgoingMessages/AwarenessMessage.d.ts +4 -4
  22. package/dist/packages/provider/src/OutgoingMessages/CloseMessage.d.ts +4 -4
  23. package/dist/packages/provider/src/OutgoingMessages/QueryAwarenessMessage.d.ts +4 -4
  24. package/dist/packages/provider/src/OutgoingMessages/StatelessMessage.d.ts +3 -3
  25. package/dist/packages/provider/src/OutgoingMessages/SyncStepOneMessage.d.ts +4 -4
  26. package/dist/packages/provider/src/OutgoingMessages/SyncStepTwoMessage.d.ts +4 -4
  27. package/dist/packages/provider/src/OutgoingMessages/UpdateMessage.d.ts +3 -3
  28. package/dist/packages/provider/src/index.d.ts +3 -3
  29. package/dist/packages/provider/src/types.d.ts +14 -14
  30. package/dist/packages/server/src/ClientConnection.d.ts +17 -17
  31. package/dist/packages/server/src/Connection.d.ts +6 -6
  32. package/dist/packages/server/src/DirectConnection.d.ts +3 -3
  33. package/dist/packages/server/src/Document.d.ts +4 -4
  34. package/dist/packages/server/src/Hocuspocus.d.ts +8 -8
  35. package/dist/packages/server/src/IncomingMessage.d.ts +3 -3
  36. package/dist/packages/server/src/MessageReceiver.d.ts +3 -3
  37. package/dist/packages/server/src/OutgoingMessage.d.ts +3 -3
  38. package/dist/packages/server/src/Server.d.ts +5 -5
  39. package/dist/packages/server/src/index.d.ts +9 -9
  40. package/dist/packages/server/src/types.d.ts +7 -7
  41. package/dist/packages/server/src/util/getParameters.d.ts +5 -5
  42. package/dist/packages/transformer/src/Prosemirror.d.ts +3 -3
  43. package/dist/packages/transformer/src/Tiptap.d.ts +3 -3
  44. package/dist/packages/transformer/src/index.d.ts +3 -3
  45. package/dist/packages/transformer/src/types.d.ts +1 -1
  46. package/dist/playground/frontend/app/SocketContext1.d.ts +2 -0
  47. package/dist/playground/frontend/app/SocketContext2.d.ts +2 -0
  48. package/package.json +40 -40
  49. package/src/EventEmitter.ts +32 -32
  50. package/src/HocuspocusProvider.ts +566 -498
  51. package/src/IncomingMessage.ts +47 -50
  52. package/src/MessageReceiver.ts +135 -132
  53. package/src/OutgoingMessage.ts +18 -14
  54. package/src/OutgoingMessages/AuthenticationMessage.ts +18 -16
  55. package/src/OutgoingMessages/AwarenessMessage.ts +38 -32
  56. package/src/OutgoingMessages/CloseMessage.ts +11 -11
  57. package/src/OutgoingMessages/QueryAwarenessMessage.ts +11 -12
  58. package/src/OutgoingMessages/StatelessMessage.ts +12 -12
  59. package/src/OutgoingMessages/SyncStepOneMessage.ts +18 -16
  60. package/src/OutgoingMessages/SyncStepTwoMessage.ts +18 -16
  61. package/src/OutgoingMessages/UpdateMessage.ts +13 -13
  62. package/src/index.ts +3 -3
  63. package/src/types.ts +69 -69
  64. package/dist/playground/frontend/app/SocketContext.d.ts +0 -2
@@ -1130,7 +1130,7 @@ class EventEmitter {
1130
1130
  emit(event, ...args) {
1131
1131
  const callbacks = this.callbacks[event];
1132
1132
  if (callbacks) {
1133
- callbacks.forEach(callback => callback.apply(this, args));
1133
+ callbacks.forEach((callback) => callback.apply(this, args));
1134
1134
  }
1135
1135
  return this;
1136
1136
  }
@@ -1139,7 +1139,7 @@ class EventEmitter {
1139
1139
  const callbacks = this.callbacks[event];
1140
1140
  if (callbacks) {
1141
1141
  if (fn) {
1142
- this.callbacks[event] = callbacks.filter(callback => callback !== fn);
1142
+ this.callbacks[event] = callbacks.filter((callback) => callback !== fn);
1143
1143
  }
1144
1144
  else {
1145
1145
  delete this.callbacks[event];
@@ -1217,7 +1217,7 @@ class CloseMessage extends OutgoingMessage {
1217
1217
  constructor() {
1218
1218
  super(...arguments);
1219
1219
  this.type = exports.MessageType.CLOSE;
1220
- this.description = 'Ask the server to close the connection';
1220
+ this.description = "Ask the server to close the connection";
1221
1221
  }
1222
1222
  get(args) {
1223
1223
  writeVarString(this.encoder, args.documentName);
@@ -1714,7 +1714,7 @@ class MessageReceiver {
1714
1714
  reason: readVarString(message.decoder),
1715
1715
  // @ts-ignore
1716
1716
  target: provider.configuration.websocketProvider.webSocket,
1717
- type: 'close',
1717
+ type: "close",
1718
1718
  };
1719
1719
  provider.onClose();
1720
1720
  provider.configuration.onClose({ event });
@@ -1724,7 +1724,8 @@ class MessageReceiver {
1724
1724
  throw new Error(`Can’t apply message of unknown type: ${type}`);
1725
1725
  }
1726
1726
  // Reply
1727
- if (message.length() > emptyMessageLength + 1) { // length of documentName (considered in emptyMessageLength plus length of yjs sync type, set in applySyncMessage)
1727
+ if (message.length() > emptyMessageLength + 1) {
1728
+ // length of documentName (considered in emptyMessageLength plus length of yjs sync type, set in applySyncMessage)
1728
1729
  // @ts-ignore
1729
1730
  provider.send(OutgoingMessage, { encoder: message.encoder });
1730
1731
  }
@@ -1780,11 +1781,11 @@ class AuthenticationMessage extends OutgoingMessage {
1780
1781
  constructor() {
1781
1782
  super(...arguments);
1782
1783
  this.type = exports.MessageType.Auth;
1783
- this.description = 'Authentication';
1784
+ this.description = "Authentication";
1784
1785
  }
1785
1786
  get(args) {
1786
- if (typeof args.token === 'undefined') {
1787
- throw new Error('The authentication message requires `token` as an argument.');
1787
+ if (typeof args.token === "undefined") {
1788
+ throw new Error("The authentication message requires `token` as an argument.");
1788
1789
  }
1789
1790
  writeVarString(this.encoder, args.documentName);
1790
1791
  writeVarUint(this.encoder, this.type);
@@ -1797,14 +1798,14 @@ class AwarenessMessage extends OutgoingMessage {
1797
1798
  constructor() {
1798
1799
  super(...arguments);
1799
1800
  this.type = exports.MessageType.Awareness;
1800
- this.description = 'Awareness states update';
1801
+ this.description = "Awareness states update";
1801
1802
  }
1802
1803
  get(args) {
1803
- if (typeof args.awareness === 'undefined') {
1804
- throw new Error('The awareness message requires awareness as an argument');
1804
+ if (typeof args.awareness === "undefined") {
1805
+ throw new Error("The awareness message requires awareness as an argument");
1805
1806
  }
1806
- if (typeof args.clients === 'undefined') {
1807
- throw new Error('The awareness message requires clients as an argument');
1807
+ if (typeof args.clients === "undefined") {
1808
+ throw new Error("The awareness message requires clients as an argument");
1808
1809
  }
1809
1810
  writeVarString(this.encoder, args.documentName);
1810
1811
  writeVarUint(this.encoder, this.type);
@@ -1824,13 +1825,13 @@ class StatelessMessage extends OutgoingMessage {
1824
1825
  constructor() {
1825
1826
  super(...arguments);
1826
1827
  this.type = exports.MessageType.Stateless;
1827
- this.description = 'A stateless message';
1828
+ this.description = "A stateless message";
1828
1829
  }
1829
1830
  get(args) {
1830
1831
  var _a;
1831
1832
  writeVarString(this.encoder, args.documentName);
1832
1833
  writeVarUint(this.encoder, this.type);
1833
- writeVarString(this.encoder, (_a = args.payload) !== null && _a !== void 0 ? _a : '');
1834
+ writeVarString(this.encoder, (_a = args.payload) !== null && _a !== void 0 ? _a : "");
1834
1835
  return this.encoder;
1835
1836
  }
1836
1837
  }
@@ -1839,11 +1840,11 @@ class SyncStepOneMessage extends OutgoingMessage {
1839
1840
  constructor() {
1840
1841
  super(...arguments);
1841
1842
  this.type = exports.MessageType.Sync;
1842
- this.description = 'First sync step';
1843
+ this.description = "First sync step";
1843
1844
  }
1844
1845
  get(args) {
1845
- if (typeof args.document === 'undefined') {
1846
- throw new Error('The sync step one message requires document as an argument');
1846
+ if (typeof args.document === "undefined") {
1847
+ throw new Error("The sync step one message requires document as an argument");
1847
1848
  }
1848
1849
  writeVarString(this.encoder, args.documentName);
1849
1850
  writeVarUint(this.encoder, this.type);
@@ -1856,7 +1857,7 @@ class UpdateMessage extends OutgoingMessage {
1856
1857
  constructor() {
1857
1858
  super(...arguments);
1858
1859
  this.type = exports.MessageType.Sync;
1859
- this.description = 'A document update';
1860
+ this.description = "A document update";
1860
1861
  }
1861
1862
  get(args) {
1862
1863
  writeVarString(this.encoder, args.documentName);
@@ -1877,7 +1878,7 @@ class HocuspocusProvider extends EventEmitter {
1877
1878
  var _a, _b, _c;
1878
1879
  super();
1879
1880
  this.configuration = {
1880
- name: '',
1881
+ name: "",
1881
1882
  // @ts-ignore
1882
1883
  document: undefined,
1883
1884
  // @ts-ignore
@@ -1914,35 +1915,44 @@ class HocuspocusProvider extends EventEmitter {
1914
1915
  this.boundPageHide = this.pageHide.bind(this);
1915
1916
  this.boundOnOpen = this.onOpen.bind(this);
1916
1917
  this.boundOnClose = this.onClose.bind(this);
1917
- this.forwardConnect = (e) => this.emit('connect', e);
1918
- this.forwardClose = (e) => this.emit('close', e);
1919
- this.forwardDisconnect = (e) => this.emit('disconnect', e);
1920
- this.forwardDestroy = (e) => this.emit('destroy', e);
1918
+ this.forwardConnect = (e) => this.emit("connect", e);
1919
+ this.forwardClose = (e) => this.emit("close", e);
1920
+ this.forwardDisconnect = (e) => this.emit("disconnect", e);
1921
+ this.forwardDestroy = (e) => this.emit("destroy", e);
1921
1922
  this.setConfiguration(configuration);
1922
- this.configuration.document = configuration.document ? configuration.document : new Y__namespace.Doc();
1923
- this.configuration.awareness = configuration.awareness !== undefined ? configuration.awareness : new Awareness(this.document);
1924
- this.on('open', this.configuration.onOpen);
1925
- this.on('message', this.configuration.onMessage);
1926
- this.on('outgoingMessage', this.configuration.onOutgoingMessage);
1927
- this.on('synced', this.configuration.onSynced);
1928
- this.on('destroy', this.configuration.onDestroy);
1929
- this.on('awarenessUpdate', this.configuration.onAwarenessUpdate);
1930
- this.on('awarenessChange', this.configuration.onAwarenessChange);
1931
- this.on('stateless', this.configuration.onStateless);
1932
- this.on('unsyncedChanges', this.configuration.onUnsyncedChanges);
1933
- this.on('authenticated', this.configuration.onAuthenticated);
1934
- this.on('authenticationFailed', this.configuration.onAuthenticationFailed);
1935
- (_a = this.awareness) === null || _a === void 0 ? void 0 : _a.on('update', () => {
1936
- this.emit('awarenessUpdate', { states: common.awarenessStatesToArray(this.awareness.getStates()) });
1923
+ this.configuration.document = configuration.document
1924
+ ? configuration.document
1925
+ : new Y__namespace.Doc();
1926
+ this.configuration.awareness =
1927
+ configuration.awareness !== undefined
1928
+ ? configuration.awareness
1929
+ : new Awareness(this.document);
1930
+ this.on("open", this.configuration.onOpen);
1931
+ this.on("message", this.configuration.onMessage);
1932
+ this.on("outgoingMessage", this.configuration.onOutgoingMessage);
1933
+ this.on("synced", this.configuration.onSynced);
1934
+ this.on("destroy", this.configuration.onDestroy);
1935
+ this.on("awarenessUpdate", this.configuration.onAwarenessUpdate);
1936
+ this.on("awarenessChange", this.configuration.onAwarenessChange);
1937
+ this.on("stateless", this.configuration.onStateless);
1938
+ this.on("unsyncedChanges", this.configuration.onUnsyncedChanges);
1939
+ this.on("authenticated", this.configuration.onAuthenticated);
1940
+ this.on("authenticationFailed", this.configuration.onAuthenticationFailed);
1941
+ (_a = this.awareness) === null || _a === void 0 ? void 0 : _a.on("update", () => {
1942
+ this.emit("awarenessUpdate", {
1943
+ states: common.awarenessStatesToArray(this.awareness.getStates()),
1944
+ });
1937
1945
  });
1938
- (_b = this.awareness) === null || _b === void 0 ? void 0 : _b.on('change', () => {
1939
- this.emit('awarenessChange', { states: common.awarenessStatesToArray(this.awareness.getStates()) });
1946
+ (_b = this.awareness) === null || _b === void 0 ? void 0 : _b.on("change", () => {
1947
+ this.emit("awarenessChange", {
1948
+ states: common.awarenessStatesToArray(this.awareness.getStates()),
1949
+ });
1940
1950
  });
1941
- this.document.on('update', this.boundDocumentUpdateHandler);
1942
- (_c = this.awareness) === null || _c === void 0 ? void 0 : _c.on('update', this.boundAwarenessUpdateHandler);
1951
+ this.document.on("update", this.boundDocumentUpdateHandler);
1952
+ (_c = this.awareness) === null || _c === void 0 ? void 0 : _c.on("update", this.boundAwarenessUpdateHandler);
1943
1953
  this.registerEventListeners();
1944
- if (this.configuration.forceSyncInterval
1945
- && typeof this.configuration.forceSyncInterval === 'number') {
1954
+ if (this.configuration.forceSyncInterval &&
1955
+ typeof this.configuration.forceSyncInterval === "number") {
1946
1956
  this.intervals.forceSync = setInterval(this.forceSync.bind(this), this.configuration.forceSyncInterval);
1947
1957
  }
1948
1958
  if (this.manageSocket) {
@@ -1973,11 +1983,11 @@ class HocuspocusProvider extends EventEmitter {
1973
1983
  }
1974
1984
  resetUnsyncedChanges() {
1975
1985
  this.unsyncedChanges = 1;
1976
- this.emit('unsyncedChanges', { number: this.unsyncedChanges });
1986
+ this.emit("unsyncedChanges", { number: this.unsyncedChanges });
1977
1987
  }
1978
1988
  incrementUnsyncedChanges() {
1979
1989
  this.unsyncedChanges += 1;
1980
- this.emit('unsyncedChanges', { number: this.unsyncedChanges });
1990
+ this.emit("unsyncedChanges", { number: this.unsyncedChanges });
1981
1991
  }
1982
1992
  decrementUnsyncedChanges() {
1983
1993
  if (this.unsyncedChanges > 0) {
@@ -1986,25 +1996,31 @@ class HocuspocusProvider extends EventEmitter {
1986
1996
  if (this.unsyncedChanges === 0) {
1987
1997
  this.synced = true;
1988
1998
  }
1989
- this.emit('unsyncedChanges', { number: this.unsyncedChanges });
1999
+ this.emit("unsyncedChanges", { number: this.unsyncedChanges });
1990
2000
  }
1991
2001
  forceSync() {
1992
2002
  this.resetUnsyncedChanges();
1993
- this.send(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name });
2003
+ this.send(SyncStepOneMessage, {
2004
+ document: this.document,
2005
+ documentName: this.configuration.name,
2006
+ });
1994
2007
  }
1995
2008
  pageHide() {
1996
2009
  if (this.awareness) {
1997
- removeAwarenessStates(this.awareness, [this.document.clientID], 'page hide');
2010
+ removeAwarenessStates(this.awareness, [this.document.clientID], "page hide");
1998
2011
  }
1999
2012
  }
2000
2013
  registerEventListeners() {
2001
- if (typeof window === 'undefined' || !('addEventListener' in window)) {
2014
+ if (typeof window === "undefined" || !("addEventListener" in window)) {
2002
2015
  return;
2003
2016
  }
2004
- window.addEventListener('pagehide', this.boundPageHide);
2017
+ window.addEventListener("pagehide", this.boundPageHide);
2005
2018
  }
2006
2019
  sendStateless(payload) {
2007
- this.send(StatelessMessage, { documentName: this.configuration.name, payload });
2020
+ this.send(StatelessMessage, {
2021
+ documentName: this.configuration.name,
2022
+ payload,
2023
+ });
2008
2024
  }
2009
2025
  documentUpdateHandler(update, origin) {
2010
2026
  if (origin === this) {
@@ -2036,28 +2052,28 @@ class HocuspocusProvider extends EventEmitter {
2036
2052
  }
2037
2053
  this.isSynced = state;
2038
2054
  if (state) {
2039
- this.emit('synced', { state });
2055
+ this.emit("synced", { state });
2040
2056
  }
2041
2057
  }
2042
2058
  receiveStateless(payload) {
2043
- this.emit('stateless', { payload });
2059
+ this.emit("stateless", { payload });
2044
2060
  }
2045
2061
  // not needed, but provides backward compatibility with e.g. lexical/yjs
2046
2062
  async connect() {
2047
2063
  if (this.manageSocket) {
2048
2064
  return this.configuration.websocketProvider.connect();
2049
2065
  }
2050
- console.warn('HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.');
2066
+ console.warn("HocuspocusProvider::connect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.");
2051
2067
  }
2052
2068
  disconnect() {
2053
2069
  if (this.manageSocket) {
2054
2070
  return this.configuration.websocketProvider.disconnect();
2055
2071
  }
2056
- console.warn('HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.');
2072
+ console.warn("HocuspocusProvider::disconnect() is deprecated and does not do anything. Please connect/disconnect on the websocketProvider, or attach/deattach providers.");
2057
2073
  }
2058
2074
  async onOpen(event) {
2059
2075
  this.isAuthenticated = false;
2060
- this.emit('open', { event });
2076
+ this.emit("open", { event });
2061
2077
  let token;
2062
2078
  try {
2063
2079
  token = await this.getToken();
@@ -2067,13 +2083,13 @@ class HocuspocusProvider extends EventEmitter {
2067
2083
  return;
2068
2084
  }
2069
2085
  this.send(AuthenticationMessage, {
2070
- token: token !== null && token !== void 0 ? token : '',
2086
+ token: token !== null && token !== void 0 ? token : "",
2071
2087
  documentName: this.configuration.name,
2072
2088
  });
2073
2089
  this.startSync();
2074
2090
  }
2075
2091
  async getToken() {
2076
- if (typeof this.configuration.token === 'function') {
2092
+ if (typeof this.configuration.token === "function") {
2077
2093
  const token = await this.configuration.token();
2078
2094
  return token;
2079
2095
  }
@@ -2081,7 +2097,10 @@ class HocuspocusProvider extends EventEmitter {
2081
2097
  }
2082
2098
  startSync() {
2083
2099
  this.resetUnsyncedChanges();
2084
- this.send(SyncStepOneMessage, { document: this.document, documentName: this.configuration.name });
2100
+ this.send(SyncStepOneMessage, {
2101
+ document: this.document,
2102
+ documentName: this.configuration.name,
2103
+ });
2085
2104
  if (this.awareness && this.awareness.getLocalState() !== null) {
2086
2105
  this.send(AwarenessMessage, {
2087
2106
  awareness: this.awareness,
@@ -2094,14 +2113,14 @@ class HocuspocusProvider extends EventEmitter {
2094
2113
  if (!this._isAttached)
2095
2114
  return;
2096
2115
  const messageSender = new MessageSender(message, args);
2097
- this.emit('outgoingMessage', { message: messageSender.message });
2116
+ this.emit("outgoingMessage", { message: messageSender.message });
2098
2117
  messageSender.send(this.configuration.websocketProvider);
2099
2118
  }
2100
2119
  onMessage(event) {
2101
2120
  const message = new IncomingMessage(event.data);
2102
2121
  const documentName = message.readVarString();
2103
2122
  message.writeVarString(documentName);
2104
- this.emit('message', { event, message: new IncomingMessage(event.data) });
2123
+ this.emit("message", { event, message: new IncomingMessage(event.data) });
2105
2124
  new MessageReceiver(message).apply(this, true);
2106
2125
  }
2107
2126
  onClose() {
@@ -2109,68 +2128,68 @@ class HocuspocusProvider extends EventEmitter {
2109
2128
  this.synced = false;
2110
2129
  // update awareness (all users except local left)
2111
2130
  if (this.awareness) {
2112
- removeAwarenessStates(this.awareness, Array.from(this.awareness.getStates().keys()).filter(client => client !== this.document.clientID), this);
2131
+ removeAwarenessStates(this.awareness, Array.from(this.awareness.getStates().keys()).filter((client) => client !== this.document.clientID), this);
2113
2132
  }
2114
2133
  }
2115
2134
  destroy() {
2116
- this.emit('destroy');
2135
+ this.emit("destroy");
2117
2136
  if (this.intervals.forceSync) {
2118
2137
  clearInterval(this.intervals.forceSync);
2119
2138
  }
2120
2139
  if (this.awareness) {
2121
- removeAwarenessStates(this.awareness, [this.document.clientID], 'provider destroy');
2122
- this.awareness.off('update', this.boundAwarenessUpdateHandler);
2140
+ removeAwarenessStates(this.awareness, [this.document.clientID], "provider destroy");
2141
+ this.awareness.off("update", this.boundAwarenessUpdateHandler);
2123
2142
  this.awareness.destroy();
2124
2143
  }
2125
- this.document.off('update', this.boundDocumentUpdateHandler);
2144
+ this.document.off("update", this.boundDocumentUpdateHandler);
2126
2145
  this.removeAllListeners();
2127
2146
  this.detach();
2128
2147
  if (this.manageSocket) {
2129
2148
  this.configuration.websocketProvider.destroy();
2130
2149
  }
2131
- if (typeof window === 'undefined' || !('removeEventListener' in window)) {
2150
+ if (typeof window === "undefined" || !("removeEventListener" in window)) {
2132
2151
  return;
2133
2152
  }
2134
- window.removeEventListener('pagehide', this.boundPageHide);
2153
+ window.removeEventListener("pagehide", this.boundPageHide);
2135
2154
  }
2136
2155
  detach() {
2137
- this.configuration.websocketProvider.off('connect', this.configuration.onConnect);
2138
- this.configuration.websocketProvider.off('connect', this.forwardConnect);
2139
- this.configuration.websocketProvider.off('open', this.boundOnOpen);
2140
- this.configuration.websocketProvider.off('close', this.boundOnClose);
2141
- this.configuration.websocketProvider.off('close', this.configuration.onClose);
2142
- this.configuration.websocketProvider.off('close', this.forwardClose);
2143
- this.configuration.websocketProvider.off('disconnect', this.configuration.onDisconnect);
2144
- this.configuration.websocketProvider.off('disconnect', this.forwardDisconnect);
2145
- this.configuration.websocketProvider.off('destroy', this.configuration.onDestroy);
2146
- this.configuration.websocketProvider.off('destroy', this.forwardDestroy);
2156
+ this.configuration.websocketProvider.off("connect", this.configuration.onConnect);
2157
+ this.configuration.websocketProvider.off("connect", this.forwardConnect);
2158
+ this.configuration.websocketProvider.off("open", this.boundOnOpen);
2159
+ this.configuration.websocketProvider.off("close", this.boundOnClose);
2160
+ this.configuration.websocketProvider.off("close", this.configuration.onClose);
2161
+ this.configuration.websocketProvider.off("close", this.forwardClose);
2162
+ this.configuration.websocketProvider.off("disconnect", this.configuration.onDisconnect);
2163
+ this.configuration.websocketProvider.off("disconnect", this.forwardDisconnect);
2164
+ this.configuration.websocketProvider.off("destroy", this.configuration.onDestroy);
2165
+ this.configuration.websocketProvider.off("destroy", this.forwardDestroy);
2147
2166
  this.configuration.websocketProvider.detach(this);
2148
2167
  this._isAttached = false;
2149
2168
  }
2150
2169
  attach() {
2151
2170
  if (this._isAttached)
2152
2171
  return;
2153
- this.configuration.websocketProvider.on('connect', this.configuration.onConnect);
2154
- this.configuration.websocketProvider.on('connect', this.forwardConnect);
2155
- this.configuration.websocketProvider.on('open', this.boundOnOpen);
2156
- this.configuration.websocketProvider.on('close', this.boundOnClose);
2157
- this.configuration.websocketProvider.on('close', this.configuration.onClose);
2158
- this.configuration.websocketProvider.on('close', this.forwardClose);
2159
- this.configuration.websocketProvider.on('disconnect', this.configuration.onDisconnect);
2160
- this.configuration.websocketProvider.on('disconnect', this.forwardDisconnect);
2161
- this.configuration.websocketProvider.on('destroy', this.configuration.onDestroy);
2162
- this.configuration.websocketProvider.on('destroy', this.forwardDestroy);
2172
+ this.configuration.websocketProvider.on("connect", this.configuration.onConnect);
2173
+ this.configuration.websocketProvider.on("connect", this.forwardConnect);
2174
+ this.configuration.websocketProvider.on("open", this.boundOnOpen);
2175
+ this.configuration.websocketProvider.on("close", this.boundOnClose);
2176
+ this.configuration.websocketProvider.on("close", this.configuration.onClose);
2177
+ this.configuration.websocketProvider.on("close", this.forwardClose);
2178
+ this.configuration.websocketProvider.on("disconnect", this.configuration.onDisconnect);
2179
+ this.configuration.websocketProvider.on("disconnect", this.forwardDisconnect);
2180
+ this.configuration.websocketProvider.on("destroy", this.configuration.onDestroy);
2181
+ this.configuration.websocketProvider.on("destroy", this.forwardDestroy);
2163
2182
  this.configuration.websocketProvider.attach(this);
2164
2183
  this._isAttached = true;
2165
2184
  }
2166
2185
  permissionDeniedHandler(reason) {
2167
- this.emit('authenticationFailed', { reason });
2186
+ this.emit("authenticationFailed", { reason });
2168
2187
  this.isAuthenticated = false;
2169
2188
  }
2170
2189
  authenticatedHandler(scope) {
2171
2190
  this.isAuthenticated = true;
2172
2191
  this.authorizedScope = scope;
2173
- this.emit('authenticated', { scope });
2192
+ this.emit("authenticated", { scope });
2174
2193
  }
2175
2194
  setAwarenessField(key, value) {
2176
2195
  if (!this.awareness) {