@agentscope-ai/chat 1.1.39 → 1.1.41-beta.1764749089549
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/bin/starter_webui.zip +0 -0
- package/components/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.tsx +8 -4
- package/components/ImageGenerator/index.tsx +1 -1
- package/components/Markdown/Markdown.tsx +105 -0
- package/components/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.tsx +1 -1
- package/components/Markdown/core/components/Null.tsx +1 -0
- package/components/Markdown/core/components/Raw.tsx +18 -0
- package/components/Markdown/{Markdown → core}/hooks/useCitationsData.tsx +3 -7
- package/components/Markdown/core/hooks/useCursorContent.tsx +15 -0
- package/components/Markdown/{Markdown/hooks/useTyping.ts → core/hooks/useTyping.tsx} +4 -1
- package/components/Markdown/core/index.tsx +18 -0
- package/components/Markdown/{plugins → core/plugins}/citations/CitationComponent.tsx +5 -3
- package/components/Markdown/{plugins → core/plugins}/citations/index.tsx +3 -4
- package/components/Markdown/{plugins → core/plugins}/cursor/Underline.tsx +1 -1
- package/components/Markdown/{plugins → core/plugins}/cursor/index.tsx +8 -8
- package/components/Markdown/demo/cursor.tsx +2 -3
- package/components/Markdown/index.en-US.md +1 -2
- package/components/Markdown/index.tsx +6 -0
- package/components/Markdown/index.zh-CN.md +1 -2
- package/components/Markdown/{Markdown/style.ts → styles.ts} +12 -21
- package/components/Markdown/types.tsx +94 -0
- package/components/index.ts +1 -3
- package/lib/AgentScopeRuntimeWebUI/core/AgentScopeRuntime/Response/Builder.js +5 -3
- package/lib/ImageGenerator/index.js +1 -1
- package/lib/Markdown/Markdown.d.ts +4 -0
- package/lib/Markdown/Markdown.js +110 -0
- package/lib/Markdown/core/components/Null.d.ts +2 -0
- package/lib/Markdown/core/components/Null.js +3 -0
- package/lib/Markdown/core/components/Raw.d.ts +8 -0
- package/lib/Markdown/core/components/Raw.js +13 -0
- package/lib/Markdown/core/hooks/useCitationsData.d.ts +6 -0
- package/lib/Markdown/{Markdown → core}/hooks/useCitationsData.js +1 -1
- package/lib/Markdown/core/hooks/useCursorContent.d.ts +4 -0
- package/lib/Markdown/core/hooks/useCursorContent.js +14 -0
- package/lib/Markdown/core/hooks/useTyping.d.ts +5 -0
- package/lib/Markdown/{Markdown → core}/hooks/useTyping.js +3 -2
- package/lib/Markdown/core/index.d.ts +2 -0
- package/lib/Markdown/{Markdown/hooks/useAnimation.js → core/index.js} +23 -23
- package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.js +5 -5
- package/lib/Markdown/{plugins → core/plugins}/citations/index.d.ts +1 -2
- package/lib/Markdown/{plugins → core/plugins}/citations/index.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.js +1 -1
- package/lib/Markdown/{plugins → core/plugins}/cursor/index.js +4 -4
- package/lib/Markdown/index.d.ts +2 -1
- package/lib/Markdown/styles.js +32 -0
- package/lib/Markdown/types.d.ts +78 -0
- package/lib/index.d.ts +0 -2
- package/lib/index.js +0 -2
- package/package.json +7 -31
- package/components/AGUI/components/HelpModal/icons.tsx +0 -68
- package/components/AGUI/components/HelpModal/index.tsx +0 -1
- package/components/AGUI/components/HelpModal/modal.tsx +0 -101
- package/components/AGUI/components/chat/Button.tsx +0 -18
- package/components/AGUI/components/chat/Chat.tsx +0 -780
- package/components/AGUI/components/chat/ChatContext.tsx +0 -248
- package/components/AGUI/components/chat/CodeBlock.tsx +0 -406
- package/components/AGUI/components/chat/Header.tsx +0 -22
- package/components/AGUI/components/chat/Icons.tsx +0 -237
- package/components/AGUI/components/chat/ImageUploadQueue.tsx +0 -77
- package/components/AGUI/components/chat/Input.tsx +0 -24
- package/components/AGUI/components/chat/Markdown.tsx +0 -134
- package/components/AGUI/components/chat/Messages.tsx +0 -259
- package/components/AGUI/components/chat/Modal.tsx +0 -133
- package/components/AGUI/components/chat/Popup.tsx +0 -57
- package/components/AGUI/components/chat/PoweredByTag.tsx +0 -29
- package/components/AGUI/components/chat/Sidebar.tsx +0 -74
- package/components/AGUI/components/chat/Suggestion.tsx +0 -132
- package/components/AGUI/components/chat/Suggestions.tsx +0 -20
- package/components/AGUI/components/chat/Textarea.tsx +0 -61
- package/components/AGUI/components/chat/Window.tsx +0 -152
- package/components/AGUI/components/chat/index.tsx +0 -11
- package/components/AGUI/components/chat/messages/AssistantMessage.tsx +0 -69
- package/components/AGUI/components/chat/messages/RenderActionExecutionMessage.tsx +0 -129
- package/components/AGUI/components/chat/messages/RenderAgentStateMessage.tsx +0 -116
- package/components/AGUI/components/chat/messages/RenderImageMessage.tsx +0 -64
- package/components/AGUI/components/chat/messages/RenderResultMessage.tsx +0 -26
- package/components/AGUI/components/chat/messages/RenderTextMessage.tsx +0 -51
- package/components/AGUI/components/chat/messages/UserMessage.tsx +0 -10
- package/components/AGUI/components/chat/props.ts +0 -186
- package/components/AGUI/components/index.ts +0 -1
- package/components/AGUI/context/index.ts +0 -1
- package/components/AGUI/hooks/index.ts +0 -1
- package/components/AGUI/hooks/use-copilot-chat-suggestions.tsx +0 -122
- package/components/AGUI/hooks/use-copy-to-clipboard.tsx +0 -29
- package/components/AGUI/hooks/use-dark-mode.ts +0 -10
- package/components/AGUI/hooks/use-push-to-talk.tsx +0 -166
- package/components/AGUI/index.tsx +0 -4
- package/components/AGUI/lib/utils.test.ts +0 -7
- package/components/AGUI/lib/utils.ts +0 -27
- package/components/AGUI/styles.css +0 -0
- package/components/AGUI/types/css.ts +0 -0
- package/components/AGUI/types/index.ts +0 -1
- package/components/AGUI/types/suggestions.ts +0 -6
- package/components/Markdown/Markdown/AnimationNode.tsx +0 -89
- package/components/Markdown/Markdown/Markdown.tsx +0 -61
- package/components/Markdown/Markdown/core/Parser.ts +0 -52
- package/components/Markdown/Markdown/core/Renderer.ts +0 -121
- package/components/Markdown/Markdown/core/index.ts +0 -4
- package/components/Markdown/Markdown/hooks/index.ts +0 -4
- package/components/Markdown/Markdown/hooks/useAnimation.tsx +0 -27
- package/components/Markdown/Markdown/hooks/useStreaming.ts +0 -503
- package/components/Markdown/Markdown/index.tsx +0 -198
- package/components/Markdown/Markdown/interface.ts +0 -217
- package/components/Markdown/demo/typing.tsx +0 -82
- package/components/Markdown/index.ts +0 -1
- package/components/Markdown/plugins/latex/index.ts +0 -109
- package/components/Markdown/plugins/type.ts +0 -71
- package/lib/AGUI/components/HelpModal/icons.d.ts +0 -5
- package/lib/AGUI/components/HelpModal/icons.js +0 -84
- package/lib/AGUI/components/HelpModal/index.d.ts +0 -1
- package/lib/AGUI/components/HelpModal/index.js +0 -1
- package/lib/AGUI/components/HelpModal/modal.d.ts +0 -1
- package/lib/AGUI/components/HelpModal/modal.js +0 -104
- package/lib/AGUI/components/chat/Button.d.ts +0 -2
- package/lib/AGUI/components/chat/Button.js +0 -27
- package/lib/AGUI/components/chat/Chat.d.ts +0 -242
- package/lib/AGUI/components/chat/Chat.js +0 -634
- package/lib/AGUI/components/chat/ChatContext.d.ts +0 -142
- package/lib/AGUI/components/chat/ChatContext.js +0 -75
- package/lib/AGUI/components/chat/CodeBlock.d.ts +0 -12
- package/lib/AGUI/components/chat/CodeBlock.js +0 -398
- package/lib/AGUI/components/chat/Header.d.ts +0 -2
- package/lib/AGUI/components/chat/Header.js +0 -28
- package/lib/AGUI/components/chat/Icons.d.ts +0 -16
- package/lib/AGUI/components/chat/Icons.js +0 -247
- package/lib/AGUI/components/chat/ImageUploadQueue.d.ts +0 -11
- package/lib/AGUI/components/chat/ImageUploadQueue.js +0 -65
- package/lib/AGUI/components/chat/Input.d.ts +0 -2
- package/lib/AGUI/components/chat/Input.js +0 -30
- package/lib/AGUI/components/chat/Markdown.d.ts +0 -7
- package/lib/AGUI/components/chat/Markdown.js +0 -187
- package/lib/AGUI/components/chat/Messages.d.ts +0 -7
- package/lib/AGUI/components/chat/Messages.js +0 -242
- package/lib/AGUI/components/chat/Modal.d.ts +0 -43
- package/lib/AGUI/components/chat/Modal.js +0 -113
- package/lib/AGUI/components/chat/Popup.d.ts +0 -49
- package/lib/AGUI/components/chat/Popup.js +0 -64
- package/lib/AGUI/components/chat/PoweredByTag.d.ts +0 -3
- package/lib/AGUI/components/chat/PoweredByTag.js +0 -27
- package/lib/AGUI/components/chat/Sidebar.d.ts +0 -2
- package/lib/AGUI/components/chat/Sidebar.js +0 -85
- package/lib/AGUI/components/chat/Suggestion.d.ts +0 -16
- package/lib/AGUI/components/chat/Suggestion.js +0 -146
- package/lib/AGUI/components/chat/Suggestions.d.ts +0 -2
- package/lib/AGUI/components/chat/Suggestions.js +0 -21
- package/lib/AGUI/components/chat/Textarea.d.ts +0 -11
- package/lib/AGUI/components/chat/Textarea.js +0 -60
- package/lib/AGUI/components/chat/Window.d.ts +0 -2
- package/lib/AGUI/components/chat/Window.js +0 -115
- package/lib/AGUI/components/chat/index.d.ts +0 -11
- package/lib/AGUI/components/chat/index.js +0 -11
- package/lib/AGUI/components/chat/messages/AssistantMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/AssistantMessage.js +0 -56
- package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderActionExecutionMessage.js +0 -114
- package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderAgentStateMessage.js +0 -97
- package/lib/AGUI/components/chat/messages/RenderImageMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderImageMessage.js +0 -61
- package/lib/AGUI/components/chat/messages/RenderResultMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderResultMessage.js +0 -27
- package/lib/AGUI/components/chat/messages/RenderTextMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/RenderTextMessage.js +0 -47
- package/lib/AGUI/components/chat/messages/UserMessage.d.ts +0 -2
- package/lib/AGUI/components/chat/messages/UserMessage.js +0 -9
- package/lib/AGUI/components/chat/props.d.ts +0 -157
- package/lib/AGUI/components/index.d.ts +0 -1
- package/lib/AGUI/components/index.js +0 -1
- package/lib/AGUI/context/index.d.ts +0 -1
- package/lib/AGUI/context/index.js +0 -1
- package/lib/AGUI/hooks/index.d.ts +0 -1
- package/lib/AGUI/hooks/index.js +0 -1
- package/lib/AGUI/hooks/use-copilot-chat-suggestions.d.ts +0 -87
- package/lib/AGUI/hooks/use-copilot-chat-suggestions.js +0 -95
- package/lib/AGUI/hooks/use-copy-to-clipboard.d.ts +0 -7
- package/lib/AGUI/hooks/use-copy-to-clipboard.js +0 -34
- package/lib/AGUI/hooks/use-dark-mode.d.ts +0 -1
- package/lib/AGUI/hooks/use-dark-mode.js +0 -4
- package/lib/AGUI/hooks/use-push-to-talk.d.ts +0 -16
- package/lib/AGUI/hooks/use-push-to-talk.js +0 -260
- package/lib/AGUI/index.d.ts +0 -4
- package/lib/AGUI/index.js +0 -4
- package/lib/AGUI/lib/utils.d.ts +0 -2
- package/lib/AGUI/lib/utils.js +0 -52
- package/lib/AGUI/styles.css +0 -0
- package/lib/AGUI/types/css.d.ts +0 -0
- package/lib/AGUI/types/css.js +0 -0
- package/lib/AGUI/types/index.d.ts +0 -1
- package/lib/AGUI/types/index.js +0 -1
- package/lib/AGUI/types/suggestions.d.ts +0 -6
- package/lib/AGUI/types/suggestions.js +0 -1
- package/lib/Markdown/Markdown/AnimationNode.d.ts +0 -20
- package/lib/Markdown/Markdown/AnimationNode.js +0 -84
- package/lib/Markdown/Markdown/Markdown.d.ts +0 -4
- package/lib/Markdown/Markdown/Markdown.js +0 -58
- package/lib/Markdown/Markdown/core/Parser.d.ts +0 -16
- package/lib/Markdown/Markdown/core/Parser.js +0 -65
- package/lib/Markdown/Markdown/core/Renderer.d.ts +0 -24
- package/lib/Markdown/Markdown/core/Renderer.js +0 -137
- package/lib/Markdown/Markdown/core/index.d.ts +0 -3
- package/lib/Markdown/Markdown/core/index.js +0 -3
- package/lib/Markdown/Markdown/hooks/index.d.ts +0 -3
- package/lib/Markdown/Markdown/hooks/index.js +0 -3
- package/lib/Markdown/Markdown/hooks/useAnimation.d.ts +0 -4
- package/lib/Markdown/Markdown/hooks/useCitationsData.d.ts +0 -7
- package/lib/Markdown/Markdown/hooks/useStreaming.d.ts +0 -3
- package/lib/Markdown/Markdown/hooks/useStreaming.js +0 -521
- package/lib/Markdown/Markdown/hooks/useTyping.d.ts +0 -4
- package/lib/Markdown/Markdown/index.d.ts +0 -84
- package/lib/Markdown/Markdown/index.js +0 -161
- package/lib/Markdown/Markdown/interface.d.ts +0 -203
- package/lib/Markdown/Markdown/interface.js +0 -1
- package/lib/Markdown/Markdown/style.js +0 -32
- package/lib/Markdown/plugins/latex/index.d.ts +0 -9
- package/lib/Markdown/plugins/latex/index.js +0 -97
- package/lib/Markdown/plugins/type.d.ts +0 -60
- package/lib/Markdown/plugins/type.js +0 -1
- /package/components/Markdown/{Markdown/defaultComponents/DisabledImage.tsx → core/components/DisableImage.tsx} +0 -0
- /package/components/Markdown/{Markdown/defaultComponents → core/components}/Media.tsx +0 -0
- /package/components/Markdown/{plugins → core/plugins}/cursor/Dot.tsx +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.d.ts +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/CodeBlock.js +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.d.ts → core/components/DisableImage.d.ts} +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents/DisabledImage.js → core/components/DisableImage.js} +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.d.ts +0 -0
- /package/lib/Markdown/{Markdown/defaultComponents → core/components}/Media.js +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/citations/CitationComponent.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/Dot.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/Underline.d.ts +0 -0
- /package/lib/Markdown/{plugins → core/plugins}/cursor/index.d.ts +0 -0
- /package/lib/Markdown/{Markdown/style.d.ts → styles.d.ts} +0 -0
- /package/lib/{AGUI/components/chat/props.js → Markdown/types.js} +0 -0
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
export var useDarkMode = function useDarkMode() {
|
|
2
|
-
if (typeof window === "undefined") return false;
|
|
3
|
-
return document.documentElement.classList.contains("dark") || document.body.classList.contains("dark") || document.documentElement.getAttribute("data-theme") === "dark" || document.body.getAttribute("data-theme") === "dark" || window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
4
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { Message } from "@copilotkit/runtime-client-gql";
|
|
3
|
-
export declare const checkMicrophonePermission: () => Promise<boolean>;
|
|
4
|
-
export declare const requestMicAndPlaybackPermission: () => Promise<{
|
|
5
|
-
stream: MediaStream;
|
|
6
|
-
audioContext: AudioContext;
|
|
7
|
-
}>;
|
|
8
|
-
export type PushToTalkState = "idle" | "recording" | "transcribing";
|
|
9
|
-
export type SendFunction = (text: string) => Promise<Message>;
|
|
10
|
-
export declare const usePushToTalk: ({ sendFunction, inProgress, }: {
|
|
11
|
-
sendFunction: SendFunction;
|
|
12
|
-
inProgress: boolean;
|
|
13
|
-
}) => {
|
|
14
|
-
pushToTalkState: PushToTalkState;
|
|
15
|
-
setPushToTalkState: import("react").Dispatch<import("react").SetStateAction<PushToTalkState>>;
|
|
16
|
-
};
|
|
@@ -1,260 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
8
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
12
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
14
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
15
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
16
|
-
import { useCopilotContext, useCopilotMessagesContext } from "@copilotkit/react-core";
|
|
17
|
-
import { useEffect, useRef, useState } from "react";
|
|
18
|
-
export var checkMicrophonePermission = /*#__PURE__*/function () {
|
|
19
|
-
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
20
|
-
var permissionStatus;
|
|
21
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
22
|
-
while (1) switch (_context.prev = _context.next) {
|
|
23
|
-
case 0:
|
|
24
|
-
_context.prev = 0;
|
|
25
|
-
_context.next = 3;
|
|
26
|
-
return navigator.permissions.query({
|
|
27
|
-
name: "microphone"
|
|
28
|
-
});
|
|
29
|
-
case 3:
|
|
30
|
-
permissionStatus = _context.sent;
|
|
31
|
-
if (!(permissionStatus.state === "granted")) {
|
|
32
|
-
_context.next = 8;
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
return _context.abrupt("return", true);
|
|
36
|
-
case 8:
|
|
37
|
-
return _context.abrupt("return", false);
|
|
38
|
-
case 9:
|
|
39
|
-
_context.next = 14;
|
|
40
|
-
break;
|
|
41
|
-
case 11:
|
|
42
|
-
_context.prev = 11;
|
|
43
|
-
_context.t0 = _context["catch"](0);
|
|
44
|
-
console.error("Error checking microphone permission", _context.t0);
|
|
45
|
-
case 14:
|
|
46
|
-
case "end":
|
|
47
|
-
return _context.stop();
|
|
48
|
-
}
|
|
49
|
-
}, _callee, null, [[0, 11]]);
|
|
50
|
-
}));
|
|
51
|
-
return function checkMicrophonePermission() {
|
|
52
|
-
return _ref.apply(this, arguments);
|
|
53
|
-
};
|
|
54
|
-
}();
|
|
55
|
-
export var requestMicAndPlaybackPermission = /*#__PURE__*/function () {
|
|
56
|
-
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
57
|
-
var stream, audioContext;
|
|
58
|
-
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
59
|
-
while (1) switch (_context2.prev = _context2.next) {
|
|
60
|
-
case 0:
|
|
61
|
-
_context2.prev = 0;
|
|
62
|
-
_context2.next = 3;
|
|
63
|
-
return navigator.mediaDevices.getUserMedia({
|
|
64
|
-
audio: true
|
|
65
|
-
});
|
|
66
|
-
case 3:
|
|
67
|
-
stream = _context2.sent;
|
|
68
|
-
audioContext = new window.AudioContext();
|
|
69
|
-
_context2.next = 7;
|
|
70
|
-
return audioContext.resume();
|
|
71
|
-
case 7:
|
|
72
|
-
return _context2.abrupt("return", {
|
|
73
|
-
stream: stream,
|
|
74
|
-
audioContext: audioContext
|
|
75
|
-
});
|
|
76
|
-
case 10:
|
|
77
|
-
_context2.prev = 10;
|
|
78
|
-
_context2.t0 = _context2["catch"](0);
|
|
79
|
-
console.error("Error requesting microphone and playback permissions", _context2.t0);
|
|
80
|
-
return _context2.abrupt("return", null);
|
|
81
|
-
case 14:
|
|
82
|
-
case "end":
|
|
83
|
-
return _context2.stop();
|
|
84
|
-
}
|
|
85
|
-
}, _callee2, null, [[0, 10]]);
|
|
86
|
-
}));
|
|
87
|
-
return function requestMicAndPlaybackPermission() {
|
|
88
|
-
return _ref2.apply(this, arguments);
|
|
89
|
-
};
|
|
90
|
-
}();
|
|
91
|
-
var startRecording = /*#__PURE__*/function () {
|
|
92
|
-
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee3(mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks, onStop) {
|
|
93
|
-
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
|
94
|
-
while (1) switch (_context3.prev = _context3.next) {
|
|
95
|
-
case 0:
|
|
96
|
-
if (!(!mediaStreamRef.current || !audioContextRef.current)) {
|
|
97
|
-
_context3.next = 7;
|
|
98
|
-
break;
|
|
99
|
-
}
|
|
100
|
-
_context3.next = 3;
|
|
101
|
-
return navigator.mediaDevices.getUserMedia({
|
|
102
|
-
audio: true
|
|
103
|
-
});
|
|
104
|
-
case 3:
|
|
105
|
-
mediaStreamRef.current = _context3.sent;
|
|
106
|
-
audioContextRef.current = new window.AudioContext();
|
|
107
|
-
_context3.next = 7;
|
|
108
|
-
return audioContextRef.current.resume();
|
|
109
|
-
case 7:
|
|
110
|
-
mediaRecorderRef.current = new MediaRecorder(mediaStreamRef.current);
|
|
111
|
-
mediaRecorderRef.current.start(1000);
|
|
112
|
-
mediaRecorderRef.current.ondataavailable = function (event) {
|
|
113
|
-
recordedChunks.push(event.data);
|
|
114
|
-
};
|
|
115
|
-
mediaRecorderRef.current.onstop = onStop;
|
|
116
|
-
case 11:
|
|
117
|
-
case "end":
|
|
118
|
-
return _context3.stop();
|
|
119
|
-
}
|
|
120
|
-
}, _callee3);
|
|
121
|
-
}));
|
|
122
|
-
return function startRecording(_x, _x2, _x3, _x4, _x5) {
|
|
123
|
-
return _ref3.apply(this, arguments);
|
|
124
|
-
};
|
|
125
|
-
}();
|
|
126
|
-
var stopRecording = function stopRecording(mediaRecorderRef) {
|
|
127
|
-
if (mediaRecorderRef.current && mediaRecorderRef.current.state !== "inactive") {
|
|
128
|
-
mediaRecorderRef.current.stop();
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
var transcribeAudio = /*#__PURE__*/function () {
|
|
132
|
-
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee4(recordedChunks, transcribeAudioUrl) {
|
|
133
|
-
var completeBlob, formData, response, transcription;
|
|
134
|
-
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
|
135
|
-
while (1) switch (_context4.prev = _context4.next) {
|
|
136
|
-
case 0:
|
|
137
|
-
completeBlob = new Blob(recordedChunks, {
|
|
138
|
-
type: "audio/mp4"
|
|
139
|
-
});
|
|
140
|
-
formData = new FormData();
|
|
141
|
-
formData.append("file", completeBlob, "recording.mp4");
|
|
142
|
-
_context4.next = 5;
|
|
143
|
-
return fetch(transcribeAudioUrl, {
|
|
144
|
-
method: "POST",
|
|
145
|
-
body: formData
|
|
146
|
-
});
|
|
147
|
-
case 5:
|
|
148
|
-
response = _context4.sent;
|
|
149
|
-
if (response.ok) {
|
|
150
|
-
_context4.next = 8;
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
throw new Error("Error: ".concat(response.statusText));
|
|
154
|
-
case 8:
|
|
155
|
-
_context4.next = 10;
|
|
156
|
-
return response.json();
|
|
157
|
-
case 10:
|
|
158
|
-
transcription = _context4.sent;
|
|
159
|
-
return _context4.abrupt("return", transcription.text);
|
|
160
|
-
case 12:
|
|
161
|
-
case "end":
|
|
162
|
-
return _context4.stop();
|
|
163
|
-
}
|
|
164
|
-
}, _callee4);
|
|
165
|
-
}));
|
|
166
|
-
return function transcribeAudio(_x6, _x7) {
|
|
167
|
-
return _ref4.apply(this, arguments);
|
|
168
|
-
};
|
|
169
|
-
}();
|
|
170
|
-
var playAudioResponse = function playAudioResponse(text, textToSpeechUrl, audioContext) {
|
|
171
|
-
var encodedText = encodeURIComponent(text);
|
|
172
|
-
var url = "".concat(textToSpeechUrl, "?text=").concat(encodedText);
|
|
173
|
-
fetch(url).then(function (response) {
|
|
174
|
-
return response.arrayBuffer();
|
|
175
|
-
}).then(function (arrayBuffer) {
|
|
176
|
-
return audioContext.decodeAudioData(arrayBuffer);
|
|
177
|
-
}).then(function (audioBuffer) {
|
|
178
|
-
var source = audioContext.createBufferSource();
|
|
179
|
-
source.buffer = audioBuffer;
|
|
180
|
-
source.connect(audioContext.destination);
|
|
181
|
-
source.start(0);
|
|
182
|
-
}).catch(function (error) {
|
|
183
|
-
console.error("Error with decoding audio data", error);
|
|
184
|
-
});
|
|
185
|
-
};
|
|
186
|
-
export var usePushToTalk = function usePushToTalk(_ref5) {
|
|
187
|
-
var sendFunction = _ref5.sendFunction,
|
|
188
|
-
inProgress = _ref5.inProgress;
|
|
189
|
-
var _useState = useState("idle"),
|
|
190
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
191
|
-
pushToTalkState = _useState2[0],
|
|
192
|
-
setPushToTalkState = _useState2[1];
|
|
193
|
-
var mediaStreamRef = useRef(null);
|
|
194
|
-
var audioContextRef = useRef(null);
|
|
195
|
-
var mediaRecorderRef = useRef(null);
|
|
196
|
-
var recordedChunks = useRef([]);
|
|
197
|
-
var generalContext = useCopilotContext();
|
|
198
|
-
var messagesContext = useCopilotMessagesContext();
|
|
199
|
-
var context = _objectSpread(_objectSpread({}, generalContext), messagesContext);
|
|
200
|
-
var _useState3 = useState(null),
|
|
201
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
202
|
-
startReadingFromMessageId = _useState4[0],
|
|
203
|
-
setStartReadingFromMessageId = _useState4[1];
|
|
204
|
-
useEffect(function () {
|
|
205
|
-
if (pushToTalkState === "recording") {
|
|
206
|
-
startRecording(mediaStreamRef, mediaRecorderRef, audioContextRef, recordedChunks.current, function () {
|
|
207
|
-
setPushToTalkState("transcribing");
|
|
208
|
-
});
|
|
209
|
-
} else {
|
|
210
|
-
stopRecording(mediaRecorderRef);
|
|
211
|
-
if (pushToTalkState === "transcribing") {
|
|
212
|
-
transcribeAudio(recordedChunks.current, context.copilotApiConfig.transcribeAudioUrl).then( /*#__PURE__*/function () {
|
|
213
|
-
var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee5(transcription) {
|
|
214
|
-
var message;
|
|
215
|
-
return _regeneratorRuntime().wrap(function _callee5$(_context5) {
|
|
216
|
-
while (1) switch (_context5.prev = _context5.next) {
|
|
217
|
-
case 0:
|
|
218
|
-
recordedChunks.current = [];
|
|
219
|
-
setPushToTalkState("idle");
|
|
220
|
-
_context5.next = 4;
|
|
221
|
-
return sendFunction(transcription);
|
|
222
|
-
case 4:
|
|
223
|
-
message = _context5.sent;
|
|
224
|
-
setStartReadingFromMessageId(message.id);
|
|
225
|
-
case 6:
|
|
226
|
-
case "end":
|
|
227
|
-
return _context5.stop();
|
|
228
|
-
}
|
|
229
|
-
}, _callee5);
|
|
230
|
-
}));
|
|
231
|
-
return function (_x8) {
|
|
232
|
-
return _ref6.apply(this, arguments);
|
|
233
|
-
};
|
|
234
|
-
}());
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
return function () {
|
|
238
|
-
stopRecording(mediaRecorderRef);
|
|
239
|
-
};
|
|
240
|
-
}, [pushToTalkState]);
|
|
241
|
-
useEffect(function () {
|
|
242
|
-
if (inProgress === false && startReadingFromMessageId) {
|
|
243
|
-
var lastMessageIndex = context.messages.findIndex(function (message) {
|
|
244
|
-
return message.id === startReadingFromMessageId;
|
|
245
|
-
});
|
|
246
|
-
var messagesAfterLast = context.messages.slice(lastMessageIndex + 1).filter(function (message) {
|
|
247
|
-
return message.isTextMessage() && message.role === "assistant";
|
|
248
|
-
});
|
|
249
|
-
var _text = messagesAfterLast.map(function (message) {
|
|
250
|
-
return message.content;
|
|
251
|
-
}).join("\n");
|
|
252
|
-
playAudioResponse(_text, context.copilotApiConfig.textToSpeechUrl, audioContextRef.current);
|
|
253
|
-
setStartReadingFromMessageId(null);
|
|
254
|
-
}
|
|
255
|
-
}, [startReadingFromMessageId, inProgress]);
|
|
256
|
-
return {
|
|
257
|
-
pushToTalkState: pushToTalkState,
|
|
258
|
-
setPushToTalkState: setPushToTalkState
|
|
259
|
-
};
|
|
260
|
-
};
|
package/lib/AGUI/index.d.ts
DELETED
package/lib/AGUI/index.js
DELETED
package/lib/AGUI/lib/utils.d.ts
DELETED
package/lib/AGUI/lib/utils.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator.return && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, catch: function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
3
|
-
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
4
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
5
|
-
export function fetcher(_x, _x2) {
|
|
6
|
-
return _fetcher.apply(this, arguments);
|
|
7
|
-
}
|
|
8
|
-
function _fetcher() {
|
|
9
|
-
_fetcher = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(input, init) {
|
|
10
|
-
var res, json, error;
|
|
11
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
12
|
-
while (1) switch (_context.prev = _context.next) {
|
|
13
|
-
case 0:
|
|
14
|
-
_context.next = 2;
|
|
15
|
-
return fetch(input, init);
|
|
16
|
-
case 2:
|
|
17
|
-
res = _context.sent;
|
|
18
|
-
if (res.ok) {
|
|
19
|
-
_context.next = 14;
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
_context.next = 6;
|
|
23
|
-
return res.json();
|
|
24
|
-
case 6:
|
|
25
|
-
json = _context.sent;
|
|
26
|
-
if (!json.error) {
|
|
27
|
-
_context.next = 13;
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
error = new Error(json.error);
|
|
31
|
-
error.status = res.status;
|
|
32
|
-
throw error;
|
|
33
|
-
case 13:
|
|
34
|
-
throw new Error("An unexpected error occurred");
|
|
35
|
-
case 14:
|
|
36
|
-
return _context.abrupt("return", res.json());
|
|
37
|
-
case 15:
|
|
38
|
-
case "end":
|
|
39
|
-
return _context.stop();
|
|
40
|
-
}
|
|
41
|
-
}, _callee);
|
|
42
|
-
}));
|
|
43
|
-
return _fetcher.apply(this, arguments);
|
|
44
|
-
}
|
|
45
|
-
export function formatDate(input) {
|
|
46
|
-
var date = new Date(input);
|
|
47
|
-
return date.toLocaleDateString("en-US", {
|
|
48
|
-
month: "long",
|
|
49
|
-
day: "numeric",
|
|
50
|
-
year: "numeric"
|
|
51
|
-
});
|
|
52
|
-
}
|
package/lib/AGUI/styles.css
DELETED
|
File without changes
|
package/lib/AGUI/types/css.d.ts
DELETED
|
File without changes
|
package/lib/AGUI/types/css.js
DELETED
|
File without changes
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { CopilotChatSuggestion } from "./suggestions";
|
package/lib/AGUI/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { DOMNode } from 'html-react-parser';
|
|
2
|
-
import React from 'react';
|
|
3
|
-
import { HTMLTag } from './hooks/useAnimation';
|
|
4
|
-
import { AnimationConfig } from './interface';
|
|
5
|
-
export interface AnimationNodeProps extends React.HTMLAttributes<HTMLElement> {
|
|
6
|
-
children?: React.ReactNode | React.ReactNode[];
|
|
7
|
-
nodeTag: HTMLTag;
|
|
8
|
-
animationConfig?: AnimationConfig;
|
|
9
|
-
streamStatus?: 'loading' | 'done';
|
|
10
|
-
domNode?: DOMNode;
|
|
11
|
-
[key: string]: unknown;
|
|
12
|
-
}
|
|
13
|
-
export interface AnimationTextProps {
|
|
14
|
-
text: string;
|
|
15
|
-
animationConfig?: AnimationConfig;
|
|
16
|
-
}
|
|
17
|
-
declare const AnimationText: React.NamedExoticComponent<AnimationTextProps>;
|
|
18
|
-
declare const AnimationNode: React.FC<AnimationNodeProps>;
|
|
19
|
-
export default AnimationNode;
|
|
20
|
-
export { AnimationText };
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
var _excluded = ["nodeTag", "children", "animationConfig", "domNode", "streamStatus"];
|
|
2
|
-
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
3
|
-
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
4
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
5
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
7
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
10
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
11
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
12
|
-
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
13
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
|
-
import React, { useEffect, useRef, useState } from 'react';
|
|
15
|
-
import { useProviderContext } from "../..";
|
|
16
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
17
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
18
|
-
var AnimationText = /*#__PURE__*/React.memo(function (props) {
|
|
19
|
-
var text = props.text,
|
|
20
|
-
animationConfig = props.animationConfig;
|
|
21
|
-
var _ref = animationConfig || {},
|
|
22
|
-
_ref$fadeDuration = _ref.fadeDuration,
|
|
23
|
-
fadeDuration = _ref$fadeDuration === void 0 ? 200 : _ref$fadeDuration,
|
|
24
|
-
_ref$easing = _ref.easing,
|
|
25
|
-
easing = _ref$easing === void 0 ? 'ease-in-out' : _ref$easing;
|
|
26
|
-
var _useState = useState([]),
|
|
27
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
-
chunks = _useState2[0],
|
|
29
|
-
setChunks = _useState2[1];
|
|
30
|
-
var prevTextRef = useRef('');
|
|
31
|
-
var _useProviderContext = useProviderContext(),
|
|
32
|
-
getPrefixCls = _useProviderContext.getPrefixCls;
|
|
33
|
-
var prefixCls = getPrefixCls('markdown');
|
|
34
|
-
useEffect(function () {
|
|
35
|
-
if (text === prevTextRef.current) return;
|
|
36
|
-
if (!(prevTextRef.current && text.indexOf(prevTextRef.current) === 0)) {
|
|
37
|
-
setChunks([text]);
|
|
38
|
-
prevTextRef.current = text;
|
|
39
|
-
return;
|
|
40
|
-
}
|
|
41
|
-
var newText = text.slice(prevTextRef.current.length);
|
|
42
|
-
if (!newText) return;
|
|
43
|
-
setChunks(function (prev) {
|
|
44
|
-
return [].concat(_toConsumableArray(prev), [newText]);
|
|
45
|
-
});
|
|
46
|
-
prevTextRef.current = text;
|
|
47
|
-
}, [text]);
|
|
48
|
-
return /*#__PURE__*/_jsx(_Fragment, {
|
|
49
|
-
children: chunks.map(function (text, index) {
|
|
50
|
-
return /*#__PURE__*/_jsx("span", {
|
|
51
|
-
style: {
|
|
52
|
-
animation: "".concat(prefixCls, "-fadeIn ").concat(fadeDuration, "ms ").concat(easing, " forwards")
|
|
53
|
-
},
|
|
54
|
-
children: text
|
|
55
|
-
}, "".concat(index, "-").concat(text));
|
|
56
|
-
})
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
var AnimationNode = function AnimationNode(props) {
|
|
60
|
-
var nodeTag = props.nodeTag,
|
|
61
|
-
children = props.children,
|
|
62
|
-
animationConfig = props.animationConfig,
|
|
63
|
-
domNode = props.domNode,
|
|
64
|
-
streamStatus = props.streamStatus,
|
|
65
|
-
restProps = _objectWithoutProperties(props, _excluded);
|
|
66
|
-
var renderChildren = function renderChildren() {
|
|
67
|
-
if (!children) return null;
|
|
68
|
-
if (Array.isArray(children)) {
|
|
69
|
-
return children.map(function (child, index) {
|
|
70
|
-
return typeof child === 'string' ? /*#__PURE__*/_jsx(AnimationText, {
|
|
71
|
-
animationConfig: animationConfig,
|
|
72
|
-
text: child
|
|
73
|
-
}, index) : child;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
return typeof children === 'string' ? /*#__PURE__*/_jsx(AnimationText, {
|
|
77
|
-
text: children,
|
|
78
|
-
animationConfig: animationConfig
|
|
79
|
-
}) : children;
|
|
80
|
-
};
|
|
81
|
-
return /*#__PURE__*/React.createElement(nodeTag, restProps, renderChildren());
|
|
82
|
-
};
|
|
83
|
-
export default AnimationNode;
|
|
84
|
-
export { AnimationText };
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
5
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
6
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
7
|
-
import classnames from 'classnames';
|
|
8
|
-
import React from 'react';
|
|
9
|
-
import { Parser, Renderer } from "./core";
|
|
10
|
-
import { useAnimation, useStreaming } from "./hooks";
|
|
11
|
-
import Style from "./style";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
14
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
15
|
-
var Markdown = function Markdown(props) {
|
|
16
|
-
var cursor = props.cursor,
|
|
17
|
-
baseFontSize = props.baseFontSize,
|
|
18
|
-
baseLineHeight = props.baseLineHeight,
|
|
19
|
-
streaming = props.streaming,
|
|
20
|
-
config = props.config,
|
|
21
|
-
components = props.components,
|
|
22
|
-
_props$paragraphTag = props.paragraphTag,
|
|
23
|
-
paragraphTag = _props$paragraphTag === void 0 ? 'p' : _props$paragraphTag,
|
|
24
|
-
content = props.content,
|
|
25
|
-
children = props.children,
|
|
26
|
-
rootClassName = props.rootClassName,
|
|
27
|
-
className = props.className,
|
|
28
|
-
style = props.style,
|
|
29
|
-
openLinksInNewTab = props.openLinksInNewTab,
|
|
30
|
-
dompurifyConfig = props.dompurifyConfig;
|
|
31
|
-
var mergedCls = classnames(rootClassName, className);
|
|
32
|
-
var mergedStyle = _objectSpread({
|
|
33
|
-
fontSize: baseFontSize,
|
|
34
|
-
lineHeight: baseLineHeight
|
|
35
|
-
}, style);
|
|
36
|
-
var displayContent = useStreaming(content || children || '', streaming, cursor);
|
|
37
|
-
var animationComponents = useAnimation(streaming);
|
|
38
|
-
if (!displayContent) return null;
|
|
39
|
-
var parser = new Parser({
|
|
40
|
-
markedConfig: config,
|
|
41
|
-
paragraphTag: paragraphTag,
|
|
42
|
-
openLinksInNewTab: openLinksInNewTab
|
|
43
|
-
});
|
|
44
|
-
var renderComponents = _objectSpread(_objectSpread({}, animationComponents), components || {});
|
|
45
|
-
var renderer = new Renderer({
|
|
46
|
-
components: renderComponents,
|
|
47
|
-
dompurifyConfig: dompurifyConfig
|
|
48
|
-
});
|
|
49
|
-
var htmlString = parser.parse(displayContent);
|
|
50
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
51
|
-
children: [/*#__PURE__*/_jsx(Style, {}), /*#__PURE__*/_jsx("div", {
|
|
52
|
-
className: mergedCls,
|
|
53
|
-
style: mergedStyle,
|
|
54
|
-
children: renderer.render(htmlString)
|
|
55
|
-
})]
|
|
56
|
-
});
|
|
57
|
-
};
|
|
58
|
-
export default Markdown;
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Marked } from 'marked';
|
|
2
|
-
import { MarkdownProps } from '../interface';
|
|
3
|
-
type ParserOptions = {
|
|
4
|
-
markedConfig?: MarkdownProps['config'];
|
|
5
|
-
paragraphTag?: string;
|
|
6
|
-
openLinksInNewTab?: boolean;
|
|
7
|
-
};
|
|
8
|
-
declare class Parser {
|
|
9
|
-
options: ParserOptions;
|
|
10
|
-
markdownInstance: Marked;
|
|
11
|
-
constructor(options?: ParserOptions);
|
|
12
|
-
private configureRenderer;
|
|
13
|
-
configureParagraph(): void;
|
|
14
|
-
parse(content: string): string;
|
|
15
|
-
}
|
|
16
|
-
export default Parser;
|