@ai-matrx/meet 0.7.81 → 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/react.js CHANGED
@@ -159,22 +159,45 @@ function normalizeDeviceError(error, operation) {
159
159
  );
160
160
  }
161
161
  }
162
- function isScreenShareCancel(error) {
163
- const named = (value) => typeof value?.name === "string" ? value.name : "";
162
+ var SYSTEM_BLOCK = /by system|permissions?[- ]policy|display-capture|disallowed|not allowed by the system/i;
163
+ function classifyScreenShareError(error) {
164
+ const read = (value, key) => {
165
+ const v = value?.[key];
166
+ return typeof v === "string" ? v : "";
167
+ };
164
168
  const cause = error instanceof MeetError ? error.cause : void 0;
165
- const names = [named(error), named(cause)];
166
- if (names.some((name) => name === "NotAllowedError" || name === "AbortError")) return true;
167
- return error instanceof MeetError && error.code === "permission-denied";
169
+ const denied = [error, cause].some((value) => {
170
+ const name = read(value, "name");
171
+ return name === "NotAllowedError" || name === "AbortError" || name === "SecurityError";
172
+ });
173
+ if (denied) {
174
+ const text3 = [read(error, "message"), read(cause, "message")].join(" ");
175
+ return SYSTEM_BLOCK.test(text3) || [error, cause].some((v) => read(v, "name") === "SecurityError") ? "blocked" : "ambiguous";
176
+ }
177
+ if (error instanceof MeetError && error.code === "permission-denied" && cause === void 0) {
178
+ return "ambiguous";
179
+ }
180
+ return "other";
168
181
  }
182
+ 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.";
169
183
  function normalizeScreenShareError(error, operation) {
170
184
  if (error instanceof MeetError) return error;
171
185
  const raw = error ?? {};
172
186
  const message = typeof raw.message === "string" ? raw.message : String(error);
173
- if (isScreenShareCancel(error)) {
187
+ const kind = classifyScreenShareError(error);
188
+ if (kind === "blocked") {
189
+ return new MeetError(
190
+ "permission-denied",
191
+ `${operation}: screen sharing is blocked (${message})`,
192
+ SCREEN_SHARE_BLOCKED_REMEDY,
193
+ error
194
+ );
195
+ }
196
+ if (kind === "ambiguous") {
174
197
  return new MeetError(
175
198
  "permission-denied",
176
- `${operation}: screen sharing was cancelled`,
177
- "Choose a screen, window or tab in the picker to share it.",
199
+ `${operation}: screen sharing was cancelled or refused`,
200
+ "Choose a screen, window or tab in the picker to share it. If no picker appeared, " + SCREEN_SHARE_BLOCKED_REMEDY,
178
201
  error
179
202
  );
180
203
  }
@@ -4038,6 +4061,7 @@ function createRoomEngine(options) {
4038
4061
  function report(level, message, remedy) {
4039
4062
  options.onDiagnostic?.(remedy === void 0 ? { level, message } : { level, message, remedy });
4040
4063
  }
4064
+ let ambiguousShareDenials = 0;
4041
4065
  function fail(error, operation) {
4042
4066
  const normalized = normalizeMeetError(error, operation);
4043
4067
  store.patch({
@@ -4428,17 +4452,17 @@ function createRoomEngine(options) {
4428
4452
  if (driver === null) return;
4429
4453
  try {
4430
4454
  await driver.setScreenShareEnabled(enabled);
4455
+ ambiguousShareDenials = 0;
4431
4456
  } catch (error) {
4432
- if (isScreenShareCancel(error)) return;
4457
+ const kind = classifyScreenShareError(error);
4458
+ if (kind === "ambiguous") {
4459
+ ambiguousShareDenials += 1;
4460
+ if (ambiguousShareDenials < 2) return;
4461
+ }
4433
4462
  const normalized = normalizeScreenShareError(error, "meet.setScreenShareEnabled");
4434
4463
  report("warn", normalized.message, normalized.remedy);
4435
- store.patch({
4436
- actionNotice: {
4437
- text: `Screen sharing is not available. ${normalized.remedy}`,
4438
- failed: true,
4439
- at: now()
4440
- }
4441
- });
4464
+ const text3 = kind === "other" ? `Screen sharing is not available. ${normalized.remedy}` : `Screen sharing did not start. ${SCREEN_SHARE_BLOCKED_REMEDY}`;
4465
+ store.patch({ actionNotice: { text: text3, failed: true, at: now() } });
4442
4466
  }
4443
4467
  },
4444
4468
  async raiseHand(raised) {