@ai-matrx/design-system 0.86.353 → 0.86.355

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.
Files changed (53) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/carousel.js +2 -2
  3. package/dist/chunk-LJKF267O.js +168 -0
  4. package/dist/chunk-LJKF267O.js.map +1 -0
  5. package/dist/{chunk-CFCWQDGC.js → chunk-RLM4RSED.js} +5 -23
  6. package/dist/chunk-RLM4RSED.js.map +1 -0
  7. package/dist/{chunk-UGQRAQTE.js → chunk-XXZA2JUP.js} +2 -2
  8. package/dist/{chunk-FLWSEDUW.js → chunk-ZMUPFGQO.js} +2 -2
  9. package/dist/controls.cjs +85 -1
  10. package/dist/controls.cjs.map +1 -1
  11. package/dist/controls.js +2 -2
  12. package/dist/data-table/drill-chart.cjs +85 -1
  13. package/dist/data-table/drill-chart.cjs.map +1 -1
  14. package/dist/data-table/drill-chart.js +1 -1
  15. package/dist/data-table/index.cjs +85 -1
  16. package/dist/data-table/index.cjs.map +1 -1
  17. package/dist/data-table/index.js +1 -1
  18. package/dist/desktop.cjs +159 -81
  19. package/dist/desktop.cjs.map +1 -1
  20. package/dist/desktop.css +8 -5
  21. package/dist/desktop.d.cts +0 -5
  22. package/dist/desktop.d.ts +0 -5
  23. package/dist/desktop.js +70 -70
  24. package/dist/desktop.js.map +1 -1
  25. package/dist/email-input-dialog.cjs +85 -1
  26. package/dist/email-input-dialog.cjs.map +1 -1
  27. package/dist/email-input-dialog.js +1 -1
  28. package/dist/index.cjs +118 -24
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +17 -1
  31. package/dist/index.d.ts +17 -1
  32. package/dist/index.js +20 -12
  33. package/dist/index.js.map +1 -1
  34. package/dist/lite-table.cjs +86 -19
  35. package/dist/lite-table.cjs.map +1 -1
  36. package/dist/lite-table.js +2 -2
  37. package/dist/notice-material.css +28 -0
  38. package/dist/record-list.cjs +86 -19
  39. package/dist/record-list.cjs.map +1 -1
  40. package/dist/record-list.js +2 -2
  41. package/dist/styles.css +1 -0
  42. package/dist/swipe-deck.cjs +85 -1
  43. package/dist/swipe-deck.cjs.map +1 -1
  44. package/dist/swipe-deck.js +1 -1
  45. package/dist/text-input-dialog.cjs +85 -1
  46. package/dist/text-input-dialog.cjs.map +1 -1
  47. package/dist/text-input-dialog.js +1 -1
  48. package/package.json +2 -2
  49. package/dist/chunk-CFCWQDGC.js.map +0 -1
  50. package/dist/chunk-HKLIRHT2.js +0 -71
  51. package/dist/chunk-HKLIRHT2.js.map +0 -1
  52. /package/dist/{chunk-UGQRAQTE.js.map → chunk-XXZA2JUP.js.map} +0 -0
  53. /package/dist/{chunk-FLWSEDUW.js.map → chunk-ZMUPFGQO.js.map} +0 -0
@@ -10,14 +10,14 @@ import {
10
10
  ReadEmpty,
11
11
  ReadStaleNotice,
12
12
  readOf
13
- } from "./chunk-CFCWQDGC.js";
13
+ } from "./chunk-RLM4RSED.js";
14
14
  import "./chunk-T4D7WAV7.js";
15
15
  import "./chunk-HEFTQUJ5.js";
16
16
  import {
17
17
  MAC_LIST_ATTRIBUTE
18
18
  } from "./chunk-5JZSBNEY.js";
19
19
  import "./chunk-K4XCB576.js";
20
- import "./chunk-HKLIRHT2.js";
20
+ import "./chunk-LJKF267O.js";
21
21
  import {
22
22
  Checkbox
23
23
  } from "./chunk-VLLUUOYJ.js";
package/dist/styles.css CHANGED
@@ -1,3 +1,4 @@
1
+ @import "./notice-material.css";
1
2
  @import "./content-transfer.css";
2
3
  @import "./controls.css";
3
4
  @import "./look-desktop.css";
@@ -102,6 +102,85 @@ var import_clipboard = require("@ai-matrx/kit/clipboard");
102
102
 
103
103
  // src/error-box.tsx
104
104
  var React = __toESM(require("react"), 1);
105
+
106
+ // src/desktop/errors.ts
107
+ var RULES = [
108
+ { code: "ENOENT", test: /\b(spawn\s+\S+\s+)?ENOENT\b|command not found|no such file or directory/i, cause: "A program or file it needs isn't on this computer. Install it or update Matrx, then try again." },
109
+ { code: "EACCES", test: /\bEACCES\b|\bEPERM\b|permission denied|operation not permitted|not authori[sz]ed by the user/i, cause: "Matrx isn't allowed to do that. Grant access in System Settings \u203A Privacy & Security, then try again." },
110
+ { code: "EADDRINUSE", test: /\bEADDRINUSE\b|address already in use|port .* (is )?(already )?in use/i, cause: "Another program is already using that port. Stop it, or choose another port." },
111
+ { code: "ECONNREFUSED", test: /\bECONNREFUSED\b|connection refused/i, cause: "The service isn't answering. It may have stopped; start it again." },
112
+ { code: "OFFLINE", test: /\bENOTFOUND\b|\bEAI_AGAIN\b|\bENETUNREACH\b|getaddrinfo|network (is )?unreachable|failed to fetch|offline/i, cause: "Can't reach the internet. Check the connection and try again." },
113
+ { code: "TIMEOUT", test: /\bETIMEDOUT\b|timed? ?out|\bTIMEOUT\b|deadline exceeded/i, cause: "It took too long to answer. Try again in a moment." },
114
+ { code: "ENOSPC", test: /\bENOSPC\b|no space left/i, cause: "The disk is full. Free some space, then try again." },
115
+ { code: "ENOMEM", test: /\bENOMEM\b|out of memory|cannot allocate memory/i, cause: "The computer ran out of memory. Close something and try again." },
116
+ { code: "UNAUTHORIZED", test: /\b401\b|unauthori[sz]ed|invalid (api )?key|not signed in|jwt expired|session expired/i, cause: "You're signed out, or the key was refused. Sign in again." },
117
+ { code: "FORBIDDEN", test: /\b403\b|forbidden/i, cause: "This account isn't allowed to do that." },
118
+ { code: "NOT_FOUND", test: /\b404\b|not found/i, cause: "It isn't there any more. Refresh and try again." },
119
+ { code: "RATE_LIMIT", test: /\b429\b|rate.?limit|too many requests/i, cause: "Too many requests just now. Wait a moment and try again." },
120
+ { code: "SERVER", test: /\b5\d\d\b|internal server error|bad gateway|service unavailable/i, cause: "The server had a problem. Try again in a moment." },
121
+ { code: "EXITED", test: /exited with code|process exited|crashed|SIGKILL|SIGSEGV|SIGTERM/i, cause: "The service stopped unexpectedly. Start it again; Copy details if it keeps happening." }
122
+ ];
123
+ var RAW = /\b[A-Z]{2,}[A-Z_]*\b|[\\/][\w.-]+[\\/]|\bat \S+ \(|\{|\}|errno|stack|undefined|null|\bspawn\b/;
124
+ function rawText(error) {
125
+ if (error instanceof Error) return error.message || error.name;
126
+ if (typeof error === "string") return error;
127
+ if (error && typeof error === "object" && "message" in error && typeof error.message === "string") {
128
+ return error.message;
129
+ }
130
+ return "";
131
+ }
132
+ function describeError(error, fallback = "Something went wrong. Try again.") {
133
+ const detail = rawText(error).trim();
134
+ if (!detail) return { cause: fallback, detail: "" };
135
+ for (const rule of RULES) {
136
+ if (rule.test.test(detail)) return { cause: rule.cause, detail, code: rule.code };
137
+ }
138
+ if (!RAW.test(detail) && detail.length <= 160) return { cause: detail, detail: "" };
139
+ return { cause: fallback, detail };
140
+ }
141
+
142
+ // src/error-sentence.ts
143
+ function errorSentenceOf(error) {
144
+ if (error == null || error === true || error === false) return "";
145
+ if (typeof error === "string") return error;
146
+ if (typeof error !== "object") return String(error);
147
+ const message = error.message;
148
+ return typeof message === "string" ? message : "";
149
+ }
150
+ var TIMED_OUT_SENTENCE = "That took too long. Nothing was lost; try again.";
151
+ var FALLBACK_ERROR_SENTENCE = "Something went wrong. Try again.";
152
+ function isTimedOutError(error, message, code) {
153
+ if (code === "57014" || code === "timed_out") return true;
154
+ if (error && typeof error === "object") {
155
+ const o = error;
156
+ if (o.code === "57014" || o.code === "timed_out" || o.sqlstate === "57014") return true;
157
+ }
158
+ const text2 = `${message ?? ""} ${errorSentenceOf(error)}`;
159
+ return /canceling statement due to statement timeout/i.test(text2);
160
+ }
161
+ function offlineText(text2) {
162
+ const t = text2.trim();
163
+ return t !== "" && (describeError(t).code === "OFFLINE" || /networkerror|network request failed|load failed/i.test(t));
164
+ }
165
+ var ANY_HOST_CODES = /* @__PURE__ */ new Set(["OFFLINE", "TIMEOUT", "UNAUTHORIZED", "FORBIDDEN", "NOT_FOUND", "RATE_LIMIT", "SERVER"]);
166
+ var MACHINE_PREFIX = /^\s*(?:\[[\w./-]+\]\s*|[a-z][\w]*(?:[._][\w]+)+:\s+)/;
167
+ var RAW_TEXT = /\b(?:Type|Reference|Syntax|Range|Internal|Eval|URI)Error\b|\bat\s+[\w$.<>]+\s*\(|\.(?:[cm]?[jt]sx?|py):\d+|(?:^|[\s(])(?:\/[\w.@-]+){2,}|\bundefined is not\b|\bcannot read propert(?:y|ies)\b|\bis not a function\b|\bunexpected token\b/i;
168
+ function peopleErrorSentence(error, message, options = {}) {
169
+ if (isTimedOutError(error, message, options.code)) return TIMED_OUT_SENTENCE;
170
+ const fallback = options.fallback ?? FALLBACK_ERROR_SENTENCE;
171
+ const raw = message?.trim() || errorSentenceOf(error).trim();
172
+ if (!raw) return fallback;
173
+ let text2 = raw;
174
+ for (let i = 0; i < 3 && MACHINE_PREFIX.test(text2); i++) text2 = text2.replace(MACHINE_PREFIX, "").trim();
175
+ if (!text2) return fallback;
176
+ if (offlineText(text2) || RAW_TEXT.test(text2) || text2 !== raw) {
177
+ const said = describeError(text2, fallback);
178
+ return said.code && ANY_HOST_CODES.has(said.code) ? said.cause : fallback;
179
+ }
180
+ return text2;
181
+ }
182
+
183
+ // src/error-box.tsx
105
184
  var import_jsx_runtime = require("react/jsx-runtime");
106
185
  var CONTEXT_KEY = /* @__PURE__ */ Symbol.for("@ai-matrx/design-system/error-actions");
107
186
  var registry = globalThis;
@@ -117,6 +196,11 @@ function ErrorActions(props) {
117
196
  if (!render) return null;
118
197
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_jsx_runtime.Fragment, { children: render(props) });
119
198
  }
199
+ function sayable(body, error) {
200
+ if (typeof body === "string") return peopleErrorSentence(error, body);
201
+ if (Array.isArray(body)) return body.map((b) => typeof b === "string" && b.trim() ? peopleErrorSentence(error, b) : b);
202
+ return body;
203
+ }
120
204
  var ErrorBox = React.forwardRef(function ErrorBox2({
121
205
  as = "p",
122
206
  message,
@@ -140,7 +224,7 @@ var ErrorBox = React.forwardRef(function ErrorBox2({
140
224
  ...origin !== void 0 ? { origin } : {}
141
225
  };
142
226
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Tag, { ref, role: "alert", "data-error-box": "", ...rest, children: [
143
- children ?? message,
227
+ sayable(children ?? message, error),
144
228
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ErrorActions, { ...facts })
145
229
  ] });
146
230
  });