@ai-matrx/meet 0.11.49 → 0.11.50

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
@@ -4078,11 +4078,10 @@ function moderationText(kind, payload) {
4078
4078
  switch (kind) {
4079
4079
  case "muted": {
4080
4080
  const source = text2(payload["source"]) ?? "microphone";
4081
- const who = payload["by_role"] === "host" || payload["by_role"] === "cohost" ? "the host" : by;
4082
- return source === "microphone" ? `You've been muted by ${who}.` : source === "camera" ? `Your camera was turned off by ${who}.` : `Your screen share was stopped by ${who}.`;
4081
+ return source === "microphone" ? `${by} muted you.` : source === "camera" ? `${by} turned off your camera.` : `${by} stopped your screen share.`;
4083
4082
  }
4084
4083
  case "ask-unmute":
4085
- return `${by === "The host" ? "The host" : by} asked you to unmute.`;
4084
+ return `${by} is asking you to unmute.`;
4086
4085
  case "removed":
4087
4086
  return `${by} removed you from this meeting.`;
4088
4087
  default:
@@ -4108,7 +4107,7 @@ function applyModeration(store, payload, now) {
4108
4107
  grants: { ...snapshot.grants, role },
4109
4108
  moderationNotice: {
4110
4109
  kind: "role",
4111
- text: role === "host" ? "You are now the host." : role === "cohost" ? "You're now a co-host." : role === "presenter" ? "You're now a presenter." : snapshot.grants.role === "presenter" ? "You're now a participant: you can no longer present." : "You're now a participant: you are no longer a co-host.",
4110
+ text: role === "host" ? "You are now the host." : role === "cohost" ? "You are now a co-host." : role === "presenter" ? "You are now a presenter." : snapshot.grants.role === "presenter" ? "You are now a participant: you can no longer present." : "You are no longer a co-host.",
4112
4111
  at: now()
4113
4112
  }
4114
4113
  });
@@ -5368,7 +5367,10 @@ function createMeetingSession(options) {
5368
5367
  const meeting = store.snapshot().meeting;
5369
5368
  const pass = options.resolvePass?.() ?? null;
5370
5369
  if (meeting === null || pass === null) return;
5371
- if (policyReading) return policyInFlight ?? void 0;
5370
+ if (policyReading) {
5371
+ await (policyInFlight ?? void 0);
5372
+ return readLivePolicy();
5373
+ }
5372
5374
  policyReading = true;
5373
5375
  let done = () => void 0;
5374
5376
  policyInFlight = new Promise((resolve) => done = resolve);
@@ -5389,6 +5391,9 @@ function createMeetingSession(options) {
5389
5391
  if (!samePolicy(snapshot.livePolicy, next) || startedAt !== snapshot.sessionStartedAt) {
5390
5392
  store.patch({ livePolicy: next, sessionStartedAt: startedAt });
5391
5393
  }
5394
+ if (read.consent_given === true && !store.snapshot().recordingConsentGiven) {
5395
+ store.patch({ recordingConsentGiven: true });
5396
+ }
5392
5397
  } catch {
5393
5398
  } finally {
5394
5399
  policyReading = false;
@@ -5693,6 +5698,21 @@ function createMeetingSession(options) {
5693
5698
  stopWaiting,
5694
5699
  readState: readState2,
5695
5700
  readLivePolicy,
5701
+ async acknowledgeConsent() {
5702
+ const meeting = requireMeeting("meet.consent");
5703
+ const pass = options.resolvePass?.() ?? null;
5704
+ const response = await options.api.request({
5705
+ path: MEET_ROUTES.consent,
5706
+ method: "POST",
5707
+ requireAuth: false,
5708
+ operation: "meet.consent",
5709
+ body: { meeting_id: meeting.id },
5710
+ ...pass !== null ? { headers: { [MEETING_PASS_HEADER]: pass } } : {}
5711
+ });
5712
+ if (!response.ok) {
5713
+ throw new MeetError("transport", `meet.consent: the server answered ${response.status}`, "Your agreement was not saved. Try again.");
5714
+ }
5715
+ },
5696
5716
  async readExit(connection, held) {
5697
5717
  const meeting = store.snapshot().meeting;
5698
5718
  const pass = held ?? options.resolvePass?.() ?? null;
@@ -6564,7 +6584,9 @@ function createMediaSupervisor(options) {
6564
6584
  const deviceKind = INPUT_KIND[kind];
6565
6585
  const previous = inUse[deviceKind];
6566
6586
  const track = store.snapshot().media[kind];
6567
- const gone = previous !== null && !isAlias(previous) && before[deviceKind].has(previous) && !now[deviceKind].has(previous);
6587
+ const aliasLabel = previous !== null && isAlias(previous) ? before[deviceKind].get(previous) : void 0;
6588
+ const aliasGone = previous !== null && aliasLabel !== void 0 && aliasLabel !== "" && (!now[deviceKind].has(previous) || now[deviceKind].get(previous) !== aliasLabel);
6589
+ const gone = aliasGone || previous !== null && !isAlias(previous) && before[deviceKind].has(previous) && !now[deviceKind].has(previous);
6568
6590
  if (gone) {
6569
6591
  const from = before[deviceKind].get(previous) ?? "";
6570
6592
  const remaining = [...now[deviceKind].entries()].filter(([id]) => !isAlias(id));
@@ -6589,7 +6611,7 @@ function createMediaSupervisor(options) {
6589
6611
  await driver.setCameraEnabled(true);
6590
6612
  store.setLocalTrack("camera", { enabled: true, unavailable: null });
6591
6613
  }
6592
- setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, to: nextLabel } });
6614
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, fromId: previous, to: nextLabel } });
6593
6615
  } catch (error) {
6594
6616
  const refused = await unavailable(error, "camera", "meet.camera(fallback)");
6595
6617
  store.setLocalTrack("camera", { enabled: false, unavailable: refused });
@@ -6597,8 +6619,24 @@ function createMediaSupervisor(options) {
6597
6619
  }
6598
6620
  } else {
6599
6621
  const active = driver.activeDevices().audioinput;
6600
- const to = (active !== null ? now.audioinput.get(active) : void 0) ?? now.audioinput.get("default") ?? remaining[0][1];
6601
- setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, to } });
6622
+ let to = (active !== null && !aliasGone ? now.audioinput.get(active) : void 0) ?? now.audioinput.get("default");
6623
+ if (to === void 0 || aliasGone) {
6624
+ const [nextId, nextLabel] = remaining[0];
6625
+ try {
6626
+ await driver.switchDevice("audioinput", nextId);
6627
+ if (track.enabled || track.unavailable !== null) {
6628
+ await driver.setMicrophoneEnabled(true);
6629
+ store.setLocalTrack("microphone", { enabled: true, unavailable: null });
6630
+ }
6631
+ to = nextLabel;
6632
+ } catch (error) {
6633
+ const refused = await unavailable(error, "microphone", "meet.microphone(fallback)");
6634
+ store.setLocalTrack("microphone", { enabled: false, unavailable: refused });
6635
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "lost", from, to: null } });
6636
+ continue;
6637
+ }
6638
+ }
6639
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, fromId: previous, to } });
6602
6640
  }
6603
6641
  continue;
6604
6642
  }
@@ -6703,6 +6741,21 @@ function createMediaSupervisor(options) {
6703
6741
  },
6704
6742
  dismissNotice() {
6705
6743
  setRegion({ notice: null });
6744
+ },
6745
+ async undoNotice() {
6746
+ const notice = region().notice;
6747
+ setRegion({ notice: null });
6748
+ const driver = options.driver();
6749
+ if (notice === null || notice.outcome !== "switched" || notice.fromId === void 0 || driver === null) return;
6750
+ const list = await snapshotDevices();
6751
+ if (!list[INPUT_KIND[notice.kind]].has(notice.fromId)) return;
6752
+ try {
6753
+ await driver.switchDevice(INPUT_KIND[notice.kind], notice.fromId);
6754
+ readInUse();
6755
+ } catch (error) {
6756
+ const refused = await unavailable(error, notice.kind, "meet.undoDeviceSwitch");
6757
+ store.setLocalTrack(notice.kind, { enabled: false, unavailable: refused });
6758
+ }
6706
6759
  }
6707
6760
  };
6708
6761
  return api;
@@ -6917,7 +6970,14 @@ function createRoomEngine(options) {
6917
6970
  const latest = store.snapshot().meeting;
6918
6971
  if (latest === null) return;
6919
6972
  store.patch({ meeting: { ...latest, endedAt: verified.endedAt } });
6920
- store.dispatch({ type: "ended" }, { reason: "ended" });
6973
+ const connection = current?.connectionIdentity ?? current?.identity ?? store.snapshot().localIdentity ?? null;
6974
+ let why;
6975
+ try {
6976
+ why = options.readExit !== void 0 && connection !== null ? await options.readExit(connection, current?.meetingPass ?? null) : void 0;
6977
+ } catch {
6978
+ why = null;
6979
+ }
6980
+ store.dispatch({ type: "ended" }, { reason: why?.exitReason === "time_limit" ? "time_limit" : "ended" });
6921
6981
  await dropRoom();
6922
6982
  options.onLeft?.("ended");
6923
6983
  } catch (error) {
@@ -7689,6 +7749,7 @@ function createRoomEngine(options) {
7689
7749
  acceptDeviceOffer: () => media.acceptOffer(),
7690
7750
  dismissDeviceOffer: () => media.dismissOffer(),
7691
7751
  dismissDeviceNotice: () => media.dismissNotice(),
7752
+ undoDeviceNotice: () => media.undoNotice(),
7692
7753
  pin(who) {
7693
7754
  store.patch({ pinned: who, layout: who === null ? "grid" : "speaker" });
7694
7755
  },