@icos-react/largemodel 1.0.20 → 1.0.22
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/index.d.ts +2 -0
- package/dist/index.js +42 -7
- package/dist/index.mjs +126 -91
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1170,6 +1170,7 @@ interface ChatButtonProps {
|
|
|
1170
1170
|
topButtonActive?: React__default.CSSProperties;
|
|
1171
1171
|
topButtonIcon?: React__default.CSSProperties;
|
|
1172
1172
|
topButtonText?: React__default.CSSProperties;
|
|
1173
|
+
taskButtonText?: React__default.CSSProperties;
|
|
1173
1174
|
sender?: React__default.CSSProperties;
|
|
1174
1175
|
input?: React__default.CSSProperties;
|
|
1175
1176
|
sendButtonContainer?: React__default.CSSProperties;
|
|
@@ -1295,6 +1296,7 @@ interface ChatCustomProps$2 {
|
|
|
1295
1296
|
topButtonActive?: React__default.CSSProperties;
|
|
1296
1297
|
topButtonIcon?: React__default.CSSProperties;
|
|
1297
1298
|
topButtonText?: React__default.CSSProperties;
|
|
1299
|
+
taskButtonText?: React__default.CSSProperties;
|
|
1298
1300
|
sender?: React__default.CSSProperties;
|
|
1299
1301
|
input?: React__default.CSSProperties;
|
|
1300
1302
|
sendButtonContainer?: React__default.CSSProperties;
|
package/dist/index.js
CHANGED
|
@@ -4524,11 +4524,22 @@ var ThinkingContent = ({
|
|
|
4524
4524
|
customStyle,
|
|
4525
4525
|
thinkingIcon,
|
|
4526
4526
|
thinkingArrowIcon,
|
|
4527
|
-
formatThinkingBarTitle
|
|
4527
|
+
formatThinkingBarTitle,
|
|
4528
|
+
isAccumulatingThinking
|
|
4528
4529
|
}) => {
|
|
4529
4530
|
const useStyles5 = createChatStyles();
|
|
4530
4531
|
const { styles } = useStyles5();
|
|
4531
4532
|
const [isExpanded, setIsExpanded] = (0, import_react20.useState)(true);
|
|
4533
|
+
const prevAccumulatingRef = (0, import_react20.useRef)(isAccumulatingThinking);
|
|
4534
|
+
(0, import_react20.useEffect)(() => {
|
|
4535
|
+
if (prevAccumulatingRef.current === true && isAccumulatingThinking === false) {
|
|
4536
|
+
if (temporarilyDisableScroll) {
|
|
4537
|
+
temporarilyDisableScroll(500, "thinking-auto-collapse");
|
|
4538
|
+
}
|
|
4539
|
+
setIsExpanded(false);
|
|
4540
|
+
}
|
|
4541
|
+
prevAccumulatingRef.current = isAccumulatingThinking;
|
|
4542
|
+
}, [isAccumulatingThinking, temporarilyDisableScroll]);
|
|
4532
4543
|
const formatTime = (ms) => {
|
|
4533
4544
|
if (ms < 1e3) {
|
|
4534
4545
|
return `${ms}ms`;
|
|
@@ -4733,7 +4744,8 @@ var processMessageContent = (props) => {
|
|
|
4733
4744
|
customStyle,
|
|
4734
4745
|
thinkingIcon,
|
|
4735
4746
|
thinkingArrowIcon,
|
|
4736
|
-
formatThinkingBarTitle
|
|
4747
|
+
formatThinkingBarTitle,
|
|
4748
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4737
4749
|
}
|
|
4738
4750
|
), (() => {
|
|
4739
4751
|
const ec = typeof message.eventContent === "object" && message.eventContent !== null && !import_react20.default.isValidElement(message.eventContent) ? message.eventContent : void 0;
|
|
@@ -4779,7 +4791,8 @@ var processMessageContent = (props) => {
|
|
|
4779
4791
|
customStyle,
|
|
4780
4792
|
thinkingIcon,
|
|
4781
4793
|
thinkingArrowIcon,
|
|
4782
|
-
formatThinkingBarTitle
|
|
4794
|
+
formatThinkingBarTitle,
|
|
4795
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4783
4796
|
}
|
|
4784
4797
|
), message.content !== "..." ? renderContentWithAnchors(
|
|
4785
4798
|
message.content,
|
|
@@ -4806,7 +4819,8 @@ var processMessageContent = (props) => {
|
|
|
4806
4819
|
customStyle,
|
|
4807
4820
|
thinkingIcon,
|
|
4808
4821
|
thinkingArrowIcon,
|
|
4809
|
-
formatThinkingBarTitle
|
|
4822
|
+
formatThinkingBarTitle,
|
|
4823
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4810
4824
|
}
|
|
4811
4825
|
));
|
|
4812
4826
|
}
|
|
@@ -7064,7 +7078,14 @@ var ChatAssistant = (0, import_react23.forwardRef)(
|
|
|
7064
7078
|
onMouseEnter: () => setIsTaskButtonHovered(true),
|
|
7065
7079
|
onMouseLeave: () => setIsTaskButtonHovered(false)
|
|
7066
7080
|
},
|
|
7067
|
-
/* @__PURE__ */ import_react23.default.createElement(
|
|
7081
|
+
/* @__PURE__ */ import_react23.default.createElement(
|
|
7082
|
+
"span",
|
|
7083
|
+
{
|
|
7084
|
+
className: styles.taskButtonText,
|
|
7085
|
+
style: customStyle?.taskButtonText
|
|
7086
|
+
},
|
|
7087
|
+
buttonConfig?.text
|
|
7088
|
+
),
|
|
7068
7089
|
/* @__PURE__ */ import_react23.default.createElement(
|
|
7069
7090
|
"img",
|
|
7070
7091
|
{
|
|
@@ -7084,7 +7105,14 @@ var ChatAssistant = (0, import_react23.forwardRef)(
|
|
|
7084
7105
|
);
|
|
7085
7106
|
}
|
|
7086
7107
|
return null;
|
|
7087
|
-
}, [
|
|
7108
|
+
}, [
|
|
7109
|
+
currentType,
|
|
7110
|
+
isTaskButtonHovered,
|
|
7111
|
+
styles.taskButton,
|
|
7112
|
+
styles.taskButtonText,
|
|
7113
|
+
styles.taskButtonCloseIcon,
|
|
7114
|
+
customStyle?.taskButtonText
|
|
7115
|
+
]);
|
|
7088
7116
|
const { forceScrollToBottom } = useChatScroll({
|
|
7089
7117
|
sendStatus,
|
|
7090
7118
|
history,
|
|
@@ -7371,7 +7399,14 @@ var ChatAssistant = (0, import_react23.forwardRef)(
|
|
|
7371
7399
|
alt: item.text
|
|
7372
7400
|
}
|
|
7373
7401
|
),
|
|
7374
|
-
/* @__PURE__ */ import_react23.default.createElement(
|
|
7402
|
+
/* @__PURE__ */ import_react23.default.createElement(
|
|
7403
|
+
"span",
|
|
7404
|
+
{
|
|
7405
|
+
className: styles.topButtonText,
|
|
7406
|
+
style: customStyle?.topButtonText
|
|
7407
|
+
},
|
|
7408
|
+
item.text
|
|
7409
|
+
)
|
|
7375
7410
|
))
|
|
7376
7411
|
), /* @__PURE__ */ import_react23.default.createElement(
|
|
7377
7412
|
"button",
|
package/dist/index.mjs
CHANGED
|
@@ -1939,13 +1939,13 @@ var ChatX = ({ userIcon, buttonImage }) => {
|
|
|
1939
1939
|
var ChatX_default = ChatX;
|
|
1940
1940
|
|
|
1941
1941
|
// src/components/ChatButton.tsx
|
|
1942
|
-
import React14, { useState as useState13, forwardRef as forwardRef8, useEffect as useEffect13, useLayoutEffect, useRef as
|
|
1942
|
+
import React14, { useState as useState13, forwardRef as forwardRef8, useEffect as useEffect13, useLayoutEffect, useRef as useRef14, useImperativeHandle as useImperativeHandle8, useCallback as useCallback14 } from "react";
|
|
1943
1943
|
|
|
1944
1944
|
// src/components/ChatDemo/ChatDemo.tsx
|
|
1945
1945
|
import { Bubble as Bubble2 } from "@ant-design/x";
|
|
1946
1946
|
import React11, {
|
|
1947
1947
|
useState as useState9,
|
|
1948
|
-
useRef as
|
|
1948
|
+
useRef as useRef10,
|
|
1949
1949
|
useEffect as useEffect9,
|
|
1950
1950
|
forwardRef as forwardRef5,
|
|
1951
1951
|
useImperativeHandle as useImperativeHandle5
|
|
@@ -4331,7 +4331,7 @@ var processHistoryRecords = (history, chatMessages, setChatMessages, setConversa
|
|
|
4331
4331
|
init_apiHandler();
|
|
4332
4332
|
|
|
4333
4333
|
// src/components/ChatDemo/messageRenderer.tsx
|
|
4334
|
-
import React10, { useEffect as useEffect8, useState as useState8 } from "react";
|
|
4334
|
+
import React10, { useEffect as useEffect8, useRef as useRef9, useState as useState8 } from "react";
|
|
4335
4335
|
import ReactMarkdown2 from "react-markdown";
|
|
4336
4336
|
import rehypeRaw from "rehype-raw";
|
|
4337
4337
|
var rightIcon = `data:image/svg+xml,${encodeURIComponent(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -4475,11 +4475,22 @@ var ThinkingContent = ({
|
|
|
4475
4475
|
customStyle,
|
|
4476
4476
|
thinkingIcon,
|
|
4477
4477
|
thinkingArrowIcon,
|
|
4478
|
-
formatThinkingBarTitle
|
|
4478
|
+
formatThinkingBarTitle,
|
|
4479
|
+
isAccumulatingThinking
|
|
4479
4480
|
}) => {
|
|
4480
4481
|
const useStyles5 = createChatStyles();
|
|
4481
4482
|
const { styles } = useStyles5();
|
|
4482
4483
|
const [isExpanded, setIsExpanded] = useState8(true);
|
|
4484
|
+
const prevAccumulatingRef = useRef9(isAccumulatingThinking);
|
|
4485
|
+
useEffect8(() => {
|
|
4486
|
+
if (prevAccumulatingRef.current === true && isAccumulatingThinking === false) {
|
|
4487
|
+
if (temporarilyDisableScroll) {
|
|
4488
|
+
temporarilyDisableScroll(500, "thinking-auto-collapse");
|
|
4489
|
+
}
|
|
4490
|
+
setIsExpanded(false);
|
|
4491
|
+
}
|
|
4492
|
+
prevAccumulatingRef.current = isAccumulatingThinking;
|
|
4493
|
+
}, [isAccumulatingThinking, temporarilyDisableScroll]);
|
|
4483
4494
|
const formatTime = (ms) => {
|
|
4484
4495
|
if (ms < 1e3) {
|
|
4485
4496
|
return `${ms}ms`;
|
|
@@ -4684,7 +4695,8 @@ var processMessageContent = (props) => {
|
|
|
4684
4695
|
customStyle,
|
|
4685
4696
|
thinkingIcon,
|
|
4686
4697
|
thinkingArrowIcon,
|
|
4687
|
-
formatThinkingBarTitle
|
|
4698
|
+
formatThinkingBarTitle,
|
|
4699
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4688
4700
|
}
|
|
4689
4701
|
), (() => {
|
|
4690
4702
|
const ec = typeof message.eventContent === "object" && message.eventContent !== null && !React10.isValidElement(message.eventContent) ? message.eventContent : void 0;
|
|
@@ -4730,7 +4742,8 @@ var processMessageContent = (props) => {
|
|
|
4730
4742
|
customStyle,
|
|
4731
4743
|
thinkingIcon,
|
|
4732
4744
|
thinkingArrowIcon,
|
|
4733
|
-
formatThinkingBarTitle
|
|
4745
|
+
formatThinkingBarTitle,
|
|
4746
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4734
4747
|
}
|
|
4735
4748
|
), message.content !== "..." ? renderContentWithAnchors(
|
|
4736
4749
|
message.content,
|
|
@@ -4757,7 +4770,8 @@ var processMessageContent = (props) => {
|
|
|
4757
4770
|
customStyle,
|
|
4758
4771
|
thinkingIcon,
|
|
4759
4772
|
thinkingArrowIcon,
|
|
4760
|
-
formatThinkingBarTitle
|
|
4773
|
+
formatThinkingBarTitle,
|
|
4774
|
+
isAccumulatingThinking: message.isAccumulatingThinking
|
|
4761
4775
|
}
|
|
4762
4776
|
));
|
|
4763
4777
|
}
|
|
@@ -4874,7 +4888,7 @@ var ChatDemo = forwardRef5(
|
|
|
4874
4888
|
const [hasMoreHistory, setHasMoreHistory] = useState9(true);
|
|
4875
4889
|
const [isLoadingMore, setIsLoadingMore] = useState9(false);
|
|
4876
4890
|
const [internalVariables, setInternalVariables] = useState9(variables || {});
|
|
4877
|
-
const hasMessageSentRef =
|
|
4891
|
+
const hasMessageSentRef = useRef10(false);
|
|
4878
4892
|
useEffect9(() => {
|
|
4879
4893
|
if (!customStyle?.userMessageContent && !customStyle?.assistantMessageContent && !customStyle?.bubbleList) {
|
|
4880
4894
|
return;
|
|
@@ -4958,8 +4972,8 @@ var ChatDemo = forwardRef5(
|
|
|
4958
4972
|
customStyle?.assistantMessageContent,
|
|
4959
4973
|
customStyle?.bubbleList
|
|
4960
4974
|
]);
|
|
4961
|
-
const inputElementRef =
|
|
4962
|
-
const topButtonsScrollRef =
|
|
4975
|
+
const inputElementRef = useRef10(null);
|
|
4976
|
+
const topButtonsScrollRef = useRef10(null);
|
|
4963
4977
|
const [canScrollLeft, setCanScrollLeft] = useState9(false);
|
|
4964
4978
|
const [canScrollRight, setCanScrollRight] = useState9(false);
|
|
4965
4979
|
const updateScrollArrows = React11.useCallback(() => {
|
|
@@ -5062,9 +5076,9 @@ var ChatDemo = forwardRef5(
|
|
|
5062
5076
|
styles.taskButtonText,
|
|
5063
5077
|
styles.taskButtonCloseIcon
|
|
5064
5078
|
]);
|
|
5065
|
-
const abortControllerRef =
|
|
5066
|
-
const eventContentInteractionBlockRef =
|
|
5067
|
-
const eventContentBlockTimeoutRef =
|
|
5079
|
+
const abortControllerRef = useRef10(null);
|
|
5080
|
+
const eventContentInteractionBlockRef = useRef10(false);
|
|
5081
|
+
const eventContentBlockTimeoutRef = useRef10(null);
|
|
5068
5082
|
const handleMessageAction = async (messageId, actionType, currentState, content2) => {
|
|
5069
5083
|
if (!enableMessageActions)
|
|
5070
5084
|
return;
|
|
@@ -5112,7 +5126,7 @@ var ChatDemo = forwardRef5(
|
|
|
5112
5126
|
}
|
|
5113
5127
|
}
|
|
5114
5128
|
}, [sceneCode]);
|
|
5115
|
-
const prevExternalCurrentTypeRef =
|
|
5129
|
+
const prevExternalCurrentTypeRef = useRef10(externalCurrentType);
|
|
5116
5130
|
useEffect9(() => {
|
|
5117
5131
|
const prevType = prevExternalCurrentTypeRef.current;
|
|
5118
5132
|
if (externalCurrentType !== void 0 && prevType && // 上一次有值
|
|
@@ -5132,7 +5146,7 @@ var ChatDemo = forwardRef5(
|
|
|
5132
5146
|
onMidValChange(midVal);
|
|
5133
5147
|
}
|
|
5134
5148
|
}, [midVal, onMidValChange]);
|
|
5135
|
-
const temporarilyDisableScrollRef =
|
|
5149
|
+
const temporarilyDisableScrollRef = useRef10(null);
|
|
5136
5150
|
const loadMoreHistory = async () => {
|
|
5137
5151
|
if (!onLoadMoreHistory || isLoadingMore || !hasMoreHistory) {
|
|
5138
5152
|
return;
|
|
@@ -5355,7 +5369,7 @@ var ChatDemo = forwardRef5(
|
|
|
5355
5369
|
getBizConversationId2();
|
|
5356
5370
|
}
|
|
5357
5371
|
}, [isBizConversationIdLoaded]);
|
|
5358
|
-
const inputFocusStateRef =
|
|
5372
|
+
const inputFocusStateRef = useRef10({ isFocused: false, selectionStart: 0, selectionEnd: 0 });
|
|
5359
5373
|
useEffect9(() => {
|
|
5360
5374
|
setTimeout(() => {
|
|
5361
5375
|
const isFirstLoad = !isInitialLoad.current && !forceRenderKey;
|
|
@@ -5473,8 +5487,8 @@ var ChatDemo = forwardRef5(
|
|
|
5473
5487
|
);
|
|
5474
5488
|
}
|
|
5475
5489
|
}, [initMessage, history, chatMessages.length, isResettingSession]);
|
|
5476
|
-
const idCounterRef =
|
|
5477
|
-
const processedStatesRef =
|
|
5490
|
+
const idCounterRef = useRef10(0);
|
|
5491
|
+
const processedStatesRef = useRef10({});
|
|
5478
5492
|
const roles2 = {
|
|
5479
5493
|
ai: {
|
|
5480
5494
|
placement: "start",
|
|
@@ -6380,7 +6394,7 @@ import { createStyles as createStyles7 } from "antd-style";
|
|
|
6380
6394
|
import React12, {
|
|
6381
6395
|
useState as useState11,
|
|
6382
6396
|
useEffect as useEffect11,
|
|
6383
|
-
useRef as
|
|
6397
|
+
useRef as useRef12,
|
|
6384
6398
|
forwardRef as forwardRef6,
|
|
6385
6399
|
useImperativeHandle as useImperativeHandle6,
|
|
6386
6400
|
useMemo as useMemo2,
|
|
@@ -6389,14 +6403,14 @@ import React12, {
|
|
|
6389
6403
|
|
|
6390
6404
|
// src/hooks/useBizConversationId.ts
|
|
6391
6405
|
init_apiHandler();
|
|
6392
|
-
import { useState as useState10, useRef as
|
|
6406
|
+
import { useState as useState10, useRef as useRef11, useCallback as useCallback11, useEffect as useEffect10 } from "react";
|
|
6393
6407
|
var useBizConversationId = (options) => {
|
|
6394
6408
|
const { initialId = "", autoFetch = false, genBizConversationIdUrl, onAuthError } = options || {};
|
|
6395
6409
|
const [bizConversationId, setBizConversationId] = useState10(initialId);
|
|
6396
6410
|
const [isLoaded, setIsLoaded] = useState10(!!initialId);
|
|
6397
6411
|
const [isFetching, setIsFetching] = useState10(false);
|
|
6398
|
-
const isFetchingRef =
|
|
6399
|
-
const hasSuccessfullyFetched =
|
|
6412
|
+
const isFetchingRef = useRef11(false);
|
|
6413
|
+
const hasSuccessfullyFetched = useRef11(!!initialId);
|
|
6400
6414
|
useEffect10(() => {
|
|
6401
6415
|
if (initialId && initialId !== bizConversationId) {
|
|
6402
6416
|
setBizConversationId(initialId);
|
|
@@ -6942,11 +6956,11 @@ var ChatAssistant = forwardRef6(
|
|
|
6942
6956
|
const { styles } = useStyle2();
|
|
6943
6957
|
const [sendStatus, setSendStatus] = useState11(false);
|
|
6944
6958
|
const [inputValue, setInputValue] = useState11("");
|
|
6945
|
-
const inputRef =
|
|
6946
|
-
const customInputElementRef =
|
|
6959
|
+
const inputRef = useRef12(null);
|
|
6960
|
+
const customInputElementRef = useRef12(null);
|
|
6947
6961
|
const [currentType, setCurrentType] = useState11("");
|
|
6948
6962
|
const [isTaskButtonHovered, setIsTaskButtonHovered] = useState11(false);
|
|
6949
|
-
const topButtonsScrollRef =
|
|
6963
|
+
const topButtonsScrollRef = useRef12(null);
|
|
6950
6964
|
const [canScrollLeft, setCanScrollLeft] = useState11(false);
|
|
6951
6965
|
const [canScrollRight, setCanScrollRight] = useState11(false);
|
|
6952
6966
|
const updateScrollArrows = React12.useCallback(() => {
|
|
@@ -6992,7 +7006,7 @@ var ChatAssistant = forwardRef6(
|
|
|
6992
7006
|
}
|
|
6993
7007
|
}
|
|
6994
7008
|
};
|
|
6995
|
-
const chatDemoRef =
|
|
7009
|
+
const chatDemoRef = useRef12(null);
|
|
6996
7010
|
const [pendingMessage, setPendingMessage] = useState11(null);
|
|
6997
7011
|
const allQuestions = useMemo2(
|
|
6998
7012
|
() => quickQuestions || QUICK_QUESTIONS,
|
|
@@ -7023,7 +7037,14 @@ var ChatAssistant = forwardRef6(
|
|
|
7023
7037
|
onMouseEnter: () => setIsTaskButtonHovered(true),
|
|
7024
7038
|
onMouseLeave: () => setIsTaskButtonHovered(false)
|
|
7025
7039
|
},
|
|
7026
|
-
/* @__PURE__ */ React12.createElement(
|
|
7040
|
+
/* @__PURE__ */ React12.createElement(
|
|
7041
|
+
"span",
|
|
7042
|
+
{
|
|
7043
|
+
className: styles.taskButtonText,
|
|
7044
|
+
style: customStyle?.taskButtonText
|
|
7045
|
+
},
|
|
7046
|
+
buttonConfig?.text
|
|
7047
|
+
),
|
|
7027
7048
|
/* @__PURE__ */ React12.createElement(
|
|
7028
7049
|
"img",
|
|
7029
7050
|
{
|
|
@@ -7043,7 +7064,14 @@ var ChatAssistant = forwardRef6(
|
|
|
7043
7064
|
);
|
|
7044
7065
|
}
|
|
7045
7066
|
return null;
|
|
7046
|
-
}, [
|
|
7067
|
+
}, [
|
|
7068
|
+
currentType,
|
|
7069
|
+
isTaskButtonHovered,
|
|
7070
|
+
styles.taskButton,
|
|
7071
|
+
styles.taskButtonText,
|
|
7072
|
+
styles.taskButtonCloseIcon,
|
|
7073
|
+
customStyle?.taskButtonText
|
|
7074
|
+
]);
|
|
7047
7075
|
const { forceScrollToBottom } = useChatScroll({
|
|
7048
7076
|
sendStatus,
|
|
7049
7077
|
history,
|
|
@@ -7073,7 +7101,7 @@ var ChatAssistant = forwardRef6(
|
|
|
7073
7101
|
}
|
|
7074
7102
|
}
|
|
7075
7103
|
};
|
|
7076
|
-
const hasInitialized =
|
|
7104
|
+
const hasInitialized = useRef12(false);
|
|
7077
7105
|
useEffect11(() => {
|
|
7078
7106
|
if (hasInitialized.current) {
|
|
7079
7107
|
return;
|
|
@@ -7330,7 +7358,14 @@ var ChatAssistant = forwardRef6(
|
|
|
7330
7358
|
alt: item.text
|
|
7331
7359
|
}
|
|
7332
7360
|
),
|
|
7333
|
-
/* @__PURE__ */ React12.createElement(
|
|
7361
|
+
/* @__PURE__ */ React12.createElement(
|
|
7362
|
+
"span",
|
|
7363
|
+
{
|
|
7364
|
+
className: styles.topButtonText,
|
|
7365
|
+
style: customStyle?.topButtonText
|
|
7366
|
+
},
|
|
7367
|
+
item.text
|
|
7368
|
+
)
|
|
7334
7369
|
))
|
|
7335
7370
|
), /* @__PURE__ */ React12.createElement(
|
|
7336
7371
|
"button",
|
|
@@ -7484,7 +7519,7 @@ var ChatAssistant = forwardRef6(
|
|
|
7484
7519
|
// src/components/DigitalHuman/index.tsx
|
|
7485
7520
|
import React13, {
|
|
7486
7521
|
useState as useState12,
|
|
7487
|
-
useRef as
|
|
7522
|
+
useRef as useRef13,
|
|
7488
7523
|
useEffect as useEffect12,
|
|
7489
7524
|
useCallback as useCallback13,
|
|
7490
7525
|
forwardRef as forwardRef7,
|
|
@@ -7849,7 +7884,7 @@ var humanSpeak = (humanRef, text) => {
|
|
|
7849
7884
|
// src/components/DigitalHuman/index.tsx
|
|
7850
7885
|
var DraggableButtonAndModal = forwardRef7(({ setAsrData, digitalHumanUrl, isVoiceActive = false }, ref) => {
|
|
7851
7886
|
const [roomId] = useState12("");
|
|
7852
|
-
const iframeRef =
|
|
7887
|
+
const iframeRef = useRef13(null);
|
|
7853
7888
|
const [humanToken] = useState12((/* @__PURE__ */ new Date()).getTime());
|
|
7854
7889
|
const humanOrigin = "https://jkqszr.bda.gov.cn";
|
|
7855
7890
|
const HUMAN_URL = `${digitalHumanUrl}${digitalHumanUrl.includes("?") ? "&" : "?"}token=${humanToken}`;
|
|
@@ -8019,8 +8054,8 @@ var ChatButton = forwardRef8(
|
|
|
8019
8054
|
beforeSend
|
|
8020
8055
|
}, ref) => {
|
|
8021
8056
|
const safeLayoutScale = Number.isFinite(layoutScale) && layoutScale > 0 ? layoutScale : 1;
|
|
8022
|
-
const humanRef =
|
|
8023
|
-
const previousHistoryRef =
|
|
8057
|
+
const humanRef = useRef14(null);
|
|
8058
|
+
const previousHistoryRef = useRef14([]);
|
|
8024
8059
|
const [componentKey, setComponentKey] = useState13(0);
|
|
8025
8060
|
const useStyle2 = createStyles8(({ token, css }) => {
|
|
8026
8061
|
return {
|
|
@@ -8153,31 +8188,31 @@ var ChatButton = forwardRef8(
|
|
|
8153
8188
|
const [asrData, setAsrData] = useState13({});
|
|
8154
8189
|
const [isVoiceActive, setIsVoiceActive] = useState13(false);
|
|
8155
8190
|
const [isHumanVisible, setIsHumanVisible] = useState13(false);
|
|
8156
|
-
const voiceTimeoutRef =
|
|
8157
|
-
const internalRef =
|
|
8191
|
+
const voiceTimeoutRef = useRef14(null);
|
|
8192
|
+
const internalRef = useRef14(null);
|
|
8158
8193
|
const [buttonPos, setButtonPos] = useState13(null);
|
|
8159
8194
|
const [dragPixelState, setDragPixelState] = useState13(null);
|
|
8160
8195
|
const [isButtonDragging, setIsButtonDragging] = useState13(false);
|
|
8161
|
-
const buttonPosRef =
|
|
8162
|
-
const dragPixelPos =
|
|
8163
|
-
const longPressTimer =
|
|
8164
|
-
const dragStartMouse =
|
|
8165
|
-
const dragStartButton =
|
|
8166
|
-
const hasDragged =
|
|
8167
|
-
const isLongPressed =
|
|
8168
|
-
const buttonRef =
|
|
8196
|
+
const buttonPosRef = useRef14(null);
|
|
8197
|
+
const dragPixelPos = useRef14(null);
|
|
8198
|
+
const longPressTimer = useRef14(null);
|
|
8199
|
+
const dragStartMouse = useRef14({ x: 0, y: 0 });
|
|
8200
|
+
const dragStartButton = useRef14({ x: 0, y: 0 });
|
|
8201
|
+
const hasDragged = useRef14(false);
|
|
8202
|
+
const isLongPressed = useRef14(false);
|
|
8203
|
+
const buttonRef = useRef14(null);
|
|
8169
8204
|
const [pendingButtonMessage, setPendingButtonMessage] = useState13(null);
|
|
8170
8205
|
const [isDragging, setIsDragging] = useState13(false);
|
|
8171
8206
|
const [dragOffset, setDragOffset] = useState13({ x: 0, y: 0 });
|
|
8172
|
-
const dragContainerOffset =
|
|
8207
|
+
const dragContainerOffset = useRef14({ x: 0, y: 0 });
|
|
8173
8208
|
const [windowPosition, setWindowPosition] = useState13({
|
|
8174
8209
|
top: windowPositon.top,
|
|
8175
8210
|
left: windowPositon.left,
|
|
8176
8211
|
right: windowPositon.right,
|
|
8177
8212
|
bottom: windowPositon.bottom
|
|
8178
8213
|
});
|
|
8179
|
-
const chatWindowRef =
|
|
8180
|
-
const windowPositionRef =
|
|
8214
|
+
const chatWindowRef = useRef14(null);
|
|
8215
|
+
const windowPositionRef = useRef14(windowPosition);
|
|
8181
8216
|
useEffect13(() => {
|
|
8182
8217
|
windowPositionRef.current = windowPosition;
|
|
8183
8218
|
if (isOpen && (windowPosition.top !== void 0 || windowPosition.left !== void 0 || windowPosition.right !== void 0 || windowPosition.bottom !== void 0)) {
|
|
@@ -8213,7 +8248,7 @@ var ChatButton = forwardRef8(
|
|
|
8213
8248
|
window.addEventListener("resize", update);
|
|
8214
8249
|
return () => window.removeEventListener("resize", update);
|
|
8215
8250
|
}, []);
|
|
8216
|
-
const hasUserDraggedRef =
|
|
8251
|
+
const hasUserDraggedRef = useRef14(false);
|
|
8217
8252
|
const convertPosition = useCallback14((value, dimension) => {
|
|
8218
8253
|
if (value === void 0)
|
|
8219
8254
|
return void 0;
|
|
@@ -9269,7 +9304,7 @@ var ChatWelcome = ({ width, height, apiInfo, padding }) => {
|
|
|
9269
9304
|
|
|
9270
9305
|
// src/components/ChatCustom.tsx
|
|
9271
9306
|
import { createStyles as createStyles10 } from "antd-style";
|
|
9272
|
-
import React16, { useState as useState15, useEffect as useEffect15, useRef as
|
|
9307
|
+
import React16, { useState as useState15, useEffect as useEffect15, useRef as useRef15, forwardRef as forwardRef9 } from "react";
|
|
9273
9308
|
import { theme } from "antd";
|
|
9274
9309
|
init_apiHandler();
|
|
9275
9310
|
var getToken5 = () => {
|
|
@@ -9374,15 +9409,15 @@ var ChatCustom = forwardRef9(({
|
|
|
9374
9409
|
const [sendStatus, setSendStatus] = useState15(false);
|
|
9375
9410
|
const [inputValue, setInputValue] = useState15("");
|
|
9376
9411
|
const [bizConversationId, setBizConversationId] = useState15("");
|
|
9377
|
-
const inputRef =
|
|
9378
|
-
const customInputElementRef =
|
|
9412
|
+
const inputRef = useRef15(null);
|
|
9413
|
+
const customInputElementRef = useRef15(null);
|
|
9379
9414
|
const { forceScrollToBottom } = useChatScroll({
|
|
9380
9415
|
sendStatus,
|
|
9381
9416
|
history,
|
|
9382
9417
|
eventContent
|
|
9383
9418
|
});
|
|
9384
|
-
const isFetchingBizConversationId =
|
|
9385
|
-
const hasSuccessfullyFetchedBizConversationId =
|
|
9419
|
+
const isFetchingBizConversationId = useRef15(false);
|
|
9420
|
+
const hasSuccessfullyFetchedBizConversationId = useRef15(false);
|
|
9386
9421
|
const fetchBizConversationId = async () => {
|
|
9387
9422
|
if (bizConversationId || isFetchingBizConversationId.current || hasSuccessfullyFetchedBizConversationId.current) {
|
|
9388
9423
|
return;
|
|
@@ -9425,7 +9460,7 @@ var ChatCustom = forwardRef9(({
|
|
|
9425
9460
|
}
|
|
9426
9461
|
}
|
|
9427
9462
|
};
|
|
9428
|
-
const hasInitialized =
|
|
9463
|
+
const hasInitialized = useRef15(false);
|
|
9429
9464
|
useEffect15(() => {
|
|
9430
9465
|
if (hasInitialized.current) {
|
|
9431
9466
|
return;
|
|
@@ -9558,7 +9593,7 @@ import { createStyles as createStyles11 } from "antd-style";
|
|
|
9558
9593
|
import React20, {
|
|
9559
9594
|
useState as useState17,
|
|
9560
9595
|
useEffect as useEffect18,
|
|
9561
|
-
useRef as
|
|
9596
|
+
useRef as useRef18,
|
|
9562
9597
|
forwardRef as forwardRef11,
|
|
9563
9598
|
useImperativeHandle as useImperativeHandle10,
|
|
9564
9599
|
useMemo as useMemo3,
|
|
@@ -9567,7 +9602,7 @@ import React20, {
|
|
|
9567
9602
|
|
|
9568
9603
|
// src/components/ChatDemo/ChatDemoRefactored.tsx
|
|
9569
9604
|
import React19, {
|
|
9570
|
-
useRef as
|
|
9605
|
+
useRef as useRef17,
|
|
9571
9606
|
useEffect as useEffect17,
|
|
9572
9607
|
forwardRef as forwardRef10,
|
|
9573
9608
|
useImperativeHandle as useImperativeHandle9,
|
|
@@ -9725,7 +9760,7 @@ var useChatSession2 = (options) => {
|
|
|
9725
9760
|
};
|
|
9726
9761
|
|
|
9727
9762
|
// src/hooks/chat/useChatAPI.ts
|
|
9728
|
-
import { useRef as
|
|
9763
|
+
import { useRef as useRef16, useCallback as useCallback17 } from "react";
|
|
9729
9764
|
var useChatAPI = (options) => {
|
|
9730
9765
|
const {
|
|
9731
9766
|
apiInfo,
|
|
@@ -9753,10 +9788,10 @@ var useChatAPI = (options) => {
|
|
|
9753
9788
|
isDeepThinkEnabled = false,
|
|
9754
9789
|
revealStreamThinking = false
|
|
9755
9790
|
} = options;
|
|
9756
|
-
const abortControllerRef =
|
|
9757
|
-
const idCounterRef =
|
|
9758
|
-
const processedStatesRef =
|
|
9759
|
-
const hasMessageSentRef =
|
|
9791
|
+
const abortControllerRef = useRef16(null);
|
|
9792
|
+
const idCounterRef = useRef16(0);
|
|
9793
|
+
const processedStatesRef = useRef16({});
|
|
9794
|
+
const hasMessageSentRef = useRef16(false);
|
|
9760
9795
|
const handleStopResponse = useCallback17(() => {
|
|
9761
9796
|
if (abortControllerRef.current) {
|
|
9762
9797
|
abortControllerRef.current.abort();
|
|
@@ -10618,7 +10653,7 @@ var ChatDemoRefactored = forwardRef10(
|
|
|
10618
10653
|
setIsTaskButtonHovered,
|
|
10619
10654
|
resetState
|
|
10620
10655
|
} = state;
|
|
10621
|
-
const inputElementRef =
|
|
10656
|
+
const inputElementRef = useRef17(null);
|
|
10622
10657
|
const currentType = externalCurrentType !== void 0 ? externalCurrentType : internalCurrentType;
|
|
10623
10658
|
const prefixButton = React19.useMemo(() => {
|
|
10624
10659
|
if (customPrefixButton) {
|
|
@@ -10676,9 +10711,9 @@ var ChatDemoRefactored = forwardRef10(
|
|
|
10676
10711
|
onTypeChange,
|
|
10677
10712
|
setInternalCurrentType
|
|
10678
10713
|
]);
|
|
10679
|
-
const eventContentInteractionBlockRef =
|
|
10680
|
-
const eventContentBlockTimeoutRef =
|
|
10681
|
-
const temporarilyDisableScrollRef =
|
|
10714
|
+
const eventContentInteractionBlockRef = useRef17(false);
|
|
10715
|
+
const eventContentBlockTimeoutRef = useRef17(null);
|
|
10716
|
+
const temporarilyDisableScrollRef = useRef17(null);
|
|
10682
10717
|
const loadMoreHistory = async () => {
|
|
10683
10718
|
if (!onLoadMoreHistory || isLoadingMore || !hasMoreHistory) {
|
|
10684
10719
|
return;
|
|
@@ -10988,7 +11023,7 @@ var ChatDemoRefactored = forwardRef10(
|
|
|
10988
11023
|
}
|
|
10989
11024
|
};
|
|
10990
11025
|
}, [temporarilyDisableScroll]);
|
|
10991
|
-
const inputFocusStateRef =
|
|
11026
|
+
const inputFocusStateRef = useRef17({ isFocused: false, selectionStart: 0, selectionEnd: 0 });
|
|
10992
11027
|
useEffect17(() => {
|
|
10993
11028
|
setTimeout(() => {
|
|
10994
11029
|
const isFirstLoad = !isInitialLoad.current && !forceRenderKey;
|
|
@@ -11126,7 +11161,7 @@ var ChatDemoRefactored = forwardRef10(
|
|
|
11126
11161
|
onEventChange,
|
|
11127
11162
|
setIsEventChangeProcessing
|
|
11128
11163
|
]);
|
|
11129
|
-
const prevExternalCurrentTypeRef =
|
|
11164
|
+
const prevExternalCurrentTypeRef = useRef17(externalCurrentType);
|
|
11130
11165
|
useEffect17(() => {
|
|
11131
11166
|
const prevType = prevExternalCurrentTypeRef.current;
|
|
11132
11167
|
if (externalCurrentType !== void 0 && prevType && (!externalCurrentType || externalCurrentType === "chat") && sceneCode) {
|
|
@@ -11830,8 +11865,8 @@ var ChatTop = forwardRef11(
|
|
|
11830
11865
|
const { styles } = useStyle2();
|
|
11831
11866
|
const [sendStatus, setSendStatus] = useState17(false);
|
|
11832
11867
|
const [inputValue, setInputValue] = useState17("");
|
|
11833
|
-
const inputRef =
|
|
11834
|
-
const customInputElementRef =
|
|
11868
|
+
const inputRef = useRef18(null);
|
|
11869
|
+
const customInputElementRef = useRef18(null);
|
|
11835
11870
|
const [currentType, setCurrentType] = useState17("");
|
|
11836
11871
|
const [isTaskButtonHovered, setIsTaskButtonHovered] = useState17(false);
|
|
11837
11872
|
const [isDeepThinkEnabled, setIsDeepThinkEnabled] = useState17(true);
|
|
@@ -11860,7 +11895,7 @@ var ChatTop = forwardRef11(
|
|
|
11860
11895
|
}
|
|
11861
11896
|
}
|
|
11862
11897
|
};
|
|
11863
|
-
const chatDemoRef =
|
|
11898
|
+
const chatDemoRef = useRef18(null);
|
|
11864
11899
|
const [pendingMessage, setPendingMessage] = useState17(null);
|
|
11865
11900
|
const prefixButton = useMemo3(() => {
|
|
11866
11901
|
if (customPrefixButton) {
|
|
@@ -11911,7 +11946,7 @@ var ChatTop = forwardRef11(
|
|
|
11911
11946
|
history,
|
|
11912
11947
|
eventContent
|
|
11913
11948
|
});
|
|
11914
|
-
const hasInitialized =
|
|
11949
|
+
const hasInitialized = useRef18(false);
|
|
11915
11950
|
useEffect18(() => {
|
|
11916
11951
|
if (hasInitialized.current) {
|
|
11917
11952
|
return;
|
|
@@ -12344,12 +12379,12 @@ var ChatTop = forwardRef11(
|
|
|
12344
12379
|
);
|
|
12345
12380
|
|
|
12346
12381
|
// src/hooks/useChatScrollOptimized.ts
|
|
12347
|
-
import { useRef as
|
|
12382
|
+
import { useRef as useRef20, useEffect as useEffect20, useCallback as useCallback21 } from "react";
|
|
12348
12383
|
|
|
12349
12384
|
// src/hooks/useSafeTimeout.ts
|
|
12350
|
-
import { useRef as
|
|
12385
|
+
import { useRef as useRef19, useCallback as useCallback20, useEffect as useEffect19 } from "react";
|
|
12351
12386
|
var useSafeTimeout = () => {
|
|
12352
|
-
const timeoutsRef =
|
|
12387
|
+
const timeoutsRef = useRef19(/* @__PURE__ */ new Set());
|
|
12353
12388
|
const setSafeTimeout = useCallback20((callback, delay) => {
|
|
12354
12389
|
const timeoutId = setTimeout(() => {
|
|
12355
12390
|
callback();
|
|
@@ -12389,16 +12424,16 @@ var useChatScrollOptimized = ({
|
|
|
12389
12424
|
hasMore,
|
|
12390
12425
|
isLoadingMore
|
|
12391
12426
|
} = {}) => {
|
|
12392
|
-
const messagesEndRef =
|
|
12393
|
-
const messagesContainerRef =
|
|
12394
|
-
const observerRef =
|
|
12395
|
-
const initialScrollRef =
|
|
12396
|
-
const isInitialLoad =
|
|
12397
|
-
const scrollDisabledRef =
|
|
12398
|
-
const userScrolledAwayRef =
|
|
12399
|
-
const isUserScrollingRef =
|
|
12400
|
-
const lastScrollTopRef =
|
|
12401
|
-
const isLoadingRef =
|
|
12427
|
+
const messagesEndRef = useRef20(null);
|
|
12428
|
+
const messagesContainerRef = useRef20(null);
|
|
12429
|
+
const observerRef = useRef20(null);
|
|
12430
|
+
const initialScrollRef = useRef20(false);
|
|
12431
|
+
const isInitialLoad = useRef20(true);
|
|
12432
|
+
const scrollDisabledRef = useRef20(false);
|
|
12433
|
+
const userScrolledAwayRef = useRef20(false);
|
|
12434
|
+
const isUserScrollingRef = useRef20(false);
|
|
12435
|
+
const lastScrollTopRef = useRef20(0);
|
|
12436
|
+
const isLoadingRef = useRef20(false);
|
|
12402
12437
|
const { setSafeTimeout, clearAllTimeouts } = useSafeTimeout();
|
|
12403
12438
|
const isUserAtBottom = useCallback21(() => {
|
|
12404
12439
|
const container = messagesContainerRef.current;
|
|
@@ -12561,11 +12596,11 @@ var useChatScrollOptimized = ({
|
|
|
12561
12596
|
};
|
|
12562
12597
|
|
|
12563
12598
|
// src/hooks/useFocusManagement.ts
|
|
12564
|
-
import { useRef as
|
|
12599
|
+
import { useRef as useRef21, useCallback as useCallback22 } from "react";
|
|
12565
12600
|
var useFocusManagement = (options = {}) => {
|
|
12566
12601
|
const { disabled, onFocus, onBlur } = options;
|
|
12567
|
-
const elementRef =
|
|
12568
|
-
const focusTimeoutRef =
|
|
12602
|
+
const elementRef = useRef21(null);
|
|
12603
|
+
const focusTimeoutRef = useRef21(null);
|
|
12569
12604
|
const cleanupFocusTimers = useCallback22(() => {
|
|
12570
12605
|
if (focusTimeoutRef.current) {
|
|
12571
12606
|
clearTimeout(focusTimeoutRef.current);
|
|
@@ -12670,9 +12705,9 @@ var useFocusManagement = (options = {}) => {
|
|
|
12670
12705
|
};
|
|
12671
12706
|
|
|
12672
12707
|
// src/hooks/useStableCallback.ts
|
|
12673
|
-
import { useRef as
|
|
12708
|
+
import { useRef as useRef22, useLayoutEffect as useLayoutEffect2, useCallback as useCallback23 } from "react";
|
|
12674
12709
|
function useStableCallback(callback) {
|
|
12675
|
-
const callbackRef =
|
|
12710
|
+
const callbackRef = useRef22(callback);
|
|
12676
12711
|
useLayoutEffect2(() => {
|
|
12677
12712
|
callbackRef.current = callback;
|
|
12678
12713
|
});
|
|
@@ -12684,12 +12719,12 @@ function useStableCallback(callback) {
|
|
|
12684
12719
|
);
|
|
12685
12720
|
}
|
|
12686
12721
|
function useStableValue(value) {
|
|
12687
|
-
const valueRef =
|
|
12722
|
+
const valueRef = useRef22(value);
|
|
12688
12723
|
useLayoutEffect2(() => {
|
|
12689
12724
|
valueRef.current = value;
|
|
12690
12725
|
});
|
|
12691
12726
|
const stableGetter = useCallback23(() => valueRef.current, []);
|
|
12692
|
-
return
|
|
12727
|
+
return useRef22(
|
|
12693
12728
|
new Proxy({}, {
|
|
12694
12729
|
get(_, prop) {
|
|
12695
12730
|
return stableGetter()[prop];
|