@scalemule/chat 0.0.8 → 0.0.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.
Files changed (80) hide show
  1. package/dist/ChatClient-DQPHdUHX.d.cts +107 -0
  2. package/dist/ChatClient-DtUKF-4c.d.ts +107 -0
  3. package/dist/constants.d.ts +9 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/core/ChatClient.d.ts +96 -0
  6. package/dist/core/ChatClient.d.ts.map +1 -0
  7. package/dist/core/EventEmitter.d.ts +11 -0
  8. package/dist/core/EventEmitter.d.ts.map +1 -0
  9. package/dist/core/MessageCache.d.ts +18 -0
  10. package/dist/core/MessageCache.d.ts.map +1 -0
  11. package/dist/core/OfflineQueue.d.ts +19 -0
  12. package/dist/core/OfflineQueue.d.ts.map +1 -0
  13. package/dist/element.d.cts +2 -0
  14. package/dist/element.d.ts +2 -0
  15. package/dist/element.d.ts.map +1 -0
  16. package/dist/embed/index.d.ts +2 -0
  17. package/dist/embed/index.d.ts.map +1 -0
  18. package/dist/factory.d.ts +8 -0
  19. package/dist/factory.d.ts.map +1 -0
  20. package/dist/iframe.d.cts +17 -0
  21. package/dist/iframe.d.ts +15 -0
  22. package/dist/iframe.d.ts.map +1 -0
  23. package/dist/index.d.cts +166 -0
  24. package/dist/index.d.ts +8 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/react-components/ChatInput.d.ts +24 -0
  27. package/dist/react-components/ChatInput.d.ts.map +1 -0
  28. package/dist/react-components/ChatMessageItem.d.ts +24 -0
  29. package/dist/react-components/ChatMessageItem.d.ts.map +1 -0
  30. package/dist/react-components/ChatMessageList.d.ts +31 -0
  31. package/dist/react-components/ChatMessageList.d.ts.map +1 -0
  32. package/dist/react-components/ChatThread.d.ts +19 -0
  33. package/dist/react-components/ChatThread.d.ts.map +1 -0
  34. package/dist/react-components/ConversationList.d.ts +13 -0
  35. package/dist/react-components/ConversationList.d.ts.map +1 -0
  36. package/dist/react-components/EmojiPicker.d.ts +15 -0
  37. package/dist/react-components/EmojiPicker.d.ts.map +1 -0
  38. package/dist/react-components/ReactionBar.d.ts +10 -0
  39. package/dist/react-components/ReactionBar.d.ts.map +1 -0
  40. package/dist/react-components/ReportDialog.d.ts +30 -0
  41. package/dist/react-components/ReportDialog.d.ts.map +1 -0
  42. package/dist/react-components/index.d.ts +10 -0
  43. package/dist/react-components/index.d.ts.map +1 -0
  44. package/dist/react-components/theme.d.ts +19 -0
  45. package/dist/react-components/theme.d.ts.map +1 -0
  46. package/dist/react-components/utils.d.ts +4 -0
  47. package/dist/react-components/utils.d.ts.map +1 -0
  48. package/dist/react.cjs +1833 -459
  49. package/dist/react.d.cts +229 -0
  50. package/dist/react.d.ts +72 -0
  51. package/dist/react.d.ts.map +1 -0
  52. package/dist/react.js +1832 -461
  53. package/dist/shared/ChatController.d.ts +65 -0
  54. package/dist/shared/ChatController.d.ts.map +1 -0
  55. package/dist/shared/upload.d.ts +3 -0
  56. package/dist/shared/upload.d.ts.map +1 -0
  57. package/dist/support-widget.global.js +50 -25
  58. package/dist/support.d.ts +99 -0
  59. package/dist/support.d.ts.map +1 -0
  60. package/dist/transport/HttpTransport.d.ts +20 -0
  61. package/dist/transport/HttpTransport.d.ts.map +1 -0
  62. package/dist/transport/WebSocketTransport.d.ts +78 -0
  63. package/dist/transport/WebSocketTransport.d.ts.map +1 -0
  64. package/dist/types-COPVrm3K.d.cts +256 -0
  65. package/dist/types-COPVrm3K.d.ts +256 -0
  66. package/dist/types.d.ts +271 -0
  67. package/dist/types.d.ts.map +1 -0
  68. package/dist/umd.d.ts +6 -0
  69. package/dist/umd.d.ts.map +1 -0
  70. package/dist/version.d.ts +2 -0
  71. package/dist/version.d.ts.map +1 -0
  72. package/dist/widget/icons.d.ts +8 -0
  73. package/dist/widget/icons.d.ts.map +1 -0
  74. package/dist/widget/index.d.ts +2 -0
  75. package/dist/widget/index.d.ts.map +1 -0
  76. package/dist/widget/storage.d.ts +5 -0
  77. package/dist/widget/storage.d.ts.map +1 -0
  78. package/dist/widget/styles.d.ts +3 -0
  79. package/dist/widget/styles.d.ts.map +1 -0
  80. package/package.json +1 -1
@@ -0,0 +1,107 @@
1
+ import { a as ChatEventMap, C as ChatConfig, b as ConnectionStatus, c as CreateConversationOptions, A as ApiResponse, d as Conversation, L as ListConversationsOptions, S as SendMessageOptions, e as ChatMessage, G as GetMessagesOptions, M as MessagesResponse, f as Attachment, U as UnreadTotalResponse, R as ReadStatus, g as ChannelSettings, h as ChannelWithSettings, i as CreateEphemeralChannelOptions, j as CreateLargeRoomOptions } from './types-COPVrm3K.cjs';
2
+
3
+ type Listener<T> = (data: T) => void;
4
+ declare class EventEmitter<EventMap extends Record<string, any>> {
5
+ private listeners;
6
+ on<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
7
+ off<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): void;
8
+ once<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
9
+ emit<K extends keyof EventMap>(event: K, ...[data]: EventMap[K] extends void ? [] : [EventMap[K]]): void;
10
+ removeAllListeners(event?: keyof EventMap): void;
11
+ }
12
+
13
+ declare class ChatClient extends EventEmitter<ChatEventMap> {
14
+ private http;
15
+ private ws;
16
+ private cache;
17
+ private offlineQueue;
18
+ private conversationSubs;
19
+ private conversationTypes;
20
+ private currentUserId?;
21
+ constructor(config: ChatConfig);
22
+ get status(): ConnectionStatus;
23
+ get userId(): string | undefined;
24
+ connect(): void;
25
+ disconnect(): void;
26
+ createConversation(options: CreateConversationOptions): Promise<ApiResponse<Conversation>>;
27
+ listConversations(options?: ListConversationsOptions): Promise<ApiResponse<Conversation[]>>;
28
+ getConversation(id: string): Promise<ApiResponse<Conversation>>;
29
+ private trackConversationType;
30
+ sendMessage(conversationId: string, options: SendMessageOptions): Promise<ApiResponse<ChatMessage>>;
31
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<ApiResponse<MessagesResponse>>;
32
+ editMessage(messageId: string, content: string): Promise<ApiResponse<void>>;
33
+ deleteMessage(messageId: string): Promise<ApiResponse<void>>;
34
+ uploadAttachment(file: File | Blob, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<ApiResponse<Attachment>>;
35
+ refreshAttachmentUrl(messageId: string, fileId: string): Promise<ApiResponse<{
36
+ url: string;
37
+ }>>;
38
+ getCachedMessages(conversationId: string): ChatMessage[];
39
+ stageOptimisticMessage(conversationId: string, message: ChatMessage): ChatMessage;
40
+ addReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
41
+ removeReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
42
+ reportMessage(messageId: string, reason: 'spam' | 'harassment' | 'hate' | 'violence' | 'other', description?: string): Promise<ApiResponse<{
43
+ reported: boolean;
44
+ }>>;
45
+ muteConversation(conversationId: string, mutedUntil?: string): Promise<ApiResponse<{
46
+ muted: boolean;
47
+ }>>;
48
+ unmuteConversation(conversationId: string): Promise<ApiResponse<{
49
+ muted: boolean;
50
+ }>>;
51
+ getUnreadTotal(): Promise<ApiResponse<UnreadTotalResponse>>;
52
+ sendTyping(conversationId: string, isTyping?: boolean): Promise<void>;
53
+ markRead(conversationId: string): Promise<void>;
54
+ getReadStatus(conversationId: string): Promise<ApiResponse<{
55
+ statuses: ReadStatus[];
56
+ }>>;
57
+ addParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
58
+ removeParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
59
+ joinPresence(conversationId: string, userData?: unknown): void;
60
+ leavePresence(conversationId: string): void;
61
+ /** Update presence status (online/away/dnd) without leaving the channel. */
62
+ updatePresence(conversationId: string, status: 'online' | 'away' | 'dnd', userData?: unknown): void;
63
+ getChannelSettings(channelId: string): Promise<ApiResponse<ChannelSettings>>;
64
+ /**
65
+ * Set the conversation type for channel name routing.
66
+ * Large rooms use `conversation:lr:` prefix to skip MySQL in the realtime service.
67
+ */
68
+ setConversationType(conversationId: string, type: Conversation['conversation_type']): void;
69
+ /**
70
+ * Find an active ephemeral or large_room channel by linked session ID.
71
+ * Returns null (not an error) if no active channel exists.
72
+ */
73
+ findChannelBySessionId(linkedSessionId: string): Promise<ChannelWithSettings | null>;
74
+ /**
75
+ * Self-join an ephemeral or large_room channel. Idempotent.
76
+ */
77
+ joinChannel(channelId: string): Promise<ApiResponse<{
78
+ participant_id: string;
79
+ role: string;
80
+ joined_at: string;
81
+ }>>;
82
+ /**
83
+ * Create an ephemeral channel tied to a session (e.g., a video snap).
84
+ */
85
+ createEphemeralChannel(options: CreateEphemeralChannelOptions): Promise<ApiResponse<ChannelWithSettings>>;
86
+ /**
87
+ * Create a large room channel (high-concurrency, skips MySQL tracking in realtime).
88
+ */
89
+ createLargeRoom(options: CreateLargeRoomOptions): Promise<ApiResponse<ChannelWithSettings>>;
90
+ /**
91
+ * Get the global concurrent subscriber count for a conversation.
92
+ */
93
+ getSubscriberCount(conversationId: string): Promise<number>;
94
+ subscribeToConversation(conversationId: string): () => void;
95
+ /** Build channel name with correct prefix based on conversation type. */
96
+ private channelName;
97
+ destroy(): void;
98
+ private handleRealtimeMessage;
99
+ private handlePrivateMessage;
100
+ private normalizeMessage;
101
+ private buildEditedMessage;
102
+ private applyReactionEvent;
103
+ private handleConversationMessage;
104
+ private flushOfflineQueue;
105
+ }
106
+
107
+ export { ChatClient as C, EventEmitter as E };
@@ -0,0 +1,107 @@
1
+ import { a as ChatEventMap, C as ChatConfig, b as ConnectionStatus, c as CreateConversationOptions, A as ApiResponse, d as Conversation, L as ListConversationsOptions, S as SendMessageOptions, e as ChatMessage, G as GetMessagesOptions, M as MessagesResponse, f as Attachment, U as UnreadTotalResponse, R as ReadStatus, g as ChannelSettings, h as ChannelWithSettings, i as CreateEphemeralChannelOptions, j as CreateLargeRoomOptions } from './types-COPVrm3K.js';
2
+
3
+ type Listener<T> = (data: T) => void;
4
+ declare class EventEmitter<EventMap extends Record<string, any>> {
5
+ private listeners;
6
+ on<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
7
+ off<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): void;
8
+ once<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
9
+ emit<K extends keyof EventMap>(event: K, ...[data]: EventMap[K] extends void ? [] : [EventMap[K]]): void;
10
+ removeAllListeners(event?: keyof EventMap): void;
11
+ }
12
+
13
+ declare class ChatClient extends EventEmitter<ChatEventMap> {
14
+ private http;
15
+ private ws;
16
+ private cache;
17
+ private offlineQueue;
18
+ private conversationSubs;
19
+ private conversationTypes;
20
+ private currentUserId?;
21
+ constructor(config: ChatConfig);
22
+ get status(): ConnectionStatus;
23
+ get userId(): string | undefined;
24
+ connect(): void;
25
+ disconnect(): void;
26
+ createConversation(options: CreateConversationOptions): Promise<ApiResponse<Conversation>>;
27
+ listConversations(options?: ListConversationsOptions): Promise<ApiResponse<Conversation[]>>;
28
+ getConversation(id: string): Promise<ApiResponse<Conversation>>;
29
+ private trackConversationType;
30
+ sendMessage(conversationId: string, options: SendMessageOptions): Promise<ApiResponse<ChatMessage>>;
31
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<ApiResponse<MessagesResponse>>;
32
+ editMessage(messageId: string, content: string): Promise<ApiResponse<void>>;
33
+ deleteMessage(messageId: string): Promise<ApiResponse<void>>;
34
+ uploadAttachment(file: File | Blob, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<ApiResponse<Attachment>>;
35
+ refreshAttachmentUrl(messageId: string, fileId: string): Promise<ApiResponse<{
36
+ url: string;
37
+ }>>;
38
+ getCachedMessages(conversationId: string): ChatMessage[];
39
+ stageOptimisticMessage(conversationId: string, message: ChatMessage): ChatMessage;
40
+ addReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
41
+ removeReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
42
+ reportMessage(messageId: string, reason: 'spam' | 'harassment' | 'hate' | 'violence' | 'other', description?: string): Promise<ApiResponse<{
43
+ reported: boolean;
44
+ }>>;
45
+ muteConversation(conversationId: string, mutedUntil?: string): Promise<ApiResponse<{
46
+ muted: boolean;
47
+ }>>;
48
+ unmuteConversation(conversationId: string): Promise<ApiResponse<{
49
+ muted: boolean;
50
+ }>>;
51
+ getUnreadTotal(): Promise<ApiResponse<UnreadTotalResponse>>;
52
+ sendTyping(conversationId: string, isTyping?: boolean): Promise<void>;
53
+ markRead(conversationId: string): Promise<void>;
54
+ getReadStatus(conversationId: string): Promise<ApiResponse<{
55
+ statuses: ReadStatus[];
56
+ }>>;
57
+ addParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
58
+ removeParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
59
+ joinPresence(conversationId: string, userData?: unknown): void;
60
+ leavePresence(conversationId: string): void;
61
+ /** Update presence status (online/away/dnd) without leaving the channel. */
62
+ updatePresence(conversationId: string, status: 'online' | 'away' | 'dnd', userData?: unknown): void;
63
+ getChannelSettings(channelId: string): Promise<ApiResponse<ChannelSettings>>;
64
+ /**
65
+ * Set the conversation type for channel name routing.
66
+ * Large rooms use `conversation:lr:` prefix to skip MySQL in the realtime service.
67
+ */
68
+ setConversationType(conversationId: string, type: Conversation['conversation_type']): void;
69
+ /**
70
+ * Find an active ephemeral or large_room channel by linked session ID.
71
+ * Returns null (not an error) if no active channel exists.
72
+ */
73
+ findChannelBySessionId(linkedSessionId: string): Promise<ChannelWithSettings | null>;
74
+ /**
75
+ * Self-join an ephemeral or large_room channel. Idempotent.
76
+ */
77
+ joinChannel(channelId: string): Promise<ApiResponse<{
78
+ participant_id: string;
79
+ role: string;
80
+ joined_at: string;
81
+ }>>;
82
+ /**
83
+ * Create an ephemeral channel tied to a session (e.g., a video snap).
84
+ */
85
+ createEphemeralChannel(options: CreateEphemeralChannelOptions): Promise<ApiResponse<ChannelWithSettings>>;
86
+ /**
87
+ * Create a large room channel (high-concurrency, skips MySQL tracking in realtime).
88
+ */
89
+ createLargeRoom(options: CreateLargeRoomOptions): Promise<ApiResponse<ChannelWithSettings>>;
90
+ /**
91
+ * Get the global concurrent subscriber count for a conversation.
92
+ */
93
+ getSubscriberCount(conversationId: string): Promise<number>;
94
+ subscribeToConversation(conversationId: string): () => void;
95
+ /** Build channel name with correct prefix based on conversation type. */
96
+ private channelName;
97
+ destroy(): void;
98
+ private handleRealtimeMessage;
99
+ private handlePrivateMessage;
100
+ private normalizeMessage;
101
+ private buildEditedMessage;
102
+ private applyReactionEvent;
103
+ private handleConversationMessage;
104
+ private flushOfflineQueue;
105
+ }
106
+
107
+ export { ChatClient as C, EventEmitter as E };
@@ -0,0 +1,9 @@
1
+ export declare const DEFAULT_API_BASE_URL = "https://api.scalemule.com";
2
+ export declare const DEFAULT_WS_RECONNECT_BASE_DELAY = 1000;
3
+ export declare const DEFAULT_WS_RECONNECT_MAX_DELAY = 30000;
4
+ export declare const DEFAULT_WS_RECONNECT_MAX_RETRIES: number;
5
+ export declare const DEFAULT_WS_HEARTBEAT_INTERVAL = 30000;
6
+ export declare const DEFAULT_MESSAGE_CACHE_SIZE = 200;
7
+ export declare const DEFAULT_MAX_CONVERSATIONS_CACHED = 50;
8
+ export declare const DEFAULT_REQUEST_TIMEOUT = 10000;
9
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,+BAA+B,OAAO,CAAC;AACpD,eAAO,MAAM,8BAA8B,QAAQ,CAAC;AACpD,eAAO,MAAM,gCAAgC,QAAW,CAAC;AACzD,eAAO,MAAM,6BAA6B,QAAQ,CAAC;AACnD,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,gCAAgC,KAAK,CAAC;AACnD,eAAO,MAAM,uBAAuB,QAAQ,CAAC"}
@@ -0,0 +1,96 @@
1
+ import { EventEmitter } from './EventEmitter';
2
+ import type { Attachment, ApiResponse, ChatConfig, ChatEventMap, ChatMessage, ChannelWithSettings, ConnectionStatus, Conversation, CreateConversationOptions, CreateEphemeralChannelOptions, CreateLargeRoomOptions, GetMessagesOptions, ListConversationsOptions, MessagesResponse, ReadStatus, SendMessageOptions, ChannelSettings, UnreadTotalResponse } from '../types';
3
+ export declare class ChatClient extends EventEmitter<ChatEventMap> {
4
+ private http;
5
+ private ws;
6
+ private cache;
7
+ private offlineQueue;
8
+ private conversationSubs;
9
+ private conversationTypes;
10
+ private currentUserId?;
11
+ constructor(config: ChatConfig);
12
+ get status(): ConnectionStatus;
13
+ get userId(): string | undefined;
14
+ connect(): void;
15
+ disconnect(): void;
16
+ createConversation(options: CreateConversationOptions): Promise<ApiResponse<Conversation>>;
17
+ listConversations(options?: ListConversationsOptions): Promise<ApiResponse<Conversation[]>>;
18
+ getConversation(id: string): Promise<ApiResponse<Conversation>>;
19
+ private trackConversationType;
20
+ sendMessage(conversationId: string, options: SendMessageOptions): Promise<ApiResponse<ChatMessage>>;
21
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<ApiResponse<MessagesResponse>>;
22
+ editMessage(messageId: string, content: string): Promise<ApiResponse<void>>;
23
+ deleteMessage(messageId: string): Promise<ApiResponse<void>>;
24
+ uploadAttachment(file: File | Blob, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<ApiResponse<Attachment>>;
25
+ refreshAttachmentUrl(messageId: string, fileId: string): Promise<ApiResponse<{
26
+ url: string;
27
+ }>>;
28
+ getCachedMessages(conversationId: string): ChatMessage[];
29
+ stageOptimisticMessage(conversationId: string, message: ChatMessage): ChatMessage;
30
+ addReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
31
+ removeReaction(messageId: string, emoji: string): Promise<ApiResponse<void>>;
32
+ reportMessage(messageId: string, reason: 'spam' | 'harassment' | 'hate' | 'violence' | 'other', description?: string): Promise<ApiResponse<{
33
+ reported: boolean;
34
+ }>>;
35
+ muteConversation(conversationId: string, mutedUntil?: string): Promise<ApiResponse<{
36
+ muted: boolean;
37
+ }>>;
38
+ unmuteConversation(conversationId: string): Promise<ApiResponse<{
39
+ muted: boolean;
40
+ }>>;
41
+ getUnreadTotal(): Promise<ApiResponse<UnreadTotalResponse>>;
42
+ sendTyping(conversationId: string, isTyping?: boolean): Promise<void>;
43
+ markRead(conversationId: string): Promise<void>;
44
+ getReadStatus(conversationId: string): Promise<ApiResponse<{
45
+ statuses: ReadStatus[];
46
+ }>>;
47
+ addParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
48
+ removeParticipant(conversationId: string, userId: string): Promise<ApiResponse<void>>;
49
+ joinPresence(conversationId: string, userData?: unknown): void;
50
+ leavePresence(conversationId: string): void;
51
+ /** Update presence status (online/away/dnd) without leaving the channel. */
52
+ updatePresence(conversationId: string, status: 'online' | 'away' | 'dnd', userData?: unknown): void;
53
+ getChannelSettings(channelId: string): Promise<ApiResponse<ChannelSettings>>;
54
+ /**
55
+ * Set the conversation type for channel name routing.
56
+ * Large rooms use `conversation:lr:` prefix to skip MySQL in the realtime service.
57
+ */
58
+ setConversationType(conversationId: string, type: Conversation['conversation_type']): void;
59
+ /**
60
+ * Find an active ephemeral or large_room channel by linked session ID.
61
+ * Returns null (not an error) if no active channel exists.
62
+ */
63
+ findChannelBySessionId(linkedSessionId: string): Promise<ChannelWithSettings | null>;
64
+ /**
65
+ * Self-join an ephemeral or large_room channel. Idempotent.
66
+ */
67
+ joinChannel(channelId: string): Promise<ApiResponse<{
68
+ participant_id: string;
69
+ role: string;
70
+ joined_at: string;
71
+ }>>;
72
+ /**
73
+ * Create an ephemeral channel tied to a session (e.g., a video snap).
74
+ */
75
+ createEphemeralChannel(options: CreateEphemeralChannelOptions): Promise<ApiResponse<ChannelWithSettings>>;
76
+ /**
77
+ * Create a large room channel (high-concurrency, skips MySQL tracking in realtime).
78
+ */
79
+ createLargeRoom(options: CreateLargeRoomOptions): Promise<ApiResponse<ChannelWithSettings>>;
80
+ /**
81
+ * Get the global concurrent subscriber count for a conversation.
82
+ */
83
+ getSubscriberCount(conversationId: string): Promise<number>;
84
+ subscribeToConversation(conversationId: string): () => void;
85
+ /** Build channel name with correct prefix based on conversation type. */
86
+ private channelName;
87
+ destroy(): void;
88
+ private handleRealtimeMessage;
89
+ private handlePrivateMessage;
90
+ private normalizeMessage;
91
+ private buildEditedMessage;
92
+ private applyReactionEvent;
93
+ private handleConversationMessage;
94
+ private flushOfflineQueue;
95
+ }
96
+ //# sourceMappingURL=ChatClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChatClient.d.ts","sourceRoot":"","sources":["../../src/core/ChatClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAO9C,OAAO,KAAK,EACV,UAAU,EACV,WAAW,EACX,UAAU,EACV,YAAY,EACZ,WAAW,EAEX,mBAAmB,EACnB,gBAAgB,EAChB,YAAY,EACZ,yBAAyB,EACzB,6BAA6B,EAC7B,sBAAsB,EACtB,kBAAkB,EAClB,wBAAwB,EAExB,gBAAgB,EAGhB,UAAU,EACV,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EAEpB,MAAM,UAAU,CAAC;AAElB,qBAAa,UAAW,SAAQ,YAAY,CAAC,YAAY,CAAC;IACxD,OAAO,CAAC,IAAI,CAAgB;IAC5B,OAAO,CAAC,EAAE,CAAqB;IAC/B,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,iBAAiB,CAAwD;IACjF,OAAO,CAAC,aAAa,CAAC,CAAS;gBAEnB,MAAM,EAAE,UAAU;IA2E9B,IAAI,MAAM,IAAI,gBAAgB,CAE7B;IAED,IAAI,MAAM,IAAI,MAAM,GAAG,SAAS,CAE/B;IAED,OAAO,IAAI,IAAI;IAIf,UAAU,IAAI,IAAI;IAUZ,kBAAkB,CAAC,OAAO,EAAE,yBAAyB,GAAG,O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BAAkB;IAyB1B,OAAO,CAAC,kBAAkB;IA0D1B,OAAO,CAAC,yBAAyB;YAoGnB,iBAAiB;CAUhC"}
@@ -0,0 +1,11 @@
1
+ type Listener<T> = (data: T) => void;
2
+ export declare class EventEmitter<EventMap extends Record<string, any>> {
3
+ private listeners;
4
+ on<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
5
+ off<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): void;
6
+ once<K extends keyof EventMap>(event: K, callback: Listener<EventMap[K]>): () => void;
7
+ emit<K extends keyof EventMap>(event: K, ...[data]: EventMap[K] extends void ? [] : [EventMap[K]]): void;
8
+ removeAllListeners(event?: keyof EventMap): void;
9
+ }
10
+ export {};
11
+ //# sourceMappingURL=EventEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../../src/core/EventEmitter.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,CAAC;AAGrC,qBAAa,YAAY,CAAC,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAC5D,OAAO,CAAC,SAAS,CAAqD;IAEtE,EAAE,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAQnF,GAAG,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI;IAI9E,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAQrF,IAAI,CAAC,CAAC,SAAS,MAAM,QAAQ,EAC3B,KAAK,EAAE,CAAC,EACR,GAAG,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,SAAS,IAAI,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GACvD,IAAI;IAaP,kBAAkB,CAAC,KAAK,CAAC,EAAE,MAAM,QAAQ,GAAG,IAAI;CAOjD"}
@@ -0,0 +1,18 @@
1
+ import type { ChatMessage } from '../types';
2
+ export declare class MessageCache {
3
+ private cache;
4
+ private maxMessages;
5
+ private maxConversations;
6
+ constructor(maxMessages?: number, maxConversations?: number);
7
+ getMessages(conversationId: string): ChatMessage[];
8
+ getMessage(conversationId: string, messageId: string): ChatMessage | undefined;
9
+ setMessages(conversationId: string, messages: ChatMessage[]): void;
10
+ addMessage(conversationId: string, message: ChatMessage): void;
11
+ upsertMessage(conversationId: string, message: ChatMessage): void;
12
+ updateMessage(conversationId: string, message: ChatMessage): void;
13
+ reconcileOptimisticMessage(conversationId: string, message: ChatMessage): ChatMessage;
14
+ removeMessage(conversationId: string, messageId: string): void;
15
+ clear(conversationId?: string): void;
16
+ private evictOldConversations;
17
+ }
18
+ //# sourceMappingURL=MessageCache.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MessageCache.d.ts","sourceRoot":"","sources":["../../src/core/MessageCache.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAoC;IACjD,OAAO,CAAC,WAAW,CAAS;IAC5B,OAAO,CAAC,gBAAgB,CAAS;gBAErB,WAAW,CAAC,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,MAAM;IAK3D,WAAW,CAAC,cAAc,EAAE,MAAM,GAAG,WAAW,EAAE;IAIlD,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI9E,WAAW,CAAC,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,IAAI;IAKlE,UAAU,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IAc9D,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IASjE,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,IAAI;IASjE,0BAA0B,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,GAAG,WAAW;IAyBrF,aAAa,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,IAAI;IAS9D,KAAK,CAAC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI;IAQpC,OAAO,CAAC,qBAAqB;CAM9B"}
@@ -0,0 +1,19 @@
1
+ interface QueuedMessage {
2
+ conversationId: string;
3
+ content: string;
4
+ message_type: string;
5
+ attachments?: unknown[];
6
+ timestamp: number;
7
+ }
8
+ export declare class OfflineQueue {
9
+ private queue;
10
+ private enabled;
11
+ constructor(enabled?: boolean);
12
+ enqueue(conversationId: string, content: string, messageType?: string, attachments?: unknown[]): void;
13
+ drain(): QueuedMessage[];
14
+ get size(): number;
15
+ private save;
16
+ private load;
17
+ }
18
+ export {};
19
+ //# sourceMappingURL=OfflineQueue.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OfflineQueue.d.ts","sourceRoot":"","sources":["../../src/core/OfflineQueue.ts"],"names":[],"mappings":"AAEA,UAAU,aAAa;IACrB,cAAc,EAAE,MAAM,CAAC;IACvB,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,EAAE,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAuB;IACpC,OAAO,CAAC,OAAO,CAAU;gBAEb,OAAO,UAAO;IAO1B,OAAO,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,WAAW,SAAS,EAAE,WAAW,CAAC,EAAE,OAAO,EAAE,GAAG,IAAI;IAYrG,KAAK,IAAI,aAAa,EAAE;IAOxB,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,OAAO,CAAC,IAAI;IAUZ,OAAO,CAAC,IAAI;CAYb"}
@@ -0,0 +1,2 @@
1
+
2
+ export { }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../src/element.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/embed/index.ts"],"names":[],"mappings":""}
@@ -0,0 +1,8 @@
1
+ import { ChatClient } from './core/ChatClient';
2
+ import type { ChatConfig } from './types';
3
+ export declare const ScaleMuleChat: {
4
+ create(config: ChatConfig): ChatClient;
5
+ version: string;
6
+ };
7
+ export type { ChatConfig };
8
+ //# sourceMappingURL=factory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,aAAa;mBACT,UAAU,GAAG,UAAU;;CAKvC,CAAC;AAEF,YAAY,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { C as ChatConfig } from './types-COPVrm3K.cjs';
2
+
3
+ declare class ChatIframeController {
4
+ private iframe;
5
+ private listeners;
6
+ constructor(container: HTMLElement, config: ChatConfig & {
7
+ conversationId?: string;
8
+ iframeSrc?: string;
9
+ });
10
+ on(event: string, callback: (data: unknown) => void): () => void;
11
+ sendMessage(content: string): void;
12
+ destroy(): void;
13
+ private handleMessage;
14
+ private postToIframe;
15
+ }
16
+
17
+ export { ChatIframeController };
@@ -0,0 +1,15 @@
1
+ import type { ChatConfig } from './types';
2
+ export declare class ChatIframeController {
3
+ private iframe;
4
+ private listeners;
5
+ constructor(container: HTMLElement, config: ChatConfig & {
6
+ conversationId?: string;
7
+ iframeSrc?: string;
8
+ });
9
+ on(event: string, callback: (data: unknown) => void): () => void;
10
+ sendMessage(content: string): void;
11
+ destroy(): void;
12
+ private handleMessage;
13
+ private postToIframe;
14
+ }
15
+ //# sourceMappingURL=iframe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"iframe.d.ts","sourceRoot":"","sources":["../src/iframe.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,SAAS,CAAC;AAEvD,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,SAAS,CAAmD;gBAGlE,SAAS,EAAE,WAAW,EACtB,MAAM,EAAE,UAAU,GAAG;QAAE,cAAc,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE;IAkBtE,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,GAAG,MAAM,IAAI;IAQhE,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAIlC,OAAO,IAAI,IAAI;IAMf,OAAO,CAAC,aAAa,CAQnB;IAEF,OAAO,CAAC,YAAY;CAGrB"}
@@ -0,0 +1,166 @@
1
+ import { C as ChatClient, E as EventEmitter } from './ChatClient-DQPHdUHX.cjs';
2
+ import { f as Attachment, e as ChatMessage, R as ReadStatus, A as ApiResponse } from './types-COPVrm3K.cjs';
3
+ export { k as ApiError, g as ChannelSettings, h as ChannelWithSettings, C as ChatConfig, a as ChatEventMap, l as ChatReaction, b as ConnectionStatus, d as Conversation, c as CreateConversationOptions, i as CreateEphemeralChannelOptions, j as CreateLargeRoomOptions, G as GetMessagesOptions, L as ListConversationsOptions, m as MessageEditedEvent, M as MessagesResponse, P as Participant, n as PresenceMember, o as ReactionEvent, p as ReactionSummary, S as SendMessageOptions, U as UnreadTotalResponse } from './types-COPVrm3K.cjs';
4
+
5
+ /**
6
+ * SupportClient — High-level client for the support chat widget.
7
+ *
8
+ * Handles visitor session lifecycle (create/restore/refresh) and exposes
9
+ * the underlying ChatClient for real-time messaging.
10
+ *
11
+ * Usage:
12
+ * ```ts
13
+ * const support = new SupportClient({ apiKey: 'pb_...', apiBaseUrl: 'https://api.scalemule.com' });
14
+ * await support.initVisitorSession({ name: 'Jane' });
15
+ * const conversation = await support.startConversation('Hi, I need help!', { page_url: location.href });
16
+ * support.chat.on('message', (msg) => console.log(msg));
17
+ * ```
18
+ */
19
+
20
+ interface SupportConversation {
21
+ id: string;
22
+ conversation_id: string;
23
+ status: string;
24
+ visitor_name?: string;
25
+ visitor_email?: string;
26
+ visitor_page_url?: string;
27
+ assigned_rep_id?: string;
28
+ assigned_rep_name?: string;
29
+ last_message_preview?: string;
30
+ last_message_at?: string;
31
+ created_at: string;
32
+ existing?: boolean;
33
+ }
34
+ interface SupportWidgetPreChatField {
35
+ key: string;
36
+ label: string;
37
+ type: string;
38
+ required: boolean;
39
+ }
40
+ interface SupportWidgetConfig {
41
+ title: string;
42
+ subtitle: string;
43
+ primary_color: string;
44
+ position: 'left' | 'right';
45
+ pre_chat_fields: SupportWidgetPreChatField[];
46
+ business_hours: Record<string, unknown>;
47
+ realtime_enabled: boolean;
48
+ welcome_message: string;
49
+ offline_message: string;
50
+ reps_online: boolean;
51
+ online_count: number;
52
+ }
53
+ interface SupportClientConfig {
54
+ apiKey: string;
55
+ apiBaseUrl?: string;
56
+ wsUrl?: string;
57
+ }
58
+ declare class SupportClient {
59
+ private chatClient;
60
+ private apiKey;
61
+ private apiBaseUrl;
62
+ private wsUrl?;
63
+ private storageKey;
64
+ private anonymousId;
65
+ private refreshToken;
66
+ private accessToken;
67
+ private tokenExpiresAt;
68
+ private userId;
69
+ private visitorName;
70
+ private visitorEmail;
71
+ constructor(config: SupportClientConfig);
72
+ /** Create or restore a visitor session. Call before startConversation(). */
73
+ initVisitorSession(info?: {
74
+ name?: string;
75
+ email?: string;
76
+ }): Promise<void>;
77
+ /** Start a new support conversation with the first message. */
78
+ startConversation(message: string, meta?: {
79
+ page_url?: string;
80
+ attachments?: Attachment[];
81
+ metadata?: Record<string, unknown>;
82
+ }): Promise<SupportConversation>;
83
+ /** Get the visitor's active/waiting support conversation, if any. */
84
+ getActiveConversation(): Promise<SupportConversation | null>;
85
+ /** Fetch widget configuration and live support availability. */
86
+ getWidgetConfig(): Promise<SupportWidgetConfig>;
87
+ /** Get the underlying ChatClient for messaging, events, typing indicators, etc. */
88
+ get chat(): ChatClient;
89
+ /** Whether a visitor session has been initialized. */
90
+ get isInitialized(): boolean;
91
+ connect(): void;
92
+ disconnect(): void;
93
+ /** The visitor's user ID (available after initVisitorSession). */
94
+ get visitorUserId(): string | null;
95
+ /** Clean up all resources. */
96
+ destroy(): void;
97
+ private initChatClient;
98
+ private refreshAccessToken;
99
+ private loadState;
100
+ private saveState;
101
+ }
102
+
103
+ interface PresenceStateMember {
104
+ userId: string;
105
+ status: string;
106
+ userData?: unknown;
107
+ }
108
+ interface ChatControllerInitOptions {
109
+ realtime?: boolean;
110
+ presence?: boolean;
111
+ }
112
+ interface ChatControllerState {
113
+ conversationId: string;
114
+ messages: ChatMessage[];
115
+ readStatuses: ReadStatus[];
116
+ typingUsers: string[];
117
+ members: PresenceStateMember[];
118
+ hasMore: boolean;
119
+ isLoading: boolean;
120
+ error: string | null;
121
+ }
122
+ interface ChatControllerEvents {
123
+ state: ChatControllerState;
124
+ ready: ChatControllerState;
125
+ error: {
126
+ message: string;
127
+ };
128
+ }
129
+ declare class ChatController extends EventEmitter<ChatControllerEvents> {
130
+ private readonly client;
131
+ private readonly conversationId;
132
+ private readonly typingTimers;
133
+ private unsubscribers;
134
+ private state;
135
+ constructor(client: ChatClient, conversationId: string);
136
+ getState(): ChatControllerState;
137
+ init(options?: ChatControllerInitOptions): Promise<ChatControllerState>;
138
+ loadMore(): Promise<void>;
139
+ sendMessage(content: string, attachments?: Attachment[]): Promise<void>;
140
+ stageOptimisticMessage(message: ChatMessage): ChatMessage;
141
+ uploadAttachment(file: File | Blob, onProgress?: (percent: number) => void, signal?: AbortSignal): Promise<ApiResponse<Attachment>>;
142
+ refreshAttachmentUrl(messageId: string, fileId: string): Promise<ApiResponse<{
143
+ url: string;
144
+ }>>;
145
+ addReaction(messageId: string, emoji: string): Promise<void>;
146
+ removeReaction(messageId: string, emoji: string): Promise<void>;
147
+ reportMessage(messageId: string, reason: 'spam' | 'harassment' | 'hate' | 'violence' | 'other', description?: string): Promise<ApiResponse<{
148
+ reported: boolean;
149
+ }>>;
150
+ muteConversation(mutedUntil?: string): Promise<ApiResponse<{
151
+ muted: boolean;
152
+ }>>;
153
+ unmuteConversation(): Promise<ApiResponse<{
154
+ muted: boolean;
155
+ }>>;
156
+ markRead(): Promise<void>;
157
+ refreshReadStatus(): Promise<ReadStatus[]>;
158
+ sendTyping(isTyping?: boolean): void;
159
+ destroy(): void;
160
+ private bindEvents;
161
+ private patchState;
162
+ }
163
+
164
+ declare const CHAT_VERSION = "0.0.7";
165
+
166
+ export { ApiResponse, Attachment, CHAT_VERSION, ChatClient, ChatController, type ChatControllerState, ChatMessage, ReadStatus, SupportClient, type SupportClientConfig, type SupportConversation, type SupportWidgetConfig, type SupportWidgetPreChatField };
@@ -0,0 +1,8 @@
1
+ export { ChatClient } from './core/ChatClient';
2
+ export { SupportClient } from './support';
3
+ export { ChatController } from './shared/ChatController';
4
+ export type { SupportConversation, SupportClientConfig, SupportWidgetConfig, SupportWidgetPreChatField, } from './support';
5
+ export type { ChatControllerState } from './shared/ChatController';
6
+ export { CHAT_VERSION } from './version';
7
+ export type { ApiError, ApiResponse, Attachment, ChannelSettings, ChannelWithSettings, ChatConfig, ChatEventMap, ChatMessage, ChatReaction, ConnectionStatus, Conversation, CreateConversationOptions, CreateEphemeralChannelOptions, CreateLargeRoomOptions, GetMessagesOptions, ListConversationsOptions, MessageEditedEvent, MessagesResponse, Participant, PresenceMember, ReactionEvent, ReactionSummary, ReadStatus, SendMessageOptions, UnreadTotalResponse, } from './types';
8
+ //# sourceMappingURL=index.d.ts.map