@ant-design/agentic-ui 2.29.59 → 2.30.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.
Files changed (52) hide show
  1. package/dist/Bubble/List/index.d.ts +7 -0
  2. package/dist/Bubble/List/index.js +10 -1
  3. package/dist/Bubble/MessagesContent/MarkdownPreview.js +27 -3
  4. package/dist/Bubble/UserBubble.js +3 -1
  5. package/dist/Bubble/type.d.ts +7 -0
  6. package/dist/Hooks/useLanguage.d.ts +1 -0
  7. package/dist/I18n/locales.d.ts +1 -0
  8. package/dist/I18n/locales.js +3 -1
  9. package/dist/MarkdownEditor/plugin.d.ts +15 -0
  10. package/dist/MarkdownEditor/style.js +156 -326
  11. package/dist/MarkdownEditor/types.d.ts +9 -0
  12. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +1 -1
  13. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +10 -3
  14. package/dist/MarkdownRenderer/AnimationText.d.ts +22 -0
  15. package/dist/MarkdownRenderer/AnimationText.js +124 -0
  16. package/dist/MarkdownRenderer/CharacterQueue.d.ts +36 -0
  17. package/dist/MarkdownRenderer/CharacterQueue.js +188 -0
  18. package/dist/MarkdownRenderer/MarkdownRenderer.d.ts +13 -0
  19. package/dist/MarkdownRenderer/MarkdownRenderer.js +348 -0
  20. package/dist/MarkdownRenderer/index.d.ts +11 -0
  21. package/dist/MarkdownRenderer/index.js +9 -0
  22. package/dist/MarkdownRenderer/renderers/ChartRenderer.d.ts +12 -0
  23. package/dist/MarkdownRenderer/renderers/ChartRenderer.js +395 -0
  24. package/dist/MarkdownRenderer/renderers/CodeRenderer.d.ts +7 -0
  25. package/dist/MarkdownRenderer/renderers/CodeRenderer.js +218 -0
  26. package/dist/MarkdownRenderer/renderers/MermaidRenderer.d.ts +7 -0
  27. package/dist/MarkdownRenderer/renderers/MermaidRenderer.js +43 -0
  28. package/dist/MarkdownRenderer/renderers/SchemaRenderer.d.ts +15 -0
  29. package/dist/MarkdownRenderer/renderers/SchemaRenderer.js +115 -0
  30. package/dist/MarkdownRenderer/renderers/index.d.ts +4 -0
  31. package/dist/MarkdownRenderer/renderers/index.js +4 -0
  32. package/dist/MarkdownRenderer/style.d.ts +16 -0
  33. package/dist/MarkdownRenderer/style.js +46 -0
  34. package/dist/MarkdownRenderer/types.d.ts +74 -0
  35. package/dist/MarkdownRenderer/types.js +1 -0
  36. package/dist/MarkdownRenderer/useMarkdownToReact.d.ts +23 -0
  37. package/dist/MarkdownRenderer/useMarkdownToReact.js +1240 -0
  38. package/dist/MarkdownRenderer/useStreaming.d.ts +29 -0
  39. package/dist/MarkdownRenderer/useStreaming.js +392 -0
  40. package/dist/Plugins/chart/AreaChart/index.js +4 -2
  41. package/dist/Plugins/chart/LineChart/index.js +4 -2
  42. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +8 -0
  43. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +31 -6
  44. package/dist/Plugins/mermaid/style.js +0 -3
  45. package/dist/TaskList/TaskList.js +3 -12
  46. package/dist/TaskList/components/TaskListItem.js +3 -12
  47. package/dist/ThoughtChainList/ThoughtChainListItem.js +2 -4
  48. package/dist/ThoughtChainList/index.js +4 -21
  49. package/dist/ToolUseBarThink/index.js +20 -59
  50. package/dist/index.d.ts +1 -0
  51. package/dist/index.js +2 -0
  52. package/package.json +2 -2
@@ -0,0 +1,124 @@
1
+ function _array_like_to_array(arr, len) {
2
+ if (len == null || len > arr.length) len = arr.length;
3
+ for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
4
+ return arr2;
5
+ }
6
+ function _array_with_holes(arr) {
7
+ if (Array.isArray(arr)) return arr;
8
+ }
9
+ function _array_without_holes(arr) {
10
+ if (Array.isArray(arr)) return _array_like_to_array(arr);
11
+ }
12
+ function _iterable_to_array(iter) {
13
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
14
+ }
15
+ function _iterable_to_array_limit(arr, i) {
16
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
17
+ if (_i == null) return;
18
+ var _arr = [];
19
+ var _n = true;
20
+ var _d = false;
21
+ var _s, _e;
22
+ try {
23
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
24
+ _arr.push(_s.value);
25
+ if (i && _arr.length === i) break;
26
+ }
27
+ } catch (err) {
28
+ _d = true;
29
+ _e = err;
30
+ } finally{
31
+ try {
32
+ if (!_n && _i["return"] != null) _i["return"]();
33
+ } finally{
34
+ if (_d) throw _e;
35
+ }
36
+ }
37
+ return _arr;
38
+ }
39
+ function _non_iterable_rest() {
40
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
41
+ }
42
+ function _non_iterable_spread() {
43
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
44
+ }
45
+ function _sliced_to_array(arr, i) {
46
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
47
+ }
48
+ function _to_consumable_array(arr) {
49
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
50
+ }
51
+ function _unsupported_iterable_to_array(o, minLen) {
52
+ if (!o) return;
53
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
54
+ var n = Object.prototype.toString.call(o).slice(8, -1);
55
+ if (n === "Object" && o.constructor) n = o.constructor.name;
56
+ if (n === "Map" || n === "Set") return Array.from(n);
57
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
58
+ }
59
+ import React, { useEffect, useMemo, useRef, useState } from "react";
60
+ /**
61
+ * 提取 React children 的纯文本
62
+ */ var extractText = function extractText1(children) {
63
+ var _children_props;
64
+ if (typeof children === 'string') return children;
65
+ if (typeof children === 'number') return String(children);
66
+ if (Array.isArray(children)) return children.map(extractText).join('');
67
+ if (/*#__PURE__*/ React.isValidElement(children) && ((_children_props = children.props) === null || _children_props === void 0 ? void 0 : _children_props.children)) {
68
+ return extractText(children.props.children);
69
+ }
70
+ return '';
71
+ };
72
+ /**
73
+ * 流式文字淡入动画组件。
74
+ *
75
+ * 移植自 @ant-design/x-markdown 的 AnimationText。
76
+ * 追踪 children 的文本变化,只给新增的部分加淡入动画 span,
77
+ * 已有的部分保持不动——不会触发整段重绘。
78
+ *
79
+ * 仅对纯文本增量有效;如果内容不是简单追加(删除/替换),直接替换所有 chunks。
80
+ */ var AnimationText = /*#__PURE__*/ React.memo(function(param) {
81
+ var children = param.children, animationConfig = param.animationConfig;
82
+ var _ref = animationConfig || {}, _ref_fadeDuration = _ref.fadeDuration, fadeDuration = _ref_fadeDuration === void 0 ? 200 : _ref_fadeDuration, _ref_easing = _ref.easing, easing = _ref_easing === void 0 ? 'ease-in-out' : _ref_easing;
83
+ var _useState = _sliced_to_array(useState([]), 2), chunks = _useState[0], setChunks = _useState[1];
84
+ var prevTextRef = useRef('');
85
+ var text = extractText(children);
86
+ useEffect(function() {
87
+ if (text === prevTextRef.current) return;
88
+ if (!prevTextRef.current || !text.startsWith(prevTextRef.current)) {
89
+ setChunks([
90
+ children
91
+ ]);
92
+ prevTextRef.current = text;
93
+ return;
94
+ }
95
+ var prevLen = prevTextRef.current.length;
96
+ setChunks(function(prev) {
97
+ return _to_consumable_array(prev).concat([
98
+ text.slice(prevLen)
99
+ ]);
100
+ });
101
+ prevTextRef.current = text;
102
+ }, [
103
+ text,
104
+ children
105
+ ]);
106
+ var animationStyle = useMemo(function() {
107
+ return {
108
+ animation: "markdownRendererFadeIn ".concat(fadeDuration, "ms ").concat(easing, " forwards"),
109
+ willChange: 'opacity',
110
+ color: 'inherit'
111
+ };
112
+ }, [
113
+ fadeDuration,
114
+ easing
115
+ ]);
116
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, chunks.map(function(chunk, index) {
117
+ return /*#__PURE__*/ React.createElement("span", {
118
+ style: animationStyle,
119
+ key: "anim-".concat(index)
120
+ }, chunk);
121
+ }));
122
+ });
123
+ AnimationText.displayName = 'AnimationText';
124
+ export default AnimationText;
@@ -0,0 +1,36 @@
1
+ import type { CharacterQueueOptions } from './types';
2
+ /**
3
+ * 字符队列——流式渲染的调度核心。
4
+ *
5
+ * - 接收 SSE 推送的 content(完整字符串,非增量)
6
+ * - 标签页可见时以 RAF 驱动逐字输出(60fps 动画)
7
+ * - 标签页不可见时降级为 setTimeout,保证后台仍能消费
8
+ * - 切回前台时自动恢复 RAF
9
+ */
10
+ export declare class CharacterQueue {
11
+ private displayedLength;
12
+ private fullContent;
13
+ private rafId;
14
+ private timerId;
15
+ private tickMode;
16
+ private onFlush;
17
+ private options;
18
+ private disposed;
19
+ constructor(onFlush: (displayed: string) => void, options?: CharacterQueueOptions);
20
+ /** SSE token 到达时调用——接收完整的 content 字符串 */
21
+ push(content: string): void;
22
+ /** 标记流式完成,flush 所有剩余内容 */
23
+ complete(): void;
24
+ /** 释放资源 */
25
+ dispose(): void;
26
+ /** 当前已展示的长度 */
27
+ getDisplayedLength(): number;
28
+ /** 完整内容 */
29
+ getFullContent(): string;
30
+ private ensureTicking;
31
+ private tick;
32
+ private scheduleNext;
33
+ private handleVisibilityChange;
34
+ private isTickActive;
35
+ private cancelAllTicks;
36
+ }
@@ -0,0 +1,188 @@
1
+ function _class_call_check(instance, Constructor) {
2
+ if (!(instance instanceof Constructor)) {
3
+ throw new TypeError("Cannot call a class as a function");
4
+ }
5
+ }
6
+ function _defineProperties(target, props) {
7
+ for(var i = 0; i < props.length; i++){
8
+ var descriptor = props[i];
9
+ descriptor.enumerable = descriptor.enumerable || false;
10
+ descriptor.configurable = true;
11
+ if ("value" in descriptor) descriptor.writable = true;
12
+ Object.defineProperty(target, descriptor.key, descriptor);
13
+ }
14
+ }
15
+ function _create_class(Constructor, protoProps, staticProps) {
16
+ if (protoProps) _defineProperties(Constructor.prototype, protoProps);
17
+ if (staticProps) _defineProperties(Constructor, staticProps);
18
+ return Constructor;
19
+ }
20
+ function _define_property(obj, key, value) {
21
+ if (key in obj) {
22
+ Object.defineProperty(obj, key, {
23
+ value: value,
24
+ enumerable: true,
25
+ configurable: true,
26
+ writable: true
27
+ });
28
+ } else {
29
+ obj[key] = value;
30
+ }
31
+ return obj;
32
+ }
33
+ var DEFAULT_CHARS_PER_FRAME = 3;
34
+ var DEFAULT_SPEED = 1.0;
35
+ var DEFAULT_BACKGROUND_INTERVAL = 100;
36
+ var DEFAULT_BACKGROUND_BATCH_MULTIPLIER = 10;
37
+ /**
38
+ * 字符队列——流式渲染的调度核心。
39
+ *
40
+ * - 接收 SSE 推送的 content(完整字符串,非增量)
41
+ * - 标签页可见时以 RAF 驱动逐字输出(60fps 动画)
42
+ * - 标签页不可见时降级为 setTimeout,保证后台仍能消费
43
+ * - 切回前台时自动恢复 RAF
44
+ */ export var CharacterQueue = /*#__PURE__*/ function() {
45
+ "use strict";
46
+ function CharacterQueue(onFlush, options) {
47
+ var _this = this;
48
+ _class_call_check(this, CharacterQueue);
49
+ var _ref, _ref1, _ref2, _ref3, _ref4, _ref5;
50
+ _define_property(this, "displayedLength", 0);
51
+ _define_property(this, "fullContent", '');
52
+ _define_property(this, "rafId", null);
53
+ _define_property(this, "timerId", null);
54
+ _define_property(this, "tickMode", 'raf');
55
+ _define_property(this, "onFlush", void 0);
56
+ _define_property(this, "options", void 0);
57
+ _define_property(this, "disposed", false);
58
+ _define_property(this, "tick", function() {
59
+ _this.rafId = null;
60
+ _this.timerId = null;
61
+ if (_this.disposed) return;
62
+ var remaining = _this.fullContent.length - _this.displayedLength;
63
+ if (remaining <= 0) return;
64
+ var isVisible = typeof document !== 'undefined' && document.visibilityState === 'visible';
65
+ var baseBatch = Math.max(1, Math.ceil(_this.options.charsPerFrame * _this.options.speed));
66
+ var batchSize = isVisible ? baseBatch : baseBatch * _this.options.backgroundBatchMultiplier;
67
+ _this.displayedLength = Math.min(_this.displayedLength + batchSize, _this.fullContent.length);
68
+ _this.onFlush(_this.fullContent.slice(0, _this.displayedLength));
69
+ if (_this.displayedLength < _this.fullContent.length) {
70
+ _this.scheduleNext(isVisible);
71
+ }
72
+ });
73
+ this.onFlush = onFlush;
74
+ this.options = {
75
+ charsPerFrame: (_ref = options === null || options === void 0 ? void 0 : options.charsPerFrame) !== null && _ref !== void 0 ? _ref : DEFAULT_CHARS_PER_FRAME,
76
+ animate: (_ref1 = options === null || options === void 0 ? void 0 : options.animate) !== null && _ref1 !== void 0 ? _ref1 : true,
77
+ speed: (_ref2 = options === null || options === void 0 ? void 0 : options.speed) !== null && _ref2 !== void 0 ? _ref2 : DEFAULT_SPEED,
78
+ flushOnComplete: (_ref3 = options === null || options === void 0 ? void 0 : options.flushOnComplete) !== null && _ref3 !== void 0 ? _ref3 : true,
79
+ backgroundInterval: (_ref4 = options === null || options === void 0 ? void 0 : options.backgroundInterval) !== null && _ref4 !== void 0 ? _ref4 : DEFAULT_BACKGROUND_INTERVAL,
80
+ backgroundBatchMultiplier: (_ref5 = options === null || options === void 0 ? void 0 : options.backgroundBatchMultiplier) !== null && _ref5 !== void 0 ? _ref5 : DEFAULT_BACKGROUND_BATCH_MULTIPLIER
81
+ };
82
+ this.handleVisibilityChange = this.handleVisibilityChange.bind(this);
83
+ if (typeof document !== 'undefined') {
84
+ document.addEventListener('visibilitychange', this.handleVisibilityChange);
85
+ }
86
+ }
87
+ _create_class(CharacterQueue, [
88
+ {
89
+ /** SSE token 到达时调用——接收完整的 content 字符串 */ key: "push",
90
+ value: function push(content) {
91
+ this.fullContent = content;
92
+ if (!this.options.animate) {
93
+ this.displayedLength = content.length;
94
+ this.onFlush(content);
95
+ return;
96
+ }
97
+ this.ensureTicking();
98
+ }
99
+ },
100
+ {
101
+ /** 标记流式完成,flush 所有剩余内容 */ key: "complete",
102
+ value: function complete() {
103
+ if (this.options.flushOnComplete) {
104
+ this.cancelAllTicks();
105
+ this.displayedLength = this.fullContent.length;
106
+ this.onFlush(this.fullContent);
107
+ }
108
+ }
109
+ },
110
+ {
111
+ /** 释放资源 */ key: "dispose",
112
+ value: function dispose() {
113
+ this.disposed = true;
114
+ this.cancelAllTicks();
115
+ if (typeof document !== 'undefined') {
116
+ document.removeEventListener('visibilitychange', this.handleVisibilityChange);
117
+ }
118
+ }
119
+ },
120
+ {
121
+ /** 当前已展示的长度 */ key: "getDisplayedLength",
122
+ value: function getDisplayedLength() {
123
+ return this.displayedLength;
124
+ }
125
+ },
126
+ {
127
+ /** 完整内容 */ key: "getFullContent",
128
+ value: function getFullContent() {
129
+ return this.fullContent;
130
+ }
131
+ },
132
+ {
133
+ key: "ensureTicking",
134
+ value: // ---- 调度核心 ----
135
+ function ensureTicking() {
136
+ if (this.disposed || this.isTickActive()) return;
137
+ var isVisible = typeof document !== 'undefined' && document.visibilityState === 'visible';
138
+ this.tickMode = isVisible ? 'raf' : 'timeout';
139
+ if (this.tickMode === 'raf') {
140
+ this.rafId = requestAnimationFrame(this.tick);
141
+ } else {
142
+ this.timerId = setTimeout(this.tick, this.options.backgroundInterval);
143
+ }
144
+ }
145
+ },
146
+ {
147
+ key: "scheduleNext",
148
+ value: function scheduleNext(isVisible) {
149
+ if (isVisible) {
150
+ this.tickMode = 'raf';
151
+ this.rafId = requestAnimationFrame(this.tick);
152
+ } else {
153
+ this.tickMode = 'timeout';
154
+ this.timerId = setTimeout(this.tick, this.options.backgroundInterval);
155
+ }
156
+ }
157
+ },
158
+ {
159
+ key: "handleVisibilityChange",
160
+ value: function handleVisibilityChange() {
161
+ if (this.disposed) return;
162
+ if (this.displayedLength >= this.fullContent.length) return;
163
+ this.cancelAllTicks();
164
+ this.ensureTicking();
165
+ }
166
+ },
167
+ {
168
+ key: "isTickActive",
169
+ value: function isTickActive() {
170
+ return this.rafId !== null || this.timerId !== null;
171
+ }
172
+ },
173
+ {
174
+ key: "cancelAllTicks",
175
+ value: function cancelAllTicks() {
176
+ if (this.rafId !== null) {
177
+ cancelAnimationFrame(this.rafId);
178
+ this.rafId = null;
179
+ }
180
+ if (this.timerId !== null) {
181
+ clearTimeout(this.timerId);
182
+ this.timerId = null;
183
+ }
184
+ }
185
+ }
186
+ ]);
187
+ return CharacterQueue;
188
+ }();
@@ -0,0 +1,13 @@
1
+ import React from 'react';
2
+ import type { MarkdownRendererProps, MarkdownRendererRef } from './types';
3
+ /**
4
+ * MarkdownRenderer —— 流式/只读场景下的轻量 Markdown 渲染器。
5
+ *
6
+ * 核心优势:
7
+ * - 不创建 Slate 实例,无编辑态开销
8
+ * - 字符队列驱动流式逐字输出动画
9
+ * - Markdown → hast → React 元素树(hast-util-to-jsx-runtime)
10
+ * - 特殊块(code / mermaid / chart / katex)通过组件映射拦截渲染
11
+ */
12
+ declare const InternalMarkdownRenderer: React.ForwardRefExoticComponent<MarkdownRendererProps & React.RefAttributes<MarkdownRendererRef>>;
13
+ export default InternalMarkdownRenderer;