@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.js CHANGED
@@ -4322,6 +4322,15 @@ function createLiveKitDriver(handlers, options = {}) {
4322
4322
  handlers.participants([local, ...remotes]);
4323
4323
  };
4324
4324
  projectRoster = roster;
4325
+ created.on(RoomEvent.TrackSubscribed, (track) => {
4326
+ if (track.kind !== Track.Kind.Audio || typeof document === "undefined") return;
4327
+ const element = track.attach();
4328
+ element.setAttribute("data-mx-meet-audio", "");
4329
+ audioSink().appendChild(element);
4330
+ }).on(RoomEvent.TrackUnsubscribed, (track) => {
4331
+ if (track.kind !== Track.Kind.Audio) return;
4332
+ for (const element of track.detach()) element.remove();
4333
+ });
4325
4334
  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) => {
4326
4335
  handlers.roomMetadata?.(metadata ?? "");
4327
4336
  }).on(RoomEvent.ActiveSpeakersChanged, (speakers) => {
@@ -4337,6 +4346,8 @@ function createLiveKitDriver(handlers, options = {}) {
4337
4346
  participant?.identity ?? null
4338
4347
  );
4339
4348
  }).on(RoomEvent.Disconnected, (reason) => {
4349
+ audioContainer?.remove();
4350
+ audioContainer = null;
4340
4351
  handlers.disconnected(reason === void 0 ? null : String(reason));
4341
4352
  });
4342
4353
  try {
@@ -4378,10 +4389,26 @@ function createLiveKitDriver(handlers, options = {}) {
4378
4389
  microphone: Track.Source.Microphone,
4379
4390
  screen: Track.Source.ScreenShare
4380
4391
  };
4392
+ trackEvents = {
4393
+ subscribed: RoomEvent.TrackSubscribed,
4394
+ localPublished: RoomEvent.LocalTrackPublished
4395
+ };
4381
4396
  room = created;
4382
4397
  return created;
4383
4398
  }
4384
4399
  let sources = null;
4400
+ let trackEvents = null;
4401
+ let audioContainer = null;
4402
+ function audioSink() {
4403
+ if (audioContainer !== null && audioContainer.isConnected) return audioContainer;
4404
+ const container = document.createElement("div");
4405
+ container.setAttribute("data-mx-meet-audio-sink", "");
4406
+ container.setAttribute("aria-hidden", "true");
4407
+ container.style.display = "none";
4408
+ document.body.appendChild(container);
4409
+ audioContainer = container;
4410
+ return container;
4411
+ }
4385
4412
  function requireRoom(operation) {
4386
4413
  if (room === null) {
4387
4414
  throw new MeetError(
@@ -4412,6 +4439,8 @@ function createLiveKitDriver(handlers, options = {}) {
4412
4439
  } catch {
4413
4440
  }
4414
4441
  projectRoster = null;
4442
+ audioContainer?.remove();
4443
+ audioContainer = null;
4415
4444
  await target.disconnect();
4416
4445
  },
4417
4446
  async setMicrophoneEnabled(enabled) {
@@ -4477,14 +4506,33 @@ function createLiveKitDriver(handlers, options = {}) {
4477
4506
  attach(identity, kind, element) {
4478
4507
  const target = requireRoom("attach");
4479
4508
  const source = sources?.[kind];
4480
- const participant = target.localParticipant.identity === identity ? target.localParticipant : target.remoteParticipants.get(identity);
4481
- if (participant === void 0 || source === void 0) return () => void 0;
4482
- const publication = participant.getTrackPublication(source);
4483
- const track = publication?.track;
4484
- if (track === void 0) return () => void 0;
4485
- track.attach(element);
4509
+ if (source === void 0) return () => void 0;
4510
+ let current = null;
4511
+ const sync = () => {
4512
+ const participant = target.localParticipant.identity === identity ? target.localParticipant : target.remoteParticipants.get(identity);
4513
+ const track = participant?.getTrackPublication(source)?.track;
4514
+ if (track === void 0 || track === current) return;
4515
+ current?.detach(element);
4516
+ track.attach(element);
4517
+ current = track;
4518
+ };
4519
+ const onTrack = (...args) => {
4520
+ const who = args[args.length - 1];
4521
+ if (who?.identity === identity) sync();
4522
+ };
4523
+ sync();
4524
+ const events = trackEvents;
4525
+ if (events !== null) {
4526
+ target.on(events.subscribed, onTrack);
4527
+ target.on(events.localPublished, onTrack);
4528
+ }
4486
4529
  return () => {
4487
- track.detach(element);
4530
+ if (events !== null) {
4531
+ target.off(events.subscribed, onTrack);
4532
+ target.off(events.localPublished, onTrack);
4533
+ }
4534
+ current?.detach(element);
4535
+ current = null;
4488
4536
  };
4489
4537
  },
4490
4538
  activeDevices() {
@@ -6074,6 +6122,7 @@ function kindOf(person) {
6074
6122
  if (person.role === "host") return "host";
6075
6123
  if (person.role === "cohost") return "cohost";
6076
6124
  if (person.role === "guest") return person.userId !== null ? "signed-in guest" : "guest";
6125
+ if (person.userId === null) return "guest";
6077
6126
  return "member";
6078
6127
  }
6079
6128
  function ms(iso) {