@zero-library/chat-copilot 3.1.1 → 3.1.3

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.cjs.js CHANGED
@@ -2289,16 +2289,16 @@ function preprocessCustomTagPayloads(content = "", payloadTagPattern) {
2289
2289
  payloadMap
2290
2290
  };
2291
2291
  }
2292
- var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(), message2) => {
2292
+ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
2293
2293
  const WrappedComponent = ({ children, streamStatus, ...rest }) => {
2294
- const rawData = resolveMappedMarkdownPayload(children, payloadMap);
2295
- return /* @__PURE__ */ jsxRuntime.jsx(Component, { message: message2, ...rest, data: rawData, loading: streamStatus === "loading" });
2294
+ const rawData = resolveMappedMarkdownPayload(children, payloadMapRef.current);
2295
+ return /* @__PURE__ */ jsxRuntime.jsx(Component, { message: messageRef.current, ...rest, data: rawData, loading: streamStatus === "loading" });
2296
2296
  };
2297
2297
  WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
2298
2298
  return WrappedComponent;
2299
2299
  };
2300
- var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(), message2) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMap, message2)]));
2301
- var XMarkdown_default = ({ message: message2, components = {}, content = "", ...rest }) => {
2300
+ var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
2301
+ var XMarkdown_default = React7.memo(({ message: message2, components = {}, content = "", ...rest }) => {
2302
2302
  const config = React7.useMemo(() => getMarkdownConfig(), []);
2303
2303
  const formattedContent = React7.useMemo(() => formatMixedContent(content), [content]);
2304
2304
  const newComponents = React7.useMemo(
@@ -2318,13 +2318,16 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2318
2318
  }),
2319
2319
  [components]
2320
2320
  );
2321
- const componentKeys = React7.useMemo(() => Object.keys(newComponents), [newComponents]);
2322
- const payloadTagPattern = React7.useMemo(() => componentKeys.join("|"), [componentKeys]);
2321
+ const payloadTagPattern = React7.useMemo(() => Object.keys(newComponents).join("|"), [newComponents]);
2323
2322
  const { content: processedContent, payloadMap } = React7.useMemo(
2324
2323
  () => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
2325
2324
  [formattedContent, payloadTagPattern]
2326
2325
  );
2327
- const markdownComponents = React7.useMemo(() => adaptMarkdownComponents(newComponents, payloadMap, message2), [componentKeys, message2, payloadMap]);
2326
+ const payloadMapRef = React7.useRef(payloadMap);
2327
+ const messageRef = React7.useRef(message2);
2328
+ payloadMapRef.current = payloadMap;
2329
+ messageRef.current = message2;
2330
+ const markdownComponents = React7.useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2328
2331
  return /* @__PURE__ */ jsxRuntime.jsx(
2329
2332
  XMarkdown__default.default,
2330
2333
  {
@@ -2335,7 +2338,7 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2335
2338
  components: markdownComponents
2336
2339
  }
2337
2340
  );
2338
- };
2341
+ });
2339
2342
  var ReportViewer = ({ artifactId, title, payload }) => {
2340
2343
  const markdown = typeof payload?.markdown === "string" ? payload.markdown : null;
2341
2344
  if (!markdown) {
@@ -3776,38 +3779,43 @@ var FilesNode = React7__default.default.memo(({ item }) => {
3776
3779
  }, [item.files]);
3777
3780
  return /* @__PURE__ */ jsxRuntime.jsx(xV2.FileCard.List, { items: fileItems });
3778
3781
  });
3782
+
3783
+ // src/components/CustomComponents/MessageNode/style.module.less
3784
+ var style_module_default2 = {
3785
+ runStartedNode: "style_module_runStartedNode"};
3779
3786
  var QuoteMsgNode = React7__default.default.memo(({ quoteMsg, role }) => {
3780
3787
  if (!quoteMsg || !quoteMsg.messageContent) return null;
3781
3788
  return /* @__PURE__ */ jsxRuntime.jsx(
3782
3789
  xV2.Bubble,
3783
3790
  {
3791
+ className: style_module_default2.quoteMsgNode,
3784
3792
  placement: role.placement,
3785
3793
  variant: "borderless",
3786
- content: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx(
3787
- antd.Tooltip,
3788
- {
3789
- arrow: false,
3790
- title: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: quoteMsg.messageContent }),
3791
- getPopupContainer: (node) => node,
3792
- children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
3793
- /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
3794
- /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { flex: 1, className: "text-ellipsis-2", style: {
3794
+ content: /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { vertical: true, gap: 8, children: /* @__PURE__ */ jsxRuntime.jsx(antd.Tooltip, { arrow: false, title: /* @__PURE__ */ jsxRuntime.jsx(XMarkdown_default, { content: quoteMsg.messageContent }), getPopupContainer: (node) => node, children: /* @__PURE__ */ jsxRuntime.jsxs(antd.Flex, { children: [
3795
+ /* @__PURE__ */ jsxRuntime.jsx("span", { children: "\u3010\u5F15\u7528\u6D88\u606F\u3011\uFF1A" }),
3796
+ /* @__PURE__ */ jsxRuntime.jsx(
3797
+ antd.Flex,
3798
+ {
3799
+ flex: 1,
3800
+ className: "text-ellipsis-2",
3801
+ style: {
3795
3802
  color: "#666",
3796
3803
  background: "rgba(0,0,0,0.04)",
3797
3804
  padding: "2px 8px",
3798
3805
  borderRadius: "4px",
3799
3806
  fontSize: "12px",
3800
3807
  cursor: "pointer"
3801
- }, children: quoteMsg.messageContent })
3802
- ] })
3803
- }
3804
- ) })
3808
+ },
3809
+ children: quoteMsg.messageContent
3810
+ }
3811
+ )
3812
+ ] }) }) })
3805
3813
  }
3806
3814
  );
3807
3815
  });
3808
3816
  var RunStartedNode = React7__default.default.memo(({ loading }) => {
3809
3817
  if (!loading) return null;
3810
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", style: { minHeight: 24 }, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
3818
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Flex, { gap: 8, align: "center", className: style_module_default2.runStartedNode, children: /* @__PURE__ */ jsxRuntime.jsx(icons.LoadingOutlined, { style: { color: "#1677ff" } }) });
3811
3819
  });
3812
3820
  function QuestionSummary({ content }) {
3813
3821
  const answer = content.replace(/^Question:\s*/, "").trim() || "\u5DF2\u56DE\u7B54";
@@ -4148,7 +4156,7 @@ var BubbleListItems_default = ({
4148
4156
  welcomeMessage = true,
4149
4157
  avatar = { user: false, agent: true },
4150
4158
  agentActions = false,
4151
- customComponents = {}
4159
+ customComponents
4152
4160
  }) => {
4153
4161
  const chatStore = useChatStore();
4154
4162
  const agentState = valtio.useSnapshot(chatStore.agent);