@antzsoft/chat-core 1.3.8 → 1.4.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/index.d.cts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-BJvQhWxC.cjs';
2
- export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MessageAckEvent, I as MessageContent, J as MessageDeletedEvent, K as MessageDeletedForMeEvent, N as MessageDeliveredEvent, O as MessageMetadata, Q as MessageReaction, T as MessageReceiptEntry, V as MessageReplyReference, W as MessageStarUpdatedEvent, X as MessageUpdatedEvent, Y as MessagesDeliveredEvent, Z as MultipartPartUrl, _ as MultipartUploadInfo, $ as NewMessageEvent, a0 as OptimisticAttachment, a1 as PlatformCompressFn, a2 as PlatformUploadFn, a3 as PlatformUploadPartFn, a4 as QuietHours, a5 as ReactionGroup, a6 as ReactionUpdatedEvent, a7 as ReactionUser, a8 as ReadReceiptEvent, a9 as ReplyAttachmentSnapshot, aa as ResolvedFileSizeLimits, ab as SendMessageAttachment, ac as SyncDeletedForMe, ad as SyncDeliveredReceipt, ae as SyncParticipantChange, af as SyncReactionEntry, ag as SyncReactions, ah as SyncReadReceipt, ai as SyncStarEntry, aj as SystemMessageMetadata, ak as TypingIndicatorEvent, al as UploadConfig, am as UploadProgress, an as UserStatusEvent, ao as resolveConfig, ap as storageApi, aq as uploadBatch } from './storage-BJvQhWxC.cjs';
1
+ import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.cjs';
2
+ export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.cjs';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import { Socket } from 'socket.io-client';
5
5
  import * as zustand_middleware from 'zustand/middleware';
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
536
536
  */
537
537
  declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
538
538
 
539
+ interface ParsedMention {
540
+ /** userId, or "all" */
541
+ id: string;
542
+ /** display name captured from the token (fallback for rendering) */
543
+ displayName: string;
544
+ /** start index of the whole token in the text (UTF-16) */
545
+ start: number;
546
+ /** end index (exclusive) of the whole token in the text (UTF-16) */
547
+ end: number;
548
+ }
549
+ /** A segment of a message: either plain text or a mention to render specially. */
550
+ type MentionPart = {
551
+ type: 'text';
552
+ text: string;
553
+ } | {
554
+ type: 'mention';
555
+ id: string;
556
+ displayName: string;
557
+ };
558
+ /**
559
+ * A piece used to compose outgoing text. Plain strings pass through verbatim;
560
+ * mention objects are serialized to `@[displayName](id)` tokens.
561
+ */
562
+ type MentionSegment = string | {
563
+ id: string;
564
+ displayName: string;
565
+ };
566
+ /**
567
+ * Finds every `@[name](id)` mention token in the text, in order of appearance.
568
+ * Pure/computed — nothing is stored. Safe to call on every render.
569
+ */
570
+ declare function parseMentions(text: string | undefined | null): ParsedMention[];
571
+ /**
572
+ * Splits text into ordered parts (plain text + mentions) for rendering.
573
+ * The caller supplies `resolveName(id, fallbackName)` to look up the current
574
+ * display name from its own directory; return the fallback when unresolvable.
575
+ * When no resolver is given, the token's embedded name is used.
576
+ */
577
+ declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
578
+ /**
579
+ * Builds outgoing message text + the `mentions` id array from composer segments.
580
+ * Deduplicates ids (a user mentioned twice is fanned out once).
581
+ *
582
+ * Example:
583
+ * buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
584
+ * → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
585
+ */
586
+ declare function buildMentionText(segments: MentionSegment[]): {
587
+ text: string;
588
+ mentions: string[];
589
+ };
590
+ /**
591
+ * Re-derives the `mentions` id array from message text — the source of truth is
592
+ * always the tokens present in the text. Use this after an edit so a mention whose
593
+ * token was removed drops out of the array (FR-10).
594
+ */
595
+ declare function extractMentionIds(text: string | undefined | null): string[];
596
+ /** True when the mentions list targets everyone (@all). */
597
+ declare function isMentionAll(mentions: string[] | undefined): boolean;
598
+
539
599
  interface ClientSocketHandle {
540
600
  emit: typeof socketEmit;
541
601
  on(event: string, handler: (...args: unknown[]) => void): void;
@@ -667,4 +727,4 @@ declare class AntzChatClient {
667
727
  uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
668
728
  }
669
729
 
670
- export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
730
+ export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-BJvQhWxC.js';
2
- export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MessageAckEvent, I as MessageContent, J as MessageDeletedEvent, K as MessageDeletedForMeEvent, N as MessageDeliveredEvent, O as MessageMetadata, Q as MessageReaction, T as MessageReceiptEntry, V as MessageReplyReference, W as MessageStarUpdatedEvent, X as MessageUpdatedEvent, Y as MessagesDeliveredEvent, Z as MultipartPartUrl, _ as MultipartUploadInfo, $ as NewMessageEvent, a0 as OptimisticAttachment, a1 as PlatformCompressFn, a2 as PlatformUploadFn, a3 as PlatformUploadPartFn, a4 as QuietHours, a5 as ReactionGroup, a6 as ReactionUpdatedEvent, a7 as ReactionUser, a8 as ReadReceiptEvent, a9 as ReplyAttachmentSnapshot, aa as ResolvedFileSizeLimits, ab as SendMessageAttachment, ac as SyncDeletedForMe, ad as SyncDeliveredReceipt, ae as SyncParticipantChange, af as SyncReactionEntry, ag as SyncReactions, ah as SyncReadReceipt, ai as SyncStarEntry, aj as SystemMessageMetadata, ak as TypingIndicatorEvent, al as UploadConfig, am as UploadProgress, an as UserStatusEvent, ao as resolveConfig, ap as storageApi, aq as uploadBatch } from './storage-BJvQhWxC.js';
1
+ import { R as ResolvedCompressionConfig, L as LoginCredentials, A as AuthResponse, a as RegisterData, b as AuthTokens, U as User, C as CrossConversationSyncResponse, c as ConversationSyncResponse, d as AppConfig, S as SendMessagePayload, e as CursorPaginatedResponse, M as Message, f as MessageReactionsResponse, P as PaginatedResponse, g as MessageReceiptsResponse, h as ConversationListParams, i as Conversation, j as Participant, k as ConversationUnreadCount, l as UnreadSummary, m as UserPreferences, n as ResolvedConfig, o as PersistStorage, p as PresignedUrlRequest, q as PresignedUrlResponse, F as FileResponse, r as CompletedPart, s as FileType, t as AntzChatConfig, u as UploadableFile, B as BatchUploadResult } from './storage-C_b-SFFH.js';
2
+ export { v as Attachment, w as CompressedFile, x as CompressionAlgorithm, y as CompressionConfig, z as ConversationType, D as ConversationUpdatedEvent, E as FileSizeLimits, G as LastReaction, H as MENTION_ALL_ID, I as MessageAckEvent, J as MessageContent, K as MessageDeletedEvent, N as MessageDeletedForMeEvent, O as MessageDeliveredEvent, Q as MessageMetadata, T as MessageReaction, V as MessageReceiptEntry, W as MessageReplyReference, X as MessageStarUpdatedEvent, Y as MessageUpdatedEvent, Z as MessagesDeliveredEvent, _ as MultipartPartUrl, $ as MultipartUploadInfo, a0 as NewMessageEvent, a1 as OptimisticAttachment, a2 as PlatformCompressFn, a3 as PlatformUploadFn, a4 as PlatformUploadPartFn, a5 as QuietHours, a6 as ReactionGroup, a7 as ReactionUpdatedEvent, a8 as ReactionUser, a9 as ReadReceiptEvent, aa as ReplyAttachmentSnapshot, ab as ResolvedFileSizeLimits, ac as SendMessageAttachment, ad as SyncDeletedForMe, ae as SyncDeliveredReceipt, af as SyncParticipantChange, ag as SyncReactionEntry, ah as SyncReactions, ai as SyncReadReceipt, aj as SyncStarEntry, ak as SystemMessageMetadata, al as TypingIndicatorEvent, am as UploadConfig, an as UploadProgress, ao as UserStatusEvent, ap as resolveConfig, aq as storageApi, ar as uploadBatch } from './storage-C_b-SFFH.js';
3
3
  import { AxiosInstance } from 'axios';
4
4
  import { Socket } from 'socket.io-client';
5
5
  import * as zustand_middleware from 'zustand/middleware';
@@ -536,6 +536,66 @@ declare function normalizeAxiosError(error: unknown): AntzChatError;
536
536
  */
537
537
  declare function resolveSystemMessageText(message: Message, currentUserId: string): string;
538
538
 
539
+ interface ParsedMention {
540
+ /** userId, or "all" */
541
+ id: string;
542
+ /** display name captured from the token (fallback for rendering) */
543
+ displayName: string;
544
+ /** start index of the whole token in the text (UTF-16) */
545
+ start: number;
546
+ /** end index (exclusive) of the whole token in the text (UTF-16) */
547
+ end: number;
548
+ }
549
+ /** A segment of a message: either plain text or a mention to render specially. */
550
+ type MentionPart = {
551
+ type: 'text';
552
+ text: string;
553
+ } | {
554
+ type: 'mention';
555
+ id: string;
556
+ displayName: string;
557
+ };
558
+ /**
559
+ * A piece used to compose outgoing text. Plain strings pass through verbatim;
560
+ * mention objects are serialized to `@[displayName](id)` tokens.
561
+ */
562
+ type MentionSegment = string | {
563
+ id: string;
564
+ displayName: string;
565
+ };
566
+ /**
567
+ * Finds every `@[name](id)` mention token in the text, in order of appearance.
568
+ * Pure/computed — nothing is stored. Safe to call on every render.
569
+ */
570
+ declare function parseMentions(text: string | undefined | null): ParsedMention[];
571
+ /**
572
+ * Splits text into ordered parts (plain text + mentions) for rendering.
573
+ * The caller supplies `resolveName(id, fallbackName)` to look up the current
574
+ * display name from its own directory; return the fallback when unresolvable.
575
+ * When no resolver is given, the token's embedded name is used.
576
+ */
577
+ declare function renderMentionParts(text: string | undefined | null, resolveName?: (id: string, fallbackName: string) => string): MentionPart[];
578
+ /**
579
+ * Builds outgoing message text + the `mentions` id array from composer segments.
580
+ * Deduplicates ids (a user mentioned twice is fanned out once).
581
+ *
582
+ * Example:
583
+ * buildMentionText(['Hey ', { id: 'u1', displayName: 'Alice' }, ', look'])
584
+ * → { text: 'Hey @[Alice](u1), look', mentions: ['u1'] }
585
+ */
586
+ declare function buildMentionText(segments: MentionSegment[]): {
587
+ text: string;
588
+ mentions: string[];
589
+ };
590
+ /**
591
+ * Re-derives the `mentions` id array from message text — the source of truth is
592
+ * always the tokens present in the text. Use this after an edit so a mention whose
593
+ * token was removed drops out of the array (FR-10).
594
+ */
595
+ declare function extractMentionIds(text: string | undefined | null): string[];
596
+ /** True when the mentions list targets everyone (@all). */
597
+ declare function isMentionAll(mentions: string[] | undefined): boolean;
598
+
539
599
  interface ClientSocketHandle {
540
600
  emit: typeof socketEmit;
541
601
  on(event: string, handler: (...args: unknown[]) => void): void;
@@ -667,4 +727,4 @@ declare class AntzChatClient {
667
727
  uploadIcon(conversationId: string, file: UploadableFile): Promise<Conversation>;
668
728
  }
669
729
 
670
- export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, performHandshake, reconnectSocket, refreshSocketAuth, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
730
+ export { AntzChatAuthError, AntzChatClient, AntzChatConfig, AntzChatError, AntzChatNetworkError, AntzChatPermissionError, AntzChatServerError, AntzChatValidationError, AppConfig, AuthResponse, AuthTokens, BatchUploadResult, CompletedPart, Conversation, ConversationListParams, ConversationSyncResponse, ConversationUnreadCount, type CreateDirectData, type CreateGroupData, CrossConversationSyncResponse, CursorPaginatedResponse, FileResponse, FileType, type LastReadEntry, type ListMessagesParams, LoginCredentials, type MentionPart, type MentionSegment, Message, MessageReactionsResponse, MessageReceiptsResponse, type MobileDeviceToken, PaginatedResponse, type ParsedMention, Participant, PersistStorage, PresignedUrlRequest, PresignedUrlResponse, RegisterData, type RegisterDeviceTokenPayload, ResolvedCompressionConfig, ResolvedConfig, type SearchParams, type SendData, SendMessagePayload, type SocketStatus, type StatusListener, type TokenStore, UnreadSummary, type UpdateConversationData, type UpdateProfilePayload, UploadableFile, User, UserPreferences, type WebPushDeviceToken, appConfigApi, authApi, buildMentionText, connectSocket, conversationsApi, createAuthStore, createRestTransitSession, decryptPayload, devicesApi, disconnectSocket, encryptPayload, extractMentionIds, fetchServerKeys, generateEphemeralKey, getApiClient, getAuthStore, getCompressionStrategy, getSessionId, getSessionKey, getSocket, getSocketStatus, initApiClient, initAuthStore, isMentionAll, isTransitEnvelope, messagesApi, normalizeAxiosError, normalizeConversation, onSocketStatus, parseMentions, performHandshake, reconnectSocket, refreshSocketAuth, renderMentionParts, resetAuthStore, resolveSystemMessageText, setApiClientInstance, setTransitSession, socketEmit, syncApi, tryGetSocket, useChatStore, usersApi };
package/dist/index.js CHANGED
@@ -515,7 +515,7 @@ var conversationsApi = {
515
515
  `/conversations/${conversationId}/participants`,
516
516
  filter ? { params: { filter } } : void 0
517
517
  );
518
- return data;
518
+ return (data ?? []).map(normalizeParticipant);
519
519
  },
520
520
  /**
521
521
  * Get unread message count for a single conversation.
@@ -641,6 +641,7 @@ var _getToken = null;
641
641
  var _userId;
642
642
  var _tenantId;
643
643
  var _config = null;
644
+ var _preservingSession = false;
644
645
  function setStatus(s) {
645
646
  _status = s;
646
647
  _statusListeners.forEach((l) => l(s));
@@ -792,7 +793,7 @@ async function _doConnect(config, getToken) {
792
793
  _socket.on("connect", () => setStatus("connected"));
793
794
  _socket.on("disconnect", () => {
794
795
  setStatus("disconnected");
795
- clearTransitSession();
796
+ if (!_preservingSession) clearTransitSession();
796
797
  });
797
798
  _socket.on("connect_error", (err) => {
798
799
  console.error("[AntzChat] Socket connect_error:", err?.message, err?.data);
@@ -895,7 +896,13 @@ function reconnectSocket(token, userId, tenantId) {
895
896
  ...tenantId && { tenantId },
896
897
  transitSessionId: existing.sessionId
897
898
  };
898
- _socket.connect();
899
+ _preservingSession = true;
900
+ try {
901
+ if (_socket.connected) _socket.disconnect();
902
+ _socket.connect();
903
+ } finally {
904
+ _preservingSession = false;
905
+ }
899
906
  return;
900
907
  }
901
908
  if (_getToken) {
@@ -1064,6 +1071,80 @@ var socketEmit = {
1064
1071
  }
1065
1072
  };
1066
1073
 
1074
+ // src/types/index.ts
1075
+ var MENTION_ALL_ID = "all";
1076
+
1077
+ // src/utils/mentions.ts
1078
+ var MENTION_TOKEN_SOURCE = "@\\[([^\\]]+)\\]\\((all|[a-fA-F0-9]{24})\\)";
1079
+ function sanitizeDisplayName(name) {
1080
+ return name.replace(/[\[\]()]/g, "").trim() || "user";
1081
+ }
1082
+ function parseMentions(text) {
1083
+ if (!text) return [];
1084
+ const re = new RegExp(MENTION_TOKEN_SOURCE, "g");
1085
+ const out = [];
1086
+ let m;
1087
+ while ((m = re.exec(text)) !== null) {
1088
+ out.push({
1089
+ id: m[2],
1090
+ displayName: m[1],
1091
+ start: m.index,
1092
+ end: m.index + m[0].length
1093
+ });
1094
+ }
1095
+ return out;
1096
+ }
1097
+ function renderMentionParts(text, resolveName) {
1098
+ if (!text) return [];
1099
+ const mentions = parseMentions(text);
1100
+ if (mentions.length === 0) return [{ type: "text", text }];
1101
+ const parts = [];
1102
+ let cursor = 0;
1103
+ for (const mn of mentions) {
1104
+ if (mn.start > cursor) {
1105
+ parts.push({ type: "text", text: text.slice(cursor, mn.start) });
1106
+ }
1107
+ const displayName = resolveName ? resolveName(mn.id, mn.displayName) : mn.displayName;
1108
+ parts.push({ type: "mention", id: mn.id, displayName });
1109
+ cursor = mn.end;
1110
+ }
1111
+ if (cursor < text.length) {
1112
+ parts.push({ type: "text", text: text.slice(cursor) });
1113
+ }
1114
+ return parts;
1115
+ }
1116
+ function buildMentionText(segments) {
1117
+ let text = "";
1118
+ const ids = [];
1119
+ const seen = /* @__PURE__ */ new Set();
1120
+ for (const seg of segments) {
1121
+ if (typeof seg === "string") {
1122
+ text += seg;
1123
+ } else {
1124
+ text += `@[${sanitizeDisplayName(seg.displayName)}](${seg.id})`;
1125
+ if (!seen.has(seg.id)) {
1126
+ seen.add(seg.id);
1127
+ ids.push(seg.id);
1128
+ }
1129
+ }
1130
+ }
1131
+ return { text, mentions: ids };
1132
+ }
1133
+ function extractMentionIds(text) {
1134
+ const ids = [];
1135
+ const seen = /* @__PURE__ */ new Set();
1136
+ for (const mn of parseMentions(text)) {
1137
+ if (!seen.has(mn.id)) {
1138
+ seen.add(mn.id);
1139
+ ids.push(mn.id);
1140
+ }
1141
+ }
1142
+ return ids;
1143
+ }
1144
+ function isMentionAll(mentions) {
1145
+ return !!mentions?.includes(MENTION_ALL_ID);
1146
+ }
1147
+
1067
1148
  // src/client-facade.ts
1068
1149
  var AntzChatClient = class {
1069
1150
  constructor(rawConfig) {
@@ -1121,8 +1202,10 @@ export {
1121
1202
  AntzChatPermissionError,
1122
1203
  AntzChatServerError,
1123
1204
  AntzChatValidationError,
1205
+ MENTION_ALL_ID,
1124
1206
  appConfigApi,
1125
1207
  authApi,
1208
+ buildMentionText,
1126
1209
  connectSocket,
1127
1210
  conversationsApi,
1128
1211
  createAuthStore,
@@ -1131,6 +1214,7 @@ export {
1131
1214
  devicesApi,
1132
1215
  disconnectSocket,
1133
1216
  encryptPayload,
1217
+ extractMentionIds,
1134
1218
  fetchServerKeys,
1135
1219
  generateEphemeralKey,
1136
1220
  getApiClient,
@@ -1142,14 +1226,17 @@ export {
1142
1226
  getSocketStatus,
1143
1227
  initApiClient,
1144
1228
  initAuthStore,
1229
+ isMentionAll,
1145
1230
  isTransitEnvelope,
1146
1231
  messagesApi,
1147
1232
  normalizeAxiosError,
1148
1233
  normalizeConversation,
1149
1234
  onSocketStatus,
1235
+ parseMentions,
1150
1236
  performHandshake,
1151
1237
  reconnectSocket,
1152
1238
  refreshSocketAuth,
1239
+ renderMentionParts,
1153
1240
  resetAuthStore,
1154
1241
  resolveConfig,
1155
1242
  resolveSystemMessageText,