@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.cjs CHANGED
@@ -4362,11 +4362,10 @@ function moderationText(kind, payload) {
4362
4362
  switch (kind) {
4363
4363
  case "muted": {
4364
4364
  const source = text2(payload["source"]) ?? "microphone";
4365
- const who = payload["by_role"] === "host" || payload["by_role"] === "cohost" ? "the host" : by;
4366
- 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}.`;
4365
+ return source === "microphone" ? `${by} muted you.` : source === "camera" ? `${by} turned off your camera.` : `${by} stopped your screen share.`;
4367
4366
  }
4368
4367
  case "ask-unmute":
4369
- return `${by === "The host" ? "The host" : by} asked you to unmute.`;
4368
+ return `${by} is asking you to unmute.`;
4370
4369
  case "removed":
4371
4370
  return `${by} removed you from this meeting.`;
4372
4371
  default:
@@ -4392,7 +4391,7 @@ function applyModeration(store, payload, now) {
4392
4391
  grants: { ...snapshot.grants, role },
4393
4392
  moderationNotice: {
4394
4393
  kind: "role",
4395
- 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.",
4394
+ 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.",
4396
4395
  at: now()
4397
4396
  }
4398
4397
  });
@@ -5652,7 +5651,10 @@ function createMeetingSession(options) {
5652
5651
  const meeting = store.snapshot().meeting;
5653
5652
  const pass = options.resolvePass?.() ?? null;
5654
5653
  if (meeting === null || pass === null) return;
5655
- if (policyReading) return policyInFlight ?? void 0;
5654
+ if (policyReading) {
5655
+ await (policyInFlight ?? void 0);
5656
+ return readLivePolicy();
5657
+ }
5656
5658
  policyReading = true;
5657
5659
  let done = () => void 0;
5658
5660
  policyInFlight = new Promise((resolve) => done = resolve);
@@ -5673,6 +5675,9 @@ function createMeetingSession(options) {
5673
5675
  if (!samePolicy(snapshot.livePolicy, next) || startedAt !== snapshot.sessionStartedAt) {
5674
5676
  store.patch({ livePolicy: next, sessionStartedAt: startedAt });
5675
5677
  }
5678
+ if (read.consent_given === true && !store.snapshot().recordingConsentGiven) {
5679
+ store.patch({ recordingConsentGiven: true });
5680
+ }
5676
5681
  } catch {
5677
5682
  } finally {
5678
5683
  policyReading = false;
@@ -5977,6 +5982,21 @@ function createMeetingSession(options) {
5977
5982
  stopWaiting,
5978
5983
  readState: readState2,
5979
5984
  readLivePolicy,
5985
+ async acknowledgeConsent() {
5986
+ const meeting = requireMeeting("meet.consent");
5987
+ const pass = options.resolvePass?.() ?? null;
5988
+ const response = await options.api.request({
5989
+ path: MEET_ROUTES.consent,
5990
+ method: "POST",
5991
+ requireAuth: false,
5992
+ operation: "meet.consent",
5993
+ body: { meeting_id: meeting.id },
5994
+ ...pass !== null ? { headers: { [MEETING_PASS_HEADER]: pass } } : {}
5995
+ });
5996
+ if (!response.ok) {
5997
+ throw new MeetError("transport", `meet.consent: the server answered ${response.status}`, "Your agreement was not saved. Try again.");
5998
+ }
5999
+ },
5980
6000
  async readExit(connection, held) {
5981
6001
  const meeting = store.snapshot().meeting;
5982
6002
  const pass = held ?? options.resolvePass?.() ?? null;
@@ -6848,7 +6868,9 @@ function createMediaSupervisor(options) {
6848
6868
  const deviceKind = INPUT_KIND[kind];
6849
6869
  const previous = inUse[deviceKind];
6850
6870
  const track = store.snapshot().media[kind];
6851
- const gone = previous !== null && !isAlias(previous) && before[deviceKind].has(previous) && !now[deviceKind].has(previous);
6871
+ const aliasLabel = previous !== null && isAlias(previous) ? before[deviceKind].get(previous) : void 0;
6872
+ const aliasGone = previous !== null && aliasLabel !== void 0 && aliasLabel !== "" && (!now[deviceKind].has(previous) || now[deviceKind].get(previous) !== aliasLabel);
6873
+ const gone = aliasGone || previous !== null && !isAlias(previous) && before[deviceKind].has(previous) && !now[deviceKind].has(previous);
6852
6874
  if (gone) {
6853
6875
  const from = before[deviceKind].get(previous) ?? "";
6854
6876
  const remaining = [...now[deviceKind].entries()].filter(([id]) => !isAlias(id));
@@ -6873,7 +6895,7 @@ function createMediaSupervisor(options) {
6873
6895
  await driver.setCameraEnabled(true);
6874
6896
  store.setLocalTrack("camera", { enabled: true, unavailable: null });
6875
6897
  }
6876
- setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, to: nextLabel } });
6898
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, fromId: previous, to: nextLabel } });
6877
6899
  } catch (error) {
6878
6900
  const refused = await unavailable(error, "camera", "meet.camera(fallback)");
6879
6901
  store.setLocalTrack("camera", { enabled: false, unavailable: refused });
@@ -6881,8 +6903,24 @@ function createMediaSupervisor(options) {
6881
6903
  }
6882
6904
  } else {
6883
6905
  const active = driver.activeDevices().audioinput;
6884
- const to = (active !== null ? now.audioinput.get(active) : void 0) ?? now.audioinput.get("default") ?? remaining[0][1];
6885
- setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, to } });
6906
+ let to = (active !== null && !aliasGone ? now.audioinput.get(active) : void 0) ?? now.audioinput.get("default");
6907
+ if (to === void 0 || aliasGone) {
6908
+ const [nextId, nextLabel] = remaining[0];
6909
+ try {
6910
+ await driver.switchDevice("audioinput", nextId);
6911
+ if (track.enabled || track.unavailable !== null) {
6912
+ await driver.setMicrophoneEnabled(true);
6913
+ store.setLocalTrack("microphone", { enabled: true, unavailable: null });
6914
+ }
6915
+ to = nextLabel;
6916
+ } catch (error) {
6917
+ const refused = await unavailable(error, "microphone", "meet.microphone(fallback)");
6918
+ store.setLocalTrack("microphone", { enabled: false, unavailable: refused });
6919
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "lost", from, to: null } });
6920
+ continue;
6921
+ }
6922
+ }
6923
+ setRegion({ notice: { id: ++noticeId, kind, outcome: "switched", from, fromId: previous, to } });
6886
6924
  }
6887
6925
  continue;
6888
6926
  }
@@ -6987,6 +7025,21 @@ function createMediaSupervisor(options) {
6987
7025
  },
6988
7026
  dismissNotice() {
6989
7027
  setRegion({ notice: null });
7028
+ },
7029
+ async undoNotice() {
7030
+ const notice = region().notice;
7031
+ setRegion({ notice: null });
7032
+ const driver = options.driver();
7033
+ if (notice === null || notice.outcome !== "switched" || notice.fromId === void 0 || driver === null) return;
7034
+ const list = await snapshotDevices();
7035
+ if (!list[INPUT_KIND[notice.kind]].has(notice.fromId)) return;
7036
+ try {
7037
+ await driver.switchDevice(INPUT_KIND[notice.kind], notice.fromId);
7038
+ readInUse();
7039
+ } catch (error) {
7040
+ const refused = await unavailable(error, notice.kind, "meet.undoDeviceSwitch");
7041
+ store.setLocalTrack(notice.kind, { enabled: false, unavailable: refused });
7042
+ }
6990
7043
  }
6991
7044
  };
6992
7045
  return api;
@@ -7201,7 +7254,14 @@ function createRoomEngine(options) {
7201
7254
  const latest = store.snapshot().meeting;
7202
7255
  if (latest === null) return;
7203
7256
  store.patch({ meeting: { ...latest, endedAt: verified.endedAt } });
7204
- store.dispatch({ type: "ended" }, { reason: "ended" });
7257
+ const connection = current?.connectionIdentity ?? current?.identity ?? store.snapshot().localIdentity ?? null;
7258
+ let why;
7259
+ try {
7260
+ why = options.readExit !== void 0 && connection !== null ? await options.readExit(connection, current?.meetingPass ?? null) : void 0;
7261
+ } catch {
7262
+ why = null;
7263
+ }
7264
+ store.dispatch({ type: "ended" }, { reason: why?.exitReason === "time_limit" ? "time_limit" : "ended" });
7205
7265
  await dropRoom();
7206
7266
  options.onLeft?.("ended");
7207
7267
  } catch (error) {
@@ -7973,6 +8033,7 @@ function createRoomEngine(options) {
7973
8033
  acceptDeviceOffer: () => media.acceptOffer(),
7974
8034
  dismissDeviceOffer: () => media.dismissOffer(),
7975
8035
  dismissDeviceNotice: () => media.dismissNotice(),
8036
+ undoDeviceNotice: () => media.undoNotice(),
7976
8037
  pin(who) {
7977
8038
  store.patch({ pinned: who, layout: who === null ? "grid" : "speaker" });
7978
8039
  },