@colyseus/sdk 0.17.25 → 0.17.27

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 (56) hide show
  1. package/LICENSE +1 -2
  2. package/build/3rd_party/discord.cjs +1 -1
  3. package/build/3rd_party/discord.mjs +1 -1
  4. package/build/Auth.cjs +1 -1
  5. package/build/Auth.mjs +1 -1
  6. package/build/Client.cjs +1 -1
  7. package/build/Client.mjs +1 -1
  8. package/build/Connection.cjs +1 -1
  9. package/build/Connection.mjs +1 -1
  10. package/build/HTTP.cjs +1 -1
  11. package/build/HTTP.mjs +1 -1
  12. package/build/Room.cjs +17 -11
  13. package/build/Room.cjs.map +1 -1
  14. package/build/Room.mjs +17 -11
  15. package/build/Room.mjs.map +1 -1
  16. package/build/Storage.cjs +1 -1
  17. package/build/Storage.mjs +1 -1
  18. package/build/core/nanoevents.cjs +1 -1
  19. package/build/core/nanoevents.mjs +1 -1
  20. package/build/core/signal.cjs +1 -1
  21. package/build/core/signal.mjs +1 -1
  22. package/build/core/utils.cjs +1 -1
  23. package/build/core/utils.mjs +1 -1
  24. package/build/debug.cjs +1 -1
  25. package/build/debug.mjs +1 -1
  26. package/build/errors/Errors.cjs +1 -1
  27. package/build/errors/Errors.mjs +1 -1
  28. package/build/index.cjs +1 -1
  29. package/build/index.mjs +1 -1
  30. package/build/legacy.cjs +1 -1
  31. package/build/legacy.mjs +1 -1
  32. package/build/serializer/NoneSerializer.cjs +1 -1
  33. package/build/serializer/NoneSerializer.mjs +1 -1
  34. package/build/serializer/SchemaSerializer.cjs +1 -1
  35. package/build/serializer/SchemaSerializer.mjs +1 -1
  36. package/build/serializer/Serializer.cjs +1 -1
  37. package/build/serializer/Serializer.mjs +1 -1
  38. package/build/transport/H3Transport.cjs +1 -1
  39. package/build/transport/H3Transport.mjs +1 -1
  40. package/build/transport/WebSocketTransport.cjs +1 -1
  41. package/build/transport/WebSocketTransport.mjs +1 -1
  42. package/dist/colyseus-cocos-creator.js +18 -11
  43. package/dist/colyseus-cocos-creator.js.map +1 -1
  44. package/dist/colyseus.js +18 -11
  45. package/dist/colyseus.js.map +1 -1
  46. package/dist/debug.js +17 -11
  47. package/dist/debug.js.map +1 -1
  48. package/package.json +9 -9
  49. package/src/Room.ts +17 -9
  50. package/README.md +0 -27
  51. package/build/HTTP_bkp.d.ts +0 -18
  52. package/build/Protocol.cjs +0 -34
  53. package/build/Protocol.cjs.map +0 -1
  54. package/build/Protocol.d.ts +0 -21
  55. package/build/Protocol.mjs +0 -34
  56. package/build/Protocol.mjs.map +0 -1
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  /**
8
8
  * The MIT License (MIT)
9
9
  *
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  class EventEmitter {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  class EventEmitter {
8
8
  handlers = [];
9
9
  register(cb, once = false) {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  function now() {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  function now() {
8
8
  return typeof (performance) !== 'undefined' ? performance.now() : Date.now();
9
9
  }
package/build/debug.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  var Client = require('./Client.cjs');
package/build/debug.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  import { Client } from './Client.mjs';
8
8
  import { CloseCode } from '@colyseus/shared-types';
9
9
 
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  class ServerError extends Error {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  class ServerError extends Error {
8
8
  code;
9
9
  headers;
package/build/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  require('./legacy.cjs');
package/build/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  import './legacy.mjs';
8
8
  export { Client, ColyseusSDK } from './Client.mjs';
9
9
  export { Room } from './Room.mjs';
package/build/legacy.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  //
package/build/legacy.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  //
8
8
  // Polyfills for legacy environments
9
9
  //
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  class NoneSerializer {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  class NoneSerializer {
8
8
  setState(rawState) { }
9
9
  getState() { return null; }
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  var schema = require('@colyseus/schema');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  import { getDecoderStateCallbacks, Reflection, Decoder } from '@colyseus/schema';
8
8
 
9
9
  //
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  const serializers = {};
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  const serializers = {};
8
8
  function registerSerializer(id, serializer) {
9
9
  serializers[id] = serializer;
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  var tslib = require('tslib');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  import { encode, decode } from '@colyseus/schema';
8
8
 
9
9
  class H3TransportTransport {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  'use strict';
8
8
 
9
9
  var NodeWebSocket = require('ws');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.27
7
7
  import NodeWebSocket from 'ws';
8
8
  import { CloseCode } from '@colyseus/shared-types';
9
9
 
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25 - @colyseus/schema 4.0.6
6
+ // colyseus.js@0.17.27 - @colyseus/schema 4.0.8
7
7
  // THIS VERSION USES "XMLHttpRequest" INSTEAD OF "fetch" FOR COMPATIBILITY WITH COCOS CREATOR
8
8
  (function (global, factory) {
9
9
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -116,6 +116,7 @@
116
116
  CONSENTED: 4e3,
117
117
  SERVER_SHUTDOWN: 4001,
118
118
  WITH_ERROR: 4002,
119
+ FAILED_TO_RECONNECT: 4003,
119
120
  MAY_TRY_RECONNECT: 4010
120
121
  };
121
122
 
@@ -8617,7 +8618,10 @@
8617
8618
  serializer.state = state;
8618
8619
  serializer.decoder = new buildExports.Decoder(state);
8619
8620
  }
8620
- this.onLeave(() => this.removeAllListeners());
8621
+ this.onLeave(() => {
8622
+ this.removeAllListeners();
8623
+ this.destroy();
8624
+ });
8621
8625
  }
8622
8626
  connect(endpoint, options, headers) {
8623
8627
  var _a;
@@ -8639,7 +8643,6 @@
8639
8643
  }
8640
8644
  else {
8641
8645
  this.onLeave.invoke(e.code, e.reason);
8642
- this.destroy();
8643
8646
  }
8644
8647
  };
8645
8648
  this.connection.events.onerror = (e) => {
@@ -8656,7 +8659,7 @@
8656
8659
  this.connection.connect(url.origin, Object.assign(Object.assign({}, options), { skipHandshake }));
8657
8660
  }
8658
8661
  else {
8659
- this.connection.connect(`${endpoint}${skipHandshake ? "?skipHandshake=1" : ""}`, headers);
8662
+ this.connection.connect(`${endpoint}${skipHandshake ? "&skipHandshake=1" : ""}`, headers);
8660
8663
  }
8661
8664
  }
8662
8665
  leave(consented = true) {
@@ -8765,6 +8768,8 @@
8765
8768
  this.onStateChange.clear();
8766
8769
  this.onError.clear();
8767
8770
  this.onLeave.clear();
8771
+ this.onReconnect.clear();
8772
+ this.onDrop.clear();
8768
8773
  this.onMessageHandlers.events = {};
8769
8774
  if (this.serializer instanceof SchemaSerializer) {
8770
8775
  // Remove callback references
@@ -8876,6 +8881,7 @@
8876
8881
  handleReconnection() {
8877
8882
  if (Date.now() - this.joinedAtTime < this.reconnection.minUptime) {
8878
8883
  console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Room has not been up for long enough for automatic reconnection. (min uptime: ${this.reconnection.minUptime}ms)`); // ❌
8884
+ this.onLeave.invoke(CloseCode.ABNORMAL_CLOSURE, "Room uptime too short for reconnection.");
8879
8885
  return;
8880
8886
  }
8881
8887
  if (!this.reconnection.isReconnecting) {
@@ -8885,6 +8891,13 @@
8885
8891
  this.retryReconnection();
8886
8892
  }
8887
8893
  retryReconnection() {
8894
+ if (this.reconnection.retryCount >= this.reconnection.maxRetries) {
8895
+ // No more retries
8896
+ console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} ❌ Reconnection failed after ${this.reconnection.maxRetries} attempts.`); // ❌
8897
+ this.reconnection.isReconnecting = false;
8898
+ this.onLeave.invoke(CloseCode.FAILED_TO_RECONNECT, "No more retries. Reconnection failed.");
8899
+ return;
8900
+ }
8888
8901
  this.reconnection.retryCount++;
8889
8902
  const delay = Math.min(this.reconnection.maxDelay, Math.max(this.reconnection.minDelay, this.reconnection.backoff(this.reconnection.retryCount, this.reconnection.delay)));
8890
8903
  console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x023F3)} will retry in ${(delay / 1000).toFixed(1)} seconds...`); // 🔄
@@ -8898,13 +8911,7 @@
8898
8911
  });
8899
8912
  }
8900
8913
  catch (e) {
8901
- console.log(".reconnect() failed", e);
8902
- if (this.reconnection.retryCount < this.reconnection.maxRetries) {
8903
- this.retryReconnection();
8904
- }
8905
- else {
8906
- console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Failed to reconnect. Is your server running? Please check server logs.`); // ❌
8907
- }
8914
+ this.retryReconnection();
8908
8915
  }
8909
8916
  }, delay);
8910
8917
  }