@ai-matrx/meet 0.7.8 → 0.7.9

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
@@ -43,6 +43,20 @@ var MeetError = class extends Error {
43
43
  return this.code === "permission-denied" || this.code === "device-not-found" || this.code === "device-in-use" || this.code === "insecure-context";
44
44
  }
45
45
  };
46
+ var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
47
+ function isRawServerText(value) {
48
+ const text3 = value.trim();
49
+ return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
50
+ }
51
+ function humanDatabaseSentence(message) {
52
+ const text3 = message.trim();
53
+ if (text3.length === 0 || isRawServerText(text3)) return null;
54
+ if (/permission denied for|violates|relation "|does not exist|syntax error|column "|jwt|pgrst|duplicate key|null value in/i.test(
55
+ text3
56
+ ))
57
+ return null;
58
+ return text3;
59
+ }
46
60
  var FORBIDDEN_CODES = /* @__PURE__ */ new Set(["42501", "PGRST301", "PGRST302"]);
47
61
  var NOT_FOUND_CODES = /* @__PURE__ */ new Set(["PGRST116", "PGRST205"]);
48
62
  var CONFLICT_CODES = /* @__PURE__ */ new Set(["23505", "40001", "55000"]);
@@ -70,8 +84,8 @@ function normalizeMeetError(error, operation) {
70
84
  if (code !== void 0 && FORBIDDEN_CODES.has(code)) {
71
85
  return new MeetError(
72
86
  "forbidden",
73
- `${operation}: denied by the database (${code}: ${message})`,
74
- "Authorization is RLS plus auth-checked RPCs (R5). Fix the policy or the caller's membership \u2014 never route around it with a service-role client in a browser.",
87
+ humanDatabaseSentence(message) ?? "You don't have access to do that in this meeting.",
88
+ "Ask the meeting's host to do it, or to give you access.",
75
89
  error
76
90
  );
77
91
  }
@@ -86,15 +100,16 @@ function normalizeMeetError(error, operation) {
86
100
  if (code !== void 0 && CONFLICT_CODES.has(code)) {
87
101
  return new MeetError(
88
102
  "conflict",
89
- `${operation}: unique violation (${code}: ${message})`,
90
- "A concurrent writer won. Re-read the meeting rather than retrying the insert \u2014 for a call invite this is the idempotency key doing its job.",
103
+ humanDatabaseSentence(message) ?? "This meeting changed a moment ago, so nothing was saved.",
104
+ "Reload to see the latest, then try again.",
91
105
  error
92
106
  );
93
107
  }
108
+ const hint = error?.hint;
94
109
  return new MeetError(
95
110
  "transport",
96
- `${operation}: ${message}`,
97
- "Transient transport failure. Reads retry once; a join failure surfaces to the room phase as `failed` with this message rather than hanging on a spinner.",
111
+ /failed to fetch|networkerror|load failed|network request failed/i.test(message) ? "The server could not be reached." : humanDatabaseSentence(message) ?? SERVER_FAILED_SENTENCE,
112
+ typeof hint === "string" && humanDatabaseSentence(hint) !== null ? hint.trim() : "Nothing was changed \u2014 retry in a moment; if it keeps happening, reload the page.",
98
113
  error
99
114
  );
100
115
  }
@@ -502,11 +517,6 @@ function readText(data) {
502
517
  }
503
518
  return "";
504
519
  }
505
- var SERVER_FAILED_SENTENCE = "The server hit an unexpected problem and nothing was changed.";
506
- function isRawServerText(value) {
507
- const text3 = value.trim();
508
- return /^internal server error\b/i.test(text3) || /^[A-Z][A-Za-z0-9]*(Error|Exception)$/.test(text3) || /^[a-z][a-z0-9]*(_[a-z0-9]+)+$/.test(text3);
509
- }
510
520
  async function refusalFromResponse(response, operation, fallbackRemedy) {
511
521
  let body = null;
512
522
  try {