@pluv/client 1.0.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -57,9 +57,7 @@ var __async = (__this, __arguments, generator) => {
57
57
  // src/index.ts
58
58
  var index_exports = {};
59
59
  __export(index_exports, {
60
- AbstractRoom: () => AbstractRoom,
61
60
  AbstractStorageStore: () => AbstractStorageStore,
62
- ConnectionState: () => ConnectionState,
63
61
  MockedRoom: () => MockedRoom,
64
62
  PluvClient: () => PluvClient,
65
63
  PluvRoom: () => PluvRoom,
@@ -69,13 +67,6 @@ __export(index_exports, {
69
67
  });
70
68
  module.exports = __toCommonJS(index_exports);
71
69
 
72
- // src/AbstractRoom.ts
73
- var AbstractRoom = class {
74
- constructor(room) {
75
- this.id = room;
76
- }
77
- };
78
-
79
70
  // src/AbstractStorageStore.ts
80
71
  var AbstractStorageStore = class {
81
72
  constructor(room) {
@@ -121,6 +112,9 @@ var PluvProcedure = class _PluvProcedure {
121
112
  }
122
113
  };
123
114
 
115
+ // src/PluvRoom.ts
116
+ var import_types = require("@pluv/types");
117
+
124
118
  // src/CrdtManager.ts
125
119
  var import_crdt = require("@pluv/crdt");
126
120
  var CrdtManager = class {
@@ -136,14 +130,17 @@ var CrdtManager = class {
136
130
  * update. This unfortunately means updates can be dropped entirely
137
131
  * @date June 13, 2023
138
132
  */
139
- applyUpdate(update, origin) {
133
+ applyUpdate(params) {
134
+ const { origin, update } = params;
140
135
  if (!this.initialized) return this;
141
136
  const updates = typeof update === "string" ? [update] : update;
142
137
  this._applyDocUpdates(this.doc, updates, origin);
143
138
  return this;
144
139
  }
145
140
  destroy() {
141
+ this.initialized = false;
146
142
  this.doc.destroy();
143
+ this.doc = this._docFactory.getEmpty();
147
144
  }
148
145
  get(key) {
149
146
  return this.doc.get(key);
@@ -152,7 +149,7 @@ var CrdtManager = class {
152
149
  return this._docFactory.getInitialized().getEncodedState();
153
150
  }
154
151
  initialize(params) {
155
- const { onInitialized, origin, update } = params;
152
+ const { origin, update } = params;
156
153
  if (this.initialized) {
157
154
  console.warn("Attempted to initialize storage multiple times");
158
155
  return this;
@@ -172,9 +169,11 @@ var CrdtManager = class {
172
169
  ).rebuildStorage(reference);
173
170
  this.initialized = true;
174
171
  initialized.destroy();
175
- onInitialized == null ? void 0 : onInitialized(this.doc.getEncodedState());
176
172
  return this;
177
173
  }
174
+ resolveEncodedState(updates) {
175
+ return this._docFactory.resolveEncodedState(updates);
176
+ }
178
177
  _applyDocUpdates(doc, updates, origin) {
179
178
  doc.transact(() => {
180
179
  doc.batchApplyEncodedState({ origin, updates });
@@ -549,15 +548,6 @@ var UsersManager = class {
549
548
  }
550
549
  };
551
550
 
552
- // src/enums.ts
553
- var ConnectionState = {
554
- Closed: "Closed",
555
- Connecting: "Connecting",
556
- Open: "Open",
557
- Unavailable: "Unavailable",
558
- Untouched: "Untouched"
559
- };
560
-
561
551
  // src/PluvRoom.ts
562
552
  var ADD_TO_STORAGE_STATE_DEBOUNCE_MS = 1e3;
563
553
  var HEARTBEAT_INTERVAL_MS = 1e4;
@@ -570,24 +560,8 @@ var ORIGIN_STORAGE_UPDATED = "$storageUpdated";
570
560
  var DEFAULT_PLUV_CLIENT_ADDON = (input) => ({
571
561
  storage: new StorageStore(input.room.id)
572
562
  });
573
- var PluvRoom = class extends AbstractRoom {
563
+ var PluvRoom = class {
574
564
  constructor(room, options) {
575
- const {
576
- addons = [],
577
- authEndpoint,
578
- debug = false,
579
- initialPresence,
580
- initialStorage,
581
- limits,
582
- metadata,
583
- onAuthorizationFail,
584
- presence,
585
- publicKey,
586
- reconnectTimeoutMs = RECONNECT_TIMEOUT_MS,
587
- router,
588
- wsEndpoint
589
- } = options;
590
- super(room);
591
565
  this._crdtNotifier = new CrdtNotifier();
592
566
  this._eventNotifier = new EventNotifier();
593
567
  this._intervals = {
@@ -613,7 +587,7 @@ var PluvRoom = class extends AbstractRoom {
613
587
  attempts: 0,
614
588
  count: 0,
615
589
  id: null,
616
- state: ConnectionState.Untouched
590
+ state: import_types.ConnectionState.Untouched
617
591
  },
618
592
  webSocket: null
619
593
  };
@@ -622,7 +596,7 @@ var PluvRoom = class extends AbstractRoom {
622
596
  this.broadcast = new Proxy(
623
597
  (event, data) => __async(this, null, function* () {
624
598
  if (!this._state.webSocket) return;
625
- if (this._state.connection.state !== ConnectionState.Open) return;
599
+ if (this._state.connection.state !== import_types.ConnectionState.Open) return;
626
600
  const type = event.toString();
627
601
  const procedure = this._router._defs.events[type];
628
602
  if (!(procedure == null ? void 0 : procedure.config.broadcast)) {
@@ -734,7 +708,7 @@ var PluvRoom = class extends AbstractRoom {
734
708
  const shouldFlatten = yield this._storageStore.getShouldFlatten();
735
709
  if (!shouldFlatten) return;
736
710
  const updates = yield this._storageStore.getUpdates();
737
- this._crdtManager.applyUpdate(updates, this);
711
+ this._crdtManager.applyUpdate({ update: updates, origin: this });
738
712
  const encodedState = this._crdtManager.doc.getEncodedState();
739
713
  yield this._storageStore.flatten(encodedState);
740
714
  }),
@@ -746,14 +720,30 @@ var PluvRoom = class extends AbstractRoom {
746
720
  DEFAULT_PLUV_CLIENT_ADDON
747
721
  );
748
722
  };
723
+ const {
724
+ addons = [],
725
+ authEndpoint,
726
+ debug = false,
727
+ initialPresence,
728
+ initialStorage,
729
+ limits,
730
+ metadata,
731
+ onAuthorizationFail,
732
+ presence,
733
+ publicKey,
734
+ reconnectTimeoutMs = RECONNECT_TIMEOUT_MS,
735
+ router,
736
+ wsEndpoint
737
+ } = options;
738
+ this.id = room;
739
+ this.metadata = metadata;
749
740
  const addon = this._getAddon(addons);
750
741
  const { storage } = __spreadValues(__spreadValues({}, DEFAULT_PLUV_CLIENT_ADDON({ room: this })), addon({ room: this }));
751
- this.metadata = metadata;
742
+ this._storageStore = storage;
752
743
  this._debug = debug;
753
744
  this._endpoints = { authEndpoint, wsEndpoint };
754
745
  this._limits = limits;
755
746
  this._reconnectTimeoutMs = reconnectTimeoutMs;
756
- this._storageStore = storage;
757
747
  if (!!publicKey) this._publicKey = publicKey;
758
748
  this._listeners = {
759
749
  onAuthorizationFail: (error) => {
@@ -781,16 +771,17 @@ var PluvRoom = class extends AbstractRoom {
781
771
  const metadata = params.metadata;
782
772
  this._setMetadata(metadata);
783
773
  const canConnect = [
784
- ConnectionState.Closed,
785
- ConnectionState.Unavailable,
786
- ConnectionState.Untouched
774
+ import_types.ConnectionState.Closed,
775
+ import_types.ConnectionState.Unavailable,
776
+ import_types.ConnectionState.Untouched
787
777
  ].some((state) => this._state.connection.state === state);
788
778
  if (!canConnect) return;
789
779
  this._clearTimeout(this._timeouts.reconnect);
790
780
  this._updateState((oldState) => {
791
- oldState.connection.state = ConnectionState.Connecting;
781
+ oldState.connection.state = import_types.ConnectionState.Connecting;
792
782
  return oldState;
793
783
  });
784
+ yield this._storageStore.initialize();
794
785
  const wsEndpoint = this._getWsEndpoint(this.id, params);
795
786
  const url = new URL(wsEndpoint);
796
787
  let authToken = null;
@@ -824,7 +815,7 @@ var PluvRoom = class extends AbstractRoom {
824
815
  disconnect() {
825
816
  return __async(this, null, function* () {
826
817
  if (!this._state.webSocket) return;
827
- const canDisconnect = [ConnectionState.Connecting, ConnectionState.Open].some(
818
+ const canDisconnect = [import_types.ConnectionState.Connecting, import_types.ConnectionState.Open].some(
828
819
  (state) => this._state.connection.state === state
829
820
  );
830
821
  if (!canDisconnect) return;
@@ -833,7 +824,7 @@ var PluvRoom = class extends AbstractRoom {
833
824
  this._clearTimeout(this._timeouts.reconnect);
834
825
  this._updateState((oldState) => {
835
826
  oldState.authorization.token = null;
836
- oldState.connection.state = ConnectionState.Closed;
827
+ oldState.connection.state = import_types.ConnectionState.Closed;
837
828
  oldState.webSocket = null;
838
829
  return oldState;
839
830
  });
@@ -855,20 +846,6 @@ var PluvRoom = class extends AbstractRoom {
855
846
  this._flattenStorageStore();
856
847
  });
857
848
  }
858
- _applyStorageStore() {
859
- return __async(this, null, function* () {
860
- const updates = yield this._storageStore.getUpdates();
861
- this._crdtManager.initialize({
862
- onInitialized: () => {
863
- this._stateNotifier.subjects["storage-loaded"].next(true);
864
- this._observeCrdt();
865
- },
866
- origin: ORIGIN_INITIALIZED,
867
- update: updates
868
- });
869
- this._emitSharedTypes();
870
- });
871
- }
872
849
  _attachWindowListeners() {
873
850
  if (typeof window === "undefined") return;
874
851
  if (typeof document === "undefined") return;
@@ -1059,33 +1036,35 @@ var PluvRoom = class extends AbstractRoom {
1059
1036
  this._stateNotifier.subjects.others.next(others);
1060
1037
  }
1061
1038
  _handleRegisteredMessage(message) {
1062
- var _a, _b;
1063
- const { connectionId } = message;
1064
- const user = message.user;
1065
- if (!connectionId) return;
1066
- if (!this._state.webSocket) throw new Error("Could not find WebSocket");
1067
- const data = message.data;
1068
- const state = data.state;
1069
- this._updateState((oldState) => {
1070
- oldState.connection.count += 1;
1071
- oldState.connection.id = connectionId;
1072
- oldState.authorization.user = user != null ? user : null;
1073
- return oldState;
1074
- });
1075
- const userInfo = {
1076
- connectionId,
1077
- presence: (_a = data.presence) != null ? _a : void 0,
1078
- user
1079
- };
1080
- this._usersManager.setMyself(userInfo);
1081
- const presence = this._usersManager.myPresence;
1082
- const myself = (_b = this._usersManager.myself) != null ? _b : null;
1083
- this._stateNotifier.subjects["my-presence"].next(presence);
1084
- this._stateNotifier.subjects.myself.next(myself);
1085
- const update = this._crdtManager.getInitialState();
1086
- this._sendMessage({
1087
- type: "$initializeSession",
1088
- data: { presence, update }
1039
+ return __async(this, null, function* () {
1040
+ var _a, _b, _c;
1041
+ const { connectionId } = message;
1042
+ const user = message.user;
1043
+ if (!connectionId) return;
1044
+ if (!this._state.webSocket) throw new Error("Could not find WebSocket");
1045
+ const data = message.data;
1046
+ const state = data.state;
1047
+ this._updateState((oldState) => {
1048
+ oldState.connection.count += 1;
1049
+ oldState.connection.id = connectionId;
1050
+ oldState.authorization.user = user != null ? user : null;
1051
+ return oldState;
1052
+ });
1053
+ const userInfo = {
1054
+ connectionId,
1055
+ presence: (_a = data.presence) != null ? _a : void 0,
1056
+ user
1057
+ };
1058
+ this._usersManager.setMyself(userInfo);
1059
+ const presence = this._usersManager.myPresence;
1060
+ const myself = (_b = this._usersManager.myself) != null ? _b : null;
1061
+ this._stateNotifier.subjects["my-presence"].next(presence);
1062
+ this._stateNotifier.subjects.myself.next(myself);
1063
+ const update = !state ? (_c = this._crdtManager.resolveEncodedState(yield this._storageStore.getUpdates())) != null ? _c : this._crdtManager.getInitialState() : this._crdtManager.getInitialState();
1064
+ this._sendMessage({
1065
+ type: "$initializeSession",
1066
+ data: { presence, update }
1067
+ });
1089
1068
  });
1090
1069
  }
1091
1070
  _handleStorageReceivedMessage(message) {
@@ -1094,24 +1073,34 @@ var PluvRoom = class extends AbstractRoom {
1094
1073
  if (!connectionId) return;
1095
1074
  if (!this._state.webSocket) throw new Error("Could not find WebSocket");
1096
1075
  const data = message.data;
1076
+ const changeKind = data.changeKind;
1097
1077
  const state = data.state;
1098
- this._crdtManager.initialize({
1099
- onInitialized: (update2) => __async(this, null, function* () {
1100
- yield this._addToStorageStore(update2);
1101
- this._emitSharedTypes();
1102
- this._observeCrdt();
1103
- this._stateNotifier.subjects["storage-loaded"].next(true);
1104
- }),
1105
- origin: ORIGIN_INITIALIZED,
1106
- update: state
1107
- });
1078
+ const updates = yield this._storageStore.getUpdates();
1079
+ const origin = ORIGIN_INITIALIZED;
1080
+ const updateStorage = (update) => {
1081
+ return this._crdtManager.initialized ? this._crdtManager.applyUpdate({ update, origin }) : this._crdtManager.initialize({ update, origin });
1082
+ };
1083
+ if (changeKind === "empty") {
1084
+ this._crdtManager.destroy();
1085
+ this._crdtManager.initialize({ origin, update: updates });
1086
+ } else if (changeKind === "initialized") {
1087
+ if (!!updates.length) updateStorage(updates);
1088
+ else {
1089
+ const encodedState2 = updateStorage(state).doc.getEncodedState();
1090
+ this._addToStorageStore(encodedState2);
1091
+ }
1092
+ } else {
1093
+ const encodedState2 = updateStorage(state).doc.getEncodedState();
1094
+ if (!!updates.length) this._crdtManager.applyUpdate({ update: updates, origin });
1095
+ yield this._addToStorageStore(encodedState2);
1096
+ }
1108
1097
  const encodedState = this._crdtManager.doc.getEncodedState();
1109
- yield this._storageStore.addUpdate(encodedState);
1110
1098
  this._emitSharedTypes();
1111
- const update = this._crdtManager.doc.getEncodedState();
1099
+ this._observeCrdt();
1100
+ this._stateNotifier.subjects["storage-loaded"].next(true);
1112
1101
  this._sendMessage({
1113
1102
  type: "$updateStorage",
1114
- data: { origin: ORIGIN_INITIALIZED, update }
1103
+ data: { origin, update: encodedState }
1115
1104
  });
1116
1105
  });
1117
1106
  }
@@ -1181,7 +1170,8 @@ var PluvRoom = class extends AbstractRoom {
1181
1170
  }
1182
1171
  _logDebug(...data) {
1183
1172
  var _a;
1184
- if (((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.NODE_ENV) === "production") return;
1173
+ if (typeof process === "undefined") return;
1174
+ if (((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "production") return;
1185
1175
  if (this._debug) console.log(...data);
1186
1176
  }
1187
1177
  _observeCrdt() {
@@ -1190,11 +1180,11 @@ var PluvRoom = class extends AbstractRoom {
1190
1180
  const unsubscribe = this._crdtManager.doc.subscribe((event) => {
1191
1181
  var _a2;
1192
1182
  const origin = (_a2 = event.origin) != null ? _a2 : null;
1193
- this._addToStorageStore(event.update);
1194
1183
  this._emitSharedTypes();
1195
1184
  if (origin === ORIGIN_INITIALIZED || origin === ORIGIN_STORAGE_UPDATED) {
1196
1185
  return;
1197
1186
  }
1187
+ this._addToStorageStore(event.update);
1198
1188
  if (!this._state.webSocket) return;
1199
1189
  if (!this._state.connection.id) return;
1200
1190
  if (this._state.webSocket.readyState !== WebSocket.OPEN) return;
@@ -1209,7 +1199,7 @@ var PluvRoom = class extends AbstractRoom {
1209
1199
  const authError = error instanceof Error ? error : new Error("Authorization failed");
1210
1200
  this._listeners.onAuthorizationFail(authError);
1211
1201
  this._updateState((oldState) => {
1212
- oldState.connection.state = ConnectionState.Unavailable;
1202
+ oldState.connection.state = import_types.ConnectionState.Unavailable;
1213
1203
  return oldState;
1214
1204
  });
1215
1205
  }
@@ -1233,14 +1223,14 @@ var PluvRoom = class extends AbstractRoom {
1233
1223
  ].some((okToRetryCode) => event.code === okToRetryCode);
1234
1224
  this._updateState((oldState) => {
1235
1225
  oldState.authorization.token = null;
1236
- oldState.connection.state = shouldRetry ? ConnectionState.Unavailable : (
1226
+ oldState.connection.state = shouldRetry ? import_types.ConnectionState.Unavailable : (
1237
1227
  /**
1238
1228
  * !HACK
1239
1229
  * @description Assume these are not recoverable. We're just going to mark this
1240
1230
  * as Closed to avoid reconnect attempts.
1241
1231
  * @date April 28, 2025
1242
1232
  */
1243
- ConnectionState.Closed
1233
+ import_types.ConnectionState.Closed
1244
1234
  );
1245
1235
  oldState.webSocket = null;
1246
1236
  return oldState;
@@ -1309,10 +1299,10 @@ var PluvRoom = class extends AbstractRoom {
1309
1299
  }
1310
1300
  }
1311
1301
  _onOpen() {
1312
- if (this._state.connection.state !== ConnectionState.Connecting) return;
1302
+ if (this._state.connection.state !== import_types.ConnectionState.Connecting) return;
1313
1303
  this._logDebug("WebSocket connected");
1314
1304
  this._updateState((oldState) => {
1315
- oldState.connection.state = ConnectionState.Open;
1305
+ oldState.connection.state = import_types.ConnectionState.Open;
1316
1306
  return oldState;
1317
1307
  });
1318
1308
  this._clearInterval(this._intervals.heartbeat);
@@ -1323,16 +1313,16 @@ var PluvRoom = class extends AbstractRoom {
1323
1313
  }
1324
1314
  _onNavigatorOffline() {
1325
1315
  return __async(this, null, function* () {
1326
- if (this._state.connection.state === ConnectionState.Closed) return;
1316
+ if (this._state.connection.state === import_types.ConnectionState.Closed) return;
1327
1317
  this._updateState((oldState) => {
1328
- oldState.connection.state = ConnectionState.Unavailable;
1318
+ oldState.connection.state = import_types.ConnectionState.Unavailable;
1329
1319
  return oldState;
1330
1320
  });
1331
1321
  });
1332
1322
  }
1333
1323
  _onNavigatorOnline() {
1334
1324
  return __async(this, null, function* () {
1335
- if (this._state.connection.state !== ConnectionState.Unavailable) return;
1325
+ if (this._state.connection.state !== import_types.ConnectionState.Unavailable) return;
1336
1326
  yield this._reconnect();
1337
1327
  });
1338
1328
  }
@@ -1341,12 +1331,12 @@ var PluvRoom = class extends AbstractRoom {
1341
1331
  if (typeof document === "undefined") return;
1342
1332
  if (document.visibilityState !== "visible") return;
1343
1333
  switch (this._state.connection.state) {
1344
- case ConnectionState.Open: {
1334
+ case import_types.ConnectionState.Open: {
1345
1335
  this._clearInterval(this._intervals.heartbeat);
1346
1336
  setInterval(this._heartbeat.bind(this), HEARTBEAT_INTERVAL_MS);
1347
1337
  return;
1348
1338
  }
1349
- case ConnectionState.Unavailable: {
1339
+ case import_types.ConnectionState.Unavailable: {
1350
1340
  yield this._reconnect();
1351
1341
  return;
1352
1342
  }
@@ -1386,7 +1376,7 @@ var PluvRoom = class extends AbstractRoom {
1386
1376
  _reconnect() {
1387
1377
  return __async(this, null, function* () {
1388
1378
  this._closeWs();
1389
- if (this._state.connection.state === ConnectionState.Closed) return;
1379
+ if (this._state.connection.state === import_types.ConnectionState.Closed) return;
1390
1380
  const metadata = this._lastMetadata;
1391
1381
  const params = typeof metadata === "undefined" ? [] : [{ metadata }];
1392
1382
  yield this.connect(...params);
@@ -1441,7 +1431,7 @@ var PluvClient = class {
1441
1431
  this._publicKey = null;
1442
1432
  this._rooms = /* @__PURE__ */ new Map();
1443
1433
  this.createRoom = (room, options = {}) => {
1444
- var _a;
1434
+ var _a, _b;
1445
1435
  const oldRoom = this.getRoom(room);
1446
1436
  if (oldRoom) return oldRoom;
1447
1437
  const newRoom = new PluvRoom(room, {
@@ -1449,12 +1439,12 @@ var PluvClient = class {
1449
1439
  authEndpoint: this._authEndpoint,
1450
1440
  debug: options.debug,
1451
1441
  initialPresence: options.initialPresence,
1452
- initialStorage: this._initialStorage,
1442
+ initialStorage: (_a = options.initialStorage) != null ? _a : this._initialStorage,
1453
1443
  limits: this._limits,
1454
1444
  metadata: this.metadata,
1455
1445
  onAuthorizationFail: options.onAuthorizationFail,
1456
1446
  presence: this._presence,
1457
- publicKey: (_a = this._publicKey) != null ? _a : void 0,
1447
+ publicKey: (_b = this._publicKey) != null ? _b : void 0,
1458
1448
  reconnectTimeoutMs: options.reconnectTimeoutMs,
1459
1449
  router: options.router,
1460
1450
  wsEndpoint: this._wsEndpoint
@@ -1523,7 +1513,8 @@ var PluvClient = class {
1523
1513
  }
1524
1514
  _logDebug(...data) {
1525
1515
  var _a;
1526
- if (((_a = process == null ? void 0 : process.env) == null ? void 0 : _a.NODE_ENV) === "production") return;
1516
+ if (typeof process === "undefined") return;
1517
+ if (((_a = process.env) == null ? void 0 : _a.NODE_ENV) === "production") return;
1527
1518
  if (this._debug) console.log(...data);
1528
1519
  }
1529
1520
  };
@@ -1537,10 +1528,9 @@ var createClient = (options) => {
1537
1528
  var infer = (callback) => callback;
1538
1529
 
1539
1530
  // src/MockedRoom.ts
1540
- var MockedRoom = class extends AbstractRoom {
1531
+ var import_types2 = require("@pluv/types");
1532
+ var MockedRoom = class {
1541
1533
  constructor(room, options) {
1542
- const { events, initialPresence, initialStorage, limits, presence, router } = options;
1543
- super(room);
1544
1534
  this._crdtNotifier = new CrdtNotifier();
1545
1535
  this._eventNotifier = new EventNotifier();
1546
1536
  this._otherNotifier = new OtherNotifier();
@@ -1553,7 +1543,7 @@ var MockedRoom = class extends AbstractRoom {
1553
1543
  attempts: 0,
1554
1544
  count: 1,
1555
1545
  id: null,
1556
- state: ConnectionState.Untouched
1546
+ state: import_types2.ConnectionState.Untouched
1557
1547
  },
1558
1548
  webSocket: null
1559
1549
  };
@@ -1564,7 +1554,7 @@ var MockedRoom = class extends AbstractRoom {
1564
1554
  this.broadcast = new Proxy(
1565
1555
  (event, data) => __async(this, null, function* () {
1566
1556
  if (!this._state.webSocket) return;
1567
- if (this._state.connection.state !== ConnectionState.Open) return;
1557
+ if (this._state.connection.state !== import_types2.ConnectionState.Open) return;
1568
1558
  const type = event.toString();
1569
1559
  const procedure = this._router._defs.events[type];
1570
1560
  if (!(procedure == null ? void 0 : procedure.config.broadcast)) {
@@ -1666,6 +1656,8 @@ var MockedRoom = class extends AbstractRoom {
1666
1656
  this._stateNotifier.subjects["my-presence"].next(myPresence);
1667
1657
  if (!!myself) this._stateNotifier.subjects["myself"].next(myself);
1668
1658
  };
1659
+ const { events, initialPresence, initialStorage, limits, presence, router } = options;
1660
+ this.id = room;
1669
1661
  this._events = events;
1670
1662
  this._limits = __spreadValues({
1671
1663
  presenceMaxSize: MAX_PRESENCE_SIZE_BYTES
@@ -1742,9 +1734,7 @@ var register = (params) => {
1742
1734
  };
1743
1735
  // Annotate the CommonJS export names for ESM import in node:
1744
1736
  0 && (module.exports = {
1745
- AbstractRoom,
1746
1737
  AbstractStorageStore,
1747
- ConnectionState,
1748
1738
  MockedRoom,
1749
1739
  PluvClient,
1750
1740
  PluvRoom,