@ai-matrx/messaging 0.4.0 → 0.7.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
@@ -39,6 +39,7 @@ __export(react_exports, {
39
39
  EmptyState: () => EmptyState,
40
40
  LinkIcon: () => LinkIcon,
41
41
  MESSAGING_EVENTS: () => MESSAGING_EVENTS,
42
+ MESSAGING_RPC_SCHEMA: () => MESSAGING_RPC_SCHEMA,
42
43
  MESSAGING_SCHEMA: () => MESSAGING_SCHEMA,
43
44
  MessageActionChips: () => MessageActionChips,
44
45
  MessageBubble: () => MessageBubble,
@@ -61,7 +62,6 @@ __export(react_exports, {
61
62
  asMessageId: () => asMessageId,
62
63
  asOrganizationId: () => asOrganizationId,
63
64
  asUserId: () => asUserId,
64
- avatarPaletteIndex: () => avatarPaletteIndex,
65
65
  composeFence: () => composeFence,
66
66
  conversationTopic: () => conversationTopic,
67
67
  createActionRegistry: () => createActionRegistry,
@@ -79,7 +79,6 @@ __export(react_exports, {
79
79
  formatLastSeen: () => formatLastSeen,
80
80
  formatMessageTime: () => formatMessageTime,
81
81
  formatTypists: () => formatTypists,
82
- getInitials: () => getInitials,
83
82
  groupMessages: () => groupMessages,
84
83
  inboxTopic: () => inboxTopic,
85
84
  invalidResponse: () => invalidResponse,
@@ -1450,6 +1449,7 @@ function createReadCache(options) {
1450
1449
 
1451
1450
  // src/core/repository.ts
1452
1451
  var MESSAGING_SCHEMA = "communication";
1452
+ var MESSAGING_RPC_SCHEMA = "public";
1453
1453
  var TABLES = {
1454
1454
  conversations: "dm_conversations",
1455
1455
  participants: "dm_conversation_participants",
@@ -1484,6 +1484,7 @@ function createMessagingRepository(options) {
1484
1484
  ...options.now !== void 0 ? { now: options.now } : {}
1485
1485
  });
1486
1486
  const db = () => client.schema(MESSAGING_SCHEMA);
1487
+ const rpcDb = () => client.schema(MESSAGING_RPC_SCHEMA);
1487
1488
  async function withSessionRetry(operation, run) {
1488
1489
  try {
1489
1490
  return await run();
@@ -1501,7 +1502,7 @@ function createMessagingRepository(options) {
1501
1502
  }
1502
1503
  }
1503
1504
  async function rpc(fn, args, operation) {
1504
- const { data, error } = await db().rpc(fn, args);
1505
+ const { data, error } = await rpcDb().rpc(fn, args);
1505
1506
  if (error !== null) throw normalizeMessagingError(error, operation);
1506
1507
  return data;
1507
1508
  }
@@ -1999,20 +2000,6 @@ function formatDateSeparator(isoString, now = Date.now(), locale) {
1999
2000
  day: "numeric"
2000
2001
  });
2001
2002
  }
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
2003
  function groupMessages(messages, args = {}) {
2017
2004
  const windowMs = args.windowMs ?? 5 * MINUTE;
2018
2005
  const now = args.now ?? Date.now();
@@ -2381,6 +2368,9 @@ function resolveActor(message, sender) {
2381
2368
  };
2382
2369
  }
2383
2370
 
2371
+ // src/react/parts.tsx
2372
+ var import_format2 = require("@ai-matrx/kit/format");
2373
+
2384
2374
  // src/react/icons.tsx
2385
2375
  var import_jsx_runtime2 = require("react/jsx-runtime");
2386
2376
  function Icon(props) {
@@ -2476,7 +2466,7 @@ var UsersIcon = (props) => /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
2476
2466
  var import_jsx_runtime3 = require("react/jsx-runtime");
2477
2467
  function Avatar(props) {
2478
2468
  const seed = props.seed ?? props.name;
2479
- const paletteIndex = avatarPaletteIndex(seed);
2469
+ const paletteIndex = (0, import_format2.avatarPaletteIndex)(seed);
2480
2470
  const className = `mx-msg__avatar${props.small === true ? " mx-msg__avatar--sm" : ""}`;
2481
2471
  return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
2482
2472
  "span",
@@ -2485,7 +2475,7 @@ function Avatar(props) {
2485
2475
  style: { background: `var(--mx-msg-avatar-${paletteIndex})` },
2486
2476
  "aria-hidden": "true",
2487
2477
  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),
2478
+ 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
2479
  props.online === true ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("i", { className: "mx-msg__presence" }) : null
2490
2480
  ]
2491
2481
  }