ibc-ai-web-sdk 2.0.2 → 2.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +334 -502
- package/dist/index.cjs.js +8 -2
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +8 -2
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +8 -2
- package/dist/index.umd.js.map +1 -1
- package/dist/index.umd.min.js +1 -1
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
|
@@ -635,8 +635,9 @@
|
|
|
635
635
|
return;
|
|
636
636
|
}
|
|
637
637
|
if (MESSAGE_EVENTS.has(event)) {
|
|
638
|
-
|
|
639
|
-
|
|
638
|
+
// 后端通过空 data 块表示逻辑换行,空字符串需保留传递给上层处理
|
|
639
|
+
if (isRuntimePlaceholder(data) || this.isEventLike(data)) return;
|
|
640
|
+
handlers.onMessage?.(data || '\n');
|
|
640
641
|
return;
|
|
641
642
|
}
|
|
642
643
|
if (DONE_EVENTS.has(event)) {
|
|
@@ -5351,6 +5352,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
5351
5352
|
const response = await this._chatClient.sendMessageStream(content, {
|
|
5352
5353
|
onMessage: chunk => {
|
|
5353
5354
|
if (!this._isPlaceholder(chunk) && !this._isEventLike(chunk)) {
|
|
5355
|
+
if (!chunk) chunk = '\n';
|
|
5354
5356
|
streamText += chunk;
|
|
5355
5357
|
this._updateMsg(msgId, streamText);
|
|
5356
5358
|
}
|
|
@@ -5586,6 +5588,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
5586
5588
|
// 运行时占位符过滤(对齐 portal)
|
|
5587
5589
|
_isPlaceholder(text) {
|
|
5588
5590
|
if (!text || typeof text !== 'string') return false;
|
|
5591
|
+
if (text === '\n' || text === '\n\n') return false;
|
|
5589
5592
|
const p = text.trim();
|
|
5590
5593
|
if (!p) return true;
|
|
5591
5594
|
return RUNTIME_PLACEHOLDERS.some(k => p.includes(k));
|
|
@@ -5981,6 +5984,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
5981
5984
|
parseMarkdown(text) {
|
|
5982
5985
|
if (!text) return '';
|
|
5983
5986
|
try {
|
|
5987
|
+
// 逐行规范化标题:确保 # 后跟空格(如 "####4.2" → "#### 4.2")
|
|
5988
|
+
const lines = text.split('\n');
|
|
5989
|
+
text = lines.map(line => line.replace(/^(\s{0,3}#{1,6})([^\s#].*)$/, '$1 $2')).join('\n');
|
|
5984
5990
|
// marked 解析 markdown
|
|
5985
5991
|
const rawHtml = g.parse(text);
|
|
5986
5992
|
// DOMPurify 净化HTML(防止XSS攻击)
|