@zero-library/chat-copilot 3.1.2 → 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.esm.js CHANGED
@@ -1,7 +1,7 @@
1
- import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, CopyOutlined, LikeOutlined, DislikeOutlined, PlayCircleOutlined, DotChartOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
1
+ import { CloudUploadOutlined, PaperClipOutlined, createFromIconfontCN, LoadingOutlined, EnterOutlined, DownloadOutlined, CloseOutlined, PlayCircleOutlined, CopyOutlined, DotChartOutlined, LikeOutlined, DislikeOutlined, ToolOutlined, SearchOutlined, UpOutlined, DownOutlined, PlusOutlined, CommentOutlined, RedoOutlined, DeleteOutlined, ClockCircleOutlined, CheckCircleOutlined } from '@ant-design/icons';
2
2
  import { Attachments, Sender, FileCard, Bubble, Think, XProvider, Mermaid, CodeHighlighter, Welcome, Prompts, Conversations } from '@ant-design/x-v2';
3
- import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, isBoolean, UserAvatar, htmlToMarkdown, copyText, FileIcon, LazyComponent, deepCopy, transforms, deepMerge, buildUrlParams, createRequest, HttpStatus, isArray, isString, isExternal, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
- import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Image as Image$1, Popover, Skeleton, Alert, Modal, Checkbox, Input, Empty, message, Drawer, List, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
3
+ import { useRefState, useDebounce, useSyncInput, createTokenManager, isEmptyObj, markdownToText, RenderWrapper, shouldRender, isFunction, downloadFile, LuyaFilePreview, MarkdownEditor, useDeepEffect, isObject, useWebSocket, isNullOrUnDef, isNumber, getFileSuffixName, FileIcon, copyText, LazyComponent, isBoolean, UserAvatar, htmlToMarkdown, buildUrlParams, isExternal, deepCopy, transforms, deepMerge, createRequest, HttpStatus, isArray, isString, transform, emit, getWebSocketUrl, safeParseJson } from '@zero-library/common';
4
+ import { App, Badge, Button, Flex, Typography, Tooltip, Layout, Tag, Spin, Splitter, Image as Image$1, Popover, Skeleton, Alert, theme, Collapse, Divider as Divider$1, Select as Select$1, Avatar, Space, Drawer, Empty, Modal, Checkbox, Input, message, List, Card, Table, Progress as Progress$1, Switch as Switch$1 } from 'antd';
5
5
  import React7, { createContext, forwardRef, useRef, useEffect, useImperativeHandle, useMemo, memo, useState, useContext, useCallback } from 'react';
6
6
  import { useSnapshot, proxy } from 'valtio';
7
7
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
@@ -2278,16 +2278,16 @@ function preprocessCustomTagPayloads(content = "", payloadTagPattern) {
2278
2278
  payloadMap
2279
2279
  };
2280
2280
  }
2281
- var adaptMarkdownComponent = (Component, payloadMap = /* @__PURE__ */ new Map(), message2) => {
2281
+ var adaptMarkdownComponent = (Component, payloadMapRef, messageRef) => {
2282
2282
  const WrappedComponent = ({ children, streamStatus, ...rest }) => {
2283
- const rawData = resolveMappedMarkdownPayload(children, payloadMap);
2284
- return /* @__PURE__ */ jsx(Component, { message: message2, ...rest, data: rawData, loading: streamStatus === "loading" });
2283
+ const rawData = resolveMappedMarkdownPayload(children, payloadMapRef.current);
2284
+ return /* @__PURE__ */ jsx(Component, { message: messageRef.current, ...rest, data: rawData, loading: streamStatus === "loading" });
2285
2285
  };
2286
2286
  WrappedComponent.displayName = `AdaptedMarkdownComponent(${Component.displayName || Component.name || "Anonymous"})`;
2287
2287
  return WrappedComponent;
2288
2288
  };
2289
- var adaptMarkdownComponents = (components, payloadMap = /* @__PURE__ */ new Map(), message2) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMap, message2)]));
2290
- var XMarkdown_default = ({ message: message2, components = {}, content = "", ...rest }) => {
2289
+ var adaptMarkdownComponents = (components, payloadMapRef, messageRef) => Object.fromEntries(Object.entries(components ?? {}).map(([key, Component]) => [key, adaptMarkdownComponent(Component, payloadMapRef, messageRef)]));
2290
+ var XMarkdown_default = memo(({ message: message2, components = {}, content = "", ...rest }) => {
2291
2291
  const config = useMemo(() => getMarkdownConfig(), []);
2292
2292
  const formattedContent = useMemo(() => formatMixedContent(content), [content]);
2293
2293
  const newComponents = useMemo(
@@ -2307,13 +2307,16 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2307
2307
  }),
2308
2308
  [components]
2309
2309
  );
2310
- const componentKeys = useMemo(() => Object.keys(newComponents), [newComponents]);
2311
- const payloadTagPattern = useMemo(() => componentKeys.join("|"), [componentKeys]);
2310
+ const payloadTagPattern = useMemo(() => Object.keys(newComponents).join("|"), [newComponents]);
2312
2311
  const { content: processedContent, payloadMap } = useMemo(
2313
2312
  () => preprocessCustomTagPayloads(formattedContent, payloadTagPattern),
2314
2313
  [formattedContent, payloadTagPattern]
2315
2314
  );
2316
- const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMap, message2), [componentKeys, message2, payloadMap]);
2315
+ const payloadMapRef = useRef(payloadMap);
2316
+ const messageRef = useRef(message2);
2317
+ payloadMapRef.current = payloadMap;
2318
+ messageRef.current = message2;
2319
+ const markdownComponents = useMemo(() => adaptMarkdownComponents(newComponents, payloadMapRef, messageRef), [payloadTagPattern]);
2317
2320
  return /* @__PURE__ */ jsx(
2318
2321
  XMarkdown,
2319
2322
  {
@@ -2324,7 +2327,7 @@ var XMarkdown_default = ({ message: message2, components = {}, content = "", ...
2324
2327
  components: markdownComponents
2325
2328
  }
2326
2329
  );
2327
- };
2330
+ });
2328
2331
  var ReportViewer = ({ artifactId, title, payload }) => {
2329
2332
  const markdown = typeof payload?.markdown === "string" ? payload.markdown : null;
2330
2333
  if (!markdown) {
@@ -4142,7 +4145,7 @@ var BubbleListItems_default = ({
4142
4145
  welcomeMessage = true,
4143
4146
  avatar = { user: false, agent: true },
4144
4147
  agentActions = false,
4145
- customComponents = {}
4148
+ customComponents
4146
4149
  }) => {
4147
4150
  const chatStore = useChatStore();
4148
4151
  const agentState = useSnapshot(chatStore.agent);