@ai-matrx/meet 0.7.9 → 0.7.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/dist/react.cjs CHANGED
@@ -4600,6 +4600,15 @@ function createLiveKitDriver(handlers, options = {}) {
4600
4600
  handlers.participants([local, ...remotes]);
4601
4601
  };
4602
4602
  projectRoster = roster;
4603
+ created.on(RoomEvent.TrackSubscribed, (track) => {
4604
+ if (track.kind !== Track.Kind.Audio || typeof document === "undefined") return;
4605
+ const element = track.attach();
4606
+ element.setAttribute("data-mx-meet-audio", "");
4607
+ audioSink().appendChild(element);
4608
+ }).on(RoomEvent.TrackUnsubscribed, (track) => {
4609
+ if (track.kind !== Track.Kind.Audio) return;
4610
+ for (const element of track.detach()) element.remove();
4611
+ });
4603
4612
  created.on(RoomEvent.ParticipantConnected, roster).on(RoomEvent.ParticipantDisconnected, roster).on(RoomEvent.TrackSubscribed, roster).on(RoomEvent.TrackUnsubscribed, roster).on(RoomEvent.TrackMuted, roster).on(RoomEvent.TrackUnmuted, roster).on(RoomEvent.LocalTrackPublished, roster).on(RoomEvent.LocalTrackUnpublished, roster).on(RoomEvent.ParticipantNameChanged, roster).on(RoomEvent.ParticipantAttributesChanged, roster).on(RoomEvent.ParticipantMetadataChanged, roster).on(RoomEvent.RoomMetadataChanged, (metadata) => {
4604
4613
  handlers.roomMetadata?.(metadata ?? "");
4605
4614
  }).on(RoomEvent.ActiveSpeakersChanged, (speakers) => {
@@ -4615,6 +4624,8 @@ function createLiveKitDriver(handlers, options = {}) {
4615
4624
  participant?.identity ?? null
4616
4625
  );
4617
4626
  }).on(RoomEvent.Disconnected, (reason) => {
4627
+ audioContainer?.remove();
4628
+ audioContainer = null;
4618
4629
  handlers.disconnected(reason === void 0 ? null : String(reason));
4619
4630
  });
4620
4631
  try {
@@ -4656,10 +4667,26 @@ function createLiveKitDriver(handlers, options = {}) {
4656
4667
  microphone: Track.Source.Microphone,
4657
4668
  screen: Track.Source.ScreenShare
4658
4669
  };
4670
+ trackEvents = {
4671
+ subscribed: RoomEvent.TrackSubscribed,
4672
+ localPublished: RoomEvent.LocalTrackPublished
4673
+ };
4659
4674
  room = created;
4660
4675
  return created;
4661
4676
  }
4662
4677
  let sources = null;
4678
+ let trackEvents = null;
4679
+ let audioContainer = null;
4680
+ function audioSink() {
4681
+ if (audioContainer !== null && audioContainer.isConnected) return audioContainer;
4682
+ const container = document.createElement("div");
4683
+ container.setAttribute("data-mx-meet-audio-sink", "");
4684
+ container.setAttribute("aria-hidden", "true");
4685
+ container.style.display = "none";
4686
+ document.body.appendChild(container);
4687
+ audioContainer = container;
4688
+ return container;
4689
+ }
4663
4690
  function requireRoom(operation) {
4664
4691
  if (room === null) {
4665
4692
  throw new MeetError(
@@ -4690,6 +4717,8 @@ function createLiveKitDriver(handlers, options = {}) {
4690
4717
  } catch {
4691
4718
  }
4692
4719
  projectRoster = null;
4720
+ audioContainer?.remove();
4721
+ audioContainer = null;
4693
4722
  await target.disconnect();
4694
4723
  },
4695
4724
  async setMicrophoneEnabled(enabled) {
@@ -4755,14 +4784,33 @@ function createLiveKitDriver(handlers, options = {}) {
4755
4784
  attach(identity, kind, element) {
4756
4785
  const target = requireRoom("attach");
4757
4786
  const source = sources?.[kind];
4758
- const participant = target.localParticipant.identity === identity ? target.localParticipant : target.remoteParticipants.get(identity);
4759
- if (participant === void 0 || source === void 0) return () => void 0;
4760
- const publication = participant.getTrackPublication(source);
4761
- const track = publication?.track;
4762
- if (track === void 0) return () => void 0;
4763
- track.attach(element);
4787
+ if (source === void 0) return () => void 0;
4788
+ let current = null;
4789
+ const sync = () => {
4790
+ const participant = target.localParticipant.identity === identity ? target.localParticipant : target.remoteParticipants.get(identity);
4791
+ const track = participant?.getTrackPublication(source)?.track;
4792
+ if (track === void 0 || track === current) return;
4793
+ current?.detach(element);
4794
+ track.attach(element);
4795
+ current = track;
4796
+ };
4797
+ const onTrack = (...args) => {
4798
+ const who = args[args.length - 1];
4799
+ if (who?.identity === identity) sync();
4800
+ };
4801
+ sync();
4802
+ const events = trackEvents;
4803
+ if (events !== null) {
4804
+ target.on(events.subscribed, onTrack);
4805
+ target.on(events.localPublished, onTrack);
4806
+ }
4764
4807
  return () => {
4765
- track.detach(element);
4808
+ if (events !== null) {
4809
+ target.off(events.subscribed, onTrack);
4810
+ target.off(events.localPublished, onTrack);
4811
+ }
4812
+ current?.detach(element);
4813
+ current = null;
4766
4814
  };
4767
4815
  },
4768
4816
  activeDevices() {
@@ -6352,6 +6400,7 @@ function kindOf(person) {
6352
6400
  if (person.role === "host") return "host";
6353
6401
  if (person.role === "cohost") return "cohost";
6354
6402
  if (person.role === "guest") return person.userId !== null ? "signed-in guest" : "guest";
6403
+ if (person.userId === null) return "guest";
6355
6404
  return "member";
6356
6405
  }
6357
6406
  function ms(iso) {