ape-im-sdk-react 1.0.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/README.md +245 -0
- package/dist/index.d.mts +150 -0
- package/dist/index.d.ts +150 -0
- package/dist/index.js +699 -0
- package/dist/index.mjs +668 -0
- package/dist/styles.css +145 -0
- package/package.json +58 -0
package/README.md
ADDED
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# ape-im-sdk-react
|
|
2
|
+
|
|
3
|
+
React SDK for **Ape Instant Messenger** - Add nostalgic AOL-style chat functionality to your ApeChain dApp with a single line of code.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 💬 **Popup Chat Widget** - Floating chat bubble with full messenger interface
|
|
8
|
+
- 🔐 **Wallet Authentication** - Connect via MetaMask, WalletConnect, or any injected wallet
|
|
9
|
+
- 🎨 **Retro AIM Aesthetic** - Classic 90s AOL Instant Messenger design
|
|
10
|
+
- 🖼️ **NFT Profile Pictures** - Use your ApeChain NFTs as avatars
|
|
11
|
+
- 💰 **Crypto Tipping** - Send APE tokens directly in chat
|
|
12
|
+
- 🔒 **Token-Gated Chats** - Create exclusive group chats for token holders
|
|
13
|
+
- 📱 **Real-time Messaging** - WebSocket-powered instant delivery
|
|
14
|
+
- 🎭 **Rich Content** - Emoji reactions, GIFs, stickers, voice messages
|
|
15
|
+
- 🌙 **Dark Mode** - Full light/dark theme support
|
|
16
|
+
|
|
17
|
+
## Installation
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npm install ape-im-sdk-react
|
|
21
|
+
# or
|
|
22
|
+
yarn add ape-im-sdk-react
|
|
23
|
+
# or
|
|
24
|
+
pnpm add ape-im-sdk-react
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
## Requirements
|
|
28
|
+
|
|
29
|
+
- **React 18+**
|
|
30
|
+
- **MetaMask** or any compatible injected Web3 wallet (window.ethereum)
|
|
31
|
+
- Ape IM API endpoint (defaults to `https://www.apeinstantmessenger.com`)
|
|
32
|
+
|
|
33
|
+
> **Note:** The SDK currently requires MetaMask or a compatible injected wallet. WalletConnect support is planned for a future release.
|
|
34
|
+
|
|
35
|
+
## Quick Start
|
|
36
|
+
|
|
37
|
+
Add the chat widget to your app with just a few lines:
|
|
38
|
+
|
|
39
|
+
```tsx
|
|
40
|
+
import { ApeIMProvider, ChatWidget } from 'ape-im-sdk-react';
|
|
41
|
+
import 'ape-im-sdk-react/styles.css';
|
|
42
|
+
|
|
43
|
+
function App() {
|
|
44
|
+
return (
|
|
45
|
+
<ApeIMProvider>
|
|
46
|
+
<YourApp />
|
|
47
|
+
<ChatWidget position="bottom-right" />
|
|
48
|
+
</ApeIMProvider>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
That's it! Your users can now click the floating chat bubble to open the messenger.
|
|
54
|
+
|
|
55
|
+
## Configuration
|
|
56
|
+
|
|
57
|
+
### ApeIMProvider Props
|
|
58
|
+
|
|
59
|
+
| Prop | Type | Default | Description |
|
|
60
|
+
|------|------|---------|-------------|
|
|
61
|
+
| `apiUrl` | `string` | `https://www.apeinstantmessenger.com` | API endpoint |
|
|
62
|
+
| `theme` | `'light' \| 'dark' \| 'system'` | `'system'` | Color theme |
|
|
63
|
+
| `onConnect` | `(user: User) => void` | - | Callback when user connects |
|
|
64
|
+
| `onDisconnect` | `() => void` | - | Callback when user disconnects |
|
|
65
|
+
|
|
66
|
+
### ChatWidget Props
|
|
67
|
+
|
|
68
|
+
| Prop | Type | Default | Description |
|
|
69
|
+
|------|------|---------|-------------|
|
|
70
|
+
| `position` | `'bottom-right' \| 'bottom-left'` | `'bottom-right'` | Widget position |
|
|
71
|
+
| `offset` | `{ x: number, y: number }` | `{ x: 20, y: 20 }` | Offset from corner |
|
|
72
|
+
| `defaultOpen` | `boolean` | `false` | Start with widget open |
|
|
73
|
+
| `bubbleSize` | `number` | `60` | Size of the chat bubble |
|
|
74
|
+
| `zIndex` | `number` | `9999` | CSS z-index |
|
|
75
|
+
|
|
76
|
+
## Hooks
|
|
77
|
+
|
|
78
|
+
### useApeIM
|
|
79
|
+
|
|
80
|
+
Access authentication state and methods:
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { useApeIM } from 'ape-im-sdk-react';
|
|
84
|
+
|
|
85
|
+
function MyComponent() {
|
|
86
|
+
const {
|
|
87
|
+
user, // Current user object
|
|
88
|
+
isConnected, // Boolean connection state
|
|
89
|
+
isLoading, // Loading state
|
|
90
|
+
connect, // Connect wallet function
|
|
91
|
+
disconnect, // Disconnect function
|
|
92
|
+
openWidget, // Open the chat widget
|
|
93
|
+
closeWidget, // Close the chat widget
|
|
94
|
+
} = useApeIM();
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<button onClick={connect}>
|
|
98
|
+
{isConnected ? user.username : 'Connect'}
|
|
99
|
+
</button>
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### useConversations
|
|
105
|
+
|
|
106
|
+
Access user's conversations:
|
|
107
|
+
|
|
108
|
+
```tsx
|
|
109
|
+
import { useConversations } from 'ape-im-sdk-react';
|
|
110
|
+
|
|
111
|
+
function ConversationList() {
|
|
112
|
+
const {
|
|
113
|
+
conversations, // Array of conversations
|
|
114
|
+
isLoading,
|
|
115
|
+
startConversation, // Start new DM
|
|
116
|
+
createGroup, // Create group chat
|
|
117
|
+
} = useConversations();
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<ul>
|
|
121
|
+
{conversations.map(conv => (
|
|
122
|
+
<li key={conv.id}>{conv.name}</li>
|
|
123
|
+
))}
|
|
124
|
+
</ul>
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
### useChat
|
|
130
|
+
|
|
131
|
+
Access chat functionality for a specific conversation:
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { useChat } from 'ape-im-sdk-react';
|
|
135
|
+
|
|
136
|
+
function ChatRoom({ conversationId }) {
|
|
137
|
+
const {
|
|
138
|
+
messages,
|
|
139
|
+
sendMessage,
|
|
140
|
+
isTyping,
|
|
141
|
+
participants,
|
|
142
|
+
} = useChat(conversationId);
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<div>
|
|
146
|
+
{messages.map(msg => (
|
|
147
|
+
<div key={msg.id}>{msg.content}</div>
|
|
148
|
+
))}
|
|
149
|
+
</div>
|
|
150
|
+
);
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
## Styling
|
|
155
|
+
|
|
156
|
+
The SDK includes default retro AIM styling. Import the CSS:
|
|
157
|
+
|
|
158
|
+
```tsx
|
|
159
|
+
import 'ape-im-sdk-react/styles.css';
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
### Custom Theming
|
|
163
|
+
|
|
164
|
+
Override CSS variables to customize:
|
|
165
|
+
|
|
166
|
+
```css
|
|
167
|
+
:root {
|
|
168
|
+
--ape-im-primary: #1D3FE7;
|
|
169
|
+
--ape-im-primary-dark: #142B99;
|
|
170
|
+
--ape-im-accent: #E8EDFF;
|
|
171
|
+
--ape-im-bubble-user: #1D3FE7;
|
|
172
|
+
--ape-im-bubble-other: #e5e5e5;
|
|
173
|
+
}
|
|
174
|
+
```
|
|
175
|
+
|
|
176
|
+
## TypeScript
|
|
177
|
+
|
|
178
|
+
Full TypeScript support with exported types:
|
|
179
|
+
|
|
180
|
+
```tsx
|
|
181
|
+
import type {
|
|
182
|
+
User,
|
|
183
|
+
Message,
|
|
184
|
+
Conversation,
|
|
185
|
+
ChatWidgetProps,
|
|
186
|
+
ApeIMProviderProps,
|
|
187
|
+
} from 'ape-im-sdk-react';
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## API Documentation
|
|
191
|
+
|
|
192
|
+
For complete API documentation, visit: https://ape-im.replit.app/docs
|
|
193
|
+
|
|
194
|
+
## Publishing to npm
|
|
195
|
+
|
|
196
|
+
To publish the SDK to npm:
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
# Navigate to the SDK package
|
|
200
|
+
cd packages/sdk-react
|
|
201
|
+
|
|
202
|
+
# Install dependencies
|
|
203
|
+
npm install
|
|
204
|
+
|
|
205
|
+
# Build the package
|
|
206
|
+
npm run build
|
|
207
|
+
|
|
208
|
+
# Login to npm (if not already)
|
|
209
|
+
npm login
|
|
210
|
+
|
|
211
|
+
# Publish to npm
|
|
212
|
+
npm publish --access public
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Versioning
|
|
216
|
+
|
|
217
|
+
Before publishing a new version, update the version in `package.json`:
|
|
218
|
+
|
|
219
|
+
```bash
|
|
220
|
+
# Patch release (1.0.0 -> 1.0.1)
|
|
221
|
+
npm version patch
|
|
222
|
+
|
|
223
|
+
# Minor release (1.0.0 -> 1.1.0)
|
|
224
|
+
npm version minor
|
|
225
|
+
|
|
226
|
+
# Major release (1.0.0 -> 2.0.0)
|
|
227
|
+
npm version major
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
## Development
|
|
231
|
+
|
|
232
|
+
```bash
|
|
233
|
+
# Install dependencies
|
|
234
|
+
npm install
|
|
235
|
+
|
|
236
|
+
# Build with watch mode for development
|
|
237
|
+
npm run dev
|
|
238
|
+
|
|
239
|
+
# Build for production
|
|
240
|
+
npm run build
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## License
|
|
244
|
+
|
|
245
|
+
MIT © Ape IM Team
|
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface User {
|
|
5
|
+
id: string;
|
|
6
|
+
walletAddress: string;
|
|
7
|
+
username: string | null;
|
|
8
|
+
profilePicture: string | null;
|
|
9
|
+
status: 'online' | 'away' | 'offline';
|
|
10
|
+
awayMessage: string | null;
|
|
11
|
+
isProfileComplete: boolean;
|
|
12
|
+
readReceiptsEnabled: boolean;
|
|
13
|
+
twitterHandle: string | null;
|
|
14
|
+
discordHandle: string | null;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
}
|
|
17
|
+
interface Message {
|
|
18
|
+
id: string;
|
|
19
|
+
conversationId: string;
|
|
20
|
+
senderId: string;
|
|
21
|
+
content: string;
|
|
22
|
+
formatting: MessageFormatting | null;
|
|
23
|
+
messageType: 'text' | 'gif' | 'image' | 'sticker' | 'voice' | 'poll';
|
|
24
|
+
isEphemeral: boolean;
|
|
25
|
+
ephemeralExpiresAt: Date | null;
|
|
26
|
+
readAt: Date | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
parentMessageId: string | null;
|
|
29
|
+
replyCount: number;
|
|
30
|
+
sender: User;
|
|
31
|
+
reactions?: Reaction[];
|
|
32
|
+
tips?: Tip[];
|
|
33
|
+
}
|
|
34
|
+
interface MessageFormatting {
|
|
35
|
+
bold?: boolean;
|
|
36
|
+
italic?: boolean;
|
|
37
|
+
underline?: boolean;
|
|
38
|
+
color?: string;
|
|
39
|
+
fontSize?: string;
|
|
40
|
+
}
|
|
41
|
+
interface Conversation {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string | null;
|
|
44
|
+
isGroup: boolean;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
lastMessageAt: Date | null;
|
|
47
|
+
participants: ConversationParticipant[];
|
|
48
|
+
lastMessage?: Message;
|
|
49
|
+
unreadCount?: number;
|
|
50
|
+
}
|
|
51
|
+
interface ConversationParticipant {
|
|
52
|
+
userId: string;
|
|
53
|
+
conversationId: string;
|
|
54
|
+
joinedAt: Date;
|
|
55
|
+
user: User;
|
|
56
|
+
}
|
|
57
|
+
interface Reaction {
|
|
58
|
+
id: string;
|
|
59
|
+
messageId: string;
|
|
60
|
+
userId: string;
|
|
61
|
+
emoji: string;
|
|
62
|
+
createdAt: Date;
|
|
63
|
+
user: User;
|
|
64
|
+
}
|
|
65
|
+
interface Tip {
|
|
66
|
+
id: string;
|
|
67
|
+
messageId: string | null;
|
|
68
|
+
senderId: string;
|
|
69
|
+
recipientId: string;
|
|
70
|
+
amount: string;
|
|
71
|
+
transactionHash: string;
|
|
72
|
+
createdAt: Date;
|
|
73
|
+
}
|
|
74
|
+
interface ApeIMProviderProps$1 {
|
|
75
|
+
children: React.ReactNode;
|
|
76
|
+
apiUrl: string;
|
|
77
|
+
theme?: 'light' | 'dark' | 'system';
|
|
78
|
+
onConnect?: (user: User) => void;
|
|
79
|
+
onDisconnect?: () => void;
|
|
80
|
+
}
|
|
81
|
+
interface ChatWidgetProps {
|
|
82
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
83
|
+
offset?: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
};
|
|
87
|
+
defaultOpen?: boolean;
|
|
88
|
+
bubbleSize?: number;
|
|
89
|
+
zIndex?: number;
|
|
90
|
+
}
|
|
91
|
+
interface ApeIMContextValue {
|
|
92
|
+
user: User | null;
|
|
93
|
+
isConnected: boolean;
|
|
94
|
+
isLoading: boolean;
|
|
95
|
+
sessionToken: string | null;
|
|
96
|
+
apiUrl: string;
|
|
97
|
+
theme: 'light' | 'dark' | 'system';
|
|
98
|
+
connect: () => Promise<void>;
|
|
99
|
+
disconnect: () => void;
|
|
100
|
+
openWidget: () => void;
|
|
101
|
+
closeWidget: () => void;
|
|
102
|
+
isWidgetOpen: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface ConversationsContextValue {
|
|
105
|
+
conversations: Conversation[];
|
|
106
|
+
isLoading: boolean;
|
|
107
|
+
error: Error | null;
|
|
108
|
+
startConversation: (userId: string) => Promise<Conversation>;
|
|
109
|
+
createGroup: (name: string, participantIds: string[]) => Promise<Conversation>;
|
|
110
|
+
refetch: () => void;
|
|
111
|
+
}
|
|
112
|
+
interface ChatContextValue {
|
|
113
|
+
messages: Message[];
|
|
114
|
+
isLoading: boolean;
|
|
115
|
+
sendMessage: (content: string, formatting?: MessageFormatting) => Promise<void>;
|
|
116
|
+
sendReaction: (messageId: string, emoji: string) => Promise<void>;
|
|
117
|
+
isTyping: User[];
|
|
118
|
+
participants: User[];
|
|
119
|
+
markAsRead: () => void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface ApeIMProviderProps {
|
|
123
|
+
children: ReactNode;
|
|
124
|
+
apiUrl?: string;
|
|
125
|
+
theme?: 'light' | 'dark' | 'system';
|
|
126
|
+
onConnect?: (user: User) => void;
|
|
127
|
+
onDisconnect?: () => void;
|
|
128
|
+
}
|
|
129
|
+
declare function ApeIMProvider({ children, apiUrl, theme, onConnect, onDisconnect, }: ApeIMProviderProps): react_jsx_runtime.JSX.Element;
|
|
130
|
+
declare function useApeIM(): ApeIMContextValue;
|
|
131
|
+
declare global {
|
|
132
|
+
interface Window {
|
|
133
|
+
ethereum?: {
|
|
134
|
+
request: (args: {
|
|
135
|
+
method: string;
|
|
136
|
+
params?: unknown[];
|
|
137
|
+
}) => Promise<string[]>;
|
|
138
|
+
on: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
139
|
+
removeListener: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare function ChatWidget({ position, offset, defaultOpen, bubbleSize, zIndex, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
145
|
+
|
|
146
|
+
declare function useConversations(): ConversationsContextValue;
|
|
147
|
+
|
|
148
|
+
declare function useChat(conversationId: string | null): ChatContextValue;
|
|
149
|
+
|
|
150
|
+
export { type ApeIMContextValue, ApeIMProvider, type ApeIMProviderProps$1 as ApeIMProviderProps, type ChatContextValue, ChatWidget, type ChatWidgetProps, type Conversation, type ConversationParticipant, type ConversationsContextValue, type Message, type MessageFormatting, type Reaction, type Tip, type User, useApeIM, useChat, useConversations };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
interface User {
|
|
5
|
+
id: string;
|
|
6
|
+
walletAddress: string;
|
|
7
|
+
username: string | null;
|
|
8
|
+
profilePicture: string | null;
|
|
9
|
+
status: 'online' | 'away' | 'offline';
|
|
10
|
+
awayMessage: string | null;
|
|
11
|
+
isProfileComplete: boolean;
|
|
12
|
+
readReceiptsEnabled: boolean;
|
|
13
|
+
twitterHandle: string | null;
|
|
14
|
+
discordHandle: string | null;
|
|
15
|
+
createdAt: Date;
|
|
16
|
+
}
|
|
17
|
+
interface Message {
|
|
18
|
+
id: string;
|
|
19
|
+
conversationId: string;
|
|
20
|
+
senderId: string;
|
|
21
|
+
content: string;
|
|
22
|
+
formatting: MessageFormatting | null;
|
|
23
|
+
messageType: 'text' | 'gif' | 'image' | 'sticker' | 'voice' | 'poll';
|
|
24
|
+
isEphemeral: boolean;
|
|
25
|
+
ephemeralExpiresAt: Date | null;
|
|
26
|
+
readAt: Date | null;
|
|
27
|
+
createdAt: Date;
|
|
28
|
+
parentMessageId: string | null;
|
|
29
|
+
replyCount: number;
|
|
30
|
+
sender: User;
|
|
31
|
+
reactions?: Reaction[];
|
|
32
|
+
tips?: Tip[];
|
|
33
|
+
}
|
|
34
|
+
interface MessageFormatting {
|
|
35
|
+
bold?: boolean;
|
|
36
|
+
italic?: boolean;
|
|
37
|
+
underline?: boolean;
|
|
38
|
+
color?: string;
|
|
39
|
+
fontSize?: string;
|
|
40
|
+
}
|
|
41
|
+
interface Conversation {
|
|
42
|
+
id: string;
|
|
43
|
+
name: string | null;
|
|
44
|
+
isGroup: boolean;
|
|
45
|
+
createdAt: Date;
|
|
46
|
+
lastMessageAt: Date | null;
|
|
47
|
+
participants: ConversationParticipant[];
|
|
48
|
+
lastMessage?: Message;
|
|
49
|
+
unreadCount?: number;
|
|
50
|
+
}
|
|
51
|
+
interface ConversationParticipant {
|
|
52
|
+
userId: string;
|
|
53
|
+
conversationId: string;
|
|
54
|
+
joinedAt: Date;
|
|
55
|
+
user: User;
|
|
56
|
+
}
|
|
57
|
+
interface Reaction {
|
|
58
|
+
id: string;
|
|
59
|
+
messageId: string;
|
|
60
|
+
userId: string;
|
|
61
|
+
emoji: string;
|
|
62
|
+
createdAt: Date;
|
|
63
|
+
user: User;
|
|
64
|
+
}
|
|
65
|
+
interface Tip {
|
|
66
|
+
id: string;
|
|
67
|
+
messageId: string | null;
|
|
68
|
+
senderId: string;
|
|
69
|
+
recipientId: string;
|
|
70
|
+
amount: string;
|
|
71
|
+
transactionHash: string;
|
|
72
|
+
createdAt: Date;
|
|
73
|
+
}
|
|
74
|
+
interface ApeIMProviderProps$1 {
|
|
75
|
+
children: React.ReactNode;
|
|
76
|
+
apiUrl: string;
|
|
77
|
+
theme?: 'light' | 'dark' | 'system';
|
|
78
|
+
onConnect?: (user: User) => void;
|
|
79
|
+
onDisconnect?: () => void;
|
|
80
|
+
}
|
|
81
|
+
interface ChatWidgetProps {
|
|
82
|
+
position?: 'bottom-right' | 'bottom-left';
|
|
83
|
+
offset?: {
|
|
84
|
+
x: number;
|
|
85
|
+
y: number;
|
|
86
|
+
};
|
|
87
|
+
defaultOpen?: boolean;
|
|
88
|
+
bubbleSize?: number;
|
|
89
|
+
zIndex?: number;
|
|
90
|
+
}
|
|
91
|
+
interface ApeIMContextValue {
|
|
92
|
+
user: User | null;
|
|
93
|
+
isConnected: boolean;
|
|
94
|
+
isLoading: boolean;
|
|
95
|
+
sessionToken: string | null;
|
|
96
|
+
apiUrl: string;
|
|
97
|
+
theme: 'light' | 'dark' | 'system';
|
|
98
|
+
connect: () => Promise<void>;
|
|
99
|
+
disconnect: () => void;
|
|
100
|
+
openWidget: () => void;
|
|
101
|
+
closeWidget: () => void;
|
|
102
|
+
isWidgetOpen: boolean;
|
|
103
|
+
}
|
|
104
|
+
interface ConversationsContextValue {
|
|
105
|
+
conversations: Conversation[];
|
|
106
|
+
isLoading: boolean;
|
|
107
|
+
error: Error | null;
|
|
108
|
+
startConversation: (userId: string) => Promise<Conversation>;
|
|
109
|
+
createGroup: (name: string, participantIds: string[]) => Promise<Conversation>;
|
|
110
|
+
refetch: () => void;
|
|
111
|
+
}
|
|
112
|
+
interface ChatContextValue {
|
|
113
|
+
messages: Message[];
|
|
114
|
+
isLoading: boolean;
|
|
115
|
+
sendMessage: (content: string, formatting?: MessageFormatting) => Promise<void>;
|
|
116
|
+
sendReaction: (messageId: string, emoji: string) => Promise<void>;
|
|
117
|
+
isTyping: User[];
|
|
118
|
+
participants: User[];
|
|
119
|
+
markAsRead: () => void;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
interface ApeIMProviderProps {
|
|
123
|
+
children: ReactNode;
|
|
124
|
+
apiUrl?: string;
|
|
125
|
+
theme?: 'light' | 'dark' | 'system';
|
|
126
|
+
onConnect?: (user: User) => void;
|
|
127
|
+
onDisconnect?: () => void;
|
|
128
|
+
}
|
|
129
|
+
declare function ApeIMProvider({ children, apiUrl, theme, onConnect, onDisconnect, }: ApeIMProviderProps): react_jsx_runtime.JSX.Element;
|
|
130
|
+
declare function useApeIM(): ApeIMContextValue;
|
|
131
|
+
declare global {
|
|
132
|
+
interface Window {
|
|
133
|
+
ethereum?: {
|
|
134
|
+
request: (args: {
|
|
135
|
+
method: string;
|
|
136
|
+
params?: unknown[];
|
|
137
|
+
}) => Promise<string[]>;
|
|
138
|
+
on: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
139
|
+
removeListener: (event: string, callback: (...args: unknown[]) => void) => void;
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
declare function ChatWidget({ position, offset, defaultOpen, bubbleSize, zIndex, }: ChatWidgetProps): react_jsx_runtime.JSX.Element;
|
|
145
|
+
|
|
146
|
+
declare function useConversations(): ConversationsContextValue;
|
|
147
|
+
|
|
148
|
+
declare function useChat(conversationId: string | null): ChatContextValue;
|
|
149
|
+
|
|
150
|
+
export { type ApeIMContextValue, ApeIMProvider, type ApeIMProviderProps$1 as ApeIMProviderProps, type ChatContextValue, ChatWidget, type ChatWidgetProps, type Conversation, type ConversationParticipant, type ConversationsContextValue, type Message, type MessageFormatting, type Reaction, type Tip, type User, useApeIM, useChat, useConversations };
|