@copilotkit/react-ui 1.79.2-canary.1792172552 → 1.81.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/dist/index.cjs +15 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -0
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +6 -0
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +15 -2
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +19 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +7 -7
- package/src/components/chat/Markdown.generative-ui.test.tsx +93 -0
- package/src/components/chat/Markdown.tsx +33 -2
- package/src/components/chat/messages/AssistantMessage.tsx +5 -1
- package/vitest.config.mjs +4 -1
package/dist/index.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
3
|
(function(global, factory) {
|
|
4
|
-
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react/jsx-runtime'), require('@copilotkit/react-core'), require('@copilotkit/shared'), require('@headlessui/react'), require('react-markdown'), require('react-syntax-highlighter'), require('remark-gfm'), require('remark-math'), require('rehype-raw'), require('rehype-sanitize'), require('@copilotkit/runtime-client-gql')) :
|
|
5
|
-
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react/jsx-runtime', '@copilotkit/react-core', '@copilotkit/shared', '@headlessui/react', 'react-markdown', 'react-syntax-highlighter', 'remark-gfm', 'remark-math', 'rehype-raw', 'rehype-sanitize', '@copilotkit/runtime-client-gql'], factory) :
|
|
6
|
-
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactUI = {}), global.React,global.ReactJsxRuntime,global.CopilotKitReactCore,global.CopilotKitShared,global.HeadlessUIReact,global.ReactMarkdown,global.ReactSyntaxHighlighter,global.remarkGfm,global.remarkMath,global.rehypeRaw,global.rehype_sanitize,global.CopilotKitRuntimeClientGQL));
|
|
7
|
-
})(this, function(exports, react, react_jsx_runtime, _copilotkit_react_core, _copilotkit_shared, _headlessui_react, react_markdown, react_syntax_highlighter, remark_gfm, remark_math, rehype_raw, rehype_sanitize, _copilotkit_runtime_client_gql) {
|
|
4
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('react'), require('react/jsx-runtime'), require('@copilotkit/react-core'), require('@copilotkit/shared'), require('@headlessui/react'), require('react-markdown'), require('@copilotkit/react-core/v2/generative-ui'), require('react-syntax-highlighter'), require('remark-gfm'), require('remark-math'), require('rehype-raw'), require('rehype-sanitize'), require('@copilotkit/runtime-client-gql')) :
|
|
5
|
+
typeof define === 'function' && define.amd ? define(['exports', 'react', 'react/jsx-runtime', '@copilotkit/react-core', '@copilotkit/shared', '@headlessui/react', 'react-markdown', '@copilotkit/react-core/v2/generative-ui', 'react-syntax-highlighter', 'remark-gfm', 'remark-math', 'rehype-raw', 'rehype-sanitize', '@copilotkit/runtime-client-gql'], factory) :
|
|
6
|
+
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.CopilotKitReactUI = {}), global.React,global.ReactJsxRuntime,global.CopilotKitReactCore,global.CopilotKitShared,global.HeadlessUIReact,global.ReactMarkdown,global._copilotkit_react_core_v2_generative_ui,global.ReactSyntaxHighlighter,global.remarkGfm,global.remarkMath,global.rehypeRaw,global.rehype_sanitize,global.CopilotKitRuntimeClientGQL));
|
|
7
|
+
})(this, function(exports, react, react_jsx_runtime, _copilotkit_react_core, _copilotkit_shared, _headlessui_react, react_markdown, _copilotkit_react_core_v2_generative_ui, react_syntax_highlighter, remark_gfm, remark_math, rehype_raw, rehype_sanitize, _copilotkit_runtime_client_gql) {
|
|
8
8
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
9
9
|
//#region \0rolldown/runtime.js
|
|
10
10
|
var __create = Object.create;
|
|
@@ -1397,7 +1397,9 @@ rehype_sanitize = __toESM(rehype_sanitize);
|
|
|
1397
1397
|
})
|
|
1398
1398
|
};
|
|
1399
1399
|
const MemoizedReactMarkdown = (0, react.memo)(react_markdown.default);
|
|
1400
|
-
const Markdown = ({ content, components, remarkPlugins, rehypePlugins, ...rest }) => {
|
|
1400
|
+
const Markdown = ({ content, components, remarkPlugins, rehypePlugins, messageId, ...rest }) => {
|
|
1401
|
+
const generativeUI = (0, _copilotkit_react_core_v2_generative_ui.useGenerativeUIRuntime)();
|
|
1402
|
+
const rendersSurfaces = (generativeUI === null || generativeUI === void 0 ? void 0 : generativeUI.transport) === "markdown" && messageId !== void 0;
|
|
1401
1403
|
const mergedComponents = (0, react.useMemo)(() => ({
|
|
1402
1404
|
...defaultComponents,
|
|
1403
1405
|
...components
|
|
@@ -1412,6 +1414,16 @@ rehype_sanitize = __toESM(rehype_sanitize);
|
|
|
1412
1414
|
...rehypePlugins !== null && rehypePlugins !== void 0 ? rehypePlugins : [],
|
|
1413
1415
|
rehype_sanitize.default
|
|
1414
1416
|
], [rehypePlugins]);
|
|
1417
|
+
if (rendersSurfaces) return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1418
|
+
className: "copilotKitMarkdown",
|
|
1419
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_copilotkit_react_core_v2_generative_ui.MarkdownSurfaces, {
|
|
1420
|
+
content,
|
|
1421
|
+
messageId,
|
|
1422
|
+
components: mergedComponents,
|
|
1423
|
+
remarkPlugins: mergedRemarkPlugins,
|
|
1424
|
+
rehypePlugins: mergedRehypePlugins
|
|
1425
|
+
})
|
|
1426
|
+
});
|
|
1415
1427
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
1416
1428
|
className: "copilotKitMarkdown",
|
|
1417
1429
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MemoizedReactMarkdown, {
|
|
@@ -1497,7 +1509,8 @@ rehype_sanitize = __toESM(rehype_sanitize);
|
|
|
1497
1509
|
className: "copilotKitMessage copilotKitAssistantMessage",
|
|
1498
1510
|
children: [content && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Markdown, {
|
|
1499
1511
|
content,
|
|
1500
|
-
components: markdownTagRenderers
|
|
1512
|
+
components: markdownTagRenderers,
|
|
1513
|
+
messageId: message === null || message === void 0 ? void 0 : message.id
|
|
1501
1514
|
}), content && !isLoading && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
1502
1515
|
className: `copilotKitMessageControls ${isCurrentMessage ? "currentMessage" : ""}`,
|
|
1503
1516
|
children: [
|