@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.
Files changed (224) hide show
  1. package/build/Debug.js +16 -4
  2. package/build/Debug.js.map +2 -2
  3. package/build/Debug.mjs +11 -1
  4. package/build/Debug.mjs.map +2 -2
  5. package/build/IPC.js +5 -3
  6. package/build/IPC.js.map +2 -2
  7. package/build/IPC.mjs +1 -0
  8. package/build/IPC.mjs.map +2 -2
  9. package/build/Logger.js +1 -0
  10. package/build/Logger.js.map +1 -1
  11. package/build/MatchMaker.js +148 -84
  12. package/build/MatchMaker.js.map +3 -3
  13. package/build/MatchMaker.mjs +130 -70
  14. package/build/MatchMaker.mjs.map +3 -3
  15. package/build/Protocol.js +54 -41
  16. package/build/Protocol.js.map +3 -3
  17. package/build/Protocol.mjs +52 -41
  18. package/build/Protocol.mjs.map +3 -3
  19. package/build/Room.js +430 -195
  20. package/build/Room.js.map +3 -3
  21. package/build/Room.mjs +417 -175
  22. package/build/Room.mjs.map +3 -3
  23. package/build/Server.js +48 -108
  24. package/build/Server.js.map +3 -3
  25. package/build/Server.mjs +39 -102
  26. package/build/Server.mjs.map +3 -3
  27. package/build/Stats.js +2 -1
  28. package/build/Stats.js.map +2 -2
  29. package/build/Stats.mjs.map +1 -1
  30. package/build/Transport.js +29 -11
  31. package/build/Transport.js.map +3 -3
  32. package/build/Transport.mjs +15 -9
  33. package/build/Transport.mjs.map +3 -3
  34. package/build/errors/RoomExceptions.js +9 -5
  35. package/build/errors/RoomExceptions.js.map +2 -2
  36. package/build/errors/RoomExceptions.mjs +8 -5
  37. package/build/errors/RoomExceptions.mjs.map +2 -2
  38. package/build/errors/SeatReservationError.js +1 -0
  39. package/build/errors/SeatReservationError.js.map +1 -1
  40. package/build/errors/ServerError.js +2 -1
  41. package/build/errors/ServerError.js.map +2 -2
  42. package/build/errors/ServerError.mjs.map +1 -1
  43. package/build/index.js +60 -26
  44. package/build/index.js.map +2 -2
  45. package/build/index.mjs +33 -7
  46. package/build/index.mjs.map +2 -2
  47. package/build/matchmaker/Lobby.js +13 -3
  48. package/build/matchmaker/Lobby.js.map +2 -2
  49. package/build/matchmaker/Lobby.mjs +11 -2
  50. package/build/matchmaker/Lobby.mjs.map +2 -2
  51. package/build/matchmaker/LocalDriver/LocalDriver.js +94 -0
  52. package/build/matchmaker/LocalDriver/LocalDriver.js.map +7 -0
  53. package/build/matchmaker/LocalDriver/LocalDriver.mjs +71 -0
  54. package/build/matchmaker/LocalDriver/LocalDriver.mjs.map +7 -0
  55. package/build/matchmaker/LocalDriver/Query.js +111 -0
  56. package/build/matchmaker/LocalDriver/Query.js.map +7 -0
  57. package/build/matchmaker/LocalDriver/Query.mjs +88 -0
  58. package/build/matchmaker/LocalDriver/Query.mjs.map +7 -0
  59. package/build/matchmaker/RegisteredHandler.js +57 -7
  60. package/build/matchmaker/RegisteredHandler.js.map +2 -2
  61. package/build/matchmaker/RegisteredHandler.mjs +54 -5
  62. package/build/matchmaker/RegisteredHandler.mjs.map +2 -2
  63. package/build/matchmaker/controller.js +8 -8
  64. package/build/matchmaker/controller.js.map +2 -2
  65. package/build/matchmaker/controller.mjs +4 -5
  66. package/build/matchmaker/controller.mjs.map +2 -2
  67. package/build/matchmaker/driver/api.js +21 -2
  68. package/build/matchmaker/driver/api.js.map +2 -2
  69. package/build/matchmaker/driver/api.mjs +18 -1
  70. package/build/matchmaker/driver/api.mjs.map +2 -2
  71. package/build/matchmaker/driver/local/LocalDriver.js +36 -7
  72. package/build/matchmaker/driver/local/LocalDriver.js.map +2 -2
  73. package/build/matchmaker/driver/local/LocalDriver.mjs +33 -5
  74. package/build/matchmaker/driver/local/LocalDriver.mjs.map +2 -2
  75. package/build/matchmaker/driver/local/Query.js +51 -18
  76. package/build/matchmaker/driver/local/Query.js.map +2 -2
  77. package/build/matchmaker/driver/local/Query.mjs +50 -18
  78. package/build/matchmaker/driver/local/Query.mjs.map +2 -2
  79. package/build/matchmaker/driver.js +44 -0
  80. package/build/matchmaker/driver.js.map +7 -0
  81. package/build/matchmaker/driver.mjs +20 -0
  82. package/build/matchmaker/driver.mjs.map +7 -0
  83. package/build/matchmaker/routes.js +79 -0
  84. package/build/matchmaker/routes.js.map +7 -0
  85. package/build/matchmaker/routes.mjs +45 -0
  86. package/build/matchmaker/routes.mjs.map +7 -0
  87. package/build/presence/LocalPresence.js +13 -27
  88. package/build/presence/LocalPresence.js.map +3 -3
  89. package/build/presence/LocalPresence.mjs +11 -16
  90. package/build/presence/LocalPresence.mjs.map +2 -2
  91. package/build/presence/Presence.js +37 -0
  92. package/build/presence/Presence.js.map +2 -2
  93. package/build/presence/Presence.mjs +29 -0
  94. package/build/presence/Presence.mjs.map +3 -3
  95. package/build/rooms/LobbyRoom.js +5 -5
  96. package/build/rooms/LobbyRoom.js.map +2 -2
  97. package/build/rooms/LobbyRoom.mjs +1 -2
  98. package/build/rooms/LobbyRoom.mjs.map +2 -2
  99. package/build/rooms/RankedQueueRoom.js +224 -0
  100. package/build/rooms/RankedQueueRoom.js.map +7 -0
  101. package/build/rooms/RankedQueueRoom.mjs +201 -0
  102. package/build/rooms/RankedQueueRoom.mjs.map +7 -0
  103. package/build/rooms/RelayRoom.js +6 -6
  104. package/build/rooms/RelayRoom.js.map +2 -2
  105. package/build/rooms/RelayRoom.mjs +4 -5
  106. package/build/rooms/RelayRoom.mjs.map +2 -2
  107. package/build/rooms/createRoom.js +51 -0
  108. package/build/rooms/createRoom.js.map +7 -0
  109. package/build/rooms/createRoom.mjs +28 -0
  110. package/build/rooms/createRoom.mjs.map +7 -0
  111. package/build/router/default_routes.js +79 -0
  112. package/build/router/default_routes.js.map +7 -0
  113. package/build/router/default_routes.mjs +45 -0
  114. package/build/router/default_routes.mjs.map +7 -0
  115. package/build/router/index.js +55 -0
  116. package/build/router/index.js.map +7 -0
  117. package/build/router/index.mjs +30 -0
  118. package/build/router/index.mjs.map +7 -0
  119. package/build/serializer/NoneSerializer.js +1 -0
  120. package/build/serializer/NoneSerializer.js.map +2 -2
  121. package/build/serializer/NoneSerializer.mjs.map +2 -2
  122. package/build/serializer/SchemaSerializer.js +6 -7
  123. package/build/serializer/SchemaSerializer.js.map +2 -2
  124. package/build/serializer/SchemaSerializer.mjs +3 -5
  125. package/build/serializer/SchemaSerializer.mjs.map +2 -2
  126. package/build/serializer/SchemaSerializerDebug.js +29 -0
  127. package/build/serializer/SchemaSerializerDebug.js.map +3 -3
  128. package/build/serializer/SchemaSerializerDebug.mjs +7 -0
  129. package/build/serializer/SchemaSerializerDebug.mjs.map +3 -3
  130. package/build/serializer/Serializer.js +1 -0
  131. package/build/serializer/Serializer.js.map +2 -2
  132. package/build/{Debug.d.ts → src/Debug.d.ts} +2 -1
  133. package/build/{IPC.d.ts → src/IPC.d.ts} +2 -2
  134. package/build/{MatchMaker.d.ts → src/MatchMaker.d.ts} +58 -33
  135. package/build/src/Protocol.d.ts +53 -0
  136. package/build/src/Room.d.ts +497 -0
  137. package/build/{Server.d.ts → src/Server.d.ts} +23 -25
  138. package/build/{Transport.d.ts → src/Transport.d.ts} +65 -22
  139. package/build/{errors → src/errors}/RoomExceptions.d.ts +8 -7
  140. package/build/src/index.d.ts +27 -0
  141. package/build/src/matchmaker/Lobby.d.ts +4 -0
  142. package/build/src/matchmaker/LocalDriver/LocalDriver.d.ts +17 -0
  143. package/build/src/matchmaker/LocalDriver/Query.d.ts +12 -0
  144. package/build/src/matchmaker/RegisteredHandler.d.ts +81 -0
  145. package/build/{matchmaker → src/matchmaker}/controller.d.ts +5 -6
  146. package/build/src/matchmaker/driver/api.d.ts +145 -0
  147. package/build/src/matchmaker/driver/local/LocalDriver.d.ts +17 -0
  148. package/build/src/matchmaker/driver/local/Query.d.ts +12 -0
  149. package/build/src/matchmaker/driver.d.ts +145 -0
  150. package/build/src/matchmaker/routes.d.ts +92 -0
  151. package/build/{presence → src/presence}/LocalPresence.d.ts +1 -1
  152. package/build/{presence → src/presence}/Presence.d.ts +2 -0
  153. package/build/{rooms → src/rooms}/LobbyRoom.d.ts +4 -4
  154. package/build/src/rooms/RankedQueueRoom.d.ts +125 -0
  155. package/build/{rooms → src/rooms}/RelayRoom.d.ts +5 -4
  156. package/build/src/rooms/createRoom.d.ts +65 -0
  157. package/build/src/router/default_routes.d.ts +103 -0
  158. package/build/src/router/index.d.ts +68 -0
  159. package/build/{serializer → src/serializer}/NoneSerializer.d.ts +2 -2
  160. package/build/{serializer → src/serializer}/SchemaSerializer.d.ts +9 -9
  161. package/build/{serializer → src/serializer}/Serializer.d.ts +3 -3
  162. package/build/{utils → src/utils}/DevMode.d.ts +5 -4
  163. package/build/{utils → src/utils}/StandardSchema.d.ts +1 -1
  164. package/build/{utils → src/utils}/Utils.d.ts +15 -4
  165. package/build/utils/DevMode.js +54 -26
  166. package/build/utils/DevMode.js.map +3 -3
  167. package/build/utils/DevMode.mjs +44 -19
  168. package/build/utils/DevMode.mjs.map +2 -2
  169. package/build/utils/StandardSchema.js.map +1 -1
  170. package/build/utils/StandardSchema.mjs.map +1 -1
  171. package/build/utils/Utils.js +8 -15
  172. package/build/utils/Utils.js.map +3 -3
  173. package/build/utils/Utils.mjs +6 -4
  174. package/build/utils/Utils.mjs.map +2 -2
  175. package/package.json +20 -14
  176. package/build/Protocol.d.ts +0 -37
  177. package/build/Room.d.ts +0 -265
  178. package/build/discovery/index.d.ts +0 -8
  179. package/build/discovery/index.js +0 -50
  180. package/build/discovery/index.js.map +0 -7
  181. package/build/discovery/index.mjs +0 -26
  182. package/build/discovery/index.mjs.map +0 -7
  183. package/build/index.d.ts +0 -24
  184. package/build/matchmaker/Lobby.d.ts +0 -4
  185. package/build/matchmaker/RegisteredHandler.d.ts +0 -19
  186. package/build/matchmaker/driver/Query.d.ts +0 -8
  187. package/build/matchmaker/driver/Query.js +0 -68
  188. package/build/matchmaker/driver/Query.js.map +0 -7
  189. package/build/matchmaker/driver/Query.mjs +0 -45
  190. package/build/matchmaker/driver/Query.mjs.map +0 -7
  191. package/build/matchmaker/driver/RoomData.d.ts +0 -19
  192. package/build/matchmaker/driver/RoomData.js +0 -79
  193. package/build/matchmaker/driver/RoomData.js.map +0 -7
  194. package/build/matchmaker/driver/RoomData.mjs +0 -56
  195. package/build/matchmaker/driver/RoomData.mjs.map +0 -7
  196. package/build/matchmaker/driver/api.d.ts +0 -104
  197. package/build/matchmaker/driver/index.d.ts +0 -13
  198. package/build/matchmaker/driver/index.js +0 -64
  199. package/build/matchmaker/driver/index.js.map +0 -7
  200. package/build/matchmaker/driver/index.mjs +0 -42
  201. package/build/matchmaker/driver/index.mjs.map +0 -7
  202. package/build/matchmaker/driver/interfaces.d.ts +0 -73
  203. package/build/matchmaker/driver/interfaces.js +0 -15
  204. package/build/matchmaker/driver/interfaces.js.map +0 -7
  205. package/build/matchmaker/driver/interfaces.mjs +0 -0
  206. package/build/matchmaker/driver/interfaces.mjs.map +0 -7
  207. package/build/matchmaker/driver/local/LocalDriver.d.ts +0 -13
  208. package/build/matchmaker/driver/local/Query.d.ts +0 -9
  209. package/build/matchmaker/driver/local/RoomData.d.ts +0 -19
  210. package/build/matchmaker/driver/local/RoomData.js +0 -79
  211. package/build/matchmaker/driver/local/RoomData.js.map +0 -7
  212. package/build/matchmaker/driver/local/RoomData.mjs +0 -57
  213. package/build/matchmaker/driver/local/RoomData.mjs.map +0 -7
  214. package/build/utils/types.d.ts +0 -1
  215. package/build/utils/types.js +0 -15
  216. package/build/utils/types.js.map +0 -7
  217. package/build/utils/types.mjs +0 -0
  218. package/build/utils/types.mjs.map +0 -7
  219. /package/build/{Logger.d.ts → src/Logger.d.ts} +0 -0
  220. /package/build/{Stats.d.ts → src/Stats.d.ts} +0 -0
  221. /package/build/{errors → src/errors}/SeatReservationError.d.ts +0 -0
  222. /package/build/{errors → src/errors}/ServerError.d.ts +0 -0
  223. /package/build/{serializer → src/serializer}/SchemaSerializerDebug.d.ts +0 -0
  224. /package/build/{utils → src/utils}/nanoevents.d.ts +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/Transport.ts"],
4
- "sourcesContent": ["import * as http from 'http';\nimport * as https from 'https';\nimport * as net from 'net';\n\nimport { Schema, StateView } from '@colyseus/schema';\nimport { EventEmitter } from 'events';\nimport { spliceOne } from './utils/Utils.js';\n\nexport abstract class Transport {\n public protocol?: string;\n public server?: net.Server | http.Server | https.Server;\n\n public abstract listen(port?: number, hostname?: string, backlog?: number, listeningListener?: Function): this;\n public abstract shutdown(): void;\n\n public abstract simulateLatency(milliseconds: number): void;\n}\n\nexport type AuthContext = {\n token?: string,\n headers: http.IncomingHttpHeaders,\n ip: string | string[];\n // FIXME: each transport may have its own specific properties.\n // \"req\" only applies to WebSocketTransport.\n req?: http.IncomingMessage;\n};\n\nexport interface ISendOptions {\n afterNextPatch?: boolean;\n}\n\nexport enum ClientState { JOINING, JOINED, RECONNECTED, LEAVING, CLOSED }\n\n/**\n * The client instance from the server-side is responsible for the transport layer between the server and the client.\n * It should not be confused with the Client from the client-side SDK, as they have completely different purposes!\n * You operate on client instances from `this.clients`, `Room#onJoin()`, `Room#onLeave()` and `Room#onMessage()`.\n *\n * - This is the raw WebSocket connection coming from the `ws` package. There are more methods available which aren't\n * encouraged to use along with Colyseus.\n */\nexport interface Client<UserData=any, AuthData=any> {\n ref: EventEmitter;\n\n /**\n * @deprecated use `sessionId` instead.\n */\n id: string;\n\n /**\n * Unique id per session.\n */\n sessionId: string; // TODO: remove sessionId on version 1.0.0\n\n /**\n * Connection state\n */\n state: ClientState;\n\n /**\n * Optional: when using `@view()` decorator in your state properties, this will be the view instance for this client.\n */\n view?: StateView;\n\n /**\n * User-defined data can be attached to the Client instance through this variable.\n * - Can be used to store custom data about the client's connection. userData is not synchronized with the client,\n * and should be used only to keep player-specific with its connection.\n */\n userData?: UserData;\n\n /**\n * auth data provided by your `onAuth`\n */\n auth?: AuthData;\n\n /**\n * Reconnection token used to re-join the room after onLeave + allowReconnection().\n *\n * IMPORTANT:\n * This is not the full reconnection token the client provides for the server.\n * The format provided by .reconnect() from the client-side must follow: \"${roomId}:${reconnectionToken}\"\n */\n reconnectionToken: string;\n\n raw(data: Uint8Array | Buffer, options?: ISendOptions, cb?: (err?: Error) => void): void;\n enqueueRaw(data: Uint8Array | Buffer, options?: ISendOptions): void;\n\n /**\n * Send a type of message to the client. Messages are encoded with MsgPack and can hold any\n * JSON-serializable data structure.\n *\n * @param type String or Number identifier the client SDK will use to receive this message\n * @param message Message payload. (automatically encoded with msgpack.)\n * @param options\n */\n send(type: string | number, message?: any, options?: ISendOptions): void;\n send(message: Schema, options?: ISendOptions): void;\n\n /**\n * Send raw bytes to this specific client.\n *\n * @param type String or Number identifier the client SDK will use to receive this message\n * @param bytes Raw byte array payload\n * @param options\n */\n sendBytes(type: string | number, bytes: Buffer | Uint8Array, options?: ISendOptions): void;\n\n /**\n * Disconnect this client from the room.\n *\n * @param code Custom close code. Default value is 1000.\n * @param data\n * @see {@link https://docs.colyseus.io/colyseus/server/room/#leavecode-number}\n */\n leave(code?: number, data?: string): void;\n\n /**\n * @deprecated Use .leave() instead.\n */\n close(code?: number, data?: string): void;\n\n /**\n * Triggers `onError` with specified code to the client-side.\n *\n * @param code\n * @param message\n */\n error(code: number, message?: string): void;\n}\n\n/**\n * Private properties of the Client instance.\n * Only accessible internally by the framework, should not be encouraged/auto-completed for the user.\n *\n * TODO: refactor this.\n * @private\n */\nexport interface ClientPrivate {\n readyState: number; // TODO: remove readyState on version 1.0.0. Use only \"state\" instead.\n _enqueuedMessages?: any[];\n _afterNextPatchQueue: Array<[string | Client, IArguments]>;\n _joinedAt: number; // \"elapsedTime\" when the client joined the room.\n}\n\nexport class ClientArray<UserData = any, AuthData = any> extends Array<Client<UserData, AuthData>> {\n public getById(sessionId: string): Client<UserData, AuthData> | undefined {\n return this.find((client) => client.sessionId === sessionId);\n }\n\n public delete(client: Client<UserData, AuthData>): boolean {\n return spliceOne(this, this.indexOf(client));\n }\n}"],
5
- "mappings": ";AAMA,SAAS,iBAAiB;AAEnB,IAAe,YAAf,MAAyB;AAQhC;AAeO,IAAK,cAAL,kBAAKA,iBAAL;AAAmB,EAAAA,0BAAA;AAAS,EAAAA,0BAAA;AAAQ,EAAAA,0BAAA;AAAa,EAAAA,0BAAA;AAAS,EAAAA,0BAAA;AAArD,SAAAA;AAAA,GAAA;AAkHL,IAAM,cAAN,cAA0D,MAAkC;AAAA,EAC1F,QAAQ,WAA2D;AACxE,WAAO,KAAK,KAAK,CAAC,WAAW,OAAO,cAAc,SAAS;AAAA,EAC7D;AAAA,EAEO,OAAO,QAA6C;AACzD,WAAO,UAAU,MAAM,KAAK,QAAQ,MAAM,CAAC;AAAA,EAC7C;AACF;",
6
- "names": ["ClientState"]
4
+ "sourcesContent": ["import * as http from 'http';\nimport * as https from 'https';\n\nimport { StateView } from '@colyseus/schema';\nimport { EventEmitter } from 'events';\nimport { spliceOne } from './utils/Utils.ts';\nimport { ServerError } from './errors/ServerError.ts';\nimport { ErrorCode } from './Protocol.ts';\nimport type { Room } from './Room.ts';\n\nexport abstract class Transport {\n public protocol?: string;\n public server?: http.Server | https.Server;\n\n public abstract listen(port?: number, hostname?: string, backlog?: number, listeningListener?: Function): this;\n public abstract shutdown(): void;\n\n public abstract simulateLatency(milliseconds: number): void;\n}\n\nexport type AuthContext = {\n token?: string,\n headers: Headers,\n ip: string | string[];\n // FIXME: each transport may have its own specific properties.\n // \"req\" only applies to WebSocketTransport.\n req?: any;\n};\n\nexport interface ISendOptions {\n afterNextPatch?: boolean;\n}\n\nexport const ClientState = { JOINING: 0, JOINED: 1, RECONNECTED: 2, LEAVING: 3, CLOSED: 4 } as const;\nexport type ClientState = (typeof ClientState)[keyof typeof ClientState];\n\n// Helper types to extract properties from the Client type parameter\ntype ExtractClientUserData<T> = T extends { userData: infer U } ? U : T;\ntype ExtractClientAuth<T> = T extends { auth: infer A } ? A : any;\ntype ExtractClientMessages<T> = T extends { messages: infer M } ? M : any;\n\n// Helper type to make message required when the message type demands it\nexport type MessageArgs<M, Options> =\n unknown extends M ? [message?: M, options?: Options] : // Handle 'any' type (backwards compatibility)\n [M] extends [never] ? [message?: M, options?: Options] :\n [M] extends [void] ? [message?: M, options?: Options] :\n [M] extends [undefined] ? [message?: M, options?: Options] :\n undefined extends M ? [message?: M, options?: Options] :\n [message: M, options?: Options];\n\n/**\n * The client instance from the server-side is responsible for the transport layer between the server and the client.\n * It should not be confused with the Client from the client-side SDK, as they have completely different purposes!\n * You operate on client instances from `this.clients`, `Room#onJoin()`, `Room#onLeave()` and `Room#onMessage()`.\n *\n * - This is the raw WebSocket connection coming from the `ws` package. There are more methods available which aren't\n * encouraged to use along with Colyseus.\n */\nexport interface Client<T extends { userData?: any, auth?: any, messages?: Record<string | number, any> } = any> {\n '~messages': ExtractClientMessages<T>;\n\n ref: EventEmitter;\n\n /**\n * @deprecated use `sessionId` instead.\n */\n id: string;\n\n /**\n * Unique id per session.\n */\n sessionId: string; // TODO: remove sessionId on version 1.0.0\n\n /**\n * Connection state\n */\n state: ClientState;\n\n /**\n * Optional: when using `@view()` decorator in your state properties, this will be the view instance for this client.\n */\n view?: StateView;\n\n /**\n * User-defined data can be attached to the Client instance through this variable.\n * - Can be used to store custom data about the client's connection. userData is not synchronized with the client,\n * and should be used only to keep player-specific with its connection.\n */\n userData?: ExtractClientUserData<T>;\n\n /**\n * auth data provided by your `onAuth`\n */\n auth?: ExtractClientAuth<T>;\n\n /**\n * Reconnection token used to re-join the room after onLeave + allowReconnection().\n *\n * IMPORTANT:\n * This is not the full reconnection token the client provides for the server.\n * The format provided by .reconnect() from the client-side must follow: \"${roomId}:${reconnectionToken}\"\n */\n reconnectionToken: string;\n\n // TODO: move these to ClientPrivate\n raw(data: Uint8Array | Buffer, options?: ISendOptions, cb?: (err?: Error) => void): void;\n enqueueRaw(data: Uint8Array | Buffer, options?: ISendOptions): void;\n\n /**\n * Send a type of message to the client. Messages are encoded with MsgPack and can hold any\n * JSON-serializable data structure.\n *\n * @param type String or Number identifier the client SDK will use to receive this message\n * @param message Message payload. (automatically encoded with msgpack.)\n * @param options\n */\n send<K extends keyof this['~messages']>(\n type: K,\n ...args: MessageArgs<this['~messages'][K], ISendOptions>\n ): void;\n\n /**\n * Send raw bytes to this specific client.\n *\n * @param type String or Number identifier the client SDK will use to receive this message\n * @param bytes Raw byte array payload\n * @param options\n */\n sendBytes(type: string | number, bytes: Buffer | Uint8Array, options?: ISendOptions): void;\n\n /**\n * Disconnect this client from the room.\n *\n * @param code Custom close code. Default value is 1000.\n * @param data\n * @see [Leave room](https://docs.colyseus.io/room#leave-room)\n */\n leave(code?: number, data?: string): void;\n\n /**\n * @deprecated Use .leave() instead.\n */\n close(code?: number, data?: string): void;\n\n /**\n * Triggers `onError` with specified code to the client-side.\n *\n * @param code\n * @param message\n */\n error(code: number, message?: string): void;\n}\n\n/**\n * Private properties of the Client instance.\n * Only accessible internally by the framework, should not be encouraged/auto-completed for the user.\n *\n * TODO: refactor this.\n * @private\n */\nexport interface ClientPrivate {\n readyState: number; // TODO: remove readyState on version 1.0.0. Use only \"state\" instead.\n _enqueuedMessages?: any[];\n _afterNextPatchQueue: Array<[string | number | Client, ArrayLike<any>]>;\n _joinedAt: number; // \"elapsedTime\" when the client joined the room.\n\n /**\n * Used for rate limiting via maxMessagesPerSecond.\n */\n _numMessagesLastSecond?: number;\n _lastMessageTime?: number;\n}\n\nexport class ClientArray<C extends Client = Client> extends Array<C> {\n public getById(sessionId: string): C | undefined {\n return this.find((client) => client.sessionId === sessionId);\n }\n\n public delete(client: C): boolean {\n return spliceOne(this, this.indexOf(client));\n }\n}\n\n/**\n * Shared internal method to connect a Client into a Room.\n * Validates seat reservation and joins the client to the room.\n *\n * @remarks\n * **\u26A0\uFE0F This is an internal API and not intended for end-user use.**\n *\n * @internal\n */\nexport async function connectClientToRoom(\n room: Room | undefined,\n client: Client & ClientPrivate,\n authContext: AuthContext,\n connectionOptions: {\n reconnectionToken?: string;\n skipHandshake?: boolean;\n },\n): Promise<void> {\n if (!room || !room.hasReservedSeat(client.sessionId, connectionOptions.reconnectionToken)) {\n throw new ServerError(ErrorCode.MATCHMAKE_EXPIRED, 'seat reservation expired.');\n }\n\n await room['_onJoin'](client, authContext, connectionOptions);\n}"],
5
+ "mappings": ";AAAA,OAAsB;AACtB,OAAuB;AAEvB,OAA0B;AAC1B,OAA6B;AAC7B,SAAS,iBAAiB;AAC1B,SAAS,mBAAmB;AAC5B,SAAS,iBAAiB;AAGnB,IAAe,YAAf,MAAyB;AAQhC;AAeO,IAAM,cAAc,EAAE,SAAS,GAAG,QAAQ,GAAG,aAAa,GAAG,SAAS,GAAG,QAAQ,EAAE;AA4InF,IAAM,cAAN,cAAqD,MAAS;AAAA,EAC5D,QAAQ,WAAkC;AAC/C,WAAO,KAAK,KAAK,CAAC,WAAW,OAAO,cAAc,SAAS;AAAA,EAC7D;AAAA,EAEO,OAAO,QAAoB;AAChC,WAAO,UAAU,MAAM,KAAK,QAAQ,MAAM,CAAC;AAAA,EAC7C;AACF;AAWA,eAAsB,oBACpB,MACA,QACA,aACA,mBAIe;AACf,MAAI,CAAC,QAAQ,CAAC,KAAK,gBAAgB,OAAO,WAAW,kBAAkB,iBAAiB,GAAG;AACzF,UAAM,IAAI,YAAY,UAAU,mBAAmB,2BAA2B;AAAA,EAChF;AAEA,QAAM,KAAK,SAAS,EAAE,QAAQ,aAAa,iBAAiB;AAC9D;",
6
+ "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -30,33 +31,33 @@ module.exports = __toCommonJS(RoomExceptions_exports);
30
31
  class OnCreateException extends Error {
31
32
  constructor(cause, message, options) {
32
33
  super(message, { cause });
33
- this.options = options;
34
34
  this.name = "OnCreateException";
35
+ this.options = options;
35
36
  }
36
37
  }
37
38
  class OnAuthException extends Error {
38
39
  constructor(cause, message, client, options) {
39
40
  super(message, { cause });
41
+ this.name = "OnAuthException";
40
42
  this.client = client;
41
43
  this.options = options;
42
- this.name = "OnAuthException";
43
44
  }
44
45
  }
45
46
  class OnJoinException extends Error {
46
47
  constructor(cause, message, client, options, auth) {
47
48
  super(message, { cause });
49
+ this.name = "OnJoinException";
48
50
  this.client = client;
49
51
  this.options = options;
50
52
  this.auth = auth;
51
- this.name = "OnJoinException";
52
53
  }
53
54
  }
54
55
  class OnLeaveException extends Error {
55
56
  constructor(cause, message, client, consented) {
56
57
  super(message, { cause });
58
+ this.name = "OnLeaveException";
57
59
  this.client = client;
58
60
  this.consented = consented;
59
- this.name = "OnLeaveException";
60
61
  }
61
62
  }
62
63
  class OnDisposeException extends Error {
@@ -68,10 +69,13 @@ class OnDisposeException extends Error {
68
69
  class OnMessageException extends Error {
69
70
  constructor(cause, message, client, payload, type) {
70
71
  super(message, { cause });
72
+ this.name = "OnMessageException";
71
73
  this.client = client;
72
74
  this.payload = payload;
73
75
  this.type = type;
74
- this.name = "OnMessageException";
76
+ }
77
+ isType(type) {
78
+ return this.type === type;
75
79
  }
76
80
  }
77
81
  class SimulationIntervalException extends Error {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/RoomExceptions.ts"],
4
- "sourcesContent": ["import type { Client } from '../Transport.js';\nimport type { ExtractAuthData, ExtractUserData, Room } from '../Room.js';\n\nexport type RoomException<R extends Room = Room> =\n OnCreateException<R> |\n OnAuthException<R> |\n OnJoinException<R> |\n OnLeaveException<R> |\n OnDisposeException |\n OnMessageException<R> |\n SimulationIntervalException |\n TimedEventException;\n\nexport class OnCreateException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public options: Parameters<R['onCreate']>[0],\n ) {\n super(message, { cause });\n this.name = 'OnCreateException';\n }\n}\n\nexport class OnAuthException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onAuth']>[0],\n public options: Parameters<R['onAuth']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnAuthException';\n }\n}\n\nexport class OnJoinException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onJoin']>[0],\n public options: Parameters<R['onJoin']>[1],\n public auth: Parameters<R['onJoin']>[2],\n ) {\n super(message, { cause });\n this.name = 'OnJoinException';\n }\n}\n\nexport class OnLeaveException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onLeave']>[0],\n public consented: Parameters<R['onLeave']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnLeaveException';\n }\n}\n\nexport class OnDisposeException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'OnDisposeException';\n }\n}\n\nexport class OnMessageException<R extends Room = Room, MessagePayload = any> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Client<ExtractUserData<R['clients']>, ExtractAuthData<R['clients']>>,\n public payload: MessagePayload,\n public type: string,\n ) {\n super(message, { cause });\n this.name = 'OnMessageException';\n }\n}\n\nexport class SimulationIntervalException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'SimulationIntervalException';\n }\n}\n\nexport class TimedEventException extends Error {\n public args: any[];\n constructor(\n cause: Error,\n message: string,\n ...args: any[]\n ) {\n super(message, { cause });\n this.name = 'TimedEventException';\n this.args = args;\n }\n}"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,MAAM,0BAAiD,MAAM;AAAA,EAClE,YACE,OACA,SACO,SACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAFjB;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,wBAA+C,MAAM;AAAA,EAChE,YACE,OACA,SACO,QACA,SACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAHjB;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,wBAA+C,MAAM;AAAA,EAChE,YACE,OACA,SACO,QACA,SACA,MACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAJjB;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,yBAAgD,MAAM;AAAA,EACjE,YACE,OACA,SACO,QACA,WACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAHjB;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,2BAA2B,MAAM;AAAA,EAC5C,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,2BAAwE,MAAM;AAAA,EACzF,YACE,OACA,SACO,QACA,SACA,MACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAJjB;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,4BAA4B,MAAM;AAAA,EAE7C,YACE,OACA,YACG,MACH;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import type { ExtractMessageType, Room } from '../Room.ts';\n\nexport type RoomMethodName = 'onCreate'\n | 'onAuth'\n | 'onJoin'\n | 'onLeave'\n | 'onDispose'\n | 'onMessage'\n | 'setSimulationInterval'\n | 'setInterval'\n | 'setTimeout';\n\nexport type RoomException<R extends Room = Room> =\n OnCreateException<R> |\n OnAuthException<R> |\n OnJoinException<R> |\n OnLeaveException<R> |\n OnDisposeException |\n OnMessageException<R> |\n SimulationIntervalException |\n TimedEventException;\n\nexport class OnCreateException<R extends Room = Room> extends Error {\n options: Parameters<R['onCreate']>[0];\n constructor(\n cause: Error,\n message: string,\n options: Parameters<R['onCreate']>[0],\n ) {\n super(message, { cause });\n this.name = 'OnCreateException';\n this.options = options;\n }\n}\n\nexport class OnAuthException<R extends Room = Room> extends Error {\n client: Parameters<R['onAuth']>[0];\n options: Parameters<R['onAuth']>[1];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onAuth']>[0],\n options: Parameters<R['onAuth']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnAuthException';\n this.client = client;\n this.options = options;\n }\n}\n\nexport class OnJoinException<R extends Room = Room> extends Error {\n client: Parameters<R['onJoin']>[0];\n options: Parameters<R['onJoin']>[1];\n auth: Parameters<R['onJoin']>[2];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onJoin']>[0],\n options: Parameters<R['onJoin']>[1],\n auth: Parameters<R['onJoin']>[2],\n ) {\n super(message, { cause });\n this.name = 'OnJoinException';\n this.client = client;\n this.options = options;\n this.auth = auth;\n }\n}\n\nexport class OnLeaveException<R extends Room = Room> extends Error {\n client: Parameters<R['onLeave']>[0];\n consented: Parameters<R['onLeave']>[1];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onLeave']>[0],\n consented: Parameters<R['onLeave']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnLeaveException';\n this.client = client;\n this.consented = consented;\n }\n}\n\nexport class OnDisposeException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'OnDisposeException';\n }\n}\n\nexport class OnMessageException<R extends Room, MessageType extends keyof R['messages'] = keyof R['messages']> extends Error {\n client: R['~client'];\n payload: ExtractMessageType<R['messages'][MessageType]>;\n type: MessageType;\n constructor(\n cause: Error,\n message: string,\n client: R['~client'],\n payload: ExtractMessageType<R['messages'][MessageType]>,\n type: MessageType,\n ) {\n super(message, { cause });\n this.name = 'OnMessageException';\n this.client = client;\n this.payload = payload;\n this.type = type;\n }\n\n public isType<T extends keyof R['messages']>(type: T): this is OnMessageException<R, T> {\n return (this.type as string) === type;\n }\n}\n\nexport class SimulationIntervalException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'SimulationIntervalException';\n }\n}\n\nexport class TimedEventException extends Error {\n public args: any[];\n constructor(\n cause: Error,\n message: string,\n ...args: any[]\n ) {\n super(message, { cause });\n this.name = 'TimedEventException';\n this.args = args;\n }\n}"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAsBO,MAAM,0BAAiD,MAAM;AAAA,EAElE,YACE,OACA,SACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,MAAM,wBAA+C,MAAM;AAAA,EAGhE,YACE,OACA,SACA,QACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,MAAM,wBAA+C,MAAM;AAAA,EAIhE,YACE,OACA,SACA,QACA,SACA,MACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,yBAAgD,MAAM;AAAA,EAGjE,YACE,OACA,SACA,QACA,WACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,MAAM,2BAA2B,MAAM;AAAA,EAC5C,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,2BAA0G,MAAM;AAAA,EAI3H,YACE,OACA,SACA,QACA,SACA,MACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,OAAsC,MAA2C;AACtF,WAAQ,KAAK,SAAoB;AAAA,EACnC;AACF;AAEO,MAAM,oCAAoC,MAAM;AAAA,EACrD,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,MAAM,4BAA4B,MAAM;AAAA,EAE7C,YACE,OACA,YACG,MACH;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
7
7
  }
@@ -2,33 +2,33 @@
2
2
  var OnCreateException = class extends Error {
3
3
  constructor(cause, message, options) {
4
4
  super(message, { cause });
5
- this.options = options;
6
5
  this.name = "OnCreateException";
6
+ this.options = options;
7
7
  }
8
8
  };
9
9
  var OnAuthException = class extends Error {
10
10
  constructor(cause, message, client, options) {
11
11
  super(message, { cause });
12
+ this.name = "OnAuthException";
12
13
  this.client = client;
13
14
  this.options = options;
14
- this.name = "OnAuthException";
15
15
  }
16
16
  };
17
17
  var OnJoinException = class extends Error {
18
18
  constructor(cause, message, client, options, auth) {
19
19
  super(message, { cause });
20
+ this.name = "OnJoinException";
20
21
  this.client = client;
21
22
  this.options = options;
22
23
  this.auth = auth;
23
- this.name = "OnJoinException";
24
24
  }
25
25
  };
26
26
  var OnLeaveException = class extends Error {
27
27
  constructor(cause, message, client, consented) {
28
28
  super(message, { cause });
29
+ this.name = "OnLeaveException";
29
30
  this.client = client;
30
31
  this.consented = consented;
31
- this.name = "OnLeaveException";
32
32
  }
33
33
  };
34
34
  var OnDisposeException = class extends Error {
@@ -40,10 +40,13 @@ var OnDisposeException = class extends Error {
40
40
  var OnMessageException = class extends Error {
41
41
  constructor(cause, message, client, payload, type) {
42
42
  super(message, { cause });
43
+ this.name = "OnMessageException";
43
44
  this.client = client;
44
45
  this.payload = payload;
45
46
  this.type = type;
46
- this.name = "OnMessageException";
47
+ }
48
+ isType(type) {
49
+ return this.type === type;
47
50
  }
48
51
  };
49
52
  var SimulationIntervalException = class extends Error {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/RoomExceptions.ts"],
4
- "sourcesContent": ["import type { Client } from '../Transport.js';\nimport type { ExtractAuthData, ExtractUserData, Room } from '../Room.js';\n\nexport type RoomException<R extends Room = Room> =\n OnCreateException<R> |\n OnAuthException<R> |\n OnJoinException<R> |\n OnLeaveException<R> |\n OnDisposeException |\n OnMessageException<R> |\n SimulationIntervalException |\n TimedEventException;\n\nexport class OnCreateException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public options: Parameters<R['onCreate']>[0],\n ) {\n super(message, { cause });\n this.name = 'OnCreateException';\n }\n}\n\nexport class OnAuthException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onAuth']>[0],\n public options: Parameters<R['onAuth']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnAuthException';\n }\n}\n\nexport class OnJoinException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onJoin']>[0],\n public options: Parameters<R['onJoin']>[1],\n public auth: Parameters<R['onJoin']>[2],\n ) {\n super(message, { cause });\n this.name = 'OnJoinException';\n }\n}\n\nexport class OnLeaveException<R extends Room = Room> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Parameters<R['onLeave']>[0],\n public consented: Parameters<R['onLeave']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnLeaveException';\n }\n}\n\nexport class OnDisposeException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'OnDisposeException';\n }\n}\n\nexport class OnMessageException<R extends Room = Room, MessagePayload = any> extends Error {\n constructor(\n cause: Error,\n message: string,\n public client: Client<ExtractUserData<R['clients']>, ExtractAuthData<R['clients']>>,\n public payload: MessagePayload,\n public type: string,\n ) {\n super(message, { cause });\n this.name = 'OnMessageException';\n }\n}\n\nexport class SimulationIntervalException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'SimulationIntervalException';\n }\n}\n\nexport class TimedEventException extends Error {\n public args: any[];\n constructor(\n cause: Error,\n message: string,\n ...args: any[]\n ) {\n super(message, { cause });\n this.name = 'TimedEventException';\n this.args = args;\n }\n}"],
5
- "mappings": ";AAaO,IAAM,oBAAN,cAAuD,MAAM;AAAA,EAClE,YACE,OACA,SACO,SACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAFjB;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAAqD,MAAM;AAAA,EAChE,YACE,OACA,SACO,QACA,SACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAHjB;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,kBAAN,cAAqD,MAAM;AAAA,EAChE,YACE,OACA,SACO,QACA,SACA,MACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAJjB;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAAsD,MAAM;AAAA,EACjE,YACE,OACA,SACO,QACA,WACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAHjB;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAA8E,MAAM;AAAA,EACzF,YACE,OACA,SACO,QACA,SACA,MACP;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AAJjB;AACA;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACrD,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAE7C,YACE,OACA,YACG,MACH;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import type { ExtractMessageType, Room } from '../Room.ts';\n\nexport type RoomMethodName = 'onCreate'\n | 'onAuth'\n | 'onJoin'\n | 'onLeave'\n | 'onDispose'\n | 'onMessage'\n | 'setSimulationInterval'\n | 'setInterval'\n | 'setTimeout';\n\nexport type RoomException<R extends Room = Room> =\n OnCreateException<R> |\n OnAuthException<R> |\n OnJoinException<R> |\n OnLeaveException<R> |\n OnDisposeException |\n OnMessageException<R> |\n SimulationIntervalException |\n TimedEventException;\n\nexport class OnCreateException<R extends Room = Room> extends Error {\n options: Parameters<R['onCreate']>[0];\n constructor(\n cause: Error,\n message: string,\n options: Parameters<R['onCreate']>[0],\n ) {\n super(message, { cause });\n this.name = 'OnCreateException';\n this.options = options;\n }\n}\n\nexport class OnAuthException<R extends Room = Room> extends Error {\n client: Parameters<R['onAuth']>[0];\n options: Parameters<R['onAuth']>[1];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onAuth']>[0],\n options: Parameters<R['onAuth']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnAuthException';\n this.client = client;\n this.options = options;\n }\n}\n\nexport class OnJoinException<R extends Room = Room> extends Error {\n client: Parameters<R['onJoin']>[0];\n options: Parameters<R['onJoin']>[1];\n auth: Parameters<R['onJoin']>[2];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onJoin']>[0],\n options: Parameters<R['onJoin']>[1],\n auth: Parameters<R['onJoin']>[2],\n ) {\n super(message, { cause });\n this.name = 'OnJoinException';\n this.client = client;\n this.options = options;\n this.auth = auth;\n }\n}\n\nexport class OnLeaveException<R extends Room = Room> extends Error {\n client: Parameters<R['onLeave']>[0];\n consented: Parameters<R['onLeave']>[1];\n constructor(\n cause: Error,\n message: string,\n client: Parameters<R['onLeave']>[0],\n consented: Parameters<R['onLeave']>[1],\n ) {\n super(message, { cause });\n this.name = 'OnLeaveException';\n this.client = client;\n this.consented = consented;\n }\n}\n\nexport class OnDisposeException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'OnDisposeException';\n }\n}\n\nexport class OnMessageException<R extends Room, MessageType extends keyof R['messages'] = keyof R['messages']> extends Error {\n client: R['~client'];\n payload: ExtractMessageType<R['messages'][MessageType]>;\n type: MessageType;\n constructor(\n cause: Error,\n message: string,\n client: R['~client'],\n payload: ExtractMessageType<R['messages'][MessageType]>,\n type: MessageType,\n ) {\n super(message, { cause });\n this.name = 'OnMessageException';\n this.client = client;\n this.payload = payload;\n this.type = type;\n }\n\n public isType<T extends keyof R['messages']>(type: T): this is OnMessageException<R, T> {\n return (this.type as string) === type;\n }\n}\n\nexport class SimulationIntervalException extends Error {\n constructor(\n cause: Error,\n message: string,\n ) {\n super(message, { cause });\n this.name = 'SimulationIntervalException';\n }\n}\n\nexport class TimedEventException extends Error {\n public args: any[];\n constructor(\n cause: Error,\n message: string,\n ...args: any[]\n ) {\n super(message, { cause });\n this.name = 'TimedEventException';\n this.args = args;\n }\n}"],
5
+ "mappings": ";AAsBO,IAAM,oBAAN,cAAuD,MAAM;AAAA,EAElE,YACE,OACA,SACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,kBAAN,cAAqD,MAAM;AAAA,EAGhE,YACE,OACA,SACA,QACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AAAA,EACjB;AACF;AAEO,IAAM,kBAAN,cAAqD,MAAM;AAAA,EAIhE,YACE,OACA,SACA,QACA,SACA,MACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,mBAAN,cAAsD,MAAM;AAAA,EAGjE,YACE,OACA,SACA,QACA,WACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,YAAY;AAAA,EACnB;AACF;AAEO,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,qBAAN,cAAgH,MAAM;AAAA,EAI3H,YACE,OACA,SACA,QACA,SACA,MACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,SAAS;AACd,SAAK,UAAU;AACf,SAAK,OAAO;AAAA,EACd;AAAA,EAEO,OAAsC,MAA2C;AACtF,WAAQ,KAAK,SAAoB;AAAA,EACnC;AACF;AAEO,IAAM,8BAAN,cAA0C,MAAM;AAAA,EACrD,YACE,OACA,SACA;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AAAA,EACd;AACF;AAEO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EAE7C,YACE,OACA,YACG,MACH;AACA,UAAM,SAAS,EAAE,MAAM,CAAC;AACxB,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/SeatReservationError.ts"],
4
4
  "sourcesContent": ["export class SeatReservationError extends Error {\n constructor(message: string) {\n super(message);\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,MAAM;AAAA,EAC9C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAAA,EACf;AACF;",
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAO,MAAM,6BAA6B,MAAM;AAAA,EAC9C,YAAY,SAAiB;AAC3B,UAAM,OAAO;AAAA,EACf;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __defProp = Object.defineProperty;
2
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -20,7 +21,7 @@ __export(ServerError_exports, {
20
21
  ServerError: () => ServerError
21
22
  });
22
23
  module.exports = __toCommonJS(ServerError_exports);
23
- var import_Protocol = require("../Protocol.js");
24
+ var import_Protocol = require("../Protocol.ts");
24
25
  class ServerError extends Error {
25
26
  constructor(code = import_Protocol.ErrorCode.MATCHMAKE_UNHANDLED, message) {
26
27
  super(message);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/ServerError.ts"],
4
- "sourcesContent": ["import { ErrorCode } from '../Protocol.js';\n\nexport class ServerError extends Error {\n public code: number;\n\n constructor(code: number = ErrorCode.MATCHMAKE_UNHANDLED, message?: string) {\n super(message);\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ServerError);\n }\n\n this.name = 'ServerError';\n this.code = code;\n }\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAEnB,MAAM,oBAAoB,MAAM;AAAA,EAGrC,YAAY,OAAe,0BAAU,qBAAqB,SAAkB;AAC1E,UAAM,OAAO;AAGb,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,WAAW;AAAA,IAC3C;AAEA,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
4
+ "sourcesContent": ["import { ErrorCode } from '../Protocol.ts';\n\nexport class ServerError extends Error {\n public code: number;\n\n constructor(code: number = ErrorCode.MATCHMAKE_UNHANDLED, message?: string) {\n super(message);\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ServerError);\n }\n\n this.name = 'ServerError';\n this.code = code;\n }\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,sBAA0B;AAEnB,MAAM,oBAAoB,MAAM;AAAA,EAGrC,YAAY,OAAe,0BAAU,qBAAqB,SAAkB;AAC1E,UAAM,OAAO;AAGb,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,WAAW;AAAA,IAC3C;AAEA,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/errors/ServerError.ts"],
4
- "sourcesContent": ["import { ErrorCode } from '../Protocol.js';\n\nexport class ServerError extends Error {\n public code: number;\n\n constructor(code: number = ErrorCode.MATCHMAKE_UNHANDLED, message?: string) {\n super(message);\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ServerError);\n }\n\n this.name = 'ServerError';\n this.code = code;\n }\n}\n"],
4
+ "sourcesContent": ["import { ErrorCode } from '../Protocol.ts';\n\nexport class ServerError extends Error {\n public code: number;\n\n constructor(code: number = ErrorCode.MATCHMAKE_UNHANDLED, message?: string) {\n super(message);\n\n // Maintains proper stack trace for where our error was thrown (only available on V8)\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, ServerError);\n }\n\n this.name = 'ServerError';\n this.code = code;\n }\n}\n"],
5
5
  "mappings": ";AAAA,SAAS,iBAAiB;AAEnB,IAAM,cAAN,MAAM,qBAAoB,MAAM;AAAA,EAGrC,YAAY,OAAe,UAAU,qBAAqB,SAAkB;AAC1E,UAAM,OAAO;AAGb,QAAI,MAAM,mBAAmB;AAC3B,YAAM,kBAAkB,MAAM,YAAW;AAAA,IAC3C;AAEA,SAAK,OAAO;AACZ,SAAK,OAAO;AAAA,EACd;AACF;",
6
6
  "names": []
7
7
  }
package/build/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -26,11 +27,12 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
26
27
  mod
27
28
  ));
28
29
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var src_exports = {};
30
- __export(src_exports, {
30
+ var index_exports = {};
31
+ __export(index_exports, {
31
32
  ClientArray: () => import_Transport.ClientArray,
32
33
  ClientState: () => import_Transport.ClientState,
33
- Clock: () => import_timer.default,
34
+ Clock: () => import_timer.ClockTimer,
35
+ CloseCode: () => import_Protocol.CloseCode,
34
36
  Deferred: () => import_Utils.Deferred,
35
37
  Delayed: () => import_timer.Delayed,
36
38
  ErrorCode: () => import_Protocol.ErrorCode,
@@ -44,6 +46,7 @@ __export(src_exports, {
44
46
  OnLeaveException: () => import_RoomExceptions.OnLeaveException,
45
47
  OnMessageException: () => import_RoomExceptions.OnMessageException,
46
48
  Protocol: () => import_Protocol.Protocol,
49
+ RankedQueueRoom: () => import_RankedQueueRoom.RankedQueueRoom,
47
50
  RegisteredHandler: () => import_RegisteredHandler.RegisteredHandler,
48
51
  RelayRoom: () => import_RelayRoom.RelayRoom,
49
52
  Room: () => import_Room.Room,
@@ -54,6 +57,12 @@ __export(src_exports, {
54
57
  SimulationIntervalException: () => import_RoomExceptions.SimulationIntervalException,
55
58
  TimedEventException: () => import_RoomExceptions.TimedEventException,
56
59
  Transport: () => import_Transport.Transport,
60
+ __globalEndpoints: () => import_router.__globalEndpoints,
61
+ connectClientToRoom: () => import_Transport.connectClientToRoom,
62
+ createEndpoint: () => import_router.createEndpoint,
63
+ createInternalContext: () => import_router.createInternalContext,
64
+ createMiddleware: () => import_router.createMiddleware,
65
+ createRouter: () => import_router.createRouter,
57
66
  debugAndPrintError: () => import_Debug.debugAndPrintError,
58
67
  debugConnection: () => import_Debug.debugConnection,
59
68
  debugDriver: () => import_Debug.debugDriver,
@@ -62,44 +71,56 @@ __export(src_exports, {
62
71
  debugMessage: () => import_Debug.debugMessage,
63
72
  debugPatch: () => import_Debug.debugPatch,
64
73
  debugPresence: () => import_Debug.debugPresence,
74
+ defineRoom: () => import_Server.defineRoom,
75
+ defineServer: () => import_Server.defineServer,
65
76
  generateId: () => import_Utils.generateId,
66
77
  getBearerToken: () => import_Utils.getBearerToken,
67
78
  getMessageBytes: () => import_Protocol.getMessageBytes,
79
+ initializeRoomCache: () => import_driver.initializeRoomCache,
68
80
  isDevMode: () => import_DevMode.isDevMode,
69
81
  logger: () => import_Logger.logger,
70
82
  matchMaker: () => matchMaker,
71
83
  requestFromIPC: () => import_IPC.requestFromIPC,
84
+ room: () => import_Room.room,
72
85
  spliceOne: () => import_Utils.spliceOne,
73
86
  subscribeIPC: () => import_IPC.subscribeIPC,
74
87
  subscribeLobby: () => import_Lobby.subscribeLobby,
75
- updateLobby: () => import_Lobby.updateLobby
88
+ toNodeHandler: () => import_router.toNodeHandler,
89
+ updateLobby: () => import_Lobby.updateLobby,
90
+ validate: () => import_Room.validate
76
91
  });
77
- module.exports = __toCommonJS(src_exports);
78
- var import_timer = __toESM(require("@colyseus/timer"));
79
- var import_Server = require("./Server.js");
80
- var import_Room = require("./Room.js");
81
- var import_Protocol = require("./Protocol.js");
82
- var import_RegisteredHandler = require("./matchmaker/RegisteredHandler.js");
83
- var import_ServerError = require("./errors/ServerError.js");
84
- var import_RoomExceptions = require("./errors/RoomExceptions.js");
85
- var matchMaker = __toESM(require("./MatchMaker.js"));
86
- var import_Lobby = require("./matchmaker/Lobby.js");
87
- __reExport(src_exports, require("./matchmaker/driver/local/LocalDriver.js"), module.exports);
88
- var import_Transport = require("./Transport.js");
89
- var import_LocalPresence = require("./presence/LocalPresence.js");
90
- var import_SchemaSerializer = require("./serializer/SchemaSerializer.js");
91
- var import_Utils = require("./utils/Utils.js");
92
- var import_DevMode = require("./utils/DevMode.js");
93
- var import_IPC = require("./IPC.js");
94
- var import_Debug = require("./Debug.js");
95
- var import_LobbyRoom = require("./rooms/LobbyRoom.js");
96
- var import_RelayRoom = require("./rooms/RelayRoom.js");
97
- var import_Logger = require("./Logger.js");
92
+ module.exports = __toCommonJS(index_exports);
93
+ var import_timer = require("@colyseus/timer");
94
+ var import_Server = require("./Server.ts");
95
+ var import_Room = require("./Room.ts");
96
+ var import_Protocol = require("./Protocol.ts");
97
+ var import_RegisteredHandler = require("./matchmaker/RegisteredHandler.ts");
98
+ var import_ServerError = require("./errors/ServerError.ts");
99
+ var import_RoomExceptions = require("./errors/RoomExceptions.ts");
100
+ var matchMaker = __toESM(require("./MatchMaker.ts"), 1);
101
+ var import_Lobby = require("./matchmaker/Lobby.ts");
102
+ __reExport(index_exports, require("./matchmaker/LocalDriver/LocalDriver.ts"), module.exports);
103
+ var import_driver = require("./matchmaker/driver.ts");
104
+ var import_Transport = require("./Transport.ts");
105
+ var import_Presence = require("./presence/Presence.ts");
106
+ var import_LocalPresence = require("./presence/LocalPresence.ts");
107
+ var import_Serializer = require("./serializer/Serializer.ts");
108
+ var import_SchemaSerializer = require("./serializer/SchemaSerializer.ts");
109
+ var import_Utils = require("./utils/Utils.ts");
110
+ var import_DevMode = require("./utils/DevMode.ts");
111
+ var import_IPC = require("./IPC.ts");
112
+ var import_Debug = require("./Debug.ts");
113
+ var import_LobbyRoom = require("./rooms/LobbyRoom.ts");
114
+ var import_RelayRoom = require("./rooms/RelayRoom.ts");
115
+ var import_RankedQueueRoom = require("./rooms/RankedQueueRoom.ts");
116
+ var import_router = require("./router/index.ts");
117
+ var import_Logger = require("./Logger.ts");
98
118
  // Annotate the CommonJS export names for ESM import in node:
99
119
  0 && (module.exports = {
100
120
  ClientArray,
101
121
  ClientState,
102
122
  Clock,
123
+ CloseCode,
103
124
  Deferred,
104
125
  Delayed,
105
126
  ErrorCode,
@@ -113,6 +134,7 @@ var import_Logger = require("./Logger.js");
113
134
  OnLeaveException,
114
135
  OnMessageException,
115
136
  Protocol,
137
+ RankedQueueRoom,
116
138
  RegisteredHandler,
117
139
  RelayRoom,
118
140
  Room,
@@ -123,6 +145,12 @@ var import_Logger = require("./Logger.js");
123
145
  SimulationIntervalException,
124
146
  TimedEventException,
125
147
  Transport,
148
+ __globalEndpoints,
149
+ connectClientToRoom,
150
+ createEndpoint,
151
+ createInternalContext,
152
+ createMiddleware,
153
+ createRouter,
126
154
  debugAndPrintError,
127
155
  debugConnection,
128
156
  debugDriver,
@@ -131,16 +159,22 @@ var import_Logger = require("./Logger.js");
131
159
  debugMessage,
132
160
  debugPatch,
133
161
  debugPresence,
162
+ defineRoom,
163
+ defineServer,
134
164
  generateId,
135
165
  getBearerToken,
136
166
  getMessageBytes,
167
+ initializeRoomCache,
137
168
  isDevMode,
138
169
  logger,
139
170
  matchMaker,
140
171
  requestFromIPC,
172
+ room,
141
173
  spliceOne,
142
174
  subscribeIPC,
143
175
  subscribeLobby,
176
+ toNodeHandler,
144
177
  updateLobby,
145
- ...require("./matchmaker/driver/local/LocalDriver.js")
178
+ validate,
179
+ ...require("./matchmaker/LocalDriver/LocalDriver.ts")
146
180
  });
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import Clock, { Delayed } from '@colyseus/timer';\n\n// Core classes\nexport { Server, type ServerOptions } from './Server.js';\nexport { Room, RoomInternalState } from './Room.js';\nexport { Protocol, ErrorCode, getMessageBytes } from './Protocol.js';\nexport { RegisteredHandler } from './matchmaker/RegisteredHandler.js';\nexport { ServerError } from './errors/ServerError.js';\n\nexport {\n type RoomException,\n OnCreateException,\n OnAuthException,\n OnJoinException,\n OnLeaveException,\n OnDisposeException,\n OnMessageException,\n SimulationIntervalException,\n TimedEventException,\n} from './errors/RoomExceptions.js';\n\n// MatchMaker\nimport * as matchMaker from './MatchMaker.js';\nexport { matchMaker };\nexport { updateLobby, subscribeLobby } from './matchmaker/Lobby.js';\n\n// Driver\nexport * from './matchmaker/driver/local/LocalDriver.js';\n\n// Transport\nexport { type Client, type ClientPrivate, type AuthContext, ClientState, ClientArray, Transport, type ISendOptions } from './Transport.js';\n\n// Presence\nexport { type Presence } from './presence/Presence.js';\nexport { LocalPresence } from './presence/LocalPresence.js';\n\n// Serializers\nexport { type Serializer } from './serializer/Serializer.js';\nexport { SchemaSerializer } from './serializer/SchemaSerializer.js';\n// export { SchemaSerializerDebug } from './serializer/SchemaSerializerDebug.js';\n\n// Utilities\nexport { Clock, Delayed };\nexport { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from './utils/Utils.js';\nexport { isDevMode } from './utils/DevMode.js';\n\n// IPC\nexport { subscribeIPC, requestFromIPC } from './IPC.js';\n\n// Debug\nexport {\n debugMatchMaking,\n debugMessage,\n debugPatch,\n debugError,\n debugConnection,\n debugDriver,\n debugPresence,\n debugAndPrintError,\n} from './Debug.js';\n\n// Default rooms\nexport { LobbyRoom } from './rooms/LobbyRoom.js';\nexport { RelayRoom } from './rooms/RelayRoom.js';\n\n// Abstract logging support\nexport { logger } from './Logger.js';\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA+B;AAG/B,oBAA2C;AAC3C,kBAAwC;AACxC,sBAAqD;AACrD,+BAAkC;AAClC,yBAA4B;AAE5B,4BAUO;AAGP,iBAA4B;AAE5B,mBAA4C;AAG5C,wBAAc,qDA3Bd;AA8BA,uBAA0H;AAI1H,2BAA8B;AAI9B,8BAAiC;AAKjC,mBAAgF;AAChF,qBAA0B;AAG1B,iBAA6C;AAG7C,mBASO;AAGP,uBAA0B;AAC1B,uBAA0B;AAG1B,oBAAuB;",
4
+ "sourcesContent": ["import { ClockTimer as Clock, Delayed } from '@colyseus/timer';\n\n// Core classes\nexport { Server, defineRoom, defineServer, type ServerOptions, type SDKTypes } from './Server.ts';\nexport { Room, room, RoomInternalState, validate, type RoomOptions, type MessageHandlerWithFormat, type ExtractMessageType, type Messages, type ExtractRoomState, type ExtractRoomMetadata, type ExtractRoomClient } from './Room.ts';\nexport { Protocol, ErrorCode, getMessageBytes, CloseCode } from './Protocol.ts';\nexport { RegisteredHandler } from './matchmaker/RegisteredHandler.ts';\nexport { ServerError } from './errors/ServerError.ts';\n\nexport {\n type RoomException,\n type RoomMethodName,\n OnCreateException,\n OnAuthException,\n OnJoinException,\n OnLeaveException,\n OnDisposeException,\n OnMessageException,\n SimulationIntervalException,\n TimedEventException,\n} from './errors/RoomExceptions.ts';\n\n// MatchMaker\nimport * as matchMaker from './MatchMaker.ts';\nexport { matchMaker };\nexport { updateLobby, subscribeLobby } from './matchmaker/Lobby.ts';\n\n// Driver\nexport * from './matchmaker/LocalDriver/LocalDriver.ts';\nexport { initializeRoomCache } from './matchmaker/driver.ts';\n\n// Transport\nexport { type Client, type ClientPrivate, type AuthContext, ClientState, ClientArray, Transport, type ISendOptions, connectClientToRoom } from './Transport.ts';\n\n// Presence\nexport { type Presence } from './presence/Presence.ts';\nexport { LocalPresence } from './presence/LocalPresence.ts';\n\n// Serializers\nexport { type Serializer } from './serializer/Serializer.ts';\nexport { SchemaSerializer } from './serializer/SchemaSerializer.ts';\n// export { SchemaSerializerDebug } from './serializer/SchemaSerializerDebug.ts';\n\n// Utilities\nexport { Clock, Delayed };\nexport { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from './utils/Utils.ts';\nexport { isDevMode } from './utils/DevMode.ts';\n\n// IPC\nexport { subscribeIPC, requestFromIPC } from './IPC.ts';\n\n// Debug\nexport {\n debugMatchMaking,\n debugMessage,\n debugPatch,\n debugError,\n debugConnection,\n debugDriver,\n debugPresence,\n debugAndPrintError,\n} from './Debug.ts';\n\n// Default rooms\nexport { LobbyRoom } from './rooms/LobbyRoom.ts';\nexport { RelayRoom } from './rooms/RelayRoom.ts';\nexport { RankedQueueRoom, type RankedQueueOptions, type MatchGroup, type MatchTeam, type ClientQueueData } from './rooms/RankedQueueRoom.ts';\n\n// Router / Endpoints\nexport {\n createEndpoint,\n createInternalContext,\n createMiddleware,\n createRouter,\n toNodeHandler,\n __globalEndpoints,\n type Router,\n} from './router/index.ts';\n\n// Abstract logging support\nexport { logger } from './Logger.ts';\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA,4BAAAA;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAG7C,oBAAoF;AACpF,kBAA0N;AAC1N,sBAAgE;AAChE,+BAAkC;AAClC,yBAA4B;AAE5B,4BAWO;AAGP,iBAA4B;AAE5B,mBAA4C;AAG5C,0BAAc,oDA5Bd;AA6BA,oBAAoC;AAGpC,uBAA+I;AAG/I,sBAA8B;AAC9B,2BAA8B;AAG9B,wBAAgC;AAChC,8BAAiC;AAKjC,mBAAgF;AAChF,qBAA0B;AAG1B,iBAA6C;AAG7C,mBASO;AAGP,uBAA0B;AAC1B,uBAA0B;AAC1B,6BAAgH;AAGhH,oBAQO;AAGP,oBAAuB;",
6
6
  "names": ["Clock"]
7
7
  }
package/build/index.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  // packages/core/src/index.ts
2
- import Clock, { Delayed } from "@colyseus/timer";
3
- import { Server } from "./Server.mjs";
4
- import { Room, RoomInternalState } from "./Room.mjs";
5
- import { Protocol, ErrorCode, getMessageBytes } from "./Protocol.mjs";
2
+ import { ClockTimer as Clock, Delayed } from "@colyseus/timer";
3
+ import { Server, defineRoom, defineServer } from "./Server.mjs";
4
+ import { Room, room, RoomInternalState, validate } from "./Room.mjs";
5
+ import { Protocol, ErrorCode, getMessageBytes, CloseCode } from "./Protocol.mjs";
6
6
  import { RegisteredHandler } from "./matchmaker/RegisteredHandler.mjs";
7
7
  import { ServerError } from "./errors/ServerError.mjs";
8
8
  import {
@@ -17,9 +17,12 @@ import {
17
17
  } from "./errors/RoomExceptions.mjs";
18
18
  import * as matchMaker from "./MatchMaker.mjs";
19
19
  import { updateLobby, subscribeLobby } from "./matchmaker/Lobby.mjs";
20
- export * from "./matchmaker/driver/local/LocalDriver.mjs";
21
- import { ClientState, ClientArray, Transport } from "./Transport.mjs";
20
+ export * from "./matchmaker/LocalDriver/LocalDriver.mjs";
21
+ import { initializeRoomCache } from "./matchmaker/driver.mjs";
22
+ import { ClientState, ClientArray, Transport, connectClientToRoom } from "./Transport.mjs";
23
+ import {} from "./presence/Presence.mjs";
22
24
  import { LocalPresence } from "./presence/LocalPresence.mjs";
25
+ import {} from "./serializer/Serializer.mjs";
23
26
  import { SchemaSerializer } from "./serializer/SchemaSerializer.mjs";
24
27
  import { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from "./utils/Utils.mjs";
25
28
  import { isDevMode } from "./utils/DevMode.mjs";
@@ -36,11 +39,21 @@ import {
36
39
  } from "./Debug.mjs";
37
40
  import { LobbyRoom } from "./rooms/LobbyRoom.mjs";
38
41
  import { RelayRoom } from "./rooms/RelayRoom.mjs";
42
+ import { RankedQueueRoom } from "./rooms/RankedQueueRoom.mjs";
43
+ import {
44
+ createEndpoint,
45
+ createInternalContext,
46
+ createMiddleware,
47
+ createRouter,
48
+ toNodeHandler,
49
+ __globalEndpoints
50
+ } from "./router/index.mjs";
39
51
  import { logger } from "./Logger.mjs";
40
52
  export {
41
53
  ClientArray,
42
54
  ClientState,
43
55
  Clock,
56
+ CloseCode,
44
57
  Deferred,
45
58
  Delayed,
46
59
  ErrorCode,
@@ -54,6 +67,7 @@ export {
54
67
  OnLeaveException,
55
68
  OnMessageException,
56
69
  Protocol,
70
+ RankedQueueRoom,
57
71
  RegisteredHandler,
58
72
  RelayRoom,
59
73
  Room,
@@ -64,6 +78,12 @@ export {
64
78
  SimulationIntervalException,
65
79
  TimedEventException,
66
80
  Transport,
81
+ __globalEndpoints,
82
+ connectClientToRoom,
83
+ createEndpoint,
84
+ createInternalContext,
85
+ createMiddleware,
86
+ createRouter,
67
87
  debugAndPrintError,
68
88
  debugConnection,
69
89
  debugDriver,
@@ -72,15 +92,21 @@ export {
72
92
  debugMessage,
73
93
  debugPatch,
74
94
  debugPresence,
95
+ defineRoom,
96
+ defineServer,
75
97
  generateId,
76
98
  getBearerToken,
77
99
  getMessageBytes,
100
+ initializeRoomCache,
78
101
  isDevMode,
79
102
  logger,
80
103
  matchMaker,
81
104
  requestFromIPC,
105
+ room,
82
106
  spliceOne,
83
107
  subscribeIPC,
84
108
  subscribeLobby,
85
- updateLobby
109
+ toNodeHandler,
110
+ updateLobby,
111
+ validate
86
112
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/index.ts"],
4
- "sourcesContent": ["import Clock, { Delayed } from '@colyseus/timer';\n\n// Core classes\nexport { Server, type ServerOptions } from './Server.js';\nexport { Room, RoomInternalState } from './Room.js';\nexport { Protocol, ErrorCode, getMessageBytes } from './Protocol.js';\nexport { RegisteredHandler } from './matchmaker/RegisteredHandler.js';\nexport { ServerError } from './errors/ServerError.js';\n\nexport {\n type RoomException,\n OnCreateException,\n OnAuthException,\n OnJoinException,\n OnLeaveException,\n OnDisposeException,\n OnMessageException,\n SimulationIntervalException,\n TimedEventException,\n} from './errors/RoomExceptions.js';\n\n// MatchMaker\nimport * as matchMaker from './MatchMaker.js';\nexport { matchMaker };\nexport { updateLobby, subscribeLobby } from './matchmaker/Lobby.js';\n\n// Driver\nexport * from './matchmaker/driver/local/LocalDriver.js';\n\n// Transport\nexport { type Client, type ClientPrivate, type AuthContext, ClientState, ClientArray, Transport, type ISendOptions } from './Transport.js';\n\n// Presence\nexport { type Presence } from './presence/Presence.js';\nexport { LocalPresence } from './presence/LocalPresence.js';\n\n// Serializers\nexport { type Serializer } from './serializer/Serializer.js';\nexport { SchemaSerializer } from './serializer/SchemaSerializer.js';\n// export { SchemaSerializerDebug } from './serializer/SchemaSerializerDebug.js';\n\n// Utilities\nexport { Clock, Delayed };\nexport { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from './utils/Utils.js';\nexport { isDevMode } from './utils/DevMode.js';\n\n// IPC\nexport { subscribeIPC, requestFromIPC } from './IPC.js';\n\n// Debug\nexport {\n debugMatchMaking,\n debugMessage,\n debugPatch,\n debugError,\n debugConnection,\n debugDriver,\n debugPresence,\n debugAndPrintError,\n} from './Debug.js';\n\n// Default rooms\nexport { LobbyRoom } from './rooms/LobbyRoom.js';\nexport { RelayRoom } from './rooms/RelayRoom.js';\n\n// Abstract logging support\nexport { logger } from './Logger.js';\n"],
5
- "mappings": ";AAAA,OAAO,SAAS,eAAe;AAG/B,SAAS,cAAkC;AAC3C,SAAS,MAAM,yBAAyB;AACxC,SAAS,UAAU,WAAW,uBAAuB;AACrD,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAE5B;AAAA,EAEE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,YAAY,gBAAgB;AAE5B,SAAS,aAAa,sBAAsB;AAG5C,cAAc;AAGd,SAA4D,aAAa,aAAa,iBAAoC;AAI1H,SAAS,qBAAqB;AAI9B,SAAS,wBAAwB;AAKjC,SAAS,YAAY,UAAU,gBAAgB,WAAW,sBAAsB;AAChF,SAAS,iBAAiB;AAG1B,SAAS,cAAc,sBAAsB;AAG7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAG1B,SAAS,cAAc;",
4
+ "sourcesContent": ["import { ClockTimer as Clock, Delayed } from '@colyseus/timer';\n\n// Core classes\nexport { Server, defineRoom, defineServer, type ServerOptions, type SDKTypes } from './Server.ts';\nexport { Room, room, RoomInternalState, validate, type RoomOptions, type MessageHandlerWithFormat, type ExtractMessageType, type Messages, type ExtractRoomState, type ExtractRoomMetadata, type ExtractRoomClient } from './Room.ts';\nexport { Protocol, ErrorCode, getMessageBytes, CloseCode } from './Protocol.ts';\nexport { RegisteredHandler } from './matchmaker/RegisteredHandler.ts';\nexport { ServerError } from './errors/ServerError.ts';\n\nexport {\n type RoomException,\n type RoomMethodName,\n OnCreateException,\n OnAuthException,\n OnJoinException,\n OnLeaveException,\n OnDisposeException,\n OnMessageException,\n SimulationIntervalException,\n TimedEventException,\n} from './errors/RoomExceptions.ts';\n\n// MatchMaker\nimport * as matchMaker from './MatchMaker.ts';\nexport { matchMaker };\nexport { updateLobby, subscribeLobby } from './matchmaker/Lobby.ts';\n\n// Driver\nexport * from './matchmaker/LocalDriver/LocalDriver.ts';\nexport { initializeRoomCache } from './matchmaker/driver.ts';\n\n// Transport\nexport { type Client, type ClientPrivate, type AuthContext, ClientState, ClientArray, Transport, type ISendOptions, connectClientToRoom } from './Transport.ts';\n\n// Presence\nexport { type Presence } from './presence/Presence.ts';\nexport { LocalPresence } from './presence/LocalPresence.ts';\n\n// Serializers\nexport { type Serializer } from './serializer/Serializer.ts';\nexport { SchemaSerializer } from './serializer/SchemaSerializer.ts';\n// export { SchemaSerializerDebug } from './serializer/SchemaSerializerDebug.ts';\n\n// Utilities\nexport { Clock, Delayed };\nexport { generateId, Deferred, HttpServerMock, spliceOne, getBearerToken } from './utils/Utils.ts';\nexport { isDevMode } from './utils/DevMode.ts';\n\n// IPC\nexport { subscribeIPC, requestFromIPC } from './IPC.ts';\n\n// Debug\nexport {\n debugMatchMaking,\n debugMessage,\n debugPatch,\n debugError,\n debugConnection,\n debugDriver,\n debugPresence,\n debugAndPrintError,\n} from './Debug.ts';\n\n// Default rooms\nexport { LobbyRoom } from './rooms/LobbyRoom.ts';\nexport { RelayRoom } from './rooms/RelayRoom.ts';\nexport { RankedQueueRoom, type RankedQueueOptions, type MatchGroup, type MatchTeam, type ClientQueueData } from './rooms/RankedQueueRoom.ts';\n\n// Router / Endpoints\nexport {\n createEndpoint,\n createInternalContext,\n createMiddleware,\n createRouter,\n toNodeHandler,\n __globalEndpoints,\n type Router,\n} from './router/index.ts';\n\n// Abstract logging support\nexport { logger } from './Logger.ts';\n"],
5
+ "mappings": ";AAAA,SAAS,cAAc,OAAO,eAAe;AAG7C,SAAS,QAAQ,YAAY,oBAAuD;AACpF,SAAS,MAAM,MAAM,mBAAmB,gBAAkL;AAC1N,SAAS,UAAU,WAAW,iBAAiB,iBAAiB;AAChE,SAAS,yBAAyB;AAClC,SAAS,mBAAmB;AAE5B;AAAA,EAGE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,YAAY,gBAAgB;AAE5B,SAAS,aAAa,sBAAsB;AAG5C,cAAc;AACd,SAAS,2BAA2B;AAGpC,SAA4D,aAAa,aAAa,WAA8B,2BAA2B;AAG/I,eAA8B;AAC9B,SAAS,qBAAqB;AAG9B,eAAgC;AAChC,SAAS,wBAAwB;AAKjC,SAAS,YAAY,UAAU,gBAAgB,WAAW,sBAAsB;AAChF,SAAS,iBAAiB;AAG1B,SAAS,cAAc,sBAAsB;AAG7C;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAGP,SAAS,iBAAiB;AAC1B,SAAS,iBAAiB;AAC1B,SAAS,uBAAuG;AAGhH;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AAGP,SAAS,cAAc;",
6
6
  "names": []
7
7
  }
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -31,11 +32,13 @@ __export(Lobby_exports, {
31
32
  updateLobby: () => updateLobby
32
33
  });
33
34
  module.exports = __toCommonJS(Lobby_exports);
34
- var matchMaker = __toESM(require("../MatchMaker.js"));
35
+ var matchMaker = __toESM(require("../MatchMaker.ts"), 1);
35
36
  const LOBBY_CHANNEL = "$lobby";
36
37
  function updateLobby(room, removed = false) {
37
- const listing = room.listing;
38
- if (listing.unlisted) return;
38
+ const listing = room["_listing"];
39
+ if (listing.unlisted || !listing.roomId) {
40
+ return;
41
+ }
39
42
  if (removed) {
40
43
  matchMaker.presence.publish(LOBBY_CHANNEL, `${listing.roomId},1`);
41
44
  } else if (!listing.private) {
@@ -43,12 +46,19 @@ function updateLobby(room, removed = false) {
43
46
  }
44
47
  }
45
48
  async function subscribeLobby(callback) {
49
+ const removedRoomIds = /* @__PURE__ */ new Set();
46
50
  const cb = async (message) => {
47
51
  const [roomId, isRemove] = message.split(",");
48
52
  if (isRemove === "1") {
53
+ removedRoomIds.add(roomId);
49
54
  callback(roomId, null);
55
+ setTimeout(() => removedRoomIds.delete(roomId), 2e3);
50
56
  } else {
57
+ removedRoomIds.delete(roomId);
51
58
  const room = (await matchMaker.query({ roomId }))[0];
59
+ if (removedRoomIds.has(roomId)) {
60
+ return;
61
+ }
52
62
  callback(roomId, room);
53
63
  }
54
64
  };