@minicode-dev/chat 0.0.0-stage → 0.1.1
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/CHANGELOG.md +24 -0
- package/README.md +163 -2
- package/assets/sounds/battleship_audio_pack/assets/cannon_fire.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/cruiser_damage_alarm.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/defeat.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ocean_ambient_loop.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/projectile_flyby.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_heavy_hit.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_hit.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_place.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_rotate.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ship_sinking.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/sonar_ping.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/ui_click.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/victory.ogg +0 -0
- package/assets/sounds/battleship_audio_pack/assets/water_splash.ogg +0 -0
- package/assets/sounds/connect4/close.ogg +0 -0
- package/assets/sounds/connect4/draw.ogg +0 -0
- package/assets/sounds/connect4/drop.ogg +0 -0
- package/assets/sounds/connect4/invite.ogg +0 -0
- package/assets/sounds/connect4/lose.ogg +0 -0
- package/assets/sounds/connect4/start.ogg +0 -0
- package/assets/sounds/connect4/turn.ogg +0 -0
- package/assets/sounds/connect4/win.ogg +0 -0
- package/assets/sounds/notification.mp3 +0 -0
- package/assets/sounds/notification.ogg +0 -0
- package/assets/sounds/ting.mp3 +0 -0
- package/assets/sounds/ting.ogg +0 -0
- package/dist/chunks/BattleshipGameCard-CW_A8Nim.js +958 -0
- package/dist/chunks/BattleshipGameCard-CW_A8Nim.js.map +1 -0
- package/dist/chunks/BattleshipPrototype-Duz-S1JE.js +373 -0
- package/dist/chunks/BattleshipPrototype-Duz-S1JE.js.map +1 -0
- package/dist/chunks/battleship-DXKuIZ1I.js +124 -0
- package/dist/chunks/battleship-DXKuIZ1I.js.map +1 -0
- package/dist/chunks/connect4Sounds-Do3nvVFx.js +1847 -0
- package/dist/chunks/connect4Sounds-Do3nvVFx.js.map +1 -0
- package/dist/chunks/createBattleScene-HIAvjixn.js +1621 -0
- package/dist/chunks/createBattleScene-HIAvjixn.js.map +1 -0
- package/dist/chunks/webglSupport-2WjPEPZ_.js +16 -0
- package/dist/chunks/webglSupport-2WjPEPZ_.js.map +1 -0
- package/dist/index.js +9519 -0
- package/dist/index.js.map +1 -0
- package/dist/styles.css +2 -0
- package/index.d.ts +470 -0
- package/package.json +67 -4
package/index.d.ts
ADDED
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
// Hand-written public types for @minicode-dev/chat. Keep in sync with src/index.js.
|
|
2
|
+
import type { ComponentType, Context, ReactNode } from 'react';
|
|
3
|
+
import type { StoreApi } from 'zustand/vanilla';
|
|
4
|
+
|
|
5
|
+
export const MINICODE_CHAT_VERSION: string;
|
|
6
|
+
|
|
7
|
+
/* ------------------------------------------------------------------ */
|
|
8
|
+
/* Transport */
|
|
9
|
+
/* ------------------------------------------------------------------ */
|
|
10
|
+
|
|
11
|
+
export type TransportStatus = 'idle' | 'connecting' | 'connected' | 'disconnected' | 'error';
|
|
12
|
+
|
|
13
|
+
export interface InboundFrame {
|
|
14
|
+
event?: string;
|
|
15
|
+
type?: string;
|
|
16
|
+
data?: any;
|
|
17
|
+
payload?: any;
|
|
18
|
+
[key: string]: any;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ChatIdentity {
|
|
22
|
+
userId: string | null;
|
|
23
|
+
/** `${backend}:${userId}` */
|
|
24
|
+
scope: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export interface ChatTransport {
|
|
28
|
+
/** Opens the connection (the shared adapter delegates to the host). */
|
|
29
|
+
connect(): Promise<void>;
|
|
30
|
+
/** Voluntary close. The shared adapter never closes the host socket. */
|
|
31
|
+
close(code?: number): void;
|
|
32
|
+
/** Fire-and-forget. Returns false when the socket is not OPEN; never throws. */
|
|
33
|
+
send(action: string, payload?: object): boolean;
|
|
34
|
+
/** Adds `request_id`; resolves on CHAT_ACK, rejects on correlated ERROR, timeout or close. */
|
|
35
|
+
request(action: string, payload?: object, opts?: { timeoutMs?: number }): Promise<InboundFrame>;
|
|
36
|
+
/** The handler returns true when it consumed the frame. Returns an unsubscribe function. */
|
|
37
|
+
onEvent(handler: (frame: InboundFrame) => boolean | void): () => void;
|
|
38
|
+
getStatus(): TransportStatus;
|
|
39
|
+
onStatus(cb: (status: TransportStatus, prev: TransportStatus) => void): () => void;
|
|
40
|
+
/** Changes on every reconnection. */
|
|
41
|
+
getConnectionId(): string | null;
|
|
42
|
+
getIdentity(): ChatIdentity;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface ReconnectOptions {
|
|
46
|
+
max?: number;
|
|
47
|
+
baseMs?: number;
|
|
48
|
+
capMs?: number;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface StandaloneTransportOptions {
|
|
52
|
+
url: string | (() => string | Promise<string>);
|
|
53
|
+
getToken?: () => string | null | undefined | Promise<string | null | undefined>;
|
|
54
|
+
tokenParam?: string;
|
|
55
|
+
reconnect?: ReconnectOptions;
|
|
56
|
+
isFatal?: (frame: InboundFrame) => boolean;
|
|
57
|
+
ping?: false | { action?: string; everyMs: number };
|
|
58
|
+
identity?: () => ChatIdentity;
|
|
59
|
+
WebSocketImpl?: typeof WebSocket;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function createStandaloneTransport(opts: StandaloneTransportOptions): ChatTransport;
|
|
63
|
+
export const TRANSPORT_STATUSES: readonly TransportStatus[];
|
|
64
|
+
/** Validates (dev) that `obj` implements ChatTransport; throws listing missing members. */
|
|
65
|
+
export function assertTransport(obj: unknown): ChatTransport;
|
|
66
|
+
|
|
67
|
+
/* ------------------------------------------------------------------ */
|
|
68
|
+
/* Connection store */
|
|
69
|
+
/* ------------------------------------------------------------------ */
|
|
70
|
+
|
|
71
|
+
export const chatConnectionStore: StoreApi<{ status: TransportStatus | string }>;
|
|
72
|
+
export function setChatConnectionStatus(status: TransportStatus | string): void;
|
|
73
|
+
export function useChatConnectionStatus(): TransportStatus | string;
|
|
74
|
+
|
|
75
|
+
/* ------------------------------------------------------------------ */
|
|
76
|
+
/* Config */
|
|
77
|
+
/* ------------------------------------------------------------------ */
|
|
78
|
+
|
|
79
|
+
export interface ChatUser {
|
|
80
|
+
id?: string | number;
|
|
81
|
+
user_id?: string | number;
|
|
82
|
+
name?: string;
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export interface ChatGamesFeatures {
|
|
87
|
+
connect4?: boolean;
|
|
88
|
+
battleship?: boolean;
|
|
89
|
+
battleshipPreview?: boolean;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface ChatFeatures {
|
|
93
|
+
reactions?: boolean;
|
|
94
|
+
editing?: boolean;
|
|
95
|
+
replies?: boolean;
|
|
96
|
+
files?: boolean;
|
|
97
|
+
voice?: boolean;
|
|
98
|
+
gifs?: boolean;
|
|
99
|
+
stickers?: boolean;
|
|
100
|
+
presence?: boolean;
|
|
101
|
+
groups?: boolean;
|
|
102
|
+
privateChats?: boolean;
|
|
103
|
+
games?: ChatGamesFeatures | false;
|
|
104
|
+
detach?: { path?: string; windowName?: string } | false;
|
|
105
|
+
install?: boolean;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export interface ChatCustomEmoji {
|
|
109
|
+
shortcode: string;
|
|
110
|
+
url?: string;
|
|
111
|
+
label?: string;
|
|
112
|
+
keywords?: string[];
|
|
113
|
+
shortcodes?: string[];
|
|
114
|
+
[key: string]: any;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface ChatStorageAdapter {
|
|
118
|
+
getItem(key: string): string | null;
|
|
119
|
+
setItem(key: string, value: string): void;
|
|
120
|
+
removeItem(key: string): void;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface ChatCallbacks {
|
|
124
|
+
onError?: (error: unknown) => void;
|
|
125
|
+
onOpenChange?: (open: boolean) => void;
|
|
126
|
+
onOpenConversation?: (conversation: any) => void;
|
|
127
|
+
onUnreadChange?: (total: number) => void;
|
|
128
|
+
onConnectionChange?: (status: TransportStatus) => void;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ChatConfig {
|
|
132
|
+
websocket?: {
|
|
133
|
+
url?: string | (() => string | Promise<string>) | null;
|
|
134
|
+
reconnect?: ReconnectOptions;
|
|
135
|
+
ping?: false | { action?: string; everyMs: number };
|
|
136
|
+
legacyRoomIdRouting?: boolean;
|
|
137
|
+
};
|
|
138
|
+
auth?: {
|
|
139
|
+
getToken?: (() => string | null | undefined | Promise<string | null | undefined>) | null;
|
|
140
|
+
tokenParam?: string;
|
|
141
|
+
};
|
|
142
|
+
/** Used as the standalone transport identity provider. */
|
|
143
|
+
user?: (() => ChatIdentity) | ChatUser | null;
|
|
144
|
+
scope?: string | null;
|
|
145
|
+
features?: ChatFeatures | false;
|
|
146
|
+
theme?: {
|
|
147
|
+
mode?: 'auto' | 'light' | 'dark';
|
|
148
|
+
tokens?: Record<string, string>;
|
|
149
|
+
fontSize?: number;
|
|
150
|
+
};
|
|
151
|
+
media?: {
|
|
152
|
+
klipy?: false | { apiKey: string; locale?: string; categoriesLocale?: string };
|
|
153
|
+
emoji?: { custom?: ChatCustomEmoji[]; lazy?: boolean };
|
|
154
|
+
maxAttachmentBytes?: number;
|
|
155
|
+
trustedMediaHosts?: string[];
|
|
156
|
+
};
|
|
157
|
+
notifications?: {
|
|
158
|
+
desktop?: boolean;
|
|
159
|
+
previews?: boolean;
|
|
160
|
+
sound?: boolean;
|
|
161
|
+
appBadge?: boolean;
|
|
162
|
+
} | false;
|
|
163
|
+
assets?: { baseUrl?: string | null };
|
|
164
|
+
storage?: { prefix?: string; adapter?: ChatStorageAdapter };
|
|
165
|
+
locale?: string;
|
|
166
|
+
portalContainer?: HTMLElement | (() => HTMLElement | null) | null;
|
|
167
|
+
callbacks?: ChatCallbacks;
|
|
168
|
+
[key: string]: any;
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/** Config after `normalizeConfig`: every section present (or `false`) and frozen. */
|
|
172
|
+
export type NormalizedChatConfig = Readonly<ChatConfig> & {
|
|
173
|
+
readonly callbacks: Readonly<Required<ChatCallbacks>>;
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
export const DEFAULT_CONFIG: NormalizedChatConfig;
|
|
177
|
+
export function normalizeConfig(config?: ChatConfig): NormalizedChatConfig;
|
|
178
|
+
|
|
179
|
+
/* ------------------------------------------------------------------ */
|
|
180
|
+
/* Chat domain store */
|
|
181
|
+
/* ------------------------------------------------------------------ */
|
|
182
|
+
|
|
183
|
+
/** Anything zustand-like: vanilla store or bound hook. */
|
|
184
|
+
export interface StoreLike<T = any> {
|
|
185
|
+
getState(): T;
|
|
186
|
+
subscribe(listener: (state: T, prev: T) => void): () => void;
|
|
187
|
+
setState?: (partial: Partial<T> | ((state: T) => Partial<T>), replace?: boolean) => void;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
export interface ChatState {
|
|
191
|
+
chatMessages: any[];
|
|
192
|
+
chatState: Record<string, any>;
|
|
193
|
+
onlineUsers: any[];
|
|
194
|
+
presenceStatus: string;
|
|
195
|
+
userSearchResults: any[];
|
|
196
|
+
userSearchQuery: string;
|
|
197
|
+
userSearchStatus: string;
|
|
198
|
+
privateRooms: Record<string, any>;
|
|
199
|
+
knownUsers: Record<string, any>;
|
|
200
|
+
myPresence: Record<string, any>;
|
|
201
|
+
[key: string]: any;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface CreateChatStoreOptions {
|
|
205
|
+
transport: ChatTransport;
|
|
206
|
+
/** Defaults to a CHAT_MESSAGE request without attachments (hosts with file relay inject theirs). */
|
|
207
|
+
sendMessage?: (roomId: string, message: string, attachments?: any[]) => Promise<void>;
|
|
208
|
+
/** Every id form of the current user (id, user_id, sub). */
|
|
209
|
+
getOwnIds?: () => string[];
|
|
210
|
+
/** Desktop notification click (after selectChat). */
|
|
211
|
+
onOpenChat?: (room: string) => void;
|
|
212
|
+
maxMessages?: number;
|
|
213
|
+
games?: StoreLike;
|
|
214
|
+
unread?: StoreLike<{ counts?: Record<string, number>; [key: string]: any }>;
|
|
215
|
+
extras?: StoreLike;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function createChatStore(options: CreateChatStoreOptions): StoreApi<ChatState>;
|
|
219
|
+
|
|
220
|
+
/* ------------------------------------------------------------------ */
|
|
221
|
+
/* Provider and hooks */
|
|
222
|
+
/* ------------------------------------------------------------------ */
|
|
223
|
+
|
|
224
|
+
export interface ChatStores {
|
|
225
|
+
unread?: StoreLike<{ counts?: Record<string, number>; [key: string]: any }>;
|
|
226
|
+
[key: string]: StoreLike | undefined;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface ChatProviderProps {
|
|
230
|
+
config?: ChatConfig;
|
|
231
|
+
/** Injected transport (e.g. LIRA adapter). Never closed by the provider. */
|
|
232
|
+
transport?: ChatTransport;
|
|
233
|
+
stores?: ChatStores;
|
|
234
|
+
/** Pre-built chat domain store; created internally when omitted. */
|
|
235
|
+
chatStore?: StoreApi<ChatState>;
|
|
236
|
+
children?: ReactNode;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
export interface ChatContextValue {
|
|
240
|
+
config: NormalizedChatConfig;
|
|
241
|
+
transport: ChatTransport | null;
|
|
242
|
+
stores: ChatStores;
|
|
243
|
+
chatStore?: StoreApi<ChatState>;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
export const LiraChatProvider: ComponentType<ChatProviderProps>;
|
|
247
|
+
export const ChatContext: Context<ChatContextValue | null>;
|
|
248
|
+
/** Throws when used outside LiraChatProvider. */
|
|
249
|
+
export function useChatContext(): ChatContextValue;
|
|
250
|
+
export function useChatConfig(): NormalizedChatConfig;
|
|
251
|
+
export function useChatTransport(): ChatTransport | null;
|
|
252
|
+
export function useChatConnection(): { status: TransportStatus; connectionId: string | null };
|
|
253
|
+
export function useChatUnreadTotal(): number;
|
|
254
|
+
|
|
255
|
+
/* ------------------------------------------------------------------ */
|
|
256
|
+
/* Protocol helpers (frozen wire format) */
|
|
257
|
+
/* ------------------------------------------------------------------ */
|
|
258
|
+
|
|
259
|
+
export const EDIT_PREFIX: 'LIRA_EDIT_V1:';
|
|
260
|
+
export const REACT_PREFIX: 'LIRA_REACT_V1:';
|
|
261
|
+
export const STICKER_NAME_PREFIX: 'sticker:';
|
|
262
|
+
|
|
263
|
+
export type MessageAction =
|
|
264
|
+
| { type: 'edit'; targetId: string; text: string }
|
|
265
|
+
| { type: 'react'; targetId: string; emoji: string; on: boolean };
|
|
266
|
+
|
|
267
|
+
export function encodeEdit(args: { targetId: string | number; text: string }): string;
|
|
268
|
+
export function encodeReaction(args: { targetId: string | number; emoji: string; on: boolean }): string;
|
|
269
|
+
export function parseMessageAction(text: string): MessageAction | null;
|
|
270
|
+
export function isMessageAction(text: unknown): boolean;
|
|
271
|
+
export function isStickerAttachment(item: unknown): boolean;
|
|
272
|
+
export function groupReactions(
|
|
273
|
+
byEmoji: Record<string, Array<string | number>> | null | undefined,
|
|
274
|
+
ownIds?: Array<string | number | null | undefined>,
|
|
275
|
+
): Array<{ emoji: string; count: number; mine: boolean; userIds: Array<string | number> }>;
|
|
276
|
+
|
|
277
|
+
/* ------------------------------------------------------------------ */
|
|
278
|
+
/* Media / assets configuration */
|
|
279
|
+
/* ------------------------------------------------------------------ */
|
|
280
|
+
|
|
281
|
+
export function configureKlipy(options?: { apiKey?: string; locale?: string; categoriesLocale?: string }): void;
|
|
282
|
+
/** Base URL of the chat sounds (default `/sounds`). `null` restores the default. */
|
|
283
|
+
export function setChatAssetsBaseUrl(url: string | null | undefined): void;
|
|
284
|
+
export function getChatAssetsBaseUrl(): string;
|
|
285
|
+
|
|
286
|
+
/* ------------------------------------------------------------------ */
|
|
287
|
+
/* Connected placements */
|
|
288
|
+
/* ------------------------------------------------------------------ */
|
|
289
|
+
|
|
290
|
+
export interface ChatWindowProps {
|
|
291
|
+
placement?: 'floating' | 'modal' | 'embedded';
|
|
292
|
+
open?: boolean;
|
|
293
|
+
onOpenChange?: (open: boolean) => void;
|
|
294
|
+
className?: string;
|
|
295
|
+
theme?: 'light' | 'dark' | 'auto' | 'black';
|
|
296
|
+
BattleshipPreviewComponent?: ComponentType<any>;
|
|
297
|
+
}
|
|
298
|
+
export interface ChatPageProps {
|
|
299
|
+
className?: string;
|
|
300
|
+
}
|
|
301
|
+
export interface ChatButtonProps {
|
|
302
|
+
className?: string;
|
|
303
|
+
label?: string;
|
|
304
|
+
onClick?: () => void;
|
|
305
|
+
pressed?: boolean;
|
|
306
|
+
badgeClassName?: string;
|
|
307
|
+
iconSize?: number;
|
|
308
|
+
}
|
|
309
|
+
// eslint-disable-next-line @typescript-eslint/no-empty-interface
|
|
310
|
+
export interface ChatNotificationsProps {}
|
|
311
|
+
|
|
312
|
+
export const ChatWindow: ComponentType<ChatWindowProps>;
|
|
313
|
+
export const ChatPage: ComponentType<ChatPageProps>;
|
|
314
|
+
export const ChatButton: ComponentType<ChatButtonProps>;
|
|
315
|
+
export const ChatNotifications: ComponentType<ChatNotificationsProps>;
|
|
316
|
+
|
|
317
|
+
/* ------------------------------------------------------------------ */
|
|
318
|
+
/* UI primitives (presentational) */
|
|
319
|
+
/* ------------------------------------------------------------------ */
|
|
320
|
+
|
|
321
|
+
export interface ChatWindowShellProps {
|
|
322
|
+
placement?: 'floating' | 'modal' | 'embedded' | 'page' | string;
|
|
323
|
+
BattleshipPreviewComponent?: ComponentType<any> | null;
|
|
324
|
+
title?: ReactNode;
|
|
325
|
+
subtitle?: ReactNode;
|
|
326
|
+
isOpen?: boolean;
|
|
327
|
+
isMaximized?: boolean;
|
|
328
|
+
isMinimized?: boolean;
|
|
329
|
+
onClose?: () => void;
|
|
330
|
+
onMinimize?: () => void;
|
|
331
|
+
onToggleMaximize?: () => void;
|
|
332
|
+
rooms?: any[];
|
|
333
|
+
users?: any[];
|
|
334
|
+
messages?: any[];
|
|
335
|
+
currentUserId?: string | number | null;
|
|
336
|
+
currentUserIds?: Array<string | number>;
|
|
337
|
+
onSelectRoom?: (room: any) => void;
|
|
338
|
+
onSelectUser?: (user: any) => void;
|
|
339
|
+
[key: string]: any;
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
export interface MessageListProps {
|
|
343
|
+
messages?: any[];
|
|
344
|
+
currentUserId?: string | number | null;
|
|
345
|
+
onCopy?: (message: any) => void;
|
|
346
|
+
onReply?: (message: any) => void;
|
|
347
|
+
panelGameKey?: string | null;
|
|
348
|
+
onReact?: (message: any, emoji: string, on: boolean) => void;
|
|
349
|
+
onEditMessage?: (message: any) => void;
|
|
350
|
+
editingId?: string | null;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
export interface MessageBubbleProps {
|
|
354
|
+
message: any;
|
|
355
|
+
isMine?: boolean;
|
|
356
|
+
senderName?: string;
|
|
357
|
+
timestamp?: string | number | Date;
|
|
358
|
+
onCopy?: (message: any) => void;
|
|
359
|
+
onReply?: (message: any) => void;
|
|
360
|
+
onJumpQuote?: (id: string) => void;
|
|
361
|
+
onReact?: (message: any, emoji: string, on: boolean) => void;
|
|
362
|
+
onEdit?: (message: any) => void;
|
|
363
|
+
isEditing?: boolean;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
export interface MessageComposerProps {
|
|
367
|
+
value: string;
|
|
368
|
+
onChange: (value: string) => void;
|
|
369
|
+
onSend: () => void;
|
|
370
|
+
disabled?: boolean;
|
|
371
|
+
attachments?: any[];
|
|
372
|
+
attachmentError?: string | null;
|
|
373
|
+
sending?: boolean;
|
|
374
|
+
onAddAttachment?: (files: File[] | FileList | any) => void;
|
|
375
|
+
onRemoveAttachment?: (attachment: any) => void;
|
|
376
|
+
reply?: any;
|
|
377
|
+
onCancelReply?: () => void;
|
|
378
|
+
onInviteGame?: (game: string) => void;
|
|
379
|
+
gameInviteDisabled?: boolean;
|
|
380
|
+
onOpenBattleshipPreview?: () => void;
|
|
381
|
+
editing?: any;
|
|
382
|
+
onStartEditLast?: () => void;
|
|
383
|
+
onCancelEdit?: () => void;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
export interface EmojiPickerProps {
|
|
387
|
+
onSelect: (emoji: string) => void;
|
|
388
|
+
isOpen: boolean;
|
|
389
|
+
onClose: () => void;
|
|
390
|
+
disabled?: boolean;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
export interface MediaPickerProps {
|
|
394
|
+
onSelect: (item: any) => void;
|
|
395
|
+
onClose: () => void;
|
|
396
|
+
disabled?: boolean;
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
export const ChatWindowShell: ComponentType<ChatWindowShellProps>;
|
|
400
|
+
export const MessageList: ComponentType<MessageListProps>;
|
|
401
|
+
export const MessageBubble: ComponentType<MessageBubbleProps>;
|
|
402
|
+
export const MessageComposer: ComponentType<MessageComposerProps>;
|
|
403
|
+
export const EmojiPicker: ComponentType<EmojiPickerProps>;
|
|
404
|
+
export const GifPicker: ComponentType<MediaPickerProps>;
|
|
405
|
+
export const StickerPicker: ComponentType<MediaPickerProps>;
|
|
406
|
+
|
|
407
|
+
export interface ChatPeople {
|
|
408
|
+
/** Ids (string|number) that identify the current user. */
|
|
409
|
+
ownIds: Array<string | number>;
|
|
410
|
+
/** Display name for a user id, or null when unknown. */
|
|
411
|
+
resolveName: (userId: string | number) => string | null;
|
|
412
|
+
}
|
|
413
|
+
export const ChatPeopleContext: Context<ChatPeople>;
|
|
414
|
+
|
|
415
|
+
// ---------------------------------------------------------------------------
|
|
416
|
+
// Chat store hooks, identity and UI open state
|
|
417
|
+
// ---------------------------------------------------------------------------
|
|
418
|
+
|
|
419
|
+
export const MAX_CHAT_MESSAGES: number;
|
|
420
|
+
export function useChatStore<T = ChatState>(selector?: (state: ChatState) => T): T;
|
|
421
|
+
export function useChatStoreApi(): StoreApi<ChatState> | null;
|
|
422
|
+
export function useChatIdentity(): { userId: string | null; ids: string[]; name: string | null; scope: string };
|
|
423
|
+
export function normalizeUser(user: unknown): { id: string | null; ids: string[]; name: string | null } | null;
|
|
424
|
+
|
|
425
|
+
export interface ChatUiState {
|
|
426
|
+
isOpen: boolean;
|
|
427
|
+
open: () => void;
|
|
428
|
+
close: () => void;
|
|
429
|
+
toggle: () => void;
|
|
430
|
+
}
|
|
431
|
+
export const chatUiStore: StoreApi<ChatUiState>;
|
|
432
|
+
export function useChatUi<T = ChatUiState>(selector?: (state: ChatUiState) => T): T;
|
|
433
|
+
|
|
434
|
+
// ---------------------------------------------------------------------------
|
|
435
|
+
// Unread counters
|
|
436
|
+
// ---------------------------------------------------------------------------
|
|
437
|
+
|
|
438
|
+
export interface ChatUnreadState {
|
|
439
|
+
counts: Record<string, number>;
|
|
440
|
+
[key: string]: any;
|
|
441
|
+
}
|
|
442
|
+
export const useChatUnread: (<T>(selector: (state: ChatUnreadState) => T) => T) & StoreApi<ChatUnreadState>;
|
|
443
|
+
export function totalUnread(state: ChatUnreadState): number;
|
|
444
|
+
export function unreadScope(backend: string, userId: string | number | null | undefined): string | null;
|
|
445
|
+
export function startUnreadStorageSync(store?: StoreLike<ChatUnreadState>): () => void;
|
|
446
|
+
|
|
447
|
+
// ---------------------------------------------------------------------------
|
|
448
|
+
// Host integration: background services (idempotent or ref-counted; return stop())
|
|
449
|
+
// ---------------------------------------------------------------------------
|
|
450
|
+
|
|
451
|
+
export function startDesktopNotifications(): () => void;
|
|
452
|
+
export function startAppBadge(options?: { store?: StoreLike<ChatUnreadState>; nav?: Navigator; schedule?: (fn: () => void) => void }): () => void;
|
|
453
|
+
export function startChatApp(): () => void;
|
|
454
|
+
export function registerChatWorker(options?: { enabled?: boolean; path?: string; swUrl?: string }): void;
|
|
455
|
+
export function openChatWindow(options?: { path?: string; windowName?: string }): boolean;
|
|
456
|
+
export function useChatInstall(): any;
|
|
457
|
+
export function startGifLibrarySync(): () => void;
|
|
458
|
+
export function startEmojiPreferencesSync(): () => void;
|
|
459
|
+
export function startConnect4Sounds(): () => void;
|
|
460
|
+
export const chatGamesStore: StoreApi<any>;
|
|
461
|
+
export const useChatGames: <T>(selector: (state: any) => T) => T;
|
|
462
|
+
|
|
463
|
+
/** File relay over a raw WebSocket shared with the host. */
|
|
464
|
+
export function consumeRelayEvent(socket: WebSocket, event: InboundFrame): boolean;
|
|
465
|
+
export function hydrateRelayMessage(socket: WebSocket, message: InboundFrame): InboundFrame;
|
|
466
|
+
export function closeRelay(socket: WebSocket): void;
|
|
467
|
+
export function sendRelayMessage(socket: WebSocket | null, roomId: string, message: string, attachments?: any[]): Promise<void>;
|
|
468
|
+
|
|
469
|
+
/** Lazily loads the Battleship 3D preview (three.js); use with React.lazy. */
|
|
470
|
+
export function loadBattleshipPreview(): Promise<{ default: ComponentType<any> }>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,69 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@minicode-dev/chat",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"private": false,
|
|
5
|
+
"description": "LIRA real-time chat (WebSocket, media, games) as a React package.",
|
|
6
|
+
"author": "Minicode",
|
|
7
|
+
"license": "UNLICENSED",
|
|
8
|
+
"repository": {
|
|
9
|
+
"type": "git",
|
|
10
|
+
"url": "git+ssh://git@github.com/MiniCodeSRL/LIRA-Frontend-backend_tool.git",
|
|
11
|
+
"directory": "packages/chat"
|
|
12
|
+
},
|
|
13
|
+
"type": "module",
|
|
14
|
+
"main": "./dist/index.js",
|
|
15
|
+
"module": "./dist/index.js",
|
|
16
|
+
"types": "./index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
".": {
|
|
19
|
+
"types": "./index.d.ts",
|
|
20
|
+
"@minicode-dev/source": "./src/index.js",
|
|
21
|
+
"import": "./dist/index.js",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./styles.css": {
|
|
25
|
+
"@minicode-dev/source": "./src/styles.css",
|
|
26
|
+
"default": "./dist/styles.css"
|
|
27
|
+
},
|
|
28
|
+
"./assets/*": "./assets/*",
|
|
29
|
+
"./package.json": "./package.json"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"assets",
|
|
34
|
+
"index.d.ts",
|
|
35
|
+
"README.md",
|
|
36
|
+
"CHANGELOG.md"
|
|
37
|
+
],
|
|
38
|
+
"sideEffects": [
|
|
39
|
+
"*.css"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "vite build",
|
|
43
|
+
"prepack": "npm run build",
|
|
44
|
+
"release": "node scripts/release.mjs"
|
|
45
|
+
},
|
|
46
|
+
"peerDependencies": {
|
|
47
|
+
"lucide-react": ">=0.400.0",
|
|
48
|
+
"react": ">=18",
|
|
49
|
+
"react-dom": ">=18",
|
|
50
|
+
"three": ">=0.134.0 <0.138.0",
|
|
51
|
+
"zustand": "^4.5.0 || ^5.0.0"
|
|
52
|
+
},
|
|
53
|
+
"peerDependenciesMeta": {
|
|
54
|
+
"three": {
|
|
55
|
+
"optional": true
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"dayjs": "^1.11.18",
|
|
60
|
+
"emojibase-data": "^17.0.0"
|
|
61
|
+
},
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"access": "public"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@vitejs/plugin-react-swc": "^4.3.3",
|
|
67
|
+
"vite": "^8.3.5"
|
|
68
|
+
}
|
|
69
|
+
}
|