@melony/react 0.1.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 +237 -0
- package/dist/index.cjs +2371 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +165 -0
- package/dist/index.d.ts +165 -0
- package/dist/index.js +2334 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
import * as React$1 from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { ClientState, Client } from 'melony/client';
|
|
4
|
+
import { Role, Event, UINode } from 'melony';
|
|
5
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
6
|
+
|
|
7
|
+
interface User {
|
|
8
|
+
id: string;
|
|
9
|
+
email: string;
|
|
10
|
+
name: string;
|
|
11
|
+
picture?: string;
|
|
12
|
+
}
|
|
13
|
+
interface Message {
|
|
14
|
+
role: Role;
|
|
15
|
+
content: Event[];
|
|
16
|
+
runId?: string;
|
|
17
|
+
threadId?: string;
|
|
18
|
+
}
|
|
19
|
+
interface ThreadData {
|
|
20
|
+
id: string;
|
|
21
|
+
title?: string;
|
|
22
|
+
updatedAt?: Date | string;
|
|
23
|
+
}
|
|
24
|
+
interface StarterPrompt {
|
|
25
|
+
label: string;
|
|
26
|
+
prompt: string;
|
|
27
|
+
icon?: React.ReactNode;
|
|
28
|
+
}
|
|
29
|
+
interface AuthService {
|
|
30
|
+
getMe: () => Promise<User | null>;
|
|
31
|
+
login: () => void;
|
|
32
|
+
logout: () => Promise<void>;
|
|
33
|
+
getToken: () => string | null;
|
|
34
|
+
}
|
|
35
|
+
interface ThreadService {
|
|
36
|
+
getThreads: () => Promise<ThreadData[]>;
|
|
37
|
+
createThread?: () => Promise<string>;
|
|
38
|
+
deleteThread: (id: string) => Promise<void>;
|
|
39
|
+
getEvents: (threadId: string) => Promise<Event[]>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface MelonyContextValue extends ClientState {
|
|
43
|
+
messages: Message[];
|
|
44
|
+
sendEvent: (event: Event, options?: {
|
|
45
|
+
runId?: string;
|
|
46
|
+
state?: Record<string, any>;
|
|
47
|
+
}) => Promise<void>;
|
|
48
|
+
clear: () => void;
|
|
49
|
+
client: Client;
|
|
50
|
+
}
|
|
51
|
+
declare const MelonyContext: React__default.Context<MelonyContextValue | undefined>;
|
|
52
|
+
interface MelonyProviderProps {
|
|
53
|
+
children: ReactNode;
|
|
54
|
+
client: Client;
|
|
55
|
+
}
|
|
56
|
+
declare const MelonyProvider: React__default.FC<MelonyProviderProps>;
|
|
57
|
+
|
|
58
|
+
interface AuthContextValue {
|
|
59
|
+
user: User | null;
|
|
60
|
+
isAuthenticated: boolean;
|
|
61
|
+
isLoading: boolean;
|
|
62
|
+
login: () => void;
|
|
63
|
+
logout: () => void;
|
|
64
|
+
getToken: () => string | null;
|
|
65
|
+
}
|
|
66
|
+
declare const AuthContext: React__default.Context<AuthContextValue | undefined>;
|
|
67
|
+
interface AuthProviderProps {
|
|
68
|
+
children: ReactNode;
|
|
69
|
+
service: AuthService;
|
|
70
|
+
}
|
|
71
|
+
declare const AuthProvider: React__default.FC<AuthProviderProps>;
|
|
72
|
+
|
|
73
|
+
interface ThreadContextValue {
|
|
74
|
+
threads: ThreadData[];
|
|
75
|
+
activeThreadId: string | null;
|
|
76
|
+
isLoading: boolean;
|
|
77
|
+
error: Error | null;
|
|
78
|
+
selectThread: (threadId: string) => void;
|
|
79
|
+
createThread: () => Promise<string>;
|
|
80
|
+
deleteThread: (threadId: string) => Promise<void>;
|
|
81
|
+
refreshThreads: () => Promise<void>;
|
|
82
|
+
threadEvents: Event[];
|
|
83
|
+
threadMessages: Message[];
|
|
84
|
+
isLoadingEvents: boolean;
|
|
85
|
+
}
|
|
86
|
+
declare const ThreadContext: React__default.Context<ThreadContextValue | undefined>;
|
|
87
|
+
interface ThreadProviderProps {
|
|
88
|
+
children: ReactNode;
|
|
89
|
+
service: ThreadService;
|
|
90
|
+
initialThreadId?: string;
|
|
91
|
+
}
|
|
92
|
+
declare const ThreadProvider: React__default.FC<ThreadProviderProps>;
|
|
93
|
+
|
|
94
|
+
declare const useMelony: () => MelonyContextValue;
|
|
95
|
+
|
|
96
|
+
declare const useAuth: () => AuthContextValue;
|
|
97
|
+
|
|
98
|
+
declare const useThreads: () => ThreadContextValue;
|
|
99
|
+
|
|
100
|
+
declare function Thread({ className, placeholder, starterPrompts, onStarterPromptClick, }: {
|
|
101
|
+
className?: string;
|
|
102
|
+
placeholder?: string;
|
|
103
|
+
starterPrompts?: StarterPrompt[];
|
|
104
|
+
onStarterPromptClick?: (prompt: string) => void;
|
|
105
|
+
}): react_jsx_runtime.JSX.Element;
|
|
106
|
+
|
|
107
|
+
interface ComposerProps {
|
|
108
|
+
value: string;
|
|
109
|
+
onChange: (value: string) => void;
|
|
110
|
+
onSubmit: (e?: React__default.FormEvent) => void;
|
|
111
|
+
placeholder?: string;
|
|
112
|
+
isLoading?: boolean;
|
|
113
|
+
className?: string;
|
|
114
|
+
}
|
|
115
|
+
declare function Composer({ value, onChange, onSubmit, placeholder, isLoading, className, }: ComposerProps): react_jsx_runtime.JSX.Element;
|
|
116
|
+
|
|
117
|
+
interface ChatPopupProps {
|
|
118
|
+
title?: string;
|
|
119
|
+
placeholder?: string;
|
|
120
|
+
starterPrompts?: StarterPrompt[];
|
|
121
|
+
defaultOpen?: boolean;
|
|
122
|
+
}
|
|
123
|
+
declare function ChatPopup({ title, placeholder, starterPrompts, defaultOpen, }: ChatPopupProps): react_jsx_runtime.JSX.Element;
|
|
124
|
+
|
|
125
|
+
interface ChatSidebarProps {
|
|
126
|
+
title?: string;
|
|
127
|
+
placeholder?: string;
|
|
128
|
+
starterPrompts?: StarterPrompt[];
|
|
129
|
+
className?: string;
|
|
130
|
+
}
|
|
131
|
+
declare function ChatSidebar({ title, placeholder, starterPrompts, className, }: ChatSidebarProps): react_jsx_runtime.JSX.Element;
|
|
132
|
+
|
|
133
|
+
interface ChatFullProps {
|
|
134
|
+
title?: string;
|
|
135
|
+
placeholder?: string;
|
|
136
|
+
starterPrompts?: StarterPrompt[];
|
|
137
|
+
className?: string;
|
|
138
|
+
}
|
|
139
|
+
declare function ChatFull({ title, placeholder, starterPrompts, className, }: ChatFullProps): react_jsx_runtime.JSX.Element;
|
|
140
|
+
|
|
141
|
+
interface ThreadListProps {
|
|
142
|
+
className?: string;
|
|
143
|
+
emptyState?: React$1.ReactNode;
|
|
144
|
+
onThreadSelect?: (threadId: string) => void;
|
|
145
|
+
}
|
|
146
|
+
declare const ThreadList: React$1.FC<ThreadListProps>;
|
|
147
|
+
|
|
148
|
+
interface AccountDialogProps {
|
|
149
|
+
className?: string;
|
|
150
|
+
variant?: "default" | "destructive" | "outline" | "secondary" | "ghost" | "link";
|
|
151
|
+
size?: "default" | "sm" | "lg" | "icon";
|
|
152
|
+
}
|
|
153
|
+
declare const AccountDialog: React$1.FC<AccountDialogProps>;
|
|
154
|
+
|
|
155
|
+
interface UIRendererProps {
|
|
156
|
+
node: UINode;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Maps UINode types to refined React elements aligned with shadcn.
|
|
160
|
+
* UI is built via elements always starting with a card element as a root.
|
|
161
|
+
* Children are always rendered elements, never raw strings.
|
|
162
|
+
*/
|
|
163
|
+
declare function UIRenderer({ node }: UIRendererProps): react_jsx_runtime.JSX.Element;
|
|
164
|
+
|
|
165
|
+
export { AccountDialog, type AccountDialogProps, AuthContext, type AuthContextValue, AuthProvider, type AuthProviderProps, type AuthService, ChatFull, type ChatFullProps, ChatPopup, type ChatPopupProps, ChatSidebar, type ChatSidebarProps, Composer, MelonyContext, type MelonyContextValue, MelonyProvider, type MelonyProviderProps, type Message, type StarterPrompt, Thread, ThreadContext, type ThreadContextValue, type ThreadData, ThreadList, type ThreadListProps, ThreadProvider, type ThreadProviderProps, type ThreadService, UIRenderer, type UIRendererProps, type User, useAuth, useMelony, useThreads };
|