@ai-matrx/meet 0.7.81 → 0.7.83

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
@@ -139,22 +139,45 @@ function normalizeDeviceError(error, operation) {
139
139
  );
140
140
  }
141
141
  }
142
- function isScreenShareCancel(error) {
143
- const named = (value) => typeof value?.name === "string" ? value.name : "";
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
+ };
144
148
  const cause = error instanceof MeetError ? error.cause : void 0;
145
- const names = [named(error), named(cause)];
146
- if (names.some((name) => name === "NotAllowedError" || name === "AbortError")) return true;
147
- return error instanceof MeetError && error.code === "permission-denied";
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";
148
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.";
149
163
  function normalizeScreenShareError(error, operation) {
150
164
  if (error instanceof MeetError) return error;
151
165
  const raw = error ?? {};
152
166
  const message = typeof raw.message === "string" ? raw.message : String(error);
153
- if (isScreenShareCancel(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") {
154
177
  return new MeetError(
155
178
  "permission-denied",
156
- `${operation}: screen sharing was cancelled`,
157
- "Choose a screen, window or tab in the picker to share it.",
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,
158
181
  error
159
182
  );
160
183
  }
@@ -4914,6 +4937,7 @@ function createRoomEngine(options) {
4914
4937
  function report(level, message, remedy) {
4915
4938
  options.onDiagnostic?.(remedy === void 0 ? { level, message } : { level, message, remedy });
4916
4939
  }
4940
+ let ambiguousShareDenials = 0;
4917
4941
  function fail(error, operation) {
4918
4942
  const normalized = normalizeMeetError(error, operation);
4919
4943
  store.patch({
@@ -5304,17 +5328,17 @@ function createRoomEngine(options) {
5304
5328
  if (driver === null) return;
5305
5329
  try {
5306
5330
  await driver.setScreenShareEnabled(enabled);
5331
+ ambiguousShareDenials = 0;
5307
5332
  } catch (error) {
5308
- if (isScreenShareCancel(error)) return;
5333
+ const kind = classifyScreenShareError(error);
5334
+ if (kind === "ambiguous") {
5335
+ ambiguousShareDenials += 1;
5336
+ if (ambiguousShareDenials < 2) return;
5337
+ }
5309
5338
  const normalized = normalizeScreenShareError(error, "meet.setScreenShareEnabled");
5310
5339
  report("warn", normalized.message, normalized.remedy);
5311
- store.patch({
5312
- actionNotice: {
5313
- text: `Screen sharing is not available. ${normalized.remedy}`,
5314
- failed: true,
5315
- at: now()
5316
- }
5317
- });
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() } });
5318
5342
  }
5319
5343
  },
5320
5344
  async raiseHand(raised) {