@ai-matrx/meet 0.11.52 → 0.11.54

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
@@ -3333,6 +3333,10 @@ function personOf(identity) {
3333
3333
  const cut = value.indexOf(CONNECTION_SEPARATOR);
3334
3334
  return cut === -1 ? value : value.slice(0, cut);
3335
3335
  }
3336
+ function userIdOfIdentity(identity) {
3337
+ const person = personOf(identity);
3338
+ return person.startsWith("user:") ? person.slice("user:".length) : null;
3339
+ }
3336
3340
  function isGuestIdentity(identity) {
3337
3341
  return personOf(identity).startsWith("guest:");
3338
3342
  }
@@ -3551,6 +3555,7 @@ function consentPending(policy, role, recordingOn, given) {
3551
3555
  function mayAdmitNow(role, participants, policy) {
3552
3556
  if (role === "none") return false;
3553
3557
  if (role === "host" || role === "cohost") return true;
3558
+ if (role === "viewer") return false;
3554
3559
  const hostIn = participants.some((p) => p.role === "host" || p.role === "cohost");
3555
3560
  return !hostIn && policy.headlessPowers === "members_admit";
3556
3561
  }
@@ -4637,21 +4642,35 @@ function heartbeatIntervalMs(roomSize) {
4637
4642
  function staleAfterMs(roomSize) {
4638
4643
  return heartbeatIntervalMs(roomSize) * 3 + 1e3;
4639
4644
  }
4645
+ function firstBeatAllowanceMs(roomSize) {
4646
+ return staleAfterMs(roomSize) * 2;
4647
+ }
4640
4648
  function createLivenessTracker(now) {
4641
4649
  const lastHeard = /* @__PURE__ */ new Map();
4650
+ const firstSeen = /* @__PURE__ */ new Map();
4642
4651
  const beats = /* @__PURE__ */ new Map();
4643
4652
  return {
4644
4653
  heard(who, beat) {
4645
4654
  lastHeard.set(who, now());
4655
+ firstSeen.delete(who);
4646
4656
  if (beat !== null) beats.set(who, beat);
4647
4657
  },
4658
+ expect(who) {
4659
+ if (!lastHeard.has(who) && !firstSeen.has(who)) firstSeen.set(who, now());
4660
+ },
4648
4661
  stale(present, roomSize) {
4649
4662
  const limit = staleAfterMs(roomSize);
4663
+ const firstLimit = firstBeatAllowanceMs(roomSize);
4650
4664
  const at = now();
4651
4665
  const out = /* @__PURE__ */ new Set();
4652
4666
  for (const who of present) {
4653
4667
  const heard = lastHeard.get(who);
4654
- if (heard !== void 0 && at - heard > limit) out.add(who);
4668
+ if (heard !== void 0) {
4669
+ if (at - heard > limit) out.add(who);
4670
+ continue;
4671
+ }
4672
+ const seen = firstSeen.get(who);
4673
+ if (seen !== void 0 && at - seen > firstLimit) out.add(who);
4655
4674
  }
4656
4675
  return out;
4657
4676
  },
@@ -4659,13 +4678,16 @@ function createLivenessTracker(now) {
4659
4678
  restartClock() {
4660
4679
  const at = now();
4661
4680
  for (const who of lastHeard.keys()) lastHeard.set(who, at);
4681
+ for (const who of firstSeen.keys()) firstSeen.set(who, at);
4662
4682
  },
4663
4683
  forget(who) {
4664
4684
  lastHeard.delete(who);
4685
+ firstSeen.delete(who);
4665
4686
  beats.delete(who);
4666
4687
  },
4667
4688
  clear() {
4668
4689
  lastHeard.clear();
4690
+ firstSeen.clear();
4669
4691
  beats.clear();
4670
4692
  }
4671
4693
  };
@@ -5255,6 +5277,17 @@ function createMeetingSession(options) {
5255
5277
  }
5256
5278
  return identity.userId;
5257
5279
  }
5280
+ function requireAdmitterUser(operation) {
5281
+ const snapshot = store.snapshot();
5282
+ if (identity.userId === null || !mayAdmitNow(effectiveRole(snapshot), snapshot.participants, snapshot.livePolicy)) {
5283
+ throw new MeetError(
5284
+ "forbidden",
5285
+ `${operation}: this participant may not let people in`,
5286
+ "Only a host or co-host admits people, unless the meeting has no host in it and lets members admit."
5287
+ );
5288
+ }
5289
+ return identity.userId;
5290
+ }
5258
5291
  function requireMeeting(operation) {
5259
5292
  const meeting = store.snapshot().meeting;
5260
5293
  if (meeting === null) {
@@ -5661,7 +5694,7 @@ function createMeetingSession(options) {
5661
5694
  meetingChannel.requestBackfill("manual");
5662
5695
  },
5663
5696
  async admit(entry, admitted) {
5664
- const by = requireHostUser("meet.admit");
5697
+ const by = requireAdmitterUser("meet.admit");
5665
5698
  const meeting = requireMeeting("meet.admit");
5666
5699
  const row = await repository.decideAdmission({
5667
5700
  meetingId: meeting.id,
@@ -5679,7 +5712,7 @@ function createMeetingSession(options) {
5679
5712
  hint();
5680
5713
  },
5681
5714
  async undeny(entry) {
5682
- const by = requireHostUser("meet.undeny");
5715
+ const by = requireAdmitterUser("meet.undeny");
5683
5716
  const meeting = requireMeeting("meet.undeny");
5684
5717
  const row = await repository.decideAdmission({
5685
5718
  meetingId: meeting.id,
@@ -5692,7 +5725,7 @@ function createMeetingSession(options) {
5692
5725
  hint();
5693
5726
  },
5694
5727
  async admitAll() {
5695
- const by = requireHostUser("meet.admitAll");
5728
+ const by = requireAdmitterUser("meet.admitAll");
5696
5729
  const meeting = requireMeeting("meet.admitAll");
5697
5730
  const rows = await repository.admitAll(meeting.id, by);
5698
5731
  for (const row of rows) {
@@ -7454,6 +7487,13 @@ function createRoomEngine(options) {
7454
7487
  const previous = new Map(liveRoster.map((p) => [p.identity, p]));
7455
7488
  const present = new Set(list.map((p) => p.identity));
7456
7489
  const graceMs = connectionPolicy.reconnectGraceSeconds * 1e3;
7490
+ if (store.snapshot().phase === "in_call") {
7491
+ for (const [who, last] of previous) {
7492
+ if (last.isLocal || present.has(who) || departures.has(who)) continue;
7493
+ departures.set(who, null);
7494
+ report("warn", `meet: ${who} vanished from the room's roster with no departure event; held as reconnecting`, "The media layer dropped a participant silently; the tile is kept for the reconnect grace.");
7495
+ }
7496
+ }
7457
7497
  for (const [who, reason] of departures) {
7458
7498
  const last = previous.get(who);
7459
7499
  const dropped = !saidBye.has(who) && (isUnannouncedDeparture(reason) || silent.has(who));
@@ -7469,6 +7509,9 @@ function createRoomEngine(options) {
7469
7509
  }
7470
7510
  departures.clear();
7471
7511
  liveRoster = list;
7512
+ for (const p of list) {
7513
+ if (!p.isLocal && (isGuestIdentity(p.identity) || userIdOfIdentity(p.identity) !== null)) liveness.expect(p.identity);
7514
+ }
7472
7515
  const localNow = list.find((p) => p.isLocal);
7473
7516
  if (localNow !== void 0 && !localNow.screenSharing && store.snapshot().share.state === "presenting") {
7474
7517
  store.patch({ share: NO_SHARE });
@@ -7489,7 +7532,7 @@ function createRoomEngine(options) {
7489
7532
  store.setParticipants(
7490
7533
  [...people.values()].map(({ entry }) => {
7491
7534
  const projected = projectParticipant(entry, joinedAt);
7492
- if (entry.reconnecting === true || !entry.isLocal && silent.has(entry.identity)) {
7535
+ if (entry.reconnecting === true || !entry.isLocal && silent.has(entry.identity) && !saidBye.has(entry.identity)) {
7493
7536
  return { ...projected, reconnecting: true, quality: "lost" };
7494
7537
  }
7495
7538
  const videoPaused = entry.isLocal ? store.snapshot().localNetwork.videoPaused : liveness.reported(entry.identity)?.vp === true;