@colyseus/sdk 0.17.8 → 0.17.11

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/build/3rd_party/discord.cjs +1 -1
  2. package/build/3rd_party/discord.mjs +1 -1
  3. package/build/Auth.cjs +1 -1
  4. package/build/Auth.mjs +1 -1
  5. package/build/Client.cjs +1 -1
  6. package/build/Client.cjs.map +1 -1
  7. package/build/Client.d.ts +6 -6
  8. package/build/Client.mjs +1 -1
  9. package/build/Client.mjs.map +1 -1
  10. package/build/Connection.cjs +1 -1
  11. package/build/Connection.mjs +1 -1
  12. package/build/HTTP.cjs +17 -2
  13. package/build/HTTP.cjs.map +1 -1
  14. package/build/HTTP.d.ts +3 -0
  15. package/build/HTTP.mjs +17 -2
  16. package/build/HTTP.mjs.map +1 -1
  17. package/build/Protocol.cjs +1 -1
  18. package/build/Protocol.mjs +1 -1
  19. package/build/Room.cjs +1 -1
  20. package/build/Room.cjs.map +1 -1
  21. package/build/Room.d.ts +19 -3
  22. package/build/Room.mjs +1 -1
  23. package/build/Room.mjs.map +1 -1
  24. package/build/Storage.cjs +1 -1
  25. package/build/Storage.mjs +1 -1
  26. package/build/core/nanoevents.cjs +1 -1
  27. package/build/core/nanoevents.mjs +1 -1
  28. package/build/core/signal.cjs +1 -1
  29. package/build/core/signal.mjs +1 -1
  30. package/build/core/utils.cjs +1 -1
  31. package/build/core/utils.cjs.map +1 -1
  32. package/build/core/utils.d.ts +11 -0
  33. package/build/core/utils.mjs +1 -1
  34. package/build/core/utils.mjs.map +1 -1
  35. package/build/errors/Errors.cjs +1 -1
  36. package/build/errors/Errors.mjs +1 -1
  37. package/build/index.cjs +1 -1
  38. package/build/index.cjs.map +1 -1
  39. package/build/index.d.ts +1 -0
  40. package/build/index.mjs +1 -1
  41. package/build/index.mjs.map +1 -1
  42. package/build/legacy.cjs +1 -1
  43. package/build/legacy.mjs +1 -1
  44. package/build/serializer/NoneSerializer.cjs +1 -1
  45. package/build/serializer/NoneSerializer.mjs +1 -1
  46. package/build/serializer/SchemaSerializer.cjs +1 -1
  47. package/build/serializer/SchemaSerializer.mjs +1 -1
  48. package/build/serializer/Serializer.cjs +1 -1
  49. package/build/serializer/Serializer.mjs +1 -1
  50. package/build/transport/H3Transport.cjs +1 -1
  51. package/build/transport/H3Transport.mjs +1 -1
  52. package/build/transport/WebSocketTransport.cjs +1 -1
  53. package/build/transport/WebSocketTransport.mjs +1 -1
  54. package/dist/colyseus-cocos-creator.js +16 -2
  55. package/dist/colyseus-cocos-creator.js.map +1 -1
  56. package/dist/colyseus.js +16 -2
  57. package/dist/colyseus.js.map +1 -1
  58. package/dist/debug.js +1 -1
  59. package/package.json +1 -1
  60. package/src/Client.ts +20 -20
  61. package/src/HTTP.ts +18 -1
  62. package/src/Room.ts +25 -6
  63. package/src/core/utils.ts +18 -1
  64. package/src/index.ts +1 -0
@@ -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.8
6
+ // colyseus.js@0.17.11
7
7
  'use strict';
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
7
7
  'use strict';
8
8
 
9
9
  function now() {
@@ -1 +1 @@
1
- {"version":3,"file":"utils.cjs","sources":["../../src/core/utils.ts"],"sourcesContent":["export function now(): number {\n return typeof(performance) !== 'undefined' ? performance.now() : Date.now();\n}"],"names":[],"mappings":";;;;;;;;SAAgB,GAAG,GAAA;IACf,OAAO,QAAO,WAAW,CAAC,KAAK,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;AAC/E;;;;"}
1
+ {"version":3,"file":"utils.cjs","sources":["../../src/core/utils.ts"],"sourcesContent":["import type { SDKTypes, Room as ServerRoom } from '@colyseus/core';\n\nexport function now(): number {\n return typeof(performance) !== 'undefined' ? performance.now() : Date.now();\n}\n\n/**\n * Infer the room constructor from ServerType based on the instance type.\n * This allows proper type inference for SDK Room methods like `send()` and `onMessage()`.\n */\nexport type InferRoomConstructor<ServerType extends SDKTypes, Instance> =\n // First, try to find a matching room constructor in ServerType['~rooms']\n ServerType extends SDKTypes<infer Rooms>\n ? {\n [K in keyof Rooms]: Instance extends InstanceType<Rooms[K]['~room']>\n ? Rooms[K]['~room']\n : never\n }[keyof Rooms]\n : // Fallback: create a synthetic constructor type from the instance\n (typeof ServerRoom) & { prototype: Instance };"],"names":[],"mappings":";;;;;;;;SAEgB,GAAG,GAAA;IACf,OAAO,QAAO,WAAW,CAAC,KAAK,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;AAC/E;;;;"}
@@ -1 +1,12 @@
1
+ import type { SDKTypes, Room as ServerRoom } from '@colyseus/core';
1
2
  export declare function now(): number;
3
+ /**
4
+ * Infer the room constructor from ServerType based on the instance type.
5
+ * This allows proper type inference for SDK Room methods like `send()` and `onMessage()`.
6
+ */
7
+ export type InferRoomConstructor<ServerType extends SDKTypes, Instance> = ServerType extends SDKTypes<infer Rooms> ? {
8
+ [K in keyof Rooms]: Instance extends InstanceType<Rooms[K]['~room']> ? Rooms[K]['~room'] : never;
9
+ }[keyof Rooms] : // Fallback: create a synthetic constructor type from the instance
10
+ (typeof ServerRoom) & {
11
+ prototype: Instance;
12
+ };
@@ -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.8
6
+ // colyseus.js@0.17.11
7
7
  function now() {
8
8
  return typeof (performance) !== 'undefined' ? performance.now() : Date.now();
9
9
  }
@@ -1 +1 @@
1
- {"version":3,"file":"utils.mjs","sources":["../../src/core/utils.ts"],"sourcesContent":["export function now(): number {\n return typeof(performance) !== 'undefined' ? performance.now() : Date.now();\n}"],"names":[],"mappings":";;;;;;SAAgB,GAAG,GAAA;IACf,OAAO,QAAO,WAAW,CAAC,KAAK,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;AAC/E;;;;"}
1
+ {"version":3,"file":"utils.mjs","sources":["../../src/core/utils.ts"],"sourcesContent":["import type { SDKTypes, Room as ServerRoom } from '@colyseus/core';\n\nexport function now(): number {\n return typeof(performance) !== 'undefined' ? performance.now() : Date.now();\n}\n\n/**\n * Infer the room constructor from ServerType based on the instance type.\n * This allows proper type inference for SDK Room methods like `send()` and `onMessage()`.\n */\nexport type InferRoomConstructor<ServerType extends SDKTypes, Instance> =\n // First, try to find a matching room constructor in ServerType['~rooms']\n ServerType extends SDKTypes<infer Rooms>\n ? {\n [K in keyof Rooms]: Instance extends InstanceType<Rooms[K]['~room']>\n ? Rooms[K]['~room']\n : never\n }[keyof Rooms]\n : // Fallback: create a synthetic constructor type from the instance\n (typeof ServerRoom) & { prototype: Instance };"],"names":[],"mappings":";;;;;;SAEgB,GAAG,GAAA;IACf,OAAO,QAAO,WAAW,CAAC,KAAK,WAAW,GAAG,WAAW,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE;AAC/E;;;;"}
@@ -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.8
6
+ // colyseus.js@0.17.11
7
7
  'use strict';
8
8
 
9
9
  exports.CloseCode = void 0;
@@ -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.8
6
+ // colyseus.js@0.17.11
7
7
  var CloseCode;
8
8
  (function (CloseCode) {
9
9
  CloseCode[CloseCode["NORMAL_CLOSURE"] = 1000] = "NORMAL_CLOSURE";
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.8
6
+ // colyseus.js@0.17.11
7
7
  'use strict';
8
8
 
9
9
  require('./legacy.cjs');
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, MatchMakeError, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { Protocol, ErrorCode } from './Protocol.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, CloseCode } from './errors/Errors.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":["registerSerializer","SchemaSerializer","NoneSerializer"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBAA,6BAAkB,CAAC,QAAQ,EAAEC,iCAAgB,CAAC;AAC9CD,6BAAkB,CAAC,MAAM,EAAEE,6BAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, MatchMakeError, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { Protocol, ErrorCode } from './Protocol.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, CloseCode } from './errors/Errors.ts';\nexport type { InferRoomConstructor } from './core/utils.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":["registerSerializer","SchemaSerializer","NoneSerializer"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBAA,6BAAkB,CAAC,QAAQ,EAAEC,iCAAgB,CAAC;AAC9CD,6BAAkB,CAAC,MAAM,EAAEE,6BAAc,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/build/index.d.ts CHANGED
@@ -4,6 +4,7 @@ export { Protocol, ErrorCode } from './Protocol.ts';
4
4
  export { Room, type RoomAvailable } from './Room.ts';
5
5
  export { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from "./Auth.ts";
6
6
  export { ServerError, CloseCode } from './errors/Errors.ts';
7
+ export type { InferRoomConstructor } from './core/utils.ts';
7
8
  import { SchemaSerializer, getStateCallbacks } from "./serializer/SchemaSerializer.ts";
8
9
  import { registerSerializer } from './serializer/Serializer.ts';
9
10
  export { Callbacks } from "@colyseus/schema";
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.8
6
+ // colyseus.js@0.17.11
7
7
  import './legacy.mjs';
8
8
  export { Client, ColyseusSDK, MatchMakeError } from './Client.mjs';
9
9
  export { ErrorCode, Protocol } from './Protocol.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, MatchMakeError, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { Protocol, ErrorCode } from './Protocol.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, CloseCode } from './errors/Errors.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAiBA,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;AAC9C,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":["../src/index.ts"],"sourcesContent":["import './legacy';\n\nexport { ColyseusSDK, Client, MatchMakeError, type JoinOptions, type EndpointSettings, type ClientOptions, type ISeatReservation as SeatReservation } from './Client.ts';\nexport { Protocol, ErrorCode } from './Protocol.ts';\nexport { Room, type RoomAvailable } from './Room.ts';\nexport { Auth, type AuthSettings, type PopupSettings, type AuthResponse, type UserDataResponse, type ForgotPasswordResponse, type AuthData } from \"./Auth.ts\";\nexport { ServerError, CloseCode } from './errors/Errors.ts';\nexport type { InferRoomConstructor } from './core/utils.ts';\n\n/*\n * Serializers\n */\nimport { SchemaSerializer, getStateCallbacks } from \"./serializer/SchemaSerializer.ts\";\nimport { NoneSerializer } from \"./serializer/NoneSerializer.ts\";\nimport { registerSerializer } from './serializer/Serializer.ts';\nexport { Callbacks } from \"@colyseus/schema\";\n\nexport { registerSerializer, SchemaSerializer, getStateCallbacks };\nregisterSerializer('schema', SchemaSerializer);\nregisterSerializer('none', NoneSerializer);\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAkBA,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,CAAC;AAC9C,kBAAkB,CAAC,MAAM,EAAE,cAAc,CAAC;;;;"}
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
7
7
  import { Reflection, Decoder, getDecoderStateCallbacks } 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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
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.8
6
+ // colyseus.js@0.17.11
7
7
  import NodeWebSocket from 'ws';
8
8
 
9
9
  const WebSocket = globalThis.WebSocket || NodeWebSocket;
@@ -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.8 - @colyseus/schema 4.0.1
6
+ // colyseus.js@0.17.11 - @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) :
@@ -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
@@ -8952,7 +8953,20 @@
8952
8953
  body,
8953
8954
  method });
8954
8955
  const url = getURLWithQueryParams(this.sdk['getHttpEndpoint'](path.toString()), mergedOptions);
8955
- 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
+ }
8956
8970
  const contentType = response.headers.get("content-type");
8957
8971
  let data;
8958
8972
  let error = null;