orchestrator-client 5.7.10 → 5.7.12

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.cjs CHANGED
@@ -1848,6 +1848,11 @@ var RealtimeClient = class {
1848
1848
  this._socket = null;
1849
1849
  this._handlers = /* @__PURE__ */ new Map();
1850
1850
  this._connected = false;
1851
+ // Every room joined through any API (subscribeTask, joinRooms, subscribe(),
1852
+ // subscribeEvents, etc.) is tracked here so it can be replayed on reconnect.
1853
+ // Server-side room membership is tied to the socket connection and is lost
1854
+ // on disconnect — the full set must be re-emitted on every reconnect.
1855
+ this._rooms = /* @__PURE__ */ new Set();
1851
1856
  // Multi-subscriber room-diffing state (mirrors WebSocketProvider)
1852
1857
  this._subscriptions = /* @__PURE__ */ new Map();
1853
1858
  this._currentRooms = /* @__PURE__ */ new Set();
@@ -1884,6 +1889,10 @@ var RealtimeClient = class {
1884
1889
  this._socket.on("connect", () => {
1885
1890
  this._connected = true;
1886
1891
  this._currentRooms = /* @__PURE__ */ new Set();
1892
+ if (this._rooms.size > 0) {
1893
+ this._socket?.emit("join", { rooms: [...this._rooms] });
1894
+ this._currentRooms = new Set(this._rooms);
1895
+ }
1887
1896
  this._syncRooms();
1888
1897
  });
1889
1898
  this._socket.on("disconnect", () => {
@@ -1941,7 +1950,9 @@ var RealtimeClient = class {
1941
1950
  */
1942
1951
  subscribeTask(taskId) {
1943
1952
  if (!this._socket) throw new Error("RealtimeClient not connected");
1944
- this._socket.emit("join", { rooms: [`task:${taskId}`] });
1953
+ const room = `task:${taskId}`;
1954
+ this._socket.emit("join", { rooms: [room] });
1955
+ this._rooms.add(room);
1945
1956
  }
1946
1957
  /**
1947
1958
  * Unsubscribe from realtime events for a specific task.
@@ -1949,7 +1960,9 @@ var RealtimeClient = class {
1949
1960
  */
1950
1961
  unsubscribeTask(taskId) {
1951
1962
  if (!this._socket) throw new Error("RealtimeClient not connected");
1952
- this._socket.emit("leave", { rooms: [`task:${taskId}`] });
1963
+ const room = `task:${taskId}`;
1964
+ this._socket.emit("leave", { rooms: [room] });
1965
+ this._rooms.delete(room);
1953
1966
  }
1954
1967
  /**
1955
1968
  * Subscribe to event-type-scoped rooms.
@@ -1959,6 +1972,7 @@ var RealtimeClient = class {
1959
1972
  if (!this._socket) throw new Error("RealtimeClient not connected");
1960
1973
  const rooms = eventTypes.map((t) => `event:${t}`);
1961
1974
  this._socket.emit("join", { rooms });
1975
+ for (const r of rooms) this._rooms.add(r);
1962
1976
  }
1963
1977
  /**
1964
1978
  * Unsubscribe from event-type-scoped rooms.
@@ -1967,6 +1981,7 @@ var RealtimeClient = class {
1967
1981
  if (!this._socket) throw new Error("RealtimeClient not connected");
1968
1982
  const rooms = eventTypes.map((t) => `event:${t}`);
1969
1983
  this._socket.emit("leave", { rooms });
1984
+ for (const r of rooms) this._rooms.delete(r);
1970
1985
  }
1971
1986
  /**
1972
1987
  * Subscribe to the `all` broadcast room (receives all events).
@@ -1974,20 +1989,25 @@ var RealtimeClient = class {
1974
1989
  subscribeAll() {
1975
1990
  if (!this._socket) throw new Error("RealtimeClient not connected");
1976
1991
  this._socket.emit("join", { rooms: ["all"] });
1992
+ this._rooms.add("all");
1977
1993
  }
1978
1994
  /**
1979
1995
  * Subscribe to a locale-specific room.
1980
1996
  */
1981
1997
  subscribeLocale(locale) {
1982
1998
  if (!this._socket) throw new Error("RealtimeClient not connected");
1983
- this._socket.emit("join", { rooms: [`locale:${locale}`] });
1999
+ const room = `locale:${locale}`;
2000
+ this._socket.emit("join", { rooms: [room] });
2001
+ this._rooms.add(room);
1984
2002
  }
1985
2003
  /**
1986
2004
  * Unsubscribe from a locale-specific room.
1987
2005
  */
1988
2006
  unsubscribeLocale(locale) {
1989
2007
  if (!this._socket) throw new Error("RealtimeClient not connected");
1990
- this._socket.emit("leave", { rooms: [`locale:${locale}`] });
2008
+ const room = `locale:${locale}`;
2009
+ this._socket.emit("leave", { rooms: [room] });
2010
+ this._rooms.delete(room);
1991
2011
  }
1992
2012
  /**
1993
2013
  * Join arbitrary rooms by name.
@@ -1995,6 +2015,7 @@ var RealtimeClient = class {
1995
2015
  joinRooms(rooms) {
1996
2016
  if (!this._socket) throw new Error("RealtimeClient not connected");
1997
2017
  this._socket.emit("join", { rooms });
2018
+ for (const r of rooms) this._rooms.add(r);
1998
2019
  }
1999
2020
  /**
2000
2021
  * Leave arbitrary rooms by name.
@@ -2002,6 +2023,7 @@ var RealtimeClient = class {
2002
2023
  leaveRooms(rooms) {
2003
2024
  if (!this._socket) throw new Error("RealtimeClient not connected");
2004
2025
  this._socket.emit("leave", { rooms });
2026
+ for (const r of rooms) this._rooms.delete(r);
2005
2027
  }
2006
2028
  // ------------------------------------------------------------------
2007
2029
  // Multi-subscriber API (mirrors WebSocketProvider room-diffing)
@@ -2059,6 +2081,8 @@ var RealtimeClient = class {
2059
2081
  const toLeave = [...this._currentRooms].filter((r) => !needed.has(r));
2060
2082
  if (toJoin.length) socket.emit("join", { rooms: toJoin });
2061
2083
  if (toLeave.length) socket.emit("leave", { rooms: toLeave });
2084
+ for (const r of toJoin) this._rooms.add(r);
2085
+ for (const r of toLeave) this._rooms.delete(r);
2062
2086
  this._currentRooms = needed;
2063
2087
  }
2064
2088
  /**