@nanotoolkit/game-sdk 0.1.9 → 0.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Lib/Bridge/GameBridge.js +5 -3
- package/index.d.ts +1 -0
- package/package.json +1 -1
package/Lib/Bridge/GameBridge.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { parseWireJSON, stringifyWireJSON } from './WireJSON.js';
|
|
2
2
|
import { GameState } from './GameState.js';
|
|
3
3
|
|
|
4
|
-
export const SDK_VERSION = '0.1.
|
|
4
|
+
export const SDK_VERSION = '0.1.10';
|
|
5
5
|
|
|
6
6
|
const REQUEST_TIMEOUT_MS = 10000;
|
|
7
7
|
|
|
@@ -409,6 +409,7 @@ function ensureStateListeners() {
|
|
|
409
409
|
const directory = roomDirectory ?? lastEntry;
|
|
410
410
|
if (!directory || msg.rooms?.gameId !== directory.gameId || !Array.isArray(msg.rooms.rooms)) return;
|
|
411
411
|
const known = new Map((directory.rooms ?? []).map((room) => [room.id, room]));
|
|
412
|
+
const updates = new Map(msg.rooms.rooms.map((room) => [room.id, room]));
|
|
412
413
|
if (msg.rooms.rooms.some((room) => !known.has(room.id))) {
|
|
413
414
|
getGameRooms().catch(() => {});
|
|
414
415
|
return;
|
|
@@ -417,9 +418,10 @@ function ensureStateListeners() {
|
|
|
417
418
|
...directory,
|
|
418
419
|
...msg.rooms,
|
|
419
420
|
topic: roomDirectory?.topic ?? lastEntry?.roomsTopic ?? 'game:' + directory.gameId,
|
|
420
|
-
rooms:
|
|
421
|
-
...known.get(room.id),
|
|
421
|
+
rooms: (directory.rooms ?? []).filter((room) => updates.has(room.id)).map((room) => ({
|
|
422
422
|
...room,
|
|
423
|
+
onlineCount: updates.get(room.id).onlineCount,
|
|
424
|
+
targetTime: updates.get(room.id).targetTime,
|
|
423
425
|
})),
|
|
424
426
|
};
|
|
425
427
|
if (lastEntry?.gameId === roomDirectory.gameId) lastEntry.rooms = roomDirectory.rooms;
|
package/index.d.ts
CHANGED