listpage-next 0.0.108 → 0.0.109
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/features/ChatClient/components/ChatPage/SimplifyChatPage.d.ts +4 -0
- package/dist/features/ChatClient/components/ChatPage/SimplifyChatPage.js +15 -3
- package/dist/features/ChatClient/context/message.js +2 -1
- package/dist/features/ChatClient/context/types.d.ts +1 -1
- package/dist/features/ChatClient/context/useChatContext.d.ts +1 -0
- package/package.json +1 -1
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import { RefObject } from "react";
|
|
1
2
|
import { BaseMessageInfo, ChatRender, ChatRequest } from "../../context";
|
|
3
|
+
import { ChatInstance } from "../../context/useChatContext";
|
|
2
4
|
export interface SimplifyChatPageProps<SessionData = any, MessageInfo extends BaseMessageInfo = any> {
|
|
3
5
|
request: ChatRequest<SessionData, MessageInfo>;
|
|
4
6
|
render: ChatRender<MessageInfo>;
|
|
5
7
|
style?: React.CSSProperties;
|
|
6
8
|
initialMessages?: MessageInfo[];
|
|
9
|
+
chatRef?: RefObject<ChatInstance>;
|
|
7
10
|
}
|
|
11
|
+
export declare const SimplifyChatPageComponent: <T = any>(props: SimplifyChatPageProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
8
12
|
export declare const SimplifyChatPage: <T = any>(props: SimplifyChatPageProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useImperativeHandle } from "react";
|
|
2
3
|
import { ChatClientProvider, MessageProvider } from "../../context/index.js";
|
|
4
|
+
import { useChatContext } from "../../context/useChatContext.js";
|
|
3
5
|
import { SimplifyClientContentBody } from "../ChatContent/ClientContentBody.js";
|
|
6
|
+
const SimplifyChatPageComponent = (props)=>{
|
|
7
|
+
const { chatRef } = props;
|
|
8
|
+
const context = useChatContext();
|
|
9
|
+
useImperativeHandle(chatRef, ()=>context, [
|
|
10
|
+
context
|
|
11
|
+
]);
|
|
12
|
+
return /*#__PURE__*/ jsx(SimplifyClientContentBody, {
|
|
13
|
+
style: props.style
|
|
14
|
+
});
|
|
15
|
+
};
|
|
4
16
|
const SimplifyChatPage = (props)=>/*#__PURE__*/ jsx(ChatClientProvider, {
|
|
5
17
|
request: props.request,
|
|
6
18
|
render: props.render,
|
|
7
19
|
children: /*#__PURE__*/ jsx(MessageProvider, {
|
|
8
20
|
request: props.request.chat,
|
|
9
21
|
initialMessages: props.initialMessages ?? [],
|
|
10
|
-
children: /*#__PURE__*/ jsx(
|
|
11
|
-
|
|
22
|
+
children: /*#__PURE__*/ jsx(SimplifyChatPageComponent, {
|
|
23
|
+
...props
|
|
12
24
|
})
|
|
13
25
|
})
|
|
14
26
|
});
|
|
15
|
-
export { SimplifyChatPage };
|
|
27
|
+
export { SimplifyChatPage, SimplifyChatPageComponent };
|
|
@@ -73,6 +73,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
|
|
|
73
73
|
setMessages([
|
|
74
74
|
...messagesRef.current
|
|
75
75
|
]);
|
|
76
|
+
const currentMsgs = messagesRef.current.map((msg)=>msg.info);
|
|
76
77
|
request(info, {
|
|
77
78
|
onCreated: (info)=>{
|
|
78
79
|
completeUserMessage(info);
|
|
@@ -104,7 +105,7 @@ const MessageProvider = ({ initialMessages, children, request })=>{
|
|
|
104
105
|
setIsRequesting(false);
|
|
105
106
|
onUpdate?.(info);
|
|
106
107
|
}
|
|
107
|
-
});
|
|
108
|
+
}, currentMsgs);
|
|
108
109
|
}, [
|
|
109
110
|
completeAssistantMessage,
|
|
110
111
|
completeUserMessage,
|
|
@@ -16,4 +16,4 @@ export type SendMessageRequest<MessageInfo extends BaseMessageInfo = any> = (inf
|
|
|
16
16
|
onUpdate: (id: string, info: MessageInfo) => void;
|
|
17
17
|
onSuccess: (id: string, info: MessageInfo) => void;
|
|
18
18
|
onError: (id: string, info: MessageInfo) => void;
|
|
19
|
-
}) => Promise<void>;
|
|
19
|
+
}, messages: MessageInfo[]) => Promise<void>;
|