@ai-matrx/meet 0.7.80 → 0.7.82

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.d.cts CHANGED
@@ -796,10 +796,10 @@ declare function unavailableFrom(error: MeetError): MediaUnavailable;
796
796
  */
797
797
  declare const LISTEN_ONLY_NOTICE = "You're attending without a microphone \u2014 others can't hear you";
798
798
  /**
799
- * True when this participant is in the room and publishing no microphone —
800
- * whether the device was refused or simply turned off. Both are listen-only,
801
- * and both deserve the same honest line; only the REMEDY differs, and that
802
- * comes from `media.microphone.unavailable`.
799
+ * True when this participant is in the room with NO USABLE microphone — the
800
+ * device was refused or is missing. A person who simply muted themselves has a
801
+ * working microphone and is not "attending without" one, so a mute never
802
+ * counts: `unavailable` is the only signal.
803
803
  */
804
804
  declare function isListenOnly(media: LocalMediaState): boolean;
805
805
  /**
@@ -2408,6 +2408,8 @@ interface MeetRoomDriver {
2408
2408
  setVideoEffect?(effect: VideoEffect): Promise<void>;
2409
2409
  /** Whether this browser can run background effects at all. */
2410
2410
  supportsVideoEffects?(): boolean;
2411
+ /** Whether this browser can share a screen at all (iOS cannot). Absent = assume yes. */
2412
+ supportsScreenShare?(): boolean;
2411
2413
  /**
2412
2414
  * Attach a participant's track to a media element. Returns the detach
2413
2415
  * function — returning it (rather than exposing `detach`) is what makes a
@@ -3463,6 +3465,8 @@ interface RoomEngine {
3463
3465
  setEffects(next: Partial<MediaEffects>): Promise<void>;
3464
3466
  /** Whether this browser can run a background effect at all (absent, never dead). */
3465
3467
  supportsVideoEffects(): boolean;
3468
+ /** Whether this browser can share a screen at all — the control is ABSENT where it cannot. */
3469
+ supportsScreenShare(): boolean;
3466
3470
  /** Choose the speaker (audio output) for this meeting. */
3467
3471
  switchDevice(kind: "audioinput" | "videoinput" | "audiooutput", deviceId: string): Promise<void>;
3468
3472
  pin(identity: ParticipantIdentity | null): void;
package/dist/index.d.ts CHANGED
@@ -796,10 +796,10 @@ declare function unavailableFrom(error: MeetError): MediaUnavailable;
796
796
  */
797
797
  declare const LISTEN_ONLY_NOTICE = "You're attending without a microphone \u2014 others can't hear you";
798
798
  /**
799
- * True when this participant is in the room and publishing no microphone —
800
- * whether the device was refused or simply turned off. Both are listen-only,
801
- * and both deserve the same honest line; only the REMEDY differs, and that
802
- * comes from `media.microphone.unavailable`.
799
+ * True when this participant is in the room with NO USABLE microphone — the
800
+ * device was refused or is missing. A person who simply muted themselves has a
801
+ * working microphone and is not "attending without" one, so a mute never
802
+ * counts: `unavailable` is the only signal.
803
803
  */
804
804
  declare function isListenOnly(media: LocalMediaState): boolean;
805
805
  /**
@@ -2408,6 +2408,8 @@ interface MeetRoomDriver {
2408
2408
  setVideoEffect?(effect: VideoEffect): Promise<void>;
2409
2409
  /** Whether this browser can run background effects at all. */
2410
2410
  supportsVideoEffects?(): boolean;
2411
+ /** Whether this browser can share a screen at all (iOS cannot). Absent = assume yes. */
2412
+ supportsScreenShare?(): boolean;
2411
2413
  /**
2412
2414
  * Attach a participant's track to a media element. Returns the detach
2413
2415
  * function — returning it (rather than exposing `detach`) is what makes a
@@ -3463,6 +3465,8 @@ interface RoomEngine {
3463
3465
  setEffects(next: Partial<MediaEffects>): Promise<void>;
3464
3466
  /** Whether this browser can run a background effect at all (absent, never dead). */
3465
3467
  supportsVideoEffects(): boolean;
3468
+ /** Whether this browser can share a screen at all — the control is ABSENT where it cannot. */
3469
+ supportsScreenShare(): boolean;
3466
3470
  /** Choose the speaker (audio output) for this meeting. */
3467
3471
  switchDevice(kind: "audioinput" | "videoinput" | "audiooutput", deviceId: string): Promise<void>;
3468
3472
  pin(identity: ParticipantIdentity | null): void;
package/dist/index.js CHANGED
@@ -139,6 +139,55 @@ function normalizeDeviceError(error, operation) {
139
139
  );
140
140
  }
141
141
  }
142
+ var SYSTEM_BLOCK = /by system|permissions?[- ]policy|display-capture|disallowed|not allowed by the system/i;
143
+ function classifyScreenShareError(error) {
144
+ const read = (value, key) => {
145
+ const v = value?.[key];
146
+ return typeof v === "string" ? v : "";
147
+ };
148
+ const cause = error instanceof MeetError ? error.cause : void 0;
149
+ const denied = [error, cause].some((value) => {
150
+ const name = read(value, "name");
151
+ return name === "NotAllowedError" || name === "AbortError" || name === "SecurityError";
152
+ });
153
+ if (denied) {
154
+ const text3 = [read(error, "message"), read(cause, "message")].join(" ");
155
+ return SYSTEM_BLOCK.test(text3) || [error, cause].some((v) => read(v, "name") === "SecurityError") ? "blocked" : "ambiguous";
156
+ }
157
+ if (error instanceof MeetError && error.code === "permission-denied" && cause === void 0) {
158
+ return "ambiguous";
159
+ }
160
+ return "other";
161
+ }
162
+ var SCREEN_SHARE_BLOCKED_REMEDY = "Your browser or computer is blocking screen sharing. On a Mac, open System Settings > Privacy & Security > Screen Recording, turn it on for your browser, then restart the browser. On a work computer, ask your administrator. You are still in the call.";
163
+ function normalizeScreenShareError(error, operation) {
164
+ if (error instanceof MeetError) return error;
165
+ const raw = error ?? {};
166
+ const message = typeof raw.message === "string" ? raw.message : String(error);
167
+ const kind = classifyScreenShareError(error);
168
+ if (kind === "blocked") {
169
+ return new MeetError(
170
+ "permission-denied",
171
+ `${operation}: screen sharing is blocked (${message})`,
172
+ SCREEN_SHARE_BLOCKED_REMEDY,
173
+ error
174
+ );
175
+ }
176
+ if (kind === "ambiguous") {
177
+ return new MeetError(
178
+ "permission-denied",
179
+ `${operation}: screen sharing was cancelled or refused`,
180
+ "Choose a screen, window or tab in the picker to share it. If no picker appeared, " + SCREEN_SHARE_BLOCKED_REMEDY,
181
+ error
182
+ );
183
+ }
184
+ return new MeetError(
185
+ "media-unsupported",
186
+ `${operation}: screen sharing is not available (${message})`,
187
+ "This browser or device could not share a screen. You are still in the call; try a desktop browser to present.",
188
+ error
189
+ );
190
+ }
142
191
  function invalidResponse(operation, detail) {
143
192
  return new MeetError(
144
193
  "invalid-response",
@@ -2602,7 +2651,7 @@ function unavailableFrom(error) {
2602
2651
  }
2603
2652
  var LISTEN_ONLY_NOTICE = "You're attending without a microphone \u2014 others can't hear you";
2604
2653
  function isListenOnly(media) {
2605
- return !media.microphone.enabled;
2654
+ return !media.microphone.enabled && media.microphone.unavailable !== null;
2606
2655
  }
2607
2656
  function listenOnlyNotice(media) {
2608
2657
  return isListenOnly(media) ? LISTEN_ONLY_NOTICE : null;
@@ -3789,7 +3838,7 @@ function createLiveKitDriver(handlers, options = {}) {
3789
3838
  try {
3790
3839
  await requireRoom("setScreenShareEnabled").localParticipant.setScreenShareEnabled(enabled);
3791
3840
  } catch (error) {
3792
- throw normalizeDeviceError(error, "meet.setScreenShareEnabled");
3841
+ throw normalizeScreenShareError(error, "meet.setScreenShareEnabled");
3793
3842
  }
3794
3843
  },
3795
3844
  async publishData(topic, payload, to) {
@@ -3826,6 +3875,9 @@ function createLiveKitDriver(handlers, options = {}) {
3826
3875
  supportsVideoEffects() {
3827
3876
  return videoEffectsSupported();
3828
3877
  },
3878
+ supportsScreenShare() {
3879
+ return typeof navigator !== "undefined" && typeof navigator.mediaDevices?.getDisplayMedia === "function";
3880
+ },
3829
3881
  attach(identity, kind, element) {
3830
3882
  const target = requireRoom("attach");
3831
3883
  const source = sources?.[kind];
@@ -4885,6 +4937,7 @@ function createRoomEngine(options) {
4885
4937
  function report(level, message, remedy) {
4886
4938
  options.onDiagnostic?.(remedy === void 0 ? { level, message } : { level, message, remedy });
4887
4939
  }
4940
+ let ambiguousShareDenials = 0;
4888
4941
  function fail(error, operation) {
4889
4942
  const normalized = normalizeMeetError(error, operation);
4890
4943
  store.patch({
@@ -5275,8 +5328,17 @@ function createRoomEngine(options) {
5275
5328
  if (driver === null) return;
5276
5329
  try {
5277
5330
  await driver.setScreenShareEnabled(enabled);
5331
+ ambiguousShareDenials = 0;
5278
5332
  } catch (error) {
5279
- throw fail(error, "meet.setScreenShareEnabled");
5333
+ const kind = classifyScreenShareError(error);
5334
+ if (kind === "ambiguous") {
5335
+ ambiguousShareDenials += 1;
5336
+ if (ambiguousShareDenials < 2) return;
5337
+ }
5338
+ const normalized = normalizeScreenShareError(error, "meet.setScreenShareEnabled");
5339
+ report("warn", normalized.message, normalized.remedy);
5340
+ const text3 = kind === "other" ? `Screen sharing is not available. ${normalized.remedy}` : `Screen sharing did not start. ${SCREEN_SHARE_BLOCKED_REMEDY}`;
5341
+ store.patch({ actionNotice: { text: text3, failed: true, at: now() } });
5280
5342
  }
5281
5343
  },
5282
5344
  async raiseHand(raised) {
@@ -5324,6 +5386,9 @@ function createRoomEngine(options) {
5324
5386
  supportsVideoEffects() {
5325
5387
  return driver?.supportsVideoEffects?.() ?? false;
5326
5388
  },
5389
+ supportsScreenShare() {
5390
+ return driver?.supportsScreenShare?.() ?? true;
5391
+ },
5327
5392
  async switchDevice(kind, deviceId) {
5328
5393
  if (driver === null) return;
5329
5394
  await driver.switchDevice(kind, deviceId);