@colyseus/sdk 0.17.7 → 0.17.10

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 (75) hide show
  1. package/build/3rd_party/discord.cjs +1 -1
  2. package/build/3rd_party/discord.mjs +1 -1
  3. package/build/Auth.cjs +1 -2
  4. package/build/Auth.cjs.map +1 -1
  5. package/build/Auth.d.ts +27 -10
  6. package/build/Auth.mjs +1 -2
  7. package/build/Auth.mjs.map +1 -1
  8. package/build/Client.cjs +1 -1
  9. package/build/Client.cjs.map +1 -1
  10. package/build/Client.d.ts +10 -9
  11. package/build/Client.mjs +1 -1
  12. package/build/Client.mjs.map +1 -1
  13. package/build/Connection.cjs +1 -1
  14. package/build/Connection.mjs +1 -1
  15. package/build/HTTP.cjs +21 -2
  16. package/build/HTTP.cjs.map +1 -1
  17. package/build/HTTP.d.ts +3 -0
  18. package/build/HTTP.mjs +21 -2
  19. package/build/HTTP.mjs.map +1 -1
  20. package/build/Protocol.cjs +1 -1
  21. package/build/Protocol.mjs +1 -1
  22. package/build/Room.cjs +2 -2
  23. package/build/Room.cjs.map +1 -1
  24. package/build/Room.d.ts +1 -5
  25. package/build/Room.mjs +2 -2
  26. package/build/Room.mjs.map +1 -1
  27. package/build/Storage.cjs +1 -1
  28. package/build/Storage.mjs +1 -1
  29. package/build/core/nanoevents.cjs +1 -1
  30. package/build/core/nanoevents.cjs.map +1 -1
  31. package/build/core/nanoevents.d.ts +9 -5
  32. package/build/core/nanoevents.mjs +1 -1
  33. package/build/core/nanoevents.mjs.map +1 -1
  34. package/build/core/signal.cjs +1 -1
  35. package/build/core/signal.mjs +1 -1
  36. package/build/core/utils.cjs +1 -1
  37. package/build/core/utils.cjs.map +1 -1
  38. package/build/core/utils.d.ts +11 -0
  39. package/build/core/utils.mjs +1 -1
  40. package/build/core/utils.mjs.map +1 -1
  41. package/build/errors/Errors.cjs +1 -1
  42. package/build/errors/Errors.mjs +1 -1
  43. package/build/index.cjs +1 -1
  44. package/build/index.cjs.map +1 -1
  45. package/build/index.d.ts +2 -1
  46. package/build/index.mjs +1 -1
  47. package/build/index.mjs.map +1 -1
  48. package/build/legacy.cjs +1 -1
  49. package/build/legacy.mjs +1 -1
  50. package/build/serializer/NoneSerializer.cjs +1 -1
  51. package/build/serializer/NoneSerializer.mjs +1 -1
  52. package/build/serializer/SchemaSerializer.cjs +1 -1
  53. package/build/serializer/SchemaSerializer.mjs +1 -1
  54. package/build/serializer/Serializer.cjs +1 -1
  55. package/build/serializer/Serializer.mjs +1 -1
  56. package/build/transport/H3Transport.cjs +1 -1
  57. package/build/transport/H3Transport.mjs +1 -1
  58. package/build/transport/WebSocketTransport.cjs +2 -2
  59. package/build/transport/WebSocketTransport.cjs.map +1 -1
  60. package/build/transport/WebSocketTransport.mjs +2 -2
  61. package/build/transport/WebSocketTransport.mjs.map +1 -1
  62. package/dist/colyseus-cocos-creator.js +22 -5
  63. package/dist/colyseus-cocos-creator.js.map +1 -1
  64. package/dist/colyseus.js +22 -5
  65. package/dist/colyseus.js.map +1 -1
  66. package/dist/debug.js +1 -1
  67. package/package.json +2 -2
  68. package/src/Auth.ts +49 -18
  69. package/src/Client.ts +25 -24
  70. package/src/HTTP.ts +23 -1
  71. package/src/Room.ts +1 -1
  72. package/src/core/nanoevents.ts +11 -3
  73. package/src/core/utils.ts +18 -1
  74. package/src/index.ts +2 -1
  75. package/src/transport/WebSocketTransport.ts +1 -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.7 - @colyseus/schema 4.0.1
6
+ // colyseus.js@0.17.10 - @colyseus/schema 4.0.1
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) :
@@ -8266,7 +8266,7 @@
8266
8266
  this.ws.send(data);
8267
8267
  }
8268
8268
  sendUnreliable(data) {
8269
- console.warn("colyseus.js: The WebSocket transport does not support unreliable messages");
8269
+ console.warn("@colyseus/sdk: The WebSocket transport does not support unreliable messages");
8270
8270
  }
8271
8271
  /**
8272
8272
  * @param url URL to connect to
@@ -8774,7 +8774,7 @@
8774
8774
  this.onMessageHandlers.emit('*', type, message);
8775
8775
  }
8776
8776
  else if (!messageType.startsWith("__")) { // ignore internal messages
8777
- (_a = console.warn) === null || _a === void 0 ? void 0 : _a.call(console, `colyseus.js: onMessage() not registered for type '${type}'.`);
8777
+ (_a = console.warn) === null || _a === void 0 ? void 0 : _a.call(console, `@colyseus/sdk: onMessage() not registered for type '${type}'.`);
8778
8778
  }
8779
8779
  }
8780
8780
  destroy() {
@@ -8918,6 +8918,7 @@
8918
8918
  }
8919
8919
  executeRequest(method, path, requestOptions) {
8920
8920
  return __awaiter(this, void 0, void 0, function* () {
8921
+ var _a;
8921
8922
  //
8922
8923
  // FIXME: if FormData is provided, merging "baseOptions.body" with
8923
8924
  // "options.body" will not work as intended
@@ -8930,6 +8931,10 @@
8930
8931
  ? Object.assign(Object.assign({}, this.options.params), ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.params) || {})) : requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.params;
8931
8932
  const headers = new Headers((this.options.headers)
8932
8933
  ? Object.assign(Object.assign({}, this.options.headers), ((requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers) || {})) : requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
8934
+ // Add Authorization header if authToken is set
8935
+ if (this.authToken && !headers.has("authorization")) {
8936
+ headers.set("authorization", `Bearer ${this.authToken}`);
8937
+ }
8933
8938
  // Stringify JSON-serializable objects for fetch() body
8934
8939
  if (isJSONSerializable(body) && typeof body === 'object' && body !== null) {
8935
8940
  if (!headers.has("content-type")) {
@@ -8948,7 +8953,20 @@
8948
8953
  body,
8949
8954
  method });
8950
8955
  const url = getURLWithQueryParams(this.sdk['getHttpEndpoint'](path.toString()), mergedOptions);
8951
- const response = yield fetch(url, mergedOptions);
8956
+ let response;
8957
+ try {
8958
+ response = yield fetch(url, mergedOptions);
8959
+ }
8960
+ catch (err) {
8961
+ // If it's an AbortError, re-throw as-is
8962
+ if (err.name === 'AbortError') {
8963
+ throw err;
8964
+ }
8965
+ // Re-throw with network error code at top level (e.g. ECONNREFUSED)
8966
+ const networkError = new ServerError(((_a = err.cause) === null || _a === void 0 ? void 0 : _a.code) || err.code, err.message);
8967
+ networkError.cause = err.cause;
8968
+ throw networkError;
8969
+ }
8952
8970
  const contentType = response.headers.get("content-type");
8953
8971
  let data;
8954
8972
  let error = null;
@@ -9186,7 +9204,6 @@
9186
9204
  }
9187
9205
  signOut() {
9188
9206
  return __awaiter(this, void 0, void 0, function* () {
9189
- // @ts-ignore
9190
9207
  this.emitChange({ user: null, token: null });
9191
9208
  });
9192
9209
  }