@ant-design/agentic-ui 2.29.59 → 2.30.1

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 (99) hide show
  1. package/dist/Bubble/List/index.d.ts +11 -0
  2. package/dist/Bubble/List/index.js +13 -1
  3. package/dist/Bubble/MessagesContent/EXCEPTION.js +11 -2
  4. package/dist/Bubble/MessagesContent/MarkdownPreview.js +34 -4
  5. package/dist/Bubble/MessagesContent/index.js +39 -10
  6. package/dist/Bubble/MessagesContent/style.js +55 -22
  7. package/dist/Bubble/UserBubble.js +3 -1
  8. package/dist/Bubble/type.d.ts +11 -0
  9. package/dist/Hooks/useLanguage.d.ts +1 -0
  10. package/dist/I18n/locales.d.ts +1 -0
  11. package/dist/I18n/locales.js +5 -3
  12. package/dist/MarkdownEditor/BaseMarkdownEditor.js +37 -5
  13. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.d.ts +4 -0
  14. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiTaskBlock.js +74 -0
  15. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.d.ts +4 -0
  16. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/AgenticUiToolUseBarBlock.js +114 -0
  17. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.d.ts +20 -0
  18. package/dist/MarkdownEditor/editor/elements/AgenticUiBlocks/agenticUiEmbedUtils.js +169 -0
  19. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.d.ts +11 -0
  20. package/dist/MarkdownEditor/editor/elements/Table/EditableTable.js +207 -0
  21. package/dist/MarkdownEditor/editor/elements/Table/Table.js +10 -276
  22. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndex/index.js +7 -227
  23. package/dist/MarkdownEditor/editor/elements/Table/TableCellIndexSpacer/index.js +20 -229
  24. package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.d.ts +9 -0
  25. package/dist/MarkdownEditor/editor/elements/Table/commands/tableCommands.js +242 -0
  26. package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.d.ts +20 -0
  27. package/dist/MarkdownEditor/editor/elements/Table/utils/editableTableWidth.js +60 -0
  28. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.d.ts +6 -0
  29. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableColWidths.js +20 -0
  30. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.d.ts +10 -0
  31. package/dist/MarkdownEditor/editor/elements/Table/utils/useEditableTableContentWidth.js +103 -0
  32. package/dist/MarkdownEditor/editor/elements/index.js +7 -0
  33. package/dist/MarkdownEditor/editor/parser/parse/parseCode.js +33 -2
  34. package/dist/MarkdownEditor/editor/parser/parserSlateNodeToMarkdown.js +3 -0
  35. package/dist/MarkdownEditor/editor/plugins/handlePaste.js +4 -1
  36. package/dist/MarkdownEditor/plugin.d.ts +15 -0
  37. package/dist/MarkdownEditor/style.js +258 -326
  38. package/dist/MarkdownEditor/types.d.ts +14 -0
  39. package/dist/MarkdownInputField/AttachmentButton/AttachmentButtonPopover.js +1 -1
  40. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileIcon.js +2 -2
  41. package/dist/MarkdownInputField/AttachmentButton/AttachmentFileList/AttachmentFileListItem.js +11 -8
  42. package/dist/MarkdownInputField/AttachmentButton/index.js +7 -2
  43. package/dist/MarkdownInputField/AttachmentButton/types.d.ts +5 -1
  44. package/dist/MarkdownInputField/AttachmentButton/utils.d.ts +7 -0
  45. package/dist/MarkdownInputField/AttachmentButton/utils.js +9 -1
  46. package/dist/MarkdownInputField/FileMapView/FileMapViewItem.js +10 -5
  47. package/dist/MarkdownInputField/FileUploadManager/index.d.ts +9 -0
  48. package/dist/MarkdownInputField/FileUploadManager/index.js +20 -4
  49. package/dist/MarkdownInputField/MarkdownInputField.js +5 -3
  50. package/dist/MarkdownInputField/SendActions/index.d.ts +9 -0
  51. package/dist/MarkdownInputField/SendActions/index.js +3 -2
  52. package/dist/MarkdownInputField/hooks/useMarkdownInputFieldRefs.js +10 -3
  53. package/dist/MarkdownInputField/utils/renderHelpers.d.ts +8 -1
  54. package/dist/MarkdownInputField/utils/renderHelpers.js +5 -1
  55. package/dist/MarkdownRenderer/AnimationText.d.ts +19 -0
  56. package/dist/MarkdownRenderer/AnimationText.js +226 -0
  57. package/dist/MarkdownRenderer/CharacterQueue.d.ts +36 -0
  58. package/dist/MarkdownRenderer/CharacterQueue.js +188 -0
  59. package/dist/MarkdownRenderer/MarkdownRenderer.d.ts +13 -0
  60. package/dist/MarkdownRenderer/MarkdownRenderer.js +362 -0
  61. package/dist/MarkdownRenderer/index.d.ts +11 -0
  62. package/dist/MarkdownRenderer/index.js +9 -0
  63. package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.d.ts +6 -0
  64. package/dist/MarkdownRenderer/renderers/AgenticUiTaskBlockRenderer.js +66 -0
  65. package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.d.ts +6 -0
  66. package/dist/MarkdownRenderer/renderers/AgenticUiToolUseBarBlockRenderer.js +134 -0
  67. package/dist/MarkdownRenderer/renderers/ChartRenderer.d.ts +12 -0
  68. package/dist/MarkdownRenderer/renderers/ChartRenderer.js +395 -0
  69. package/dist/MarkdownRenderer/renderers/CodeRenderer.d.ts +7 -0
  70. package/dist/MarkdownRenderer/renderers/CodeRenderer.js +218 -0
  71. package/dist/MarkdownRenderer/renderers/MermaidRenderer.d.ts +7 -0
  72. package/dist/MarkdownRenderer/renderers/MermaidRenderer.js +43 -0
  73. package/dist/MarkdownRenderer/renderers/SchemaRenderer.d.ts +15 -0
  74. package/dist/MarkdownRenderer/renderers/SchemaRenderer.js +115 -0
  75. package/dist/MarkdownRenderer/renderers/index.d.ts +4 -0
  76. package/dist/MarkdownRenderer/renderers/index.js +4 -0
  77. package/dist/MarkdownRenderer/style.d.ts +16 -0
  78. package/dist/MarkdownRenderer/style.js +47 -0
  79. package/dist/MarkdownRenderer/types.d.ts +74 -0
  80. package/dist/MarkdownRenderer/types.js +1 -0
  81. package/dist/MarkdownRenderer/useMarkdownToReact.d.ts +23 -0
  82. package/dist/MarkdownRenderer/useMarkdownToReact.js +1241 -0
  83. package/dist/MarkdownRenderer/useStreaming.d.ts +29 -0
  84. package/dist/MarkdownRenderer/useStreaming.js +399 -0
  85. package/dist/Plugins/chart/AreaChart/index.js +4 -2
  86. package/dist/Plugins/chart/ChartRender.js +1 -0
  87. package/dist/Plugins/chart/LineChart/index.js +4 -2
  88. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.d.ts +8 -0
  89. package/dist/Plugins/chart/components/ChartContainer/ChartErrorBoundary.js +31 -6
  90. package/dist/Plugins/chart/index.js +3 -1
  91. package/dist/Plugins/mermaid/style.js +0 -3
  92. package/dist/TaskList/TaskList.js +3 -12
  93. package/dist/TaskList/components/TaskListItem.js +3 -12
  94. package/dist/ThoughtChainList/ThoughtChainListItem.js +2 -4
  95. package/dist/ThoughtChainList/index.js +4 -21
  96. package/dist/ToolUseBarThink/index.js +20 -59
  97. package/dist/index.d.ts +1 -0
  98. package/dist/index.js +2 -0
  99. package/package.json +2 -1
@@ -0,0 +1,226 @@
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 _define_property(obj, key, value) {
13
+ if (key in obj) {
14
+ Object.defineProperty(obj, key, {
15
+ value: value,
16
+ enumerable: true,
17
+ configurable: true,
18
+ writable: true
19
+ });
20
+ } else {
21
+ obj[key] = value;
22
+ }
23
+ return obj;
24
+ }
25
+ function _iterable_to_array(iter) {
26
+ if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
27
+ }
28
+ function _iterable_to_array_limit(arr, i) {
29
+ var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"];
30
+ if (_i == null) return;
31
+ var _arr = [];
32
+ var _n = true;
33
+ var _d = false;
34
+ var _s, _e;
35
+ try {
36
+ for(_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true){
37
+ _arr.push(_s.value);
38
+ if (i && _arr.length === i) break;
39
+ }
40
+ } catch (err) {
41
+ _d = true;
42
+ _e = err;
43
+ } finally{
44
+ try {
45
+ if (!_n && _i["return"] != null) _i["return"]();
46
+ } finally{
47
+ if (_d) throw _e;
48
+ }
49
+ }
50
+ return _arr;
51
+ }
52
+ function _non_iterable_rest() {
53
+ throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
54
+ }
55
+ function _non_iterable_spread() {
56
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
57
+ }
58
+ function _object_spread(target) {
59
+ for(var i = 1; i < arguments.length; i++){
60
+ var source = arguments[i] != null ? arguments[i] : {};
61
+ var ownKeys = Object.keys(source);
62
+ if (typeof Object.getOwnPropertySymbols === "function") {
63
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
64
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
65
+ }));
66
+ }
67
+ ownKeys.forEach(function(key) {
68
+ _define_property(target, key, source[key]);
69
+ });
70
+ }
71
+ return target;
72
+ }
73
+ function ownKeys(object, enumerableOnly) {
74
+ var keys = Object.keys(object);
75
+ if (Object.getOwnPropertySymbols) {
76
+ var symbols = Object.getOwnPropertySymbols(object);
77
+ if (enumerableOnly) {
78
+ symbols = symbols.filter(function(sym) {
79
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
80
+ });
81
+ }
82
+ keys.push.apply(keys, symbols);
83
+ }
84
+ return keys;
85
+ }
86
+ function _object_spread_props(target, source) {
87
+ source = source != null ? source : {};
88
+ if (Object.getOwnPropertyDescriptors) {
89
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
90
+ } else {
91
+ ownKeys(Object(source)).forEach(function(key) {
92
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
93
+ });
94
+ }
95
+ return target;
96
+ }
97
+ function _sliced_to_array(arr, i) {
98
+ return _array_with_holes(arr) || _iterable_to_array_limit(arr, i) || _unsupported_iterable_to_array(arr, i) || _non_iterable_rest();
99
+ }
100
+ function _to_consumable_array(arr) {
101
+ return _array_without_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_spread();
102
+ }
103
+ function _unsupported_iterable_to_array(o, minLen) {
104
+ if (!o) return;
105
+ if (typeof o === "string") return _array_like_to_array(o, minLen);
106
+ var n = Object.prototype.toString.call(o).slice(8, -1);
107
+ if (n === "Object" && o.constructor) n = o.constructor.name;
108
+ if (n === "Map" || n === "Set") return Array.from(n);
109
+ if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _array_like_to_array(o, minLen);
110
+ }
111
+ import React, { useEffect, useMemo, useRef, useState } from "react";
112
+ /**
113
+ * 提取 React children 的纯文本
114
+ */ var extractText = function extractText1(children) {
115
+ var _children_props;
116
+ if (typeof children === 'string') return children;
117
+ if (typeof children === 'number') return String(children);
118
+ if (Array.isArray(children)) return children.map(extractText).join('');
119
+ if (/*#__PURE__*/ React.isValidElement(children) && ((_children_props = children.props) === null || _children_props === void 0 ? void 0 : _children_props.children)) {
120
+ return extractText(children.props.children);
121
+ }
122
+ return '';
123
+ };
124
+ /**
125
+ * 识别 children 中是否包含 React 元素节点。
126
+ * 富文本结构(链接、脚注、图片等)在纯文本差分下会丢失结构信息,直接透传更安全。
127
+ */ var hasElementNode = function hasElementNode1(children) {
128
+ if (children === null || children === undefined || typeof children === 'boolean') return false;
129
+ if (typeof children === 'string' || typeof children === 'number') return false;
130
+ if (Array.isArray(children)) return children.some(hasElementNode);
131
+ return /*#__PURE__*/ React.isValidElement(children);
132
+ };
133
+ /**
134
+ * 流式文字淡入动画组件。
135
+ *
136
+ * 采用 opacity + translateY(GPU 硬件加速),清爽流派。
137
+ * 动画结束后通过 animationend 标记 done,仍用 span 包裹以保持布局稳定。
138
+ */ var AnimationText = /*#__PURE__*/ React.memo(function(param) {
139
+ var children = param.children, animationConfig = param.animationConfig;
140
+ 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-out' : _ref_easing;
141
+ var _useState = _sliced_to_array(useState([]), 2), chunks = _useState[0], setChunks = _useState[1];
142
+ var prevTextRef = useRef('');
143
+ var text = extractText(children);
144
+ var hasElementContent = hasElementNode(children);
145
+ useEffect(function() {
146
+ if (hasElementContent) {
147
+ prevTextRef.current = text;
148
+ return;
149
+ }
150
+ if (text === prevTextRef.current) return;
151
+ if (!prevTextRef.current || !text.startsWith(prevTextRef.current)) {
152
+ setChunks([
153
+ {
154
+ key: '0',
155
+ text: text,
156
+ content: children,
157
+ done: false
158
+ }
159
+ ]);
160
+ prevTextRef.current = text;
161
+ return;
162
+ }
163
+ var prevLen = prevTextRef.current.length;
164
+ var newText = text.slice(prevLen);
165
+ var newKey = "anim-".concat(Date.now(), "-").concat(prevLen);
166
+ setChunks(function(prev) {
167
+ return _to_consumable_array(prev).concat([
168
+ {
169
+ key: newKey,
170
+ text: newText,
171
+ done: false
172
+ }
173
+ ]);
174
+ });
175
+ prevTextRef.current = text;
176
+ }, [
177
+ text,
178
+ children,
179
+ hasElementContent
180
+ ]);
181
+ var handleAnimationEnd = function handleAnimationEnd(key) {
182
+ setChunks(function(prev) {
183
+ return prev.map(function(c) {
184
+ return c.key === key ? _object_spread_props(_object_spread({}, c), {
185
+ done: true
186
+ }) : c;
187
+ });
188
+ });
189
+ };
190
+ var animationStyle = useMemo(function() {
191
+ return {
192
+ display: 'inline-block',
193
+ animation: "markdownRendererSlideFadeIn ".concat(fadeDuration, "ms ").concat(easing, " forwards"),
194
+ willChange: 'opacity, transform',
195
+ color: 'inherit'
196
+ };
197
+ }, [
198
+ fadeDuration,
199
+ easing
200
+ ]);
201
+ /** 动画结束后仍用 inline-block 包裹,避免从 span 变为裸内容时的宽度重排 */ var doneChunkStyle = useMemo(function() {
202
+ return {
203
+ display: 'inline-block',
204
+ color: 'inherit'
205
+ };
206
+ }, []);
207
+ if (hasElementContent) {
208
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, children);
209
+ }
210
+ return /*#__PURE__*/ React.createElement(React.Fragment, null, chunks.map(function(chunk) {
211
+ var _chunk_content;
212
+ var rendered = (_chunk_content = chunk.content) !== null && _chunk_content !== void 0 ? _chunk_content : chunk.text;
213
+ return chunk.done ? /*#__PURE__*/ React.createElement("span", {
214
+ key: chunk.key,
215
+ style: doneChunkStyle
216
+ }, rendered) : /*#__PURE__*/ React.createElement("span", {
217
+ key: chunk.key,
218
+ style: animationStyle,
219
+ onAnimationEnd: function onAnimationEnd() {
220
+ return handleAnimationEnd(chunk.key);
221
+ }
222
+ }, rendered);
223
+ }));
224
+ });
225
+ AnimationText.displayName = 'AnimationText';
226
+ 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;