@ai-matrx/meet 0.11.35 → 0.11.36

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
@@ -4757,6 +4757,7 @@ function createLiveKitDriver(handlers, options = {}) {
4757
4757
  projectRoster = roster;
4758
4758
  created.on(RoomEvent.TrackSubscribed, (track) => {
4759
4759
  if (track.kind !== Track.Kind.Audio || typeof document === "undefined") return;
4760
+ if (!remoteAudioPlayback) return;
4760
4761
  const element = track.attach();
4761
4762
  element.setAttribute("data-mx-meet-audio", "");
4762
4763
  audioSink().appendChild(element);
@@ -4841,6 +4842,7 @@ function createLiveKitDriver(handlers, options = {}) {
4841
4842
  let sources = null;
4842
4843
  let trackEvents = null;
4843
4844
  let audioContainer = null;
4845
+ let remoteAudioPlayback = true;
4844
4846
  function audioSink() {
4845
4847
  if (audioContainer !== null && audioContainer.isConnected) return audioContainer;
4846
4848
  const container = document.createElement("div");
@@ -4999,6 +5001,14 @@ function createLiveKitDriver(handlers, options = {}) {
4999
5001
  throw normalizeDeviceError(error, "meet.switchDevice");
5000
5002
  }
5001
5003
  },
5004
+ setRemoteAudioPlayback(enabled) {
5005
+ remoteAudioPlayback = enabled;
5006
+ if (enabled || audioContainer === null) return;
5007
+ for (const element of Array.from(audioContainer.querySelectorAll("[data-mx-meet-audio]"))) {
5008
+ if (element instanceof HTMLMediaElement) element.srcObject = null;
5009
+ element.remove();
5010
+ }
5011
+ },
5002
5012
  async startAudio() {
5003
5013
  const target = room;
5004
5014
  if (target === null) return;
@@ -6903,6 +6913,7 @@ function createRoomEngine(options) {
6903
6913
  return;
6904
6914
  }
6905
6915
  driver = created;
6916
+ if (token.connectionKind === "companion") created.setRemoteAudioPlayback?.(false);
6906
6917
  await created.connect(token.serverUrl, token.token);
6907
6918
  store.patch({ failure: null, connection: "stable" });
6908
6919
  store.dispatch({ type: "connected" });
@@ -7164,6 +7175,19 @@ function createRoomEngine(options) {
7164
7175
  }
7165
7176
  },
7166
7177
  leave: leaveRoom,
7178
+ async checkElsewhere(roomName) {
7179
+ const claim = options.tabClaim;
7180
+ const userId = identity.userId;
7181
+ if (claim === void 0 || userId === null) return false;
7182
+ const before = store.snapshot();
7183
+ if (before.phase !== "prejoin" || before.secondDevice !== null) return false;
7184
+ if (!await claim.presentElsewhere(String(roomName), `user:${String(userId)}`)) return false;
7185
+ const now2 = store.snapshot();
7186
+ if (now2.phase !== "prejoin" || now2.secondDevice !== null) return false;
7187
+ store.patch({ secondDevice: { rule: "ask_switch_or_join" } });
7188
+ report("info", "meet: this browser already has you in this meeting \u2014 offering the choice before Join");
7189
+ return true;
7190
+ },
7167
7191
  backToPrejoin() {
7168
7192
  store.dispatch({ type: "back_to_prejoin", click: true });
7169
7193
  },