@colyseus/core 0.16.23 → 0.17.0
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/Debug.js +16 -4
- package/build/Debug.js.map +2 -2
- package/build/Debug.mjs +11 -1
- package/build/Debug.mjs.map +2 -2
- package/build/IPC.js +5 -3
- package/build/IPC.js.map +2 -2
- package/build/IPC.mjs +1 -0
- package/build/IPC.mjs.map +2 -2
- package/build/Logger.js +1 -0
- package/build/Logger.js.map +1 -1
- package/build/MatchMaker.js +148 -84
- package/build/MatchMaker.js.map +3 -3
- package/build/MatchMaker.mjs +130 -70
- package/build/MatchMaker.mjs.map +3 -3
- package/build/Protocol.js +54 -41
- package/build/Protocol.js.map +3 -3
- package/build/Protocol.mjs +52 -41
- package/build/Protocol.mjs.map +3 -3
- package/build/Room.js +430 -195
- package/build/Room.js.map +3 -3
- package/build/Room.mjs +417 -175
- package/build/Room.mjs.map +3 -3
- package/build/Server.js +48 -108
- package/build/Server.js.map +3 -3
- package/build/Server.mjs +39 -102
- package/build/Server.mjs.map +3 -3
- package/build/Stats.js +2 -1
- package/build/Stats.js.map +2 -2
- package/build/Stats.mjs.map +1 -1
- package/build/Transport.js +29 -11
- package/build/Transport.js.map +3 -3
- package/build/Transport.mjs +15 -9
- package/build/Transport.mjs.map +3 -3
- package/build/errors/RoomExceptions.js +9 -5
- package/build/errors/RoomExceptions.js.map +2 -2
- package/build/errors/RoomExceptions.mjs +8 -5
- package/build/errors/RoomExceptions.mjs.map +2 -2
- package/build/errors/SeatReservationError.js +1 -0
- package/build/errors/SeatReservationError.js.map +1 -1
- package/build/errors/ServerError.js +2 -1
- package/build/errors/ServerError.js.map +2 -2
- package/build/errors/ServerError.mjs.map +1 -1
- package/build/index.js +60 -26
- package/build/index.js.map +2 -2
- package/build/index.mjs +33 -7
- package/build/index.mjs.map +2 -2
- package/build/matchmaker/Lobby.js +13 -3
- package/build/matchmaker/Lobby.js.map +2 -2
- package/build/matchmaker/Lobby.mjs +11 -2
- package/build/matchmaker/Lobby.mjs.map +2 -2
- package/build/matchmaker/LocalDriver/LocalDriver.js +94 -0
- package/build/matchmaker/LocalDriver/LocalDriver.js.map +7 -0
- package/build/matchmaker/LocalDriver/LocalDriver.mjs +71 -0
- package/build/matchmaker/LocalDriver/LocalDriver.mjs.map +7 -0
- package/build/matchmaker/LocalDriver/Query.js +111 -0
- package/build/matchmaker/LocalDriver/Query.js.map +7 -0
- package/build/matchmaker/LocalDriver/Query.mjs +88 -0
- package/build/matchmaker/LocalDriver/Query.mjs.map +7 -0
- package/build/matchmaker/RegisteredHandler.js +57 -7
- package/build/matchmaker/RegisteredHandler.js.map +2 -2
- package/build/matchmaker/RegisteredHandler.mjs +54 -5
- package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
- package/build/matchmaker/controller.js +8 -8
- package/build/matchmaker/controller.js.map +2 -2
- package/build/matchmaker/controller.mjs +4 -5
- package/build/matchmaker/controller.mjs.map +2 -2
- package/build/matchmaker/driver/api.js +21 -2
- package/build/matchmaker/driver/api.js.map +2 -2
- package/build/matchmaker/driver/api.mjs +18 -1
- package/build/matchmaker/driver/api.mjs.map +2 -2
- package/build/matchmaker/driver/local/LocalDriver.js +36 -7
- package/build/matchmaker/driver/local/LocalDriver.js.map +2 -2
- package/build/matchmaker/driver/local/LocalDriver.mjs +33 -5
- package/build/matchmaker/driver/local/LocalDriver.mjs.map +2 -2
- package/build/matchmaker/driver/local/Query.js +51 -18
- package/build/matchmaker/driver/local/Query.js.map +2 -2
- package/build/matchmaker/driver/local/Query.mjs +50 -18
- package/build/matchmaker/driver/local/Query.mjs.map +2 -2
- package/build/matchmaker/driver.js +44 -0
- package/build/matchmaker/driver.js.map +7 -0
- package/build/matchmaker/driver.mjs +20 -0
- package/build/matchmaker/driver.mjs.map +7 -0
- package/build/matchmaker/routes.js +79 -0
- package/build/matchmaker/routes.js.map +7 -0
- package/build/matchmaker/routes.mjs +45 -0
- package/build/matchmaker/routes.mjs.map +7 -0
- package/build/presence/LocalPresence.js +13 -27
- package/build/presence/LocalPresence.js.map +3 -3
- package/build/presence/LocalPresence.mjs +11 -16
- package/build/presence/LocalPresence.mjs.map +2 -2
- package/build/presence/Presence.js +37 -0
- package/build/presence/Presence.js.map +2 -2
- package/build/presence/Presence.mjs +29 -0
- package/build/presence/Presence.mjs.map +3 -3
- package/build/rooms/LobbyRoom.js +5 -5
- package/build/rooms/LobbyRoom.js.map +2 -2
- package/build/rooms/LobbyRoom.mjs +1 -2
- package/build/rooms/LobbyRoom.mjs.map +2 -2
- package/build/rooms/RankedQueueRoom.js +224 -0
- package/build/rooms/RankedQueueRoom.js.map +7 -0
- package/build/rooms/RankedQueueRoom.mjs +201 -0
- package/build/rooms/RankedQueueRoom.mjs.map +7 -0
- package/build/rooms/RelayRoom.js +6 -6
- package/build/rooms/RelayRoom.js.map +2 -2
- package/build/rooms/RelayRoom.mjs +4 -5
- package/build/rooms/RelayRoom.mjs.map +2 -2
- package/build/rooms/createRoom.js +51 -0
- package/build/rooms/createRoom.js.map +7 -0
- package/build/rooms/createRoom.mjs +28 -0
- package/build/rooms/createRoom.mjs.map +7 -0
- package/build/router/default_routes.js +79 -0
- package/build/router/default_routes.js.map +7 -0
- package/build/router/default_routes.mjs +45 -0
- package/build/router/default_routes.mjs.map +7 -0
- package/build/router/index.js +55 -0
- package/build/router/index.js.map +7 -0
- package/build/router/index.mjs +30 -0
- package/build/router/index.mjs.map +7 -0
- package/build/serializer/NoneSerializer.js +1 -0
- package/build/serializer/NoneSerializer.js.map +2 -2
- package/build/serializer/NoneSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializer.js +6 -7
- package/build/serializer/SchemaSerializer.js.map +2 -2
- package/build/serializer/SchemaSerializer.mjs +3 -5
- package/build/serializer/SchemaSerializer.mjs.map +2 -2
- package/build/serializer/SchemaSerializerDebug.js +29 -0
- package/build/serializer/SchemaSerializerDebug.js.map +3 -3
- package/build/serializer/SchemaSerializerDebug.mjs +7 -0
- package/build/serializer/SchemaSerializerDebug.mjs.map +3 -3
- package/build/serializer/Serializer.js +1 -0
- package/build/serializer/Serializer.js.map +2 -2
- package/build/{Debug.d.ts → src/Debug.d.ts} +2 -1
- package/build/{IPC.d.ts → src/IPC.d.ts} +2 -2
- package/build/{MatchMaker.d.ts → src/MatchMaker.d.ts} +58 -33
- package/build/src/Protocol.d.ts +53 -0
- package/build/src/Room.d.ts +497 -0
- package/build/{Server.d.ts → src/Server.d.ts} +23 -25
- package/build/{Transport.d.ts → src/Transport.d.ts} +65 -22
- package/build/{errors → src/errors}/RoomExceptions.d.ts +8 -7
- package/build/src/index.d.ts +27 -0
- package/build/src/matchmaker/Lobby.d.ts +4 -0
- package/build/src/matchmaker/LocalDriver/LocalDriver.d.ts +17 -0
- package/build/src/matchmaker/LocalDriver/Query.d.ts +12 -0
- package/build/src/matchmaker/RegisteredHandler.d.ts +81 -0
- package/build/{matchmaker → src/matchmaker}/controller.d.ts +5 -6
- package/build/src/matchmaker/driver/api.d.ts +145 -0
- package/build/src/matchmaker/driver/local/LocalDriver.d.ts +17 -0
- package/build/src/matchmaker/driver/local/Query.d.ts +12 -0
- package/build/src/matchmaker/driver.d.ts +145 -0
- package/build/src/matchmaker/routes.d.ts +92 -0
- package/build/{presence → src/presence}/LocalPresence.d.ts +1 -1
- package/build/{presence → src/presence}/Presence.d.ts +2 -0
- package/build/{rooms → src/rooms}/LobbyRoom.d.ts +4 -4
- package/build/src/rooms/RankedQueueRoom.d.ts +125 -0
- package/build/{rooms → src/rooms}/RelayRoom.d.ts +5 -4
- package/build/src/rooms/createRoom.d.ts +65 -0
- package/build/src/router/default_routes.d.ts +103 -0
- package/build/src/router/index.d.ts +68 -0
- package/build/{serializer → src/serializer}/NoneSerializer.d.ts +2 -2
- package/build/{serializer → src/serializer}/SchemaSerializer.d.ts +9 -9
- package/build/{serializer → src/serializer}/Serializer.d.ts +3 -3
- package/build/{utils → src/utils}/DevMode.d.ts +5 -4
- package/build/{utils → src/utils}/StandardSchema.d.ts +1 -1
- package/build/{utils → src/utils}/Utils.d.ts +15 -4
- package/build/utils/DevMode.js +54 -26
- package/build/utils/DevMode.js.map +3 -3
- package/build/utils/DevMode.mjs +44 -19
- package/build/utils/DevMode.mjs.map +2 -2
- package/build/utils/StandardSchema.js.map +1 -1
- package/build/utils/StandardSchema.mjs.map +1 -1
- package/build/utils/Utils.js +8 -15
- package/build/utils/Utils.js.map +3 -3
- package/build/utils/Utils.mjs +6 -4
- package/build/utils/Utils.mjs.map +2 -2
- package/package.json +20 -14
- package/build/Protocol.d.ts +0 -37
- package/build/Room.d.ts +0 -265
- package/build/discovery/index.d.ts +0 -8
- package/build/discovery/index.js +0 -50
- package/build/discovery/index.js.map +0 -7
- package/build/discovery/index.mjs +0 -26
- package/build/discovery/index.mjs.map +0 -7
- package/build/index.d.ts +0 -24
- package/build/matchmaker/Lobby.d.ts +0 -4
- package/build/matchmaker/RegisteredHandler.d.ts +0 -19
- package/build/matchmaker/driver/Query.d.ts +0 -8
- package/build/matchmaker/driver/Query.js +0 -68
- package/build/matchmaker/driver/Query.js.map +0 -7
- package/build/matchmaker/driver/Query.mjs +0 -45
- package/build/matchmaker/driver/Query.mjs.map +0 -7
- package/build/matchmaker/driver/RoomData.d.ts +0 -19
- package/build/matchmaker/driver/RoomData.js +0 -79
- package/build/matchmaker/driver/RoomData.js.map +0 -7
- package/build/matchmaker/driver/RoomData.mjs +0 -56
- package/build/matchmaker/driver/RoomData.mjs.map +0 -7
- package/build/matchmaker/driver/api.d.ts +0 -104
- package/build/matchmaker/driver/index.d.ts +0 -13
- package/build/matchmaker/driver/index.js +0 -64
- package/build/matchmaker/driver/index.js.map +0 -7
- package/build/matchmaker/driver/index.mjs +0 -42
- package/build/matchmaker/driver/index.mjs.map +0 -7
- package/build/matchmaker/driver/interfaces.d.ts +0 -73
- package/build/matchmaker/driver/interfaces.js +0 -15
- package/build/matchmaker/driver/interfaces.js.map +0 -7
- package/build/matchmaker/driver/interfaces.mjs +0 -0
- package/build/matchmaker/driver/interfaces.mjs.map +0 -7
- package/build/matchmaker/driver/local/LocalDriver.d.ts +0 -13
- package/build/matchmaker/driver/local/Query.d.ts +0 -9
- package/build/matchmaker/driver/local/RoomData.d.ts +0 -19
- package/build/matchmaker/driver/local/RoomData.js +0 -79
- package/build/matchmaker/driver/local/RoomData.js.map +0 -7
- package/build/matchmaker/driver/local/RoomData.mjs +0 -57
- package/build/matchmaker/driver/local/RoomData.mjs.map +0 -7
- package/build/utils/types.d.ts +0 -1
- package/build/utils/types.js +0 -15
- package/build/utils/types.js.map +0 -7
- package/build/utils/types.mjs +0 -0
- package/build/utils/types.mjs.map +0 -7
- /package/build/{Logger.d.ts → src/Logger.d.ts} +0 -0
- /package/build/{Stats.d.ts → src/Stats.d.ts} +0 -0
- /package/build/{errors → src/errors}/SeatReservationError.d.ts +0 -0
- /package/build/{errors → src/errors}/ServerError.d.ts +0 -0
- /package/build/{serializer → src/serializer}/SchemaSerializerDebug.d.ts +0 -0
- /package/build/{utils → src/utils}/nanoevents.d.ts +0 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
export declare const postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
2
|
+
method: "POST";
|
|
3
|
+
}, any>;
|
|
4
|
+
export declare function getDefaultRouter(): {
|
|
5
|
+
handler: (request: Request) => Promise<Response>;
|
|
6
|
+
endpoints: {
|
|
7
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
8
|
+
method: "POST";
|
|
9
|
+
}, any>;
|
|
10
|
+
};
|
|
11
|
+
extend: <NE extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE) => {
|
|
12
|
+
handler: (request: Request) => Promise<Response>;
|
|
13
|
+
endpoints: {
|
|
14
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
15
|
+
method: "POST";
|
|
16
|
+
}, any>;
|
|
17
|
+
} & NE;
|
|
18
|
+
extend: <NE_1 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_1) => {
|
|
19
|
+
handler: (request: Request) => Promise<Response>;
|
|
20
|
+
endpoints: {
|
|
21
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
22
|
+
method: "POST";
|
|
23
|
+
}, any>;
|
|
24
|
+
} & NE & NE_1;
|
|
25
|
+
extend: <NE_2 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_2) => {
|
|
26
|
+
handler: (request: Request) => Promise<Response>;
|
|
27
|
+
endpoints: {
|
|
28
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
29
|
+
method: "POST";
|
|
30
|
+
}, any>;
|
|
31
|
+
} & NE & NE_1 & NE_2;
|
|
32
|
+
extend: <NE_3 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_3) => {
|
|
33
|
+
handler: (request: Request) => Promise<Response>;
|
|
34
|
+
endpoints: {
|
|
35
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
36
|
+
method: "POST";
|
|
37
|
+
}, any>;
|
|
38
|
+
} & NE & NE_1 & NE_2 & NE_3;
|
|
39
|
+
extend: <NE_4 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_4) => {
|
|
40
|
+
handler: (request: Request) => Promise<Response>;
|
|
41
|
+
endpoints: {
|
|
42
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
43
|
+
method: "POST";
|
|
44
|
+
}, any>;
|
|
45
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4;
|
|
46
|
+
extend: <NE_5 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_5) => {
|
|
47
|
+
handler: (request: Request) => Promise<Response>;
|
|
48
|
+
endpoints: {
|
|
49
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
50
|
+
method: "POST";
|
|
51
|
+
}, any>;
|
|
52
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5;
|
|
53
|
+
extend: <NE_6 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_6) => {
|
|
54
|
+
handler: (request: Request) => Promise<Response>;
|
|
55
|
+
endpoints: {
|
|
56
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
57
|
+
method: "POST";
|
|
58
|
+
}, any>;
|
|
59
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6;
|
|
60
|
+
extend: <NE_7 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_7) => {
|
|
61
|
+
handler: (request: Request) => Promise<Response>;
|
|
62
|
+
endpoints: {
|
|
63
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
64
|
+
method: "POST";
|
|
65
|
+
}, any>;
|
|
66
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7;
|
|
67
|
+
extend: <NE_8 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_8) => {
|
|
68
|
+
handler: (request: Request) => Promise<Response>;
|
|
69
|
+
endpoints: {
|
|
70
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
71
|
+
method: "POST";
|
|
72
|
+
}, any>;
|
|
73
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8;
|
|
74
|
+
extend: <NE_9 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_9) => {
|
|
75
|
+
handler: (request: Request) => Promise<Response>;
|
|
76
|
+
endpoints: {
|
|
77
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
78
|
+
method: "POST";
|
|
79
|
+
}, any>;
|
|
80
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8 & NE_9;
|
|
81
|
+
extend: <NE_10 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_10) => any;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
};
|
|
85
|
+
};
|
|
86
|
+
};
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
};
|
|
92
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EventEmitter } from 'events';
|
|
2
|
-
import { Presence } from './Presence.
|
|
2
|
+
import type { Presence } from './Presence.ts';
|
|
3
3
|
type Callback = (...args: any[]) => void;
|
|
4
4
|
export declare class LocalPresence implements Presence {
|
|
5
5
|
subscriptions: EventEmitter<[never]>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Room } from "../Room.ts";
|
|
1
2
|
/**
|
|
2
3
|
* When you need to scale your server on multiple processes and/or machines, you'd need to provide
|
|
3
4
|
* the Presence option to the Server. The purpose of Presence is to allow communicating and
|
|
@@ -193,3 +194,4 @@ export interface Presence {
|
|
|
193
194
|
setMaxListeners(number: number): void;
|
|
194
195
|
shutdown(): void;
|
|
195
196
|
}
|
|
197
|
+
export declare function createScopedPresence(room: Room, presence: Presence): Presence;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { IRoomCache } from '../matchmaker/
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { IRoomCache } from '../matchmaker/LocalDriver/LocalDriver.ts';
|
|
2
|
+
import type { Client } from '../Transport.ts';
|
|
3
|
+
import { Room } from '../Room.ts';
|
|
4
4
|
export interface FilterInput {
|
|
5
5
|
name?: string;
|
|
6
6
|
metadata?: any;
|
|
@@ -18,6 +18,6 @@ export declare class LobbyRoom extends Room {
|
|
|
18
18
|
onJoin(client: Client, options: LobbyOptions): void;
|
|
19
19
|
onLeave(client: Client): void;
|
|
20
20
|
onDispose(): void;
|
|
21
|
-
protected filterItemsForClient(options: LobbyOptions): IRoomCache[];
|
|
21
|
+
protected filterItemsForClient(options: LobbyOptions): IRoomCache<any>[];
|
|
22
22
|
protected filterItemForClient(room: IRoomCache, filter?: LobbyOptions['filter']): boolean;
|
|
23
23
|
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { Room, type Client, type IRoomCache } from "@colyseus/core";
|
|
2
|
+
export interface RankedQueueOptions {
|
|
3
|
+
/**
|
|
4
|
+
* number of players on each match
|
|
5
|
+
*/
|
|
6
|
+
maxPlayers?: number;
|
|
7
|
+
/**
|
|
8
|
+
* name of the room to create
|
|
9
|
+
*/
|
|
10
|
+
matchRoomName: string;
|
|
11
|
+
/**
|
|
12
|
+
* after these cycles, create a match with a bot
|
|
13
|
+
*/
|
|
14
|
+
maxWaitingCycles?: number;
|
|
15
|
+
/**
|
|
16
|
+
* after this time, try to fit this client with a not-so-compatible group
|
|
17
|
+
*/
|
|
18
|
+
maxWaitingCyclesForPriority?: number;
|
|
19
|
+
/**
|
|
20
|
+
* If set, teams must have the same size to be matched together
|
|
21
|
+
*/
|
|
22
|
+
maxTeamSize?: number;
|
|
23
|
+
/**
|
|
24
|
+
* If `allowIncompleteGroups` is true, players inside an unmatched group (that
|
|
25
|
+
* did not reached `maxPlayers`, and `maxWaitingCycles` has been
|
|
26
|
+
* reached) will be matched together. Your room should fill the remaining
|
|
27
|
+
* spots with "bots" on this case.
|
|
28
|
+
*/
|
|
29
|
+
allowIncompleteGroups?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Comparison function for matching clients to groups
|
|
32
|
+
* Returns true if the client is compatible with the group
|
|
33
|
+
*/
|
|
34
|
+
compare?: (client: ClientQueueData, matchGroup: MatchGroup) => boolean;
|
|
35
|
+
/**
|
|
36
|
+
*
|
|
37
|
+
* When onGroupReady is set, the "roomNameToCreate" option is ignored.
|
|
38
|
+
*/
|
|
39
|
+
onGroupReady?: (this: RankedQueueRoom, group: MatchGroup) => Promise<IRoomCache>;
|
|
40
|
+
}
|
|
41
|
+
export interface MatchGroup {
|
|
42
|
+
averageRank: number;
|
|
43
|
+
clients: Array<Client<{
|
|
44
|
+
userData: ClientQueueData;
|
|
45
|
+
}>>;
|
|
46
|
+
ready?: boolean;
|
|
47
|
+
confirmed?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface MatchTeam {
|
|
50
|
+
averageRank: number;
|
|
51
|
+
clients: Array<Client<{
|
|
52
|
+
userData: ClientQueueData;
|
|
53
|
+
}>>;
|
|
54
|
+
teamId: string | symbol;
|
|
55
|
+
}
|
|
56
|
+
export interface ClientQueueData {
|
|
57
|
+
/**
|
|
58
|
+
* Rank of the client
|
|
59
|
+
*/
|
|
60
|
+
rank: number;
|
|
61
|
+
/**
|
|
62
|
+
* Timestamp of when the client entered the queue
|
|
63
|
+
*/
|
|
64
|
+
currentCycle?: number;
|
|
65
|
+
/**
|
|
66
|
+
* Optional: if matching with a team, the team ID
|
|
67
|
+
*/
|
|
68
|
+
teamId?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Additional options passed by the client when joining the room
|
|
71
|
+
*/
|
|
72
|
+
options?: any;
|
|
73
|
+
/**
|
|
74
|
+
* Match group the client is currently in
|
|
75
|
+
*/
|
|
76
|
+
group?: MatchGroup;
|
|
77
|
+
/**
|
|
78
|
+
* Whether the client has confirmed the connection to the room
|
|
79
|
+
*/
|
|
80
|
+
confirmed?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* Whether the client should be prioritized in the queue
|
|
83
|
+
* (e.g. for players that are waiting for a long time)
|
|
84
|
+
*/
|
|
85
|
+
highPriority?: boolean;
|
|
86
|
+
/**
|
|
87
|
+
* The last number of clients in the queue sent to the client
|
|
88
|
+
*/
|
|
89
|
+
lastQueueClientCount?: number;
|
|
90
|
+
}
|
|
91
|
+
export declare class RankedQueueRoom extends Room {
|
|
92
|
+
maxPlayers: number;
|
|
93
|
+
maxTeamSize: number;
|
|
94
|
+
allowIncompleteGroups: boolean;
|
|
95
|
+
maxWaitingCycles: number;
|
|
96
|
+
maxWaitingCyclesForPriority?: number;
|
|
97
|
+
/**
|
|
98
|
+
* Evaluate groups for each client at interval
|
|
99
|
+
*/
|
|
100
|
+
cycleTickInterval: number;
|
|
101
|
+
/**
|
|
102
|
+
* Groups of players per iteration
|
|
103
|
+
*/
|
|
104
|
+
groups: MatchGroup[];
|
|
105
|
+
highPriorityGroups: MatchGroup[];
|
|
106
|
+
matchRoomName: string;
|
|
107
|
+
protected compare: (client: ClientQueueData, matchGroup: MatchGroup) => boolean;
|
|
108
|
+
protected onGroupReady: (group: MatchGroup) => Promise<IRoomCache<any>>;
|
|
109
|
+
messages: {
|
|
110
|
+
confirm: (client: Client, _: unknown) => void;
|
|
111
|
+
};
|
|
112
|
+
onCreate(options: RankedQueueOptions): void;
|
|
113
|
+
onJoin(client: Client, options: any, auth?: unknown): void;
|
|
114
|
+
addToQueue(client: Client, queueData: ClientQueueData): void;
|
|
115
|
+
createMatchGroup(): MatchGroup;
|
|
116
|
+
reassignMatchGroups(): void;
|
|
117
|
+
redistributeTeams(sortedClients: Client<{
|
|
118
|
+
userData: ClientQueueData;
|
|
119
|
+
}>[]): void;
|
|
120
|
+
redistributeClients(sortedClients: Client<{
|
|
121
|
+
userData: ClientQueueData;
|
|
122
|
+
}>[], currentGroup?: MatchGroup, totalRank?: number): MatchGroup;
|
|
123
|
+
evaluateHighPriorityGroups(): void;
|
|
124
|
+
processGroupsReady(): void;
|
|
125
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MapSchema, Schema } from '@colyseus/schema';
|
|
2
|
-
import { Room } from '../Room.
|
|
3
|
-
import { Client } from '../Transport.
|
|
2
|
+
import { Room } from '../Room.ts';
|
|
3
|
+
import type { Client } from '../Transport.ts';
|
|
4
4
|
declare class Player extends Schema {
|
|
5
5
|
connected: boolean;
|
|
6
6
|
name: string;
|
|
@@ -15,7 +15,8 @@ declare class State extends Schema {
|
|
|
15
15
|
* allowReconnectionTime: 20
|
|
16
16
|
* });
|
|
17
17
|
*/
|
|
18
|
-
export declare class RelayRoom extends Room
|
|
18
|
+
export declare class RelayRoom extends Room {
|
|
19
|
+
state: State;
|
|
19
20
|
allowReconnectionTime: number;
|
|
20
21
|
onCreate(options: Partial<{
|
|
21
22
|
maxClients: number;
|
|
@@ -23,6 +24,6 @@ export declare class RelayRoom extends Room<State> {
|
|
|
23
24
|
metadata: any;
|
|
24
25
|
}>): void;
|
|
25
26
|
onJoin(client: Client, options?: any): void;
|
|
26
|
-
onLeave(client: Client,
|
|
27
|
+
onLeave(client: Client, code: number): Promise<void>;
|
|
27
28
|
}
|
|
28
29
|
export {};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Exploration: defineRoom() factory function
|
|
3
|
+
*
|
|
4
|
+
* Goal: Allow users to define rooms without explicit generic parameters,
|
|
5
|
+
* while still getting full type inference for broadcast() and client.send()
|
|
6
|
+
*/
|
|
7
|
+
import { Room, type Client } from "@colyseus/core";
|
|
8
|
+
/**
|
|
9
|
+
* Helper type for cleaner Client typing with messages.
|
|
10
|
+
* Reduces boilerplate from `Client<{ messages: M }>` to `MessageClient<M>`.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* type MyClient = MessageClient<{
|
|
15
|
+
* chat: { text: string };
|
|
16
|
+
* move: { x: number; y: number };
|
|
17
|
+
* }>;
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export type MessageClient<Messages extends Record<string, any>> = Client<{
|
|
21
|
+
messages: Messages;
|
|
22
|
+
}>;
|
|
23
|
+
/**
|
|
24
|
+
* Options for createRoom factory function.
|
|
25
|
+
*/
|
|
26
|
+
interface DefineRoomOptions<TClient extends Client = Client, State extends object = any, JoinOptions = any> {
|
|
27
|
+
state?: State | (() => State);
|
|
28
|
+
onCreate?(this: Room<State, any, TClient>, options: any): void | Promise<void>;
|
|
29
|
+
onJoin?(this: Room<State, any, TClient>, client: TClient, options: JoinOptions): void | Promise<void>;
|
|
30
|
+
onLeave?(this: Room<State, any, TClient>, client: TClient, code?: number): void | Promise<void>;
|
|
31
|
+
onDispose?(this: Room<State, any, TClient>): void | Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Create a Room class from an options object.
|
|
35
|
+
* Provides Vue-style object configuration with full type inference.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* type MyClient = Client<{
|
|
40
|
+
* userData: { rank: number };
|
|
41
|
+
* auth: { odToken: string };
|
|
42
|
+
* messages: {
|
|
43
|
+
* chat: { text: string };
|
|
44
|
+
* move: { x: number; y: number };
|
|
45
|
+
* };
|
|
46
|
+
* }>;
|
|
47
|
+
*
|
|
48
|
+
* const MyRoom = createRoom<MyClient, MyState>({
|
|
49
|
+
* state: () => new MyState(),
|
|
50
|
+
*
|
|
51
|
+
* onCreate() {
|
|
52
|
+
* console.log("Room created");
|
|
53
|
+
* },
|
|
54
|
+
*
|
|
55
|
+
* onJoin(client, options) {
|
|
56
|
+
* client.send("chat", { text: "Welcome!" }); // ✅ typed!
|
|
57
|
+
* this.broadcast("move", { x: 0, y: 0 }); // ✅ typed!
|
|
58
|
+
* client.userData.rank; // ✅ typed!
|
|
59
|
+
* client.auth.odToken; // ✅ typed!
|
|
60
|
+
* }
|
|
61
|
+
* });
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
export declare function createRoom<TClient extends Client = Client, State extends object = any, JoinOptions = any>(options: DefineRoomOptions<TClient, State, JoinOptions>): typeof Room<State, any, TClient>;
|
|
65
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
export declare const postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
2
|
+
method: "POST";
|
|
3
|
+
}, any>;
|
|
4
|
+
export declare function getDefaultRouter(): {
|
|
5
|
+
handler: (request: Request) => Promise<Response>;
|
|
6
|
+
endpoints: {
|
|
7
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
8
|
+
method: "POST";
|
|
9
|
+
}, any>;
|
|
10
|
+
};
|
|
11
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
12
|
+
extend: <NE extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE) => {
|
|
13
|
+
handler: (request: Request) => Promise<Response>;
|
|
14
|
+
endpoints: {
|
|
15
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
16
|
+
method: "POST";
|
|
17
|
+
}, any>;
|
|
18
|
+
} & NE;
|
|
19
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
20
|
+
extend: <NE_1 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_1) => {
|
|
21
|
+
handler: (request: Request) => Promise<Response>;
|
|
22
|
+
endpoints: {
|
|
23
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
24
|
+
method: "POST";
|
|
25
|
+
}, any>;
|
|
26
|
+
} & NE & NE_1;
|
|
27
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
28
|
+
extend: <NE_2 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_2) => {
|
|
29
|
+
handler: (request: Request) => Promise<Response>;
|
|
30
|
+
endpoints: {
|
|
31
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
32
|
+
method: "POST";
|
|
33
|
+
}, any>;
|
|
34
|
+
} & NE & NE_1 & NE_2;
|
|
35
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
36
|
+
extend: <NE_3 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_3) => {
|
|
37
|
+
handler: (request: Request) => Promise<Response>;
|
|
38
|
+
endpoints: {
|
|
39
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
40
|
+
method: "POST";
|
|
41
|
+
}, any>;
|
|
42
|
+
} & NE & NE_1 & NE_2 & NE_3;
|
|
43
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
44
|
+
extend: <NE_4 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_4) => {
|
|
45
|
+
handler: (request: Request) => Promise<Response>;
|
|
46
|
+
endpoints: {
|
|
47
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
48
|
+
method: "POST";
|
|
49
|
+
}, any>;
|
|
50
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4;
|
|
51
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
52
|
+
extend: <NE_5 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_5) => {
|
|
53
|
+
handler: (request: Request) => Promise<Response>;
|
|
54
|
+
endpoints: {
|
|
55
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
56
|
+
method: "POST";
|
|
57
|
+
}, any>;
|
|
58
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5;
|
|
59
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
60
|
+
extend: <NE_6 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_6) => {
|
|
61
|
+
handler: (request: Request) => Promise<Response>;
|
|
62
|
+
endpoints: {
|
|
63
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
64
|
+
method: "POST";
|
|
65
|
+
}, any>;
|
|
66
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6;
|
|
67
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
68
|
+
extend: <NE_7 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_7) => {
|
|
69
|
+
handler: (request: Request) => Promise<Response>;
|
|
70
|
+
endpoints: {
|
|
71
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
72
|
+
method: "POST";
|
|
73
|
+
}, any>;
|
|
74
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7;
|
|
75
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
76
|
+
extend: <NE_8 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_8) => {
|
|
77
|
+
handler: (request: Request) => Promise<Response>;
|
|
78
|
+
endpoints: {
|
|
79
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
80
|
+
method: "POST";
|
|
81
|
+
}, any>;
|
|
82
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8;
|
|
83
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
84
|
+
extend: <NE_9 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_9) => {
|
|
85
|
+
handler: (request: Request) => Promise<Response>;
|
|
86
|
+
endpoints: {
|
|
87
|
+
postMatchmakeMethod: import("@colyseus/better-call").StrictEndpoint<"/matchmake/:method/:roomName", {
|
|
88
|
+
method: "POST";
|
|
89
|
+
}, any>;
|
|
90
|
+
} & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8 & NE_9;
|
|
91
|
+
addEndpoint: (endpoint: import("@colyseus/better-call").Endpoint) => void;
|
|
92
|
+
extend: <NE_10 extends Record<string, import("@colyseus/better-call").Endpoint>>(newEndpoints: NE_10) => any;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { Server } from "http";
|
|
2
|
+
import { type Endpoint, type Router, type RouterConfig } from "@colyseus/better-call";
|
|
3
|
+
import { toNodeHandler } from "@colyseus/better-call/node";
|
|
4
|
+
export { createEndpoint, createMiddleware, createInternalContext, } from "@colyseus/better-call";
|
|
5
|
+
export { type Router, toNodeHandler };
|
|
6
|
+
export declare function bindRouterToServer(server: Server, router: Router): void;
|
|
7
|
+
/**
|
|
8
|
+
* Do not use this directly. This is used internally by `@colyseus/playground`.
|
|
9
|
+
* TODO: refactor. Avoid using globals.
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export declare let __globalEndpoints: Record<string, Endpoint>;
|
|
13
|
+
export declare function createRouter<E extends Record<string, Endpoint>, Config extends RouterConfig>(endpoints: E, config?: Config): {
|
|
14
|
+
handler: (request: Request) => Promise<Response>;
|
|
15
|
+
endpoints: E;
|
|
16
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
17
|
+
extend: <NE extends Record<string, Endpoint>>(newEndpoints: NE) => {
|
|
18
|
+
handler: (request: Request) => Promise<Response>;
|
|
19
|
+
endpoints: E & NE;
|
|
20
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
21
|
+
extend: <NE_1 extends Record<string, Endpoint>>(newEndpoints: NE_1) => {
|
|
22
|
+
handler: (request: Request) => Promise<Response>;
|
|
23
|
+
endpoints: E & NE & NE_1;
|
|
24
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
25
|
+
extend: <NE_2 extends Record<string, Endpoint>>(newEndpoints: NE_2) => {
|
|
26
|
+
handler: (request: Request) => Promise<Response>;
|
|
27
|
+
endpoints: E & NE & NE_1 & NE_2;
|
|
28
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
29
|
+
extend: <NE_3 extends Record<string, Endpoint>>(newEndpoints: NE_3) => {
|
|
30
|
+
handler: (request: Request) => Promise<Response>;
|
|
31
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3;
|
|
32
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
33
|
+
extend: <NE_4 extends Record<string, Endpoint>>(newEndpoints: NE_4) => {
|
|
34
|
+
handler: (request: Request) => Promise<Response>;
|
|
35
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4;
|
|
36
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
37
|
+
extend: <NE_5 extends Record<string, Endpoint>>(newEndpoints: NE_5) => {
|
|
38
|
+
handler: (request: Request) => Promise<Response>;
|
|
39
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5;
|
|
40
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
41
|
+
extend: <NE_6 extends Record<string, Endpoint>>(newEndpoints: NE_6) => {
|
|
42
|
+
handler: (request: Request) => Promise<Response>;
|
|
43
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6;
|
|
44
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
45
|
+
extend: <NE_7 extends Record<string, Endpoint>>(newEndpoints: NE_7) => {
|
|
46
|
+
handler: (request: Request) => Promise<Response>;
|
|
47
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7;
|
|
48
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
49
|
+
extend: <NE_8 extends Record<string, Endpoint>>(newEndpoints: NE_8) => {
|
|
50
|
+
handler: (request: Request) => Promise<Response>;
|
|
51
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8;
|
|
52
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
53
|
+
extend: <NE_9 extends Record<string, Endpoint>>(newEndpoints: NE_9) => {
|
|
54
|
+
handler: (request: Request) => Promise<Response>;
|
|
55
|
+
endpoints: E & NE & NE_1 & NE_2 & NE_3 & NE_4 & NE_5 & NE_6 & NE_7 & NE_8 & NE_9;
|
|
56
|
+
addEndpoint: (endpoint: Endpoint) => void;
|
|
57
|
+
extend: <NE_10 extends Record<string, Endpoint>>(newEndpoints: NE_10) => any;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
};
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Client } from '../Transport.
|
|
2
|
-
import { Serializer } from './Serializer.
|
|
1
|
+
import type { Client } from '../Transport.ts';
|
|
2
|
+
import type { Serializer } from './Serializer.ts';
|
|
3
3
|
export declare class NoneSerializer<T = any> implements Serializer<T> {
|
|
4
4
|
id: string;
|
|
5
5
|
reset(data: any): void;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { Serializer } from './Serializer.
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import type { Serializer } from './Serializer.ts';
|
|
2
|
+
import { type Client } from '../Transport.ts';
|
|
3
|
+
import { type Iterator, Encoder, Schema, StateView } from '@colyseus/schema';
|
|
4
4
|
declare const SHARED_VIEW: {};
|
|
5
5
|
export declare class SchemaSerializer<T extends Schema> implements Serializer<T> {
|
|
6
6
|
id: string;
|
|
7
7
|
protected encoder: Encoder<T>;
|
|
8
8
|
protected hasFilters: boolean;
|
|
9
|
-
protected handshakeCache:
|
|
9
|
+
protected handshakeCache: Uint8Array;
|
|
10
10
|
protected needFullEncode: boolean;
|
|
11
|
-
protected fullEncodeBuffer:
|
|
12
|
-
protected fullEncodeCache:
|
|
11
|
+
protected fullEncodeBuffer: Uint8Array;
|
|
12
|
+
protected fullEncodeCache: Uint8Array;
|
|
13
13
|
protected sharedOffsetCache: Iterator;
|
|
14
|
-
protected encodedViews: Map<StateView | typeof SHARED_VIEW,
|
|
14
|
+
protected encodedViews: Map<StateView | typeof SHARED_VIEW, Uint8Array>;
|
|
15
15
|
reset(newState: T & Schema): void;
|
|
16
|
-
getFullState(client?: Client):
|
|
16
|
+
getFullState(client?: Client): Uint8Array<ArrayBufferLike>;
|
|
17
17
|
applyPatches(clients: Client[]): boolean;
|
|
18
|
-
handshake():
|
|
18
|
+
handshake(): Uint8Array<ArrayBufferLike>;
|
|
19
19
|
}
|
|
20
20
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Client } from '../Transport.
|
|
1
|
+
import type { Client } from '../Transport.ts';
|
|
2
2
|
export interface Serializer<T> {
|
|
3
3
|
id: string;
|
|
4
4
|
reset(data: any): void;
|
|
5
|
-
getFullState(client?: Client):
|
|
5
|
+
getFullState(client?: Client): Uint8Array;
|
|
6
6
|
applyPatches(clients: Client[], state: T): boolean;
|
|
7
|
-
handshake?():
|
|
7
|
+
handshake?(): Uint8Array;
|
|
8
8
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { Room } from '../Room.js';
|
|
3
|
-
export declare const debugDevMode: debug.IDebugger;
|
|
1
|
+
import type { Room } from '../Room.ts';
|
|
4
2
|
export declare let isDevMode: boolean;
|
|
3
|
+
export declare function hasDevModeCache(): boolean;
|
|
4
|
+
export declare function getDevModeCache(): any;
|
|
5
|
+
export declare function writeDevModeCache(cache: any): void;
|
|
5
6
|
export declare function setDevMode(bool: boolean): void;
|
|
6
7
|
export declare function reloadFromCache(): Promise<void>;
|
|
7
8
|
export declare function cacheRoomHistory(rooms: {
|
|
8
9
|
[roomId: string]: Room;
|
|
9
10
|
}): Promise<void>;
|
|
10
|
-
export declare function getPreviousProcessId(hostname
|
|
11
|
+
export declare function getPreviousProcessId(hostname?: string): Promise<string>;
|
|
11
12
|
export declare function getRoomRestoreListKey(): string;
|
|
12
13
|
export declare function getProcessRestoreKey(): string;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { StandardSchemaV1 } from '@standard-schema/spec';
|
|
1
|
+
import type { StandardSchemaV1 } from '@standard-schema/spec';
|
|
2
2
|
export type { StandardSchemaV1 };
|
|
3
3
|
export declare function standardValidate<T extends StandardSchemaV1>(schema: T, input: StandardSchemaV1.InferInput<T>): StandardSchemaV1.InferOutput<T>;
|
|
@@ -1,6 +1,17 @@
|
|
|
1
1
|
import { EventEmitter } from "events";
|
|
2
|
-
import { RoomException } from '../errors/RoomExceptions.
|
|
3
|
-
|
|
2
|
+
import { type RoomException, type RoomMethodName } from '../errors/RoomExceptions.ts';
|
|
3
|
+
export type Type<T> = new (...args: any[]) => T;
|
|
4
|
+
export type MethodName<T> = string & {
|
|
5
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? K : never;
|
|
6
|
+
}[keyof T];
|
|
7
|
+
/**
|
|
8
|
+
* Utility type that extracts the return type of a method or the type of a property
|
|
9
|
+
* from a given class/object type.
|
|
10
|
+
*
|
|
11
|
+
* - If the key is a method, returns the awaited return type of that method
|
|
12
|
+
* - If the key is a property, returns the type of that property
|
|
13
|
+
*/
|
|
14
|
+
export type ExtractMethodOrPropertyType<TClass, TKey extends keyof TClass> = TClass[TKey] extends (...args: any[]) => infer R ? Awaited<R> : TClass[TKey];
|
|
4
15
|
export declare const REMOTE_ROOM_SHORT_TIMEOUT: number;
|
|
5
16
|
export declare const MAX_CONCURRENT_CREATE_ROOM_WAIT_TIME: number;
|
|
6
17
|
export declare function generateId(length?: number): string;
|
|
@@ -13,12 +24,12 @@ export declare class Deferred<T = any> {
|
|
|
13
24
|
resolve: Function;
|
|
14
25
|
reject: Function;
|
|
15
26
|
constructor(promise?: Promise<T>);
|
|
16
|
-
then(
|
|
27
|
+
then(onFulfilled?: (value: T) => any, onRejected?: (reason: any) => any): Promise<any>;
|
|
17
28
|
catch(func: (value: any) => any): Promise<any>;
|
|
18
29
|
static reject(reason?: any): Deferred<never>;
|
|
19
30
|
static resolve<T = any>(value?: T): Deferred<T>;
|
|
20
31
|
}
|
|
21
32
|
export declare function merge(a: any, ...objs: any[]): any;
|
|
22
|
-
export declare function wrapTryCatch(method: Function, onError: (error: RoomException, methodName:
|
|
33
|
+
export declare function wrapTryCatch(method: Function, onError: (error: RoomException, methodName: RoomMethodName) => void, exceptionClass: Type<RoomException>, methodName: RoomMethodName, rethrow?: boolean, ...additionalErrorArgs: any[]): (...args: any[]) => any;
|
|
23
34
|
export declare class HttpServerMock extends EventEmitter {
|
|
24
35
|
}
|