@ai-matrx/messaging 0.4.0 → 0.6.0

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.cjs CHANGED
@@ -61,7 +61,6 @@ __export(react_exports, {
61
61
  asMessageId: () => asMessageId,
62
62
  asOrganizationId: () => asOrganizationId,
63
63
  asUserId: () => asUserId,
64
- avatarPaletteIndex: () => avatarPaletteIndex,
65
64
  composeFence: () => composeFence,
66
65
  conversationTopic: () => conversationTopic,
67
66
  createActionRegistry: () => createActionRegistry,
@@ -79,7 +78,6 @@ __export(react_exports, {
79
78
  formatLastSeen: () => formatLastSeen,
80
79
  formatMessageTime: () => formatMessageTime,
81
80
  formatTypists: () => formatTypists,
82
- getInitials: () => getInitials,
83
81
  groupMessages: () => groupMessages,
84
82
  inboxTopic: () => inboxTopic,
85
83
  invalidResponse: () => invalidResponse,
@@ -1999,20 +1997,6 @@ function formatDateSeparator(isoString, now = Date.now(), locale) {
1999
1997
  day: "numeric"
2000
1998
  });
2001
1999
  }
2002
- function getInitials(name) {
2003
- const parts = name.trim().split(/\s+/).filter(Boolean);
2004
- if (parts.length === 0) return "?";
2005
- const first = parts[0]?.[0] ?? "";
2006
- const last = parts.length > 1 ? parts.at(-1)?.[0] ?? "" : "";
2007
- return `${first}${last}`.toUpperCase() || "?";
2008
- }
2009
- function avatarPaletteIndex(seed, buckets = 8) {
2010
- let hash = 0;
2011
- for (let index = 0; index < seed.length; index += 1) {
2012
- hash = hash * 31 + seed.charCodeAt(index) | 0;
2013
- }
2014
- return Math.abs(hash) % buckets;
2015
- }
2016
2000
  function groupMessages(messages, args = {}) {
2017
2001
  const windowMs = args.windowMs ?? 5 * MINUTE;
2018
2002
  const now = args.now ?? Date.now();
@@ -2381,6 +2365,9 @@ function resolveActor(message, sender) {
2381
2365
  };
2382
2366
  }
2383
2367
 
2368
+ // src/react/parts.tsx
2369
+ var import_format2 = require("@ai-matrx/kit/format");
2370
+
2384
2371
  // src/react/icons.tsx
2385
2372
  var import_jsx_runtime2 = require("react/jsx-runtime");
2386
2373
  function Icon(props) {
@@ -2476,7 +2463,7 @@ var UsersIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2476
2463
  var import_jsx_runtime3 = require("react/jsx-runtime");
2477
2464
  function Avatar(props) {
2478
2465
  const seed = props.seed ?? props.name;
2479
- const paletteIndex = avatarPaletteIndex(seed);
2466
+ const paletteIndex = (0, import_format2.avatarPaletteIndex)(seed);
2480
2467
  const className = `mx-msg__avatar${props.small === true ? " mx-msg__avatar--sm" : ""}`;
2481
2468
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2482
2469
  "span",
@@ -2485,7 +2472,7 @@ function Avatar(props) {
2485
2472
  style: { background: `var(--mx-msg-avatar-${paletteIndex})` },
2486
2473
  "aria-hidden": "true",
2487
2474
  children: [
2488
- props.imageUrl != null && props.imageUrl.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { className: "mx-msg__avatar-img", src: props.imageUrl, alt: "", loading: "lazy" }) : getInitials(props.name),
2475
+ props.imageUrl != null && props.imageUrl.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("img", { className: "mx-msg__avatar-img", src: props.imageUrl, alt: "", loading: "lazy" }) : (0, import_format2.getInitials)(props.name),
2489
2476
  props.online === true ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("i", { className: "mx-msg__presence" }) : null
2490
2477
  ]
2491
2478
  }