@ai-matrx/meet 0.11.51 → 0.11.52

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
@@ -6109,6 +6109,16 @@ var ALIVE_TOPIC = "mx.alive";
6109
6109
  function encodeBeat(beat) {
6110
6110
  return JSON.stringify({ q: beat.q, vp: beat.vp });
6111
6111
  }
6112
+ function encodeBye() {
6113
+ return JSON.stringify({ bye: true });
6114
+ }
6115
+ function isBye(payload) {
6116
+ try {
6117
+ return JSON.parse(payload).bye === true;
6118
+ } catch {
6119
+ return false;
6120
+ }
6121
+ }
6112
6122
  function decodeBeat(payload) {
6113
6123
  try {
6114
6124
  const raw = JSON.parse(payload);
@@ -6335,6 +6345,7 @@ function createRoomEngine(options) {
6335
6345
  const autoOff = createVideoAutoOff(() => connectionPolicy.videoAutoOffAfterPoorSeconds * 1e3, now);
6336
6346
  const lkQuality = /* @__PURE__ */ new Map();
6337
6347
  let silent = /* @__PURE__ */ new Set();
6348
+ const saidBye = /* @__PURE__ */ new Set();
6338
6349
  let healthTimer = null;
6339
6350
  let lastBeatAt = 0;
6340
6351
  let wasUnstable = false;
@@ -6365,6 +6376,7 @@ function createRoomEngine(options) {
6365
6376
  assessor.reset();
6366
6377
  autoOff.reset();
6367
6378
  silent = /* @__PURE__ */ new Set();
6379
+ saidBye.clear();
6368
6380
  lkQuality.clear();
6369
6381
  lastBeatAt = 0;
6370
6382
  wasUnstable = false;
@@ -6422,6 +6434,13 @@ function createRoomEngine(options) {
6422
6434
  await target?.disconnect();
6423
6435
  }
6424
6436
  async function leaveRoom() {
6437
+ const target = driver;
6438
+ if (target !== null && store.snapshot().phase === "in_call") {
6439
+ await Promise.race([
6440
+ target.publishData(ALIVE_TOPIC, encodeBye()).catch(() => void 0),
6441
+ new Promise((resolve) => setTimeout(resolve, 300))
6442
+ ]);
6443
+ }
6425
6444
  store.dispatch({ type: "leave" });
6426
6445
  await dropRoom();
6427
6446
  options.onLeft?.(null);
@@ -6517,8 +6536,6 @@ function createRoomEngine(options) {
6517
6536
  },
6518
6537
  participantLeft(who, reason) {
6519
6538
  departures.set(who, reason);
6520
- liveness.forget(who);
6521
- silent.delete(who);
6522
6539
  },
6523
6540
  roomMetadata(metadata) {
6524
6541
  let parsed = {};
@@ -6561,8 +6578,12 @@ function createRoomEngine(options) {
6561
6578
  const snap = store.snapshot();
6562
6579
  if (snap.phase !== "in_call" || snap.connection !== "stable") return;
6563
6580
  startHealth();
6581
+ const before = assessor.current();
6564
6582
  const quality = assessor.push(reading);
6565
6583
  const path = pathOf(reading);
6584
+ if (quality !== before) {
6585
+ report("info", `meet: this connection reads ${quality} (round trip ${reading.rttMs ?? "?"} ms, path ${path})`, "Diagnostic only.");
6586
+ }
6566
6587
  patchLocalNetwork({ quality, ...path !== "unknown" ? { path } : {} });
6567
6588
  refreshQualities();
6568
6589
  const cameraOn = snap.media.camera.enabled;
@@ -6577,6 +6598,11 @@ function createRoomEngine(options) {
6577
6598
  connectionState(state) {
6578
6599
  supervisor.driverState(state);
6579
6600
  if (state === "connected" && store.snapshot().phase === "joining") store.dispatch({ type: "connected" });
6601
+ if (state === "connected") {
6602
+ startHealth();
6603
+ lastBeatAt = 0;
6604
+ healthTick();
6605
+ }
6580
6606
  },
6581
6607
  transcription(event) {
6582
6608
  const snapshot = store.snapshot();
@@ -6668,6 +6694,10 @@ function createRoomEngine(options) {
6668
6694
  }
6669
6695
  const sender = personOf(from ?? "");
6670
6696
  if (from !== null) {
6697
+ if (topic === ALIVE_TOPIC && isBye(payload)) {
6698
+ saidBye.add(from);
6699
+ return;
6700
+ }
6671
6701
  const beat = topic === ALIVE_TOPIC ? decodeBeat(payload) : null;
6672
6702
  const before = liveness.reported(from);
6673
6703
  liveness.heard(from, beat);
@@ -6900,10 +6930,17 @@ function createRoomEngine(options) {
6900
6930
  const graceMs = connectionPolicy.reconnectGraceSeconds * 1e3;
6901
6931
  for (const [who, reason] of departures) {
6902
6932
  const last = previous.get(who);
6903
- if (last !== void 0 && !last.isLocal && !present.has(who) && graceMs > 0 && isUnannouncedDeparture(reason)) {
6933
+ const dropped = !saidBye.has(who) && (isUnannouncedDeparture(reason) || silent.has(who));
6934
+ report("info", `meet: ${who} left the room (${reason ?? "no reason"}${dropped ? ", held as reconnecting" : ""})`, "Diagnostic only.");
6935
+ if (last !== void 0 && !last.isLocal && !present.has(who) && graceMs > 0 && dropped) {
6904
6936
  ghosts.set(who, { participant: last, until: at + graceMs });
6905
6937
  }
6906
6938
  }
6939
+ for (const who of departures.keys()) {
6940
+ liveness.forget(who);
6941
+ silent.delete(who);
6942
+ saidBye.delete(who);
6943
+ }
6907
6944
  departures.clear();
6908
6945
  liveRoster = list;
6909
6946
  const localNow = list.find((p) => p.isLocal);