@antha/multiplayer-core 0.0.3 → 0.0.4

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.
@@ -1,7 +1,7 @@
1
1
  import { type JsonCompatibleValue, type MaybePromise, type PartialWithUndefined } from '@augment-vir/common';
2
2
  import { type FindPortOptions } from '@rest-vir/api';
3
3
  import { type AnyDuration } from 'date-vir';
4
- import { ListenTarget } from 'typed-event-target';
4
+ import { ListenTarget, type RemoveListenerCallback } from 'typed-event-target';
5
5
  import { type ClientId, type RoomId } from '../multiplayer-id.js';
6
6
  import { type RoomInput } from '../webrtc/webrtc-multiplayer-controller.js';
7
7
  import { RoomRejectionError } from './errors.js';
@@ -397,7 +397,9 @@ export declare class MultiplayerRoomController<Message extends JsonCompatibleVal
397
397
  *
398
398
  * If a callback is provided, it is called each time the room list is updated.
399
399
  */
400
- startRoomUpdates(callback?: ControllerRoomListListener | undefined): import("typed-event-target").RemoveListenerCallback;
400
+ startRoomUpdates(callback: ControllerRoomListListener): RemoveListenerCallback;
401
+ startRoomUpdates(callback?: undefined): undefined;
402
+ startRoomUpdates(callback?: ControllerRoomListListener | undefined): RemoveListenerCallback | undefined;
401
403
  /** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
402
404
  stopRoomUpdates(): void;
403
405
  /** Send a generic message to the current room. */
@@ -1,7 +1,7 @@
1
1
  import { waitUntil } from '@augment-vir/assert';
2
2
  import { ensureError, makeWritable, } from '@augment-vir/common';
3
3
  import { convertDuration } from 'date-vir';
4
- import { defineTypedCustomEvent, ListenTarget } from 'typed-event-target';
4
+ import { defineTypedCustomEvent, ListenTarget, } from 'typed-event-target';
5
5
  import { WebrtcMultiplayerConnectionUpdateEvent, WebrtcMultiplayerController, WebrtcMultiplayerMessageEvent, } from '../webrtc/webrtc-multiplayer-controller.js';
6
6
  import { RoomRejectionError } from './errors.js';
7
7
  import { multiplayerHealthEndpoint, multiplayerRoomsEndpoint, } from './multiplayer-api.js';
@@ -178,17 +178,17 @@ export class MultiplayerRoomController extends ListenTarget {
178
178
  throw error;
179
179
  }
180
180
  }
181
- /**
182
- * Listen for room list updates, including while connected to a room.
183
- *
184
- * If a callback is provided, it is called each time the room list is updated.
185
- */
186
181
  startRoomUpdates(callback) {
187
182
  this.isListeningToRoomUpdates = true;
188
183
  this.startRoomInterval();
189
- return this.listen(ControllerRoomListEvent, async (event) => {
190
- await callback?.(event.detail);
191
- });
184
+ if (callback) {
185
+ return this.listen(ControllerRoomListEvent, async (event) => {
186
+ await callback(event.detail);
187
+ });
188
+ }
189
+ else {
190
+ return undefined;
191
+ }
192
192
  }
193
193
  /** Turn off room list updates and remove callbacks added via `startRoomUpdates`. */
194
194
  stopRoomUpdates() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antha/multiplayer-core",
3
- "version": "0.0.3",
3
+ "version": "0.0.4",
4
4
  "description": "Core functionalities for Antha multiplayer mods.",
5
5
  "keywords": [
6
6
  "vir",