@colyseus/sdk 0.17.25 → 0.17.26

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 (50) hide show
  1. package/build/3rd_party/discord.cjs +1 -1
  2. package/build/3rd_party/discord.mjs +1 -1
  3. package/build/Auth.cjs +1 -1
  4. package/build/Auth.mjs +1 -1
  5. package/build/Client.cjs +1 -1
  6. package/build/Client.mjs +1 -1
  7. package/build/Connection.cjs +1 -1
  8. package/build/Connection.mjs +1 -1
  9. package/build/HTTP.bkp.d.ts +103 -0
  10. package/build/HTTP.cjs +1 -1
  11. package/build/HTTP.mjs +1 -1
  12. package/build/Room.cjs +16 -10
  13. package/build/Room.cjs.map +1 -1
  14. package/build/Room.mjs +16 -10
  15. package/build/Room.mjs.map +1 -1
  16. package/build/Storage.cjs +1 -1
  17. package/build/Storage.mjs +1 -1
  18. package/build/core/nanoevents.cjs +1 -1
  19. package/build/core/nanoevents.mjs +1 -1
  20. package/build/core/signal.cjs +1 -1
  21. package/build/core/signal.mjs +1 -1
  22. package/build/core/utils.cjs +1 -1
  23. package/build/core/utils.mjs +1 -1
  24. package/build/debug.cjs +1 -1
  25. package/build/debug.mjs +1 -1
  26. package/build/errors/Errors.cjs +1 -1
  27. package/build/errors/Errors.mjs +1 -1
  28. package/build/index.cjs +1 -1
  29. package/build/index.mjs +1 -1
  30. package/build/legacy.cjs +1 -1
  31. package/build/legacy.mjs +1 -1
  32. package/build/serializer/NoneSerializer.cjs +1 -1
  33. package/build/serializer/NoneSerializer.mjs +1 -1
  34. package/build/serializer/SchemaSerializer.cjs +1 -1
  35. package/build/serializer/SchemaSerializer.mjs +1 -1
  36. package/build/serializer/Serializer.cjs +1 -1
  37. package/build/serializer/Serializer.mjs +1 -1
  38. package/build/transport/H3Transport.cjs +1 -1
  39. package/build/transport/H3Transport.mjs +1 -1
  40. package/build/transport/WebSocketTransport.cjs +1 -1
  41. package/build/transport/WebSocketTransport.mjs +1 -1
  42. package/dist/colyseus-cocos-creator.js +17 -10
  43. package/dist/colyseus-cocos-creator.js.map +1 -1
  44. package/dist/colyseus.d.ts +3969 -0
  45. package/dist/colyseus.js +17 -10
  46. package/dist/colyseus.js.map +1 -1
  47. package/dist/debug.js +16 -10
  48. package/dist/debug.js.map +1 -1
  49. package/package.json +8 -8
  50. package/src/Room.ts +16 -8
@@ -1 +1 @@
1
- {"version":3,"file":"Room.mjs","sources":["../src/Room.ts"],"sourcesContent":["import { CloseCode, Protocol, type InferState, type NormalizeRoomType, type ExtractRoomMessages, type ExtractRoomClientMessages, type ExtractMessageType } from '@colyseus/shared-types';\nimport { decode, Decoder, encode, Iterator, Schema } from '@colyseus/schema';\n\nimport { Packr, unpack } from '@colyseus/msgpackr';\n\nimport { Connection } from './Connection.ts';\nimport { getSerializer, Serializer } from './serializer/Serializer.ts';\n\n// The unused imports here are important for better `.d.ts` file generation\n// (Later merged with `dts-bundle-generator`)\nimport { createNanoEvents } from './core/nanoevents.ts';\nimport { createSignal } from './core/signal.ts';\n\nimport { SchemaConstructor, SchemaSerializer } from './serializer/SchemaSerializer.ts';\n\nimport { now } from './core/utils.ts';\n\n// Infer serializer type based on State: SchemaSerializer for Schema types, Serializer otherwise\nexport type InferSerializer<State> = [State] extends [Schema]\n ? SchemaSerializer<State>\n : Serializer<State>;\n\nexport interface RoomAvailable<Metadata = any> {\n name: string;\n roomId: string;\n clients: number;\n maxClients: number;\n metadata?: Metadata;\n}\n\nexport interface ReconnectionOptions {\n /**\n * The maximum number of reconnection attempts.\n */\n maxRetries: number;\n\n /**\n * The minimum delay between reconnection attempts.\n */\n minDelay: number;\n\n /**\n * The maximum delay between reconnection attempts.\n */\n maxDelay: number;\n\n /**\n * The minimum uptime of the room before reconnection attempts can be made.\n */\n minUptime: number;\n\n /**\n * The current number of reconnection attempts.\n */\n retryCount: number;\n\n /**\n * The initial delay between reconnection attempts.\n */\n delay: number;\n\n /**\n * The function to calculate the delay between reconnection attempts.\n * @param attempt - The current attempt number.\n * @param delay - The initial delay between reconnection attempts.\n * @returns The delay between reconnection attempts.\n */\n backoff: (attempt: number, delay: number) => number;\n\n /**\n * The maximum number of enqueued messages to buffer.\n */\n maxEnqueuedMessages: number;\n\n /**\n * Buffer for messages sent while connection is not open.\n * These messages will be sent once the connection is re-established.\n */\n enqueuedMessages: Array<{ data: Uint8Array }>;\n\n /**\n * Whether the room is currently reconnecting.\n */\n isReconnecting: boolean;\n}\n\nexport class Room<\n T = any,\n State = InferState<T, never>,\n> {\n public roomId: string;\n public sessionId: string;\n public reconnectionToken: string;\n\n public name: string;\n public connection: Connection;\n\n // Public signals\n public onStateChange = createSignal<(state: State) => void>();\n public onError = createSignal<(code: number, message?: string) => void>();\n public onLeave = createSignal<(code: number, reason?: string) => void>();\n\n public onReconnect = createSignal<() => void>();\n public onDrop = createSignal<(code: number, reason?: string) => void>();\n\n protected onJoin = createSignal();\n\n public serializerId: string;\n public serializer: InferSerializer<State>;\n\n // reconnection logic\n public reconnection: ReconnectionOptions = {\n retryCount: 0,\n maxRetries: 15,\n delay: 100,\n minDelay: 100,\n maxDelay: 5000,\n minUptime: 5000,\n backoff: exponentialBackoff,\n maxEnqueuedMessages: 10,\n enqueuedMessages: [],\n isReconnecting: false,\n };\n\n protected joinedAtTime: number = 0;\n\n protected onMessageHandlers = createNanoEvents();\n\n protected packr: Packr;\n\n #lastPingTime: number = 0;\n #pingCallback?: (ms: number) => void = undefined;\n\n constructor(name: string, rootSchema?: SchemaConstructor<State>) {\n this.name = name;\n\n this.packr = new Packr();\n\n // msgpackr workaround: force buffer to be created.\n this.packr.encode(undefined);\n\n if (rootSchema) {\n const serializer: SchemaSerializer = new (getSerializer(\"schema\"));\n this.serializer = serializer;\n\n const state: State = new rootSchema();\n serializer.state = state;\n serializer.decoder = new Decoder(state as Schema);\n }\n\n this.onLeave(() => this.removeAllListeners());\n }\n\n public connect(endpoint: string, options?: any, headers?: any) {\n this.connection = new Connection(options.protocol);\n this.connection.events.onmessage = this.onMessageCallback.bind(this);\n this.connection.events.onclose = (e: CloseEvent) => {\n if (this.joinedAtTime === 0) {\n console.warn?.(`Room connection was closed unexpectedly (${e.code}): ${e.reason}`);\n this.onError.invoke(e.code, e.reason);\n return;\n }\n\n if (\n e.code === CloseCode.NO_STATUS_RECEIVED ||\n e.code === CloseCode.ABNORMAL_CLOSURE ||\n e.code === CloseCode.GOING_AWAY ||\n e.code === CloseCode.MAY_TRY_RECONNECT\n ) {\n this.onDrop.invoke(e.code, e.reason);\n this.handleReconnection();\n\n } else {\n this.onLeave.invoke(e.code, e.reason);\n this.destroy();\n }\n };\n\n this.connection.events.onerror = (e: CloseEvent) => {\n this.onError.invoke(e.code, e.reason);\n };\n\n /**\n * if local serializer has state, it means we don't need to receive the\n * handshake from the server\n */\n const skipHandshake = (this.serializer?.getState() !== undefined);\n\n if (options.protocol === \"h3\") {\n // FIXME: refactor this.\n const url = new URL(endpoint);\n this.connection.connect(url.origin, { ...options, skipHandshake });\n\n } else {\n this.connection.connect(`${endpoint}${skipHandshake ? \"?skipHandshake=1\" : \"\"}`, headers);\n }\n\n }\n\n public leave(consented: boolean = true): Promise<number> {\n return new Promise((resolve) => {\n this.onLeave((code) => resolve(code));\n\n if (this.connection) {\n if (consented) {\n this.packr.buffer[0] = Protocol.LEAVE_ROOM;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n\n } else {\n this.connection.close();\n }\n\n } else {\n this.onLeave.invoke(CloseCode.CONSENTED);\n }\n });\n }\n\n public onMessage<MessageType extends keyof ExtractRoomClientMessages<NormalizeRoomType<T>>>(\n message: MessageType,\n callback: (payload: ExtractRoomClientMessages<NormalizeRoomType<T>>[MessageType]) => void\n ): () => void\n public onMessage<Payload = any>(type: \"*\", callback: (messageType: string | number, payload: Payload) => void): () => void\n // Fallback overload: only available when no typed client messages are defined\n public onMessage<Payload = any>(\n type: [keyof ExtractRoomClientMessages<NormalizeRoomType<T>>] extends [never] ? (string | number) : never,\n callback: (payload: Payload) => void\n ): () => void\n public onMessage(type: '*' | string | number, callback: (...args: any[]) => void) {\n return this.onMessageHandlers.on(this.getMessageHandlerKey(type), callback);\n }\n\n public ping(callback: (ms: number) => void) {\n // skip if connection is not open\n if (!this.connection?.isOpen) {\n return;\n }\n\n this.#lastPingTime = now();\n this.#pingCallback = callback;\n this.packr.buffer[0] = Protocol.PING;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n }\n\n public send<MessageType extends keyof ExtractRoomMessages<NormalizeRoomType<T>>>(\n messageType: MessageType,\n payload?: ExtractMessageType<ExtractRoomMessages<NormalizeRoomType<T>>[MessageType]>\n ): void\n // Fallback overload: only available when no typed messages are defined\n public send<Payload = any>(\n messageType: [keyof ExtractRoomMessages<NormalizeRoomType<T>>] extends [never] ? (string | number) : never,\n payload?: Payload\n ): void\n public send(messageType: string | number, payload?: any): void {\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA;\n\n if (typeof(messageType) === \"string\") {\n encode.string(this.packr.buffer as Buffer, messageType, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, messageType, it);\n }\n\n // force packr to use beginning of the buffer\n this.packr.position = 0;\n\n const data = (payload !== undefined)\n ? this.packr.pack(payload, 2048 + it.offset) // 2048 = RESERVE_START_SPACE\n : this.packr.buffer.subarray(0, it.offset);\n\n // If connection is not open, buffer the message\n if (!this.connection.isOpen) {\n enqueueMessage(this, new Uint8Array(data));\n } else {\n this.connection.send(data);\n }\n }\n\n public sendUnreliable<T = any>(type: string | number, message?: T): void {\n // If connection is not open, skip\n if (!this.connection.isOpen) { return; }\n\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA;\n\n if (typeof(type) === \"string\") {\n encode.string(this.packr.buffer as Buffer, type, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, type, it);\n }\n\n // force packr to use beginning of the buffer\n this.packr.position = 0;\n\n const data = (message !== undefined)\n ? this.packr.pack(message, 2048 + it.offset) // 2048 = RESERVE_START_SPACE\n : this.packr.buffer.subarray(0, it.offset);\n\n this.connection.sendUnreliable(data);\n }\n\n public sendBytes(type: string | number, bytes: Uint8Array) {\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA_BYTES;\n\n if (typeof(type) === \"string\") {\n encode.string(this.packr.buffer as Buffer, type, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, type, it);\n }\n\n // check if buffer needs to be resized\n // TODO: can we avoid this?\n if (bytes.byteLength + it.offset > this.packr.buffer.byteLength) {\n const newBuffer = new Uint8Array(it.offset + bytes.byteLength);\n newBuffer.set(this.packr.buffer);\n this.packr.useBuffer(newBuffer);\n }\n\n this.packr.buffer.set(bytes, it.offset);\n\n // If connection is not open, buffer the message\n if (!this.connection.isOpen) {\n enqueueMessage(this, this.packr.buffer.subarray(0, it.offset + bytes.byteLength));\n } else {\n this.connection.send(this.packr.buffer.subarray(0, it.offset + bytes.byteLength));\n }\n\n }\n\n public get state (): State {\n return this.serializer.getState();\n }\n\n public removeAllListeners() {\n this.onJoin.clear();\n this.onStateChange.clear();\n this.onError.clear();\n this.onLeave.clear();\n this.onMessageHandlers.events = {};\n\n if (this.serializer instanceof SchemaSerializer) {\n // Remove callback references\n this.serializer.decoder.root.callbacks = {};\n }\n }\n\n protected onMessageCallback(event: MessageEvent) {\n const buffer = new Uint8Array(event.data);\n\n const it: Iterator = { offset: 1 };\n const code = buffer[0];\n\n if (code === Protocol.JOIN_ROOM) {\n const reconnectionToken = decode.utf8Read(buffer as Buffer, it, buffer[it.offset++]);\n this.serializerId = decode.utf8Read(buffer as Buffer, it, buffer[it.offset++]);\n\n // Instantiate serializer if not locally available.\n if (!this.serializer) {\n const serializer = getSerializer(this.serializerId);\n this.serializer = new serializer();\n }\n\n // apply handshake on first join (no need to do this on reconnect)\n if (buffer.byteLength > it.offset && this.serializer.handshake) {\n this.serializer.handshake(buffer, it);\n }\n\n if (this.joinedAtTime === 0) {\n this.joinedAtTime = Date.now();\n this.onJoin.invoke();\n\n } else {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x2705)} reconnection successful!`); // ✅\n this.reconnection.isReconnecting = false;\n this.onReconnect.invoke();\n }\n\n this.reconnectionToken = `${this.roomId}:${reconnectionToken}`;\n\n // acknowledge successfull JOIN_ROOM\n this.packr.buffer[0] = Protocol.JOIN_ROOM;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n\n // Send any enqueued messages that were buffered while disconnected\n if (this.reconnection.enqueuedMessages.length > 0) {\n for (const message of this.reconnection.enqueuedMessages) {\n this.connection.send(message.data);\n }\n // Clear the buffer after sending\n this.reconnection.enqueuedMessages = [];\n }\n\n } else if (code === Protocol.ERROR) {\n const code = decode.number(buffer as Buffer, it);\n const message = decode.string(buffer as Buffer, it);\n\n this.onError.invoke(code, message);\n\n } else if (code === Protocol.LEAVE_ROOM) {\n this.leave();\n\n } else if (code === Protocol.ROOM_STATE) {\n this.serializer.setState(buffer, it);\n this.onStateChange.invoke(this.serializer.getState());\n\n } else if (code === Protocol.ROOM_STATE_PATCH) {\n this.serializer.patch(buffer, it);\n this.onStateChange.invoke(this.serializer.getState());\n\n } else if (code === Protocol.ROOM_DATA) {\n const type = (decode.stringCheck(buffer as Buffer, it))\n ? decode.string(buffer as Buffer, it)\n : decode.number(buffer as Buffer, it);\n\n const message = (buffer.byteLength > it.offset)\n ? unpack(buffer as Buffer, { start: it.offset })\n : undefined;\n\n this.dispatchMessage(type, message);\n\n } else if (code === Protocol.ROOM_DATA_BYTES) {\n const type = (decode.stringCheck(buffer as Buffer, it))\n ? decode.string(buffer as Buffer, it)\n : decode.number(buffer as Buffer, it);\n\n this.dispatchMessage(type, buffer.subarray(it.offset));\n\n } else if (code === Protocol.PING) {\n this.#pingCallback?.(Math.round(now() - this.#lastPingTime));\n this.#pingCallback = undefined;\n }\n }\n\n private dispatchMessage(type: string | number, message: any) {\n const messageType = this.getMessageHandlerKey(type);\n\n if (this.onMessageHandlers.events[messageType]) {\n this.onMessageHandlers.emit(messageType, message);\n\n } else if (this.onMessageHandlers.events['*']) {\n this.onMessageHandlers.emit('*', type, message);\n\n } else if (!messageType.startsWith(\"__\")) { // ignore internal messages\n console.warn?.(`@colyseus/sdk: onMessage() not registered for type '${type}'.`);\n }\n }\n\n private destroy () {\n if (this.serializer) {\n this.serializer.teardown();\n }\n }\n\n private getMessageHandlerKey(type: string | number): string {\n switch (typeof(type)) {\n // string\n case \"string\": return type;\n\n // number\n case \"number\": return `i${type}`;\n\n default: throw new Error(\"invalid message type.\");\n }\n }\n\n private handleReconnection() {\n if (Date.now() - this.joinedAtTime < this.reconnection.minUptime) {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Room has not been up for long enough for automatic reconnection. (min uptime: ${this.reconnection.minUptime}ms)`); // ❌\n return;\n }\n\n if (!this.reconnection.isReconnecting) {\n this.reconnection.retryCount = 0;\n this.reconnection.isReconnecting = true;\n }\n\n this.retryReconnection();\n }\n\n private retryReconnection() {\n this.reconnection.retryCount++;\n\n const delay = Math.min(this.reconnection.maxDelay, Math.max(this.reconnection.minDelay, this.reconnection.backoff(this.reconnection.retryCount, this.reconnection.delay)));\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x023F3)} will retry in ${(delay/1000).toFixed(1)} seconds...`); // 🔄\n\n // Wait before attempting reconnection\n setTimeout(() => {\n try {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x1F504)} Re-establishing sessionId '${this.sessionId}' with roomId '${this.roomId}'... (attempt ${this.reconnection.retryCount} of ${this.reconnection.maxRetries})`); // 🔄\n this.connection.reconnect({\n reconnectionToken: this.reconnectionToken.split(\":\")[1],\n skipHandshake: true, // we already applied the handshake on first join\n });\n\n } catch (e) {\n console.log(\".reconnect() failed\", e);\n if (this.reconnection.retryCount < this.reconnection.maxRetries) {\n this.retryReconnection();\n } else {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Failed to reconnect. Is your server running? Please check server logs.`); // ❌\n }\n }\n }, delay);\n }\n}\n\nconst exponentialBackoff = (attempt: number, delay: number) => {\n return Math.floor(Math.pow(2, attempt) * delay);\n}\n\nfunction enqueueMessage(room: Room, message: Uint8Array) {\n room.reconnection.enqueuedMessages.push({ data: message });\n if (room.reconnection.enqueuedMessages.length > room.reconnection.maxEnqueuedMessages) {\n room.reconnection.enqueuedMessages.shift();\n }\n}"],"names":[],"mappings":";;;;;;;;;;;;;;;;MAsFa,IAAI,CAAA;AAIN,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,iBAAiB;AAEjB,IAAA,IAAI;AACJ,IAAA,UAAU;;IAGV,aAAa,GAAG,YAAY,EAA0B;IACtD,OAAO,GAAG,YAAY,EAA4C;IAClE,OAAO,GAAG,YAAY,EAA2C;IAEjE,WAAW,GAAG,YAAY,EAAc;IACxC,MAAM,GAAG,YAAY,EAA2C;IAE7D,MAAM,GAAG,YAAY,EAAE;AAE1B,IAAA,YAAY;AACZ,IAAA,UAAU;;AAGV,IAAA,YAAY,GAAwB;AACvC,QAAA,UAAU,EAAE,CAAC;AACb,QAAA,UAAU,EAAE,EAAE;AACd,QAAA,KAAK,EAAE,GAAG;AACV,QAAA,QAAQ,EAAE,GAAG;AACb,QAAA,QAAQ,EAAE,IAAI;AACd,QAAA,SAAS,EAAE,IAAI;AACf,QAAA,OAAO,EAAE,kBAAkB;AAC3B,QAAA,mBAAmB,EAAE,EAAE;AACvB,QAAA,gBAAgB,EAAE,EAAE;AACpB,QAAA,cAAc,EAAE,KAAK;KACxB;IAES,YAAY,GAAW,CAAC;IAExB,iBAAiB,GAAG,gBAAgB,EAAE;AAEtC,IAAA,KAAK;IAEf,aAAa,GAAW,CAAC;IACzB,aAAa,GAA0B,SAAS;IAEhD,WAAA,CAAY,IAAY,EAAE,UAAqC,EAAA;AAC3D,QAAA,IAAI,CAAC,IAAI,GAAG,IAAI;AAEhB,QAAA,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,EAAE;;AAGxB,QAAA,IAAI,CAAC,KAA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,UAAU,EAAE;oBAC7D,IAAI,CAAC,iBAAiB,EAAE;gBAC5B;qBAAO;AACH,oBAAA,OAAO,CAAC,IAAI,CAAC,CAAA,yBAAA,EAA4B,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,CAAA,uEAAA,CAAyE,CAAC,CAAC;gBACpJ;YACJ;QACJ,CAAC,EAAE,KAAK,CAAC;IACb;AACH;AAED,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,KAAa,KAAI;AAC1D,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,IAAU,EAAE,OAAmB,EAAA;AACnD,IAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC1D,IAAA,IAAI,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE;AACnF,QAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,KAAK,EAAE;IAC9C;AACJ;;;;"}
1
+ {"version":3,"file":"Room.mjs","sources":["../src/Room.ts"],"sourcesContent":["import { CloseCode, Protocol, type InferState, type NormalizeRoomType, type ExtractRoomMessages, type ExtractRoomClientMessages, type ExtractMessageType } from '@colyseus/shared-types';\nimport { decode, Decoder, encode, Iterator, Schema } from '@colyseus/schema';\n\nimport { Packr, unpack } from '@colyseus/msgpackr';\n\nimport { Connection } from './Connection.ts';\nimport { getSerializer, Serializer } from './serializer/Serializer.ts';\n\n// The unused imports here are important for better `.d.ts` file generation\n// (Later merged with `dts-bundle-generator`)\nimport { createNanoEvents } from './core/nanoevents.ts';\nimport { createSignal } from './core/signal.ts';\n\nimport { SchemaConstructor, SchemaSerializer } from './serializer/SchemaSerializer.ts';\n\nimport { now } from './core/utils.ts';\n\n// Infer serializer type based on State: SchemaSerializer for Schema types, Serializer otherwise\nexport type InferSerializer<State> = [State] extends [Schema]\n ? SchemaSerializer<State>\n : Serializer<State>;\n\nexport interface RoomAvailable<Metadata = any> {\n name: string;\n roomId: string;\n clients: number;\n maxClients: number;\n metadata?: Metadata;\n}\n\nexport interface ReconnectionOptions {\n /**\n * The maximum number of reconnection attempts.\n */\n maxRetries: number;\n\n /**\n * The minimum delay between reconnection attempts.\n */\n minDelay: number;\n\n /**\n * The maximum delay between reconnection attempts.\n */\n maxDelay: number;\n\n /**\n * The minimum uptime of the room before reconnection attempts can be made.\n */\n minUptime: number;\n\n /**\n * The current number of reconnection attempts.\n */\n retryCount: number;\n\n /**\n * The initial delay between reconnection attempts.\n */\n delay: number;\n\n /**\n * The function to calculate the delay between reconnection attempts.\n * @param attempt - The current attempt number.\n * @param delay - The initial delay between reconnection attempts.\n * @returns The delay between reconnection attempts.\n */\n backoff: (attempt: number, delay: number) => number;\n\n /**\n * The maximum number of enqueued messages to buffer.\n */\n maxEnqueuedMessages: number;\n\n /**\n * Buffer for messages sent while connection is not open.\n * These messages will be sent once the connection is re-established.\n */\n enqueuedMessages: Array<{ data: Uint8Array }>;\n\n /**\n * Whether the room is currently reconnecting.\n */\n isReconnecting: boolean;\n}\n\nexport class Room<\n T = any,\n State = InferState<T, never>,\n> {\n public roomId: string;\n public sessionId: string;\n public reconnectionToken: string;\n\n public name: string;\n public connection: Connection;\n\n // Public signals\n public onStateChange = createSignal<(state: State) => void>();\n public onError = createSignal<(code: number, message?: string) => void>();\n public onLeave = createSignal<(code: number, reason?: string) => void>();\n\n public onReconnect = createSignal<() => void>();\n public onDrop = createSignal<(code: number, reason?: string) => void>();\n\n protected onJoin = createSignal();\n\n public serializerId: string;\n public serializer: InferSerializer<State>;\n\n // reconnection logic\n public reconnection: ReconnectionOptions = {\n retryCount: 0,\n maxRetries: 15,\n delay: 100,\n minDelay: 100,\n maxDelay: 5000,\n minUptime: 5000,\n backoff: exponentialBackoff,\n maxEnqueuedMessages: 10,\n enqueuedMessages: [],\n isReconnecting: false,\n };\n\n protected joinedAtTime: number = 0;\n\n protected onMessageHandlers = createNanoEvents();\n\n protected packr: Packr;\n\n #lastPingTime: number = 0;\n #pingCallback?: (ms: number) => void = undefined;\n\n constructor(name: string, rootSchema?: SchemaConstructor<State>) {\n this.name = name;\n\n this.packr = new Packr();\n\n // msgpackr workaround: force buffer to be created.\n this.packr.encode(undefined);\n\n if (rootSchema) {\n const serializer: SchemaSerializer = new (getSerializer(\"schema\"));\n this.serializer = serializer;\n\n const state: State = new rootSchema();\n serializer.state = state;\n serializer.decoder = new Decoder(state as Schema);\n }\n\n this.onLeave(() => {\n this.removeAllListeners();\n this.destroy();\n });\n }\n\n public connect(endpoint: string, options?: any, headers?: any) {\n this.connection = new Connection(options.protocol);\n this.connection.events.onmessage = this.onMessageCallback.bind(this);\n this.connection.events.onclose = (e: CloseEvent) => {\n if (this.joinedAtTime === 0) {\n console.warn?.(`Room connection was closed unexpectedly (${e.code}): ${e.reason}`);\n this.onError.invoke(e.code, e.reason);\n return;\n }\n\n if (\n e.code === CloseCode.NO_STATUS_RECEIVED ||\n e.code === CloseCode.ABNORMAL_CLOSURE ||\n e.code === CloseCode.GOING_AWAY ||\n e.code === CloseCode.MAY_TRY_RECONNECT\n ) {\n this.onDrop.invoke(e.code, e.reason);\n this.handleReconnection();\n\n } else {\n this.onLeave.invoke(e.code, e.reason);\n }\n };\n\n this.connection.events.onerror = (e: CloseEvent) => {\n this.onError.invoke(e.code, e.reason);\n };\n\n /**\n * if local serializer has state, it means we don't need to receive the\n * handshake from the server\n */\n const skipHandshake = (this.serializer?.getState() !== undefined);\n\n if (options.protocol === \"h3\") {\n // FIXME: refactor this.\n const url = new URL(endpoint);\n this.connection.connect(url.origin, { ...options, skipHandshake });\n\n } else {\n this.connection.connect(`${endpoint}${skipHandshake ? \"?skipHandshake=1\" : \"\"}`, headers);\n }\n\n }\n\n public leave(consented: boolean = true): Promise<number> {\n return new Promise((resolve) => {\n this.onLeave((code) => resolve(code));\n\n if (this.connection) {\n if (consented) {\n this.packr.buffer[0] = Protocol.LEAVE_ROOM;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n\n } else {\n this.connection.close();\n }\n\n } else {\n this.onLeave.invoke(CloseCode.CONSENTED);\n }\n });\n }\n\n public onMessage<MessageType extends keyof ExtractRoomClientMessages<NormalizeRoomType<T>>>(\n message: MessageType,\n callback: (payload: ExtractRoomClientMessages<NormalizeRoomType<T>>[MessageType]) => void\n ): () => void\n public onMessage<Payload = any>(type: \"*\", callback: (messageType: string | number, payload: Payload) => void): () => void\n // Fallback overload: only available when no typed client messages are defined\n public onMessage<Payload = any>(\n type: [keyof ExtractRoomClientMessages<NormalizeRoomType<T>>] extends [never] ? (string | number) : never,\n callback: (payload: Payload) => void\n ): () => void\n public onMessage(type: '*' | string | number, callback: (...args: any[]) => void) {\n return this.onMessageHandlers.on(this.getMessageHandlerKey(type), callback);\n }\n\n public ping(callback: (ms: number) => void) {\n // skip if connection is not open\n if (!this.connection?.isOpen) {\n return;\n }\n\n this.#lastPingTime = now();\n this.#pingCallback = callback;\n this.packr.buffer[0] = Protocol.PING;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n }\n\n public send<MessageType extends keyof ExtractRoomMessages<NormalizeRoomType<T>>>(\n messageType: MessageType,\n payload?: ExtractMessageType<ExtractRoomMessages<NormalizeRoomType<T>>[MessageType]>\n ): void\n // Fallback overload: only available when no typed messages are defined\n public send<Payload = any>(\n messageType: [keyof ExtractRoomMessages<NormalizeRoomType<T>>] extends [never] ? (string | number) : never,\n payload?: Payload\n ): void\n public send(messageType: string | number, payload?: any): void {\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA;\n\n if (typeof(messageType) === \"string\") {\n encode.string(this.packr.buffer as Buffer, messageType, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, messageType, it);\n }\n\n // force packr to use beginning of the buffer\n this.packr.position = 0;\n\n const data = (payload !== undefined)\n ? this.packr.pack(payload, 2048 + it.offset) // 2048 = RESERVE_START_SPACE\n : this.packr.buffer.subarray(0, it.offset);\n\n // If connection is not open, buffer the message\n if (!this.connection.isOpen) {\n enqueueMessage(this, new Uint8Array(data));\n } else {\n this.connection.send(data);\n }\n }\n\n public sendUnreliable<T = any>(type: string | number, message?: T): void {\n // If connection is not open, skip\n if (!this.connection.isOpen) { return; }\n\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA;\n\n if (typeof(type) === \"string\") {\n encode.string(this.packr.buffer as Buffer, type, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, type, it);\n }\n\n // force packr to use beginning of the buffer\n this.packr.position = 0;\n\n const data = (message !== undefined)\n ? this.packr.pack(message, 2048 + it.offset) // 2048 = RESERVE_START_SPACE\n : this.packr.buffer.subarray(0, it.offset);\n\n this.connection.sendUnreliable(data);\n }\n\n public sendBytes(type: string | number, bytes: Uint8Array) {\n const it: Iterator = { offset: 1 };\n this.packr.buffer[0] = Protocol.ROOM_DATA_BYTES;\n\n if (typeof(type) === \"string\") {\n encode.string(this.packr.buffer as Buffer, type, it);\n\n } else {\n encode.number(this.packr.buffer as Buffer, type, it);\n }\n\n // check if buffer needs to be resized\n // TODO: can we avoid this?\n if (bytes.byteLength + it.offset > this.packr.buffer.byteLength) {\n const newBuffer = new Uint8Array(it.offset + bytes.byteLength);\n newBuffer.set(this.packr.buffer);\n this.packr.useBuffer(newBuffer);\n }\n\n this.packr.buffer.set(bytes, it.offset);\n\n // If connection is not open, buffer the message\n if (!this.connection.isOpen) {\n enqueueMessage(this, this.packr.buffer.subarray(0, it.offset + bytes.byteLength));\n } else {\n this.connection.send(this.packr.buffer.subarray(0, it.offset + bytes.byteLength));\n }\n\n }\n\n public get state (): State {\n return this.serializer.getState();\n }\n\n public removeAllListeners() {\n this.onJoin.clear();\n this.onStateChange.clear();\n this.onError.clear();\n this.onLeave.clear();\n this.onReconnect.clear();\n this.onDrop.clear();\n this.onMessageHandlers.events = {};\n\n if (this.serializer instanceof SchemaSerializer) {\n // Remove callback references\n this.serializer.decoder.root.callbacks = {};\n }\n }\n\n protected onMessageCallback(event: MessageEvent) {\n const buffer = new Uint8Array(event.data);\n\n const it: Iterator = { offset: 1 };\n const code = buffer[0];\n\n if (code === Protocol.JOIN_ROOM) {\n const reconnectionToken = decode.utf8Read(buffer as Buffer, it, buffer[it.offset++]);\n this.serializerId = decode.utf8Read(buffer as Buffer, it, buffer[it.offset++]);\n\n // Instantiate serializer if not locally available.\n if (!this.serializer) {\n const serializer = getSerializer(this.serializerId);\n this.serializer = new serializer();\n }\n\n // apply handshake on first join (no need to do this on reconnect)\n if (buffer.byteLength > it.offset && this.serializer.handshake) {\n this.serializer.handshake(buffer, it);\n }\n\n if (this.joinedAtTime === 0) {\n this.joinedAtTime = Date.now();\n this.onJoin.invoke();\n\n } else {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x2705)} reconnection successful!`); // ✅\n this.reconnection.isReconnecting = false;\n this.onReconnect.invoke();\n }\n\n this.reconnectionToken = `${this.roomId}:${reconnectionToken}`;\n\n // acknowledge successfull JOIN_ROOM\n this.packr.buffer[0] = Protocol.JOIN_ROOM;\n this.connection.send(this.packr.buffer.subarray(0, 1));\n\n // Send any enqueued messages that were buffered while disconnected\n if (this.reconnection.enqueuedMessages.length > 0) {\n for (const message of this.reconnection.enqueuedMessages) {\n this.connection.send(message.data);\n }\n // Clear the buffer after sending\n this.reconnection.enqueuedMessages = [];\n }\n\n } else if (code === Protocol.ERROR) {\n const code = decode.number(buffer as Buffer, it);\n const message = decode.string(buffer as Buffer, it);\n\n this.onError.invoke(code, message);\n\n } else if (code === Protocol.LEAVE_ROOM) {\n this.leave();\n\n } else if (code === Protocol.ROOM_STATE) {\n this.serializer.setState(buffer, it);\n this.onStateChange.invoke(this.serializer.getState());\n\n } else if (code === Protocol.ROOM_STATE_PATCH) {\n this.serializer.patch(buffer, it);\n this.onStateChange.invoke(this.serializer.getState());\n\n } else if (code === Protocol.ROOM_DATA) {\n const type = (decode.stringCheck(buffer as Buffer, it))\n ? decode.string(buffer as Buffer, it)\n : decode.number(buffer as Buffer, it);\n\n const message = (buffer.byteLength > it.offset)\n ? unpack(buffer as Buffer, { start: it.offset })\n : undefined;\n\n this.dispatchMessage(type, message);\n\n } else if (code === Protocol.ROOM_DATA_BYTES) {\n const type = (decode.stringCheck(buffer as Buffer, it))\n ? decode.string(buffer as Buffer, it)\n : decode.number(buffer as Buffer, it);\n\n this.dispatchMessage(type, buffer.subarray(it.offset));\n\n } else if (code === Protocol.PING) {\n this.#pingCallback?.(Math.round(now() - this.#lastPingTime));\n this.#pingCallback = undefined;\n }\n }\n\n private dispatchMessage(type: string | number, message: any) {\n const messageType = this.getMessageHandlerKey(type);\n\n if (this.onMessageHandlers.events[messageType]) {\n this.onMessageHandlers.emit(messageType, message);\n\n } else if (this.onMessageHandlers.events['*']) {\n this.onMessageHandlers.emit('*', type, message);\n\n } else if (!messageType.startsWith(\"__\")) { // ignore internal messages\n console.warn?.(`@colyseus/sdk: onMessage() not registered for type '${type}'.`);\n }\n }\n\n private destroy () {\n if (this.serializer) {\n this.serializer.teardown();\n }\n }\n\n private getMessageHandlerKey(type: string | number): string {\n switch (typeof(type)) {\n // string\n case \"string\": return type;\n\n // number\n case \"number\": return `i${type}`;\n\n default: throw new Error(\"invalid message type.\");\n }\n }\n\n private handleReconnection() {\n if (Date.now() - this.joinedAtTime < this.reconnection.minUptime) {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Room has not been up for long enough for automatic reconnection. (min uptime: ${this.reconnection.minUptime}ms)`); // ❌\n this.onLeave.invoke(CloseCode.ABNORMAL_CLOSURE, \"Room uptime too short for reconnection.\");\n return;\n }\n\n if (!this.reconnection.isReconnecting) {\n this.reconnection.retryCount = 0;\n this.reconnection.isReconnecting = true;\n }\n\n this.retryReconnection();\n }\n\n private retryReconnection() {\n if (this.reconnection.retryCount >= this.reconnection.maxRetries) {\n // No more retries\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} ❌ Reconnection failed after ${this.reconnection.maxRetries} attempts.`); // ❌\n this.reconnection.isReconnecting = false;\n this.onLeave.invoke(CloseCode.FAILED_TO_RECONNECT, \"No more retries. Reconnection failed.\");\n return;\n }\n\n this.reconnection.retryCount++;\n\n const delay = Math.min(this.reconnection.maxDelay, Math.max(this.reconnection.minDelay, this.reconnection.backoff(this.reconnection.retryCount, this.reconnection.delay)));\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x023F3)} will retry in ${(delay/1000).toFixed(1)} seconds...`); // 🔄\n\n // Wait before attempting reconnection\n setTimeout(() => {\n try {\n console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x1F504)} Re-establishing sessionId '${this.sessionId}' with roomId '${this.roomId}'... (attempt ${this.reconnection.retryCount} of ${this.reconnection.maxRetries})`); // 🔄\n this.connection.reconnect({\n reconnectionToken: this.reconnectionToken.split(\":\")[1],\n skipHandshake: true, // we already applied the handshake on first join\n });\n\n } catch (e) {\n this.retryReconnection();\n }\n }, delay);\n }\n}\n\nconst exponentialBackoff = (attempt: number, delay: number) => {\n return Math.floor(Math.pow(2, attempt) * delay);\n}\n\nfunction enqueueMessage(room: Room, message: Uint8Array) {\n room.reconnection.enqueuedMessages.push({ data: message });\n if (room.reconnection.enqueuedMessages.length > room.reconnection.maxEnqueuedMessages) {\n room.reconnection.enqueuedMessages.shift();\n }\n}"],"names":[],"mappings":";;;;;;;;;;;;;;;;MAsFa,IAAI,CAAA;AAIN,IAAA,MAAM;AACN,IAAA,SAAS;AACT,IAAA,iBAAiB;AAEjB,IAAA,IAAI;AACJ,IAAA,UAAU;;IAGV,aAAa,GAAG,YAAY,EAA0B;IACtD,OAAO,GAAG,YAAY,EAA4C;IAClE,OAAO,GAAG,YAAY,EAA2C;IAEjE,WAAW,GAAG,YAAY,EAAc;IACxC,MAAM,GAAG,YAAY,EAA2C;IAE7D,M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ED,MAAM,kBAAkB,GAAG,CAAC,OAAe,EAAE,KAAa,KAAI;AAC1D,IAAA,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,KAAK,CAAC;AACnD,CAAC;AAED,SAAS,cAAc,CAAC,IAAU,EAAE,OAAmB,EAAA;AACnD,IAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC1D,IAAA,IAAI,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,MAAM,GAAG,IAAI,CAAC,YAAY,CAAC,mBAAmB,EAAE;AACnF,QAAA,IAAI,CAAC,YAAY,CAAC,gBAAgB,CAAC,KAAK,EAAE;IAC9C;AACJ;;;;"}
package/build/Storage.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  var tslib = require('tslib');
package/build/Storage.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  /// <reference path="../typings/cocos-creator.d.ts" />
8
8
  /**
9
9
  * We do not assign 'storage' to window.localStorage immediatelly for React
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  /**
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  /**
8
8
  * The MIT License (MIT)
9
9
  *
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  class EventEmitter {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  class EventEmitter {
8
8
  handlers = [];
9
9
  register(cb, once = false) {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  function now() {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  function now() {
8
8
  return typeof (performance) !== 'undefined' ? performance.now() : Date.now();
9
9
  }
package/build/debug.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  var Client = require('./Client.cjs');
package/build/debug.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  import { Client } from './Client.mjs';
8
8
  import { CloseCode } from '@colyseus/shared-types';
9
9
 
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  class ServerError extends Error {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  class ServerError extends Error {
8
8
  code;
9
9
  headers;
package/build/index.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  require('./legacy.cjs');
package/build/index.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  import './legacy.mjs';
8
8
  export { Client, ColyseusSDK } from './Client.mjs';
9
9
  export { Room } from './Room.mjs';
package/build/legacy.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  //
package/build/legacy.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  //
8
8
  // Polyfills for legacy environments
9
9
  //
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  class NoneSerializer {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  class NoneSerializer {
8
8
  setState(rawState) { }
9
9
  getState() { return null; }
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  var schema = require('@colyseus/schema');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  import { getDecoderStateCallbacks, Reflection, Decoder } from '@colyseus/schema';
8
8
 
9
9
  //
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  const serializers = {};
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  const serializers = {};
8
8
  function registerSerializer(id, serializer) {
9
9
  serializers[id] = serializer;
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  var tslib = require('tslib');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  import { encode, decode } from '@colyseus/schema';
8
8
 
9
9
  class H3TransportTransport {
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  'use strict';
8
8
 
9
9
  var NodeWebSocket = require('ws');
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25
6
+ // colyseus.js@0.17.26
7
7
  import NodeWebSocket from 'ws';
8
8
  import { CloseCode } from '@colyseus/shared-types';
9
9
 
@@ -3,7 +3,7 @@
3
3
  // This software is released under the MIT License.
4
4
  // https://opensource.org/license/MIT
5
5
  //
6
- // colyseus.js@0.17.25 - @colyseus/schema 4.0.6
6
+ // colyseus.js@0.17.26 - @colyseus/schema 4.0.8
7
7
  // THIS VERSION USES "XMLHttpRequest" INSTEAD OF "fetch" FOR COMPATIBILITY WITH COCOS CREATOR
8
8
  (function (global, factory) {
9
9
  typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
@@ -116,6 +116,7 @@
116
116
  CONSENTED: 4e3,
117
117
  SERVER_SHUTDOWN: 4001,
118
118
  WITH_ERROR: 4002,
119
+ FAILED_TO_RECONNECT: 4003,
119
120
  MAY_TRY_RECONNECT: 4010
120
121
  };
121
122
 
@@ -8617,7 +8618,10 @@
8617
8618
  serializer.state = state;
8618
8619
  serializer.decoder = new buildExports.Decoder(state);
8619
8620
  }
8620
- this.onLeave(() => this.removeAllListeners());
8621
+ this.onLeave(() => {
8622
+ this.removeAllListeners();
8623
+ this.destroy();
8624
+ });
8621
8625
  }
8622
8626
  connect(endpoint, options, headers) {
8623
8627
  var _a;
@@ -8639,7 +8643,6 @@
8639
8643
  }
8640
8644
  else {
8641
8645
  this.onLeave.invoke(e.code, e.reason);
8642
- this.destroy();
8643
8646
  }
8644
8647
  };
8645
8648
  this.connection.events.onerror = (e) => {
@@ -8765,6 +8768,8 @@
8765
8768
  this.onStateChange.clear();
8766
8769
  this.onError.clear();
8767
8770
  this.onLeave.clear();
8771
+ this.onReconnect.clear();
8772
+ this.onDrop.clear();
8768
8773
  this.onMessageHandlers.events = {};
8769
8774
  if (this.serializer instanceof SchemaSerializer) {
8770
8775
  // Remove callback references
@@ -8876,6 +8881,7 @@
8876
8881
  handleReconnection() {
8877
8882
  if (Date.now() - this.joinedAtTime < this.reconnection.minUptime) {
8878
8883
  console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Room has not been up for long enough for automatic reconnection. (min uptime: ${this.reconnection.minUptime}ms)`); // ❌
8884
+ this.onLeave.invoke(CloseCode.ABNORMAL_CLOSURE, "Room uptime too short for reconnection.");
8879
8885
  return;
8880
8886
  }
8881
8887
  if (!this.reconnection.isReconnecting) {
@@ -8885,6 +8891,13 @@
8885
8891
  this.retryReconnection();
8886
8892
  }
8887
8893
  retryReconnection() {
8894
+ if (this.reconnection.retryCount >= this.reconnection.maxRetries) {
8895
+ // No more retries
8896
+ console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} ❌ Reconnection failed after ${this.reconnection.maxRetries} attempts.`); // ❌
8897
+ this.reconnection.isReconnecting = false;
8898
+ this.onLeave.invoke(CloseCode.FAILED_TO_RECONNECT, "No more retries. Reconnection failed.");
8899
+ return;
8900
+ }
8888
8901
  this.reconnection.retryCount++;
8889
8902
  const delay = Math.min(this.reconnection.maxDelay, Math.max(this.reconnection.minDelay, this.reconnection.backoff(this.reconnection.retryCount, this.reconnection.delay)));
8890
8903
  console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x023F3)} will retry in ${(delay / 1000).toFixed(1)} seconds...`); // 🔄
@@ -8898,13 +8911,7 @@
8898
8911
  });
8899
8912
  }
8900
8913
  catch (e) {
8901
- console.log(".reconnect() failed", e);
8902
- if (this.reconnection.retryCount < this.reconnection.maxRetries) {
8903
- this.retryReconnection();
8904
- }
8905
- else {
8906
- console.info(`[Colyseus reconnection]: ${String.fromCodePoint(0x274C)} Failed to reconnect. Is your server running? Please check server logs.`); // ❌
8907
- }
8914
+ this.retryReconnection();
8908
8915
  }
8909
8916
  }, delay);
8910
8917
  }