@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.js CHANGED
@@ -5784,6 +5784,16 @@ var ALIVE_TOPIC = "mx.alive";
5784
5784
  function encodeBeat(beat) {
5785
5785
  return JSON.stringify({ q: beat.q, vp: beat.vp });
5786
5786
  }
5787
+ function encodeBye() {
5788
+ return JSON.stringify({ bye: true });
5789
+ }
5790
+ function isBye(payload) {
5791
+ try {
5792
+ return JSON.parse(payload).bye === true;
5793
+ } catch {
5794
+ return false;
5795
+ }
5796
+ }
5787
5797
  function decodeBeat(payload) {
5788
5798
  try {
5789
5799
  const raw = JSON.parse(payload);
@@ -6010,6 +6020,7 @@ function createRoomEngine(options) {
6010
6020
  const autoOff = createVideoAutoOff(() => connectionPolicy.videoAutoOffAfterPoorSeconds * 1e3, now);
6011
6021
  const lkQuality = /* @__PURE__ */ new Map();
6012
6022
  let silent = /* @__PURE__ */ new Set();
6023
+ const saidBye = /* @__PURE__ */ new Set();
6013
6024
  let healthTimer = null;
6014
6025
  let lastBeatAt = 0;
6015
6026
  let wasUnstable = false;
@@ -6040,6 +6051,7 @@ function createRoomEngine(options) {
6040
6051
  assessor.reset();
6041
6052
  autoOff.reset();
6042
6053
  silent = /* @__PURE__ */ new Set();
6054
+ saidBye.clear();
6043
6055
  lkQuality.clear();
6044
6056
  lastBeatAt = 0;
6045
6057
  wasUnstable = false;
@@ -6097,6 +6109,13 @@ function createRoomEngine(options) {
6097
6109
  await target?.disconnect();
6098
6110
  }
6099
6111
  async function leaveRoom() {
6112
+ const target = driver;
6113
+ if (target !== null && store.snapshot().phase === "in_call") {
6114
+ await Promise.race([
6115
+ target.publishData(ALIVE_TOPIC, encodeBye()).catch(() => void 0),
6116
+ new Promise((resolve) => setTimeout(resolve, 300))
6117
+ ]);
6118
+ }
6100
6119
  store.dispatch({ type: "leave" });
6101
6120
  await dropRoom();
6102
6121
  options.onLeft?.(null);
@@ -6192,8 +6211,6 @@ function createRoomEngine(options) {
6192
6211
  },
6193
6212
  participantLeft(who, reason) {
6194
6213
  departures.set(who, reason);
6195
- liveness.forget(who);
6196
- silent.delete(who);
6197
6214
  },
6198
6215
  roomMetadata(metadata) {
6199
6216
  let parsed = {};
@@ -6236,8 +6253,12 @@ function createRoomEngine(options) {
6236
6253
  const snap = store.snapshot();
6237
6254
  if (snap.phase !== "in_call" || snap.connection !== "stable") return;
6238
6255
  startHealth();
6256
+ const before = assessor.current();
6239
6257
  const quality = assessor.push(reading);
6240
6258
  const path = pathOf(reading);
6259
+ if (quality !== before) {
6260
+ report("info", `meet: this connection reads ${quality} (round trip ${reading.rttMs ?? "?"} ms, path ${path})`, "Diagnostic only.");
6261
+ }
6241
6262
  patchLocalNetwork({ quality, ...path !== "unknown" ? { path } : {} });
6242
6263
  refreshQualities();
6243
6264
  const cameraOn = snap.media.camera.enabled;
@@ -6252,6 +6273,11 @@ function createRoomEngine(options) {
6252
6273
  connectionState(state) {
6253
6274
  supervisor.driverState(state);
6254
6275
  if (state === "connected" && store.snapshot().phase === "joining") store.dispatch({ type: "connected" });
6276
+ if (state === "connected") {
6277
+ startHealth();
6278
+ lastBeatAt = 0;
6279
+ healthTick();
6280
+ }
6255
6281
  },
6256
6282
  transcription(event) {
6257
6283
  const snapshot = store.snapshot();
@@ -6343,6 +6369,10 @@ function createRoomEngine(options) {
6343
6369
  }
6344
6370
  const sender = personOf(from ?? "");
6345
6371
  if (from !== null) {
6372
+ if (topic === ALIVE_TOPIC && isBye(payload)) {
6373
+ saidBye.add(from);
6374
+ return;
6375
+ }
6346
6376
  const beat = topic === ALIVE_TOPIC ? decodeBeat(payload) : null;
6347
6377
  const before = liveness.reported(from);
6348
6378
  liveness.heard(from, beat);
@@ -6575,10 +6605,17 @@ function createRoomEngine(options) {
6575
6605
  const graceMs = connectionPolicy.reconnectGraceSeconds * 1e3;
6576
6606
  for (const [who, reason] of departures) {
6577
6607
  const last = previous.get(who);
6578
- if (last !== void 0 && !last.isLocal && !present.has(who) && graceMs > 0 && isUnannouncedDeparture(reason)) {
6608
+ const dropped = !saidBye.has(who) && (isUnannouncedDeparture(reason) || silent.has(who));
6609
+ report("info", `meet: ${who} left the room (${reason ?? "no reason"}${dropped ? ", held as reconnecting" : ""})`, "Diagnostic only.");
6610
+ if (last !== void 0 && !last.isLocal && !present.has(who) && graceMs > 0 && dropped) {
6579
6611
  ghosts.set(who, { participant: last, until: at + graceMs });
6580
6612
  }
6581
6613
  }
6614
+ for (const who of departures.keys()) {
6615
+ liveness.forget(who);
6616
+ silent.delete(who);
6617
+ saidBye.delete(who);
6618
+ }
6582
6619
  departures.clear();
6583
6620
  liveRoster = list;
6584
6621
  const localNow = list.find((p) => p.isLocal);