@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.
- package/build/3rd_party/discord.cjs +1 -1
- package/build/3rd_party/discord.mjs +1 -1
- package/build/Auth.cjs +1 -1
- package/build/Auth.mjs +1 -1
- package/build/Client.cjs +1 -1
- package/build/Client.cjs.map +1 -1
- package/build/Client.d.ts +6 -6
- package/build/Client.mjs +1 -1
- package/build/Client.mjs.map +1 -1
- package/build/Connection.cjs +1 -1
- package/build/Connection.mjs +1 -1
- package/build/HTTP.cjs +17 -2
- package/build/HTTP.cjs.map +1 -1
- package/build/HTTP.d.ts +3 -0
- package/build/HTTP.mjs +17 -2
- package/build/HTTP.mjs.map +1 -1
- package/build/Protocol.cjs +1 -1
- package/build/Protocol.mjs +1 -1
- package/build/Room.cjs +1 -1
- package/build/Room.cjs.map +1 -1
- package/build/Room.d.ts +19 -3
- package/build/Room.mjs +1 -1
- package/build/Room.mjs.map +1 -1
- package/build/Storage.cjs +1 -1
- package/build/Storage.mjs +1 -1
- package/build/core/nanoevents.cjs +1 -1
- package/build/core/nanoevents.mjs +1 -1
- package/build/core/signal.cjs +1 -1
- package/build/core/signal.mjs +1 -1
- package/build/core/utils.cjs +1 -1
- package/build/core/utils.cjs.map +1 -1
- package/build/core/utils.d.ts +11 -0
- package/build/core/utils.mjs +1 -1
- package/build/core/utils.mjs.map +1 -1
- package/build/errors/Errors.cjs +1 -1
- package/build/errors/Errors.mjs +1 -1
- package/build/index.cjs +1 -1
- package/build/index.cjs.map +1 -1
- package/build/index.d.ts +1 -0
- package/build/index.mjs +1 -1
- package/build/index.mjs.map +1 -1
- package/build/legacy.cjs +1 -1
- package/build/legacy.mjs +1 -1
- package/build/serializer/NoneSerializer.cjs +1 -1
- package/build/serializer/NoneSerializer.mjs +1 -1
- package/build/serializer/SchemaSerializer.cjs +1 -1
- package/build/serializer/SchemaSerializer.mjs +1 -1
- package/build/serializer/Serializer.cjs +1 -1
- package/build/serializer/Serializer.mjs +1 -1
- package/build/transport/H3Transport.cjs +1 -1
- package/build/transport/H3Transport.mjs +1 -1
- package/build/transport/WebSocketTransport.cjs +1 -1
- package/build/transport/WebSocketTransport.mjs +1 -1
- package/dist/colyseus-cocos-creator.js +16 -2
- package/dist/colyseus-cocos-creator.js.map +1 -1
- package/dist/colyseus.js +16 -2
- package/dist/colyseus.js.map +1 -1
- package/dist/debug.js +1 -1
- package/package.json +1 -1
- package/src/Client.ts +20 -20
- package/src/HTTP.ts +18 -1
- package/src/Room.ts +25 -6
- package/src/core/utils.ts +18 -1
- package/src/index.ts +1 -0
package/build/core/signal.cjs
CHANGED
package/build/core/signal.mjs
CHANGED
package/build/core/utils.cjs
CHANGED
package/build/core/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../src/core/utils.ts"],"sourcesContent":["
|
|
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;;;;"}
|
package/build/core/utils.d.ts
CHANGED
|
@@ -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
|
+
};
|
package/build/core/utils.mjs
CHANGED
package/build/core/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../src/core/utils.ts"],"sourcesContent":["
|
|
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;;;;"}
|
package/build/errors/Errors.cjs
CHANGED
package/build/errors/Errors.mjs
CHANGED
package/build/index.cjs
CHANGED
package/build/index.cjs.map
CHANGED
|
@@ -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":";;;;;;;;;;;;;;;;;;;
|
|
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.
|
|
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';
|
package/build/index.mjs.map
CHANGED
|
@@ -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":";;;;;;;;;;;;;;;;;;
|
|
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
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.
|
|
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
|
-
|
|
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;
|