ibc-ai-web-sdk 2.0.1 → 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 +11 -39
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +11 -39
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +11 -39
- 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
|
@@ -4,25 +4,6 @@
|
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.AIWebSDK = {}));
|
|
5
5
|
})(this, (function (exports) { 'use strict';
|
|
6
6
|
|
|
7
|
-
// 机器人图标 - 内联轻量 SVG(尺寸 ~900 bytes,替换原 1.9MB 的 base64 GIF)
|
|
8
|
-
// 设计为圆形类属色背景 + 白色几何机器人脸,适配 border-radius 截切
|
|
9
|
-
var robotIcon = 'data:image/svg+xml,' + encodeURIComponent(`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
|
|
10
|
-
<defs>
|
|
11
|
-
<linearGradient id="g" x1="0" y1="0" x2="1" y2="1">
|
|
12
|
-
<stop offset="0%" stop-color="#2563eb"/>
|
|
13
|
-
<stop offset="100%" stop-color="#7c3aed"/>
|
|
14
|
-
</linearGradient>
|
|
15
|
-
</defs>
|
|
16
|
-
<circle cx="50" cy="50" r="50" fill="url(#g)"/>
|
|
17
|
-
<rect x="24" y="36" width="14" height="14" rx="4" fill="#fff" opacity=".9"/>
|
|
18
|
-
<rect x="62" y="36" width="14" height="14" rx="4" fill="#fff" opacity=".9"/>
|
|
19
|
-
<circle cx="28" cy="40" r="3.5" fill="#2563eb"/>
|
|
20
|
-
<circle cx="66" cy="40" r="3.5" fill="#2563eb"/>
|
|
21
|
-
<rect x="38" y="26" width="4" height="10" rx="2" fill="#fff" opacity=".8"/>
|
|
22
|
-
<circle cx="40" cy="24" r="5" fill="#fff" opacity=".7"/>
|
|
23
|
-
<path d="M36 62 Q50 76 64 62" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" opacity=".8"/>
|
|
24
|
-
</svg>`);
|
|
25
|
-
|
|
26
7
|
/**
|
|
27
8
|
* 错误码常量
|
|
28
9
|
* 统一定义所有错误码,方便维护
|
|
@@ -654,8 +635,9 @@
|
|
|
654
635
|
return;
|
|
655
636
|
}
|
|
656
637
|
if (MESSAGE_EVENTS.has(event)) {
|
|
657
|
-
|
|
658
|
-
|
|
638
|
+
// 后端通过空 data 块表示逻辑换行,空字符串需保留传递给上层处理
|
|
639
|
+
if (isRuntimePlaceholder(data) || this.isEventLike(data)) return;
|
|
640
|
+
handlers.onMessage?.(data || '\n');
|
|
659
641
|
return;
|
|
660
642
|
}
|
|
661
643
|
if (DONE_EVENTS.has(event)) {
|
|
@@ -3686,16 +3668,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
3686
3668
|
padding: 0 0 18px;
|
|
3687
3669
|
}
|
|
3688
3670
|
.welcome-content { margin-bottom: 0; width: 100%; }
|
|
3689
|
-
/* 欢迎页图标(与Vue一致:使用img而非emoji) */
|
|
3690
|
-
.welcome-icon {
|
|
3691
|
-
width: 52px;
|
|
3692
|
-
height: auto;
|
|
3693
|
-
margin-bottom: 12px;
|
|
3694
|
-
opacity: 1;
|
|
3695
|
-
animation: none;
|
|
3696
|
-
border-radius: 999px;
|
|
3697
|
-
box-shadow: 0 8px 26px rgba(15, 23, 42, 0.08);
|
|
3698
|
-
}
|
|
3699
3671
|
@keyframes floatUp { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
|
|
3700
3672
|
|
|
3701
3673
|
/* 欢迎标题 - 渐变品牌色 */
|
|
@@ -4213,9 +4185,11 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4213
4185
|
color: var(--ai-primary);
|
|
4214
4186
|
background: rgba(37, 99, 235, 0.08);
|
|
4215
4187
|
}
|
|
4188
|
+
.input-tool.attach-tool { display: none; }
|
|
4216
4189
|
|
|
4217
4190
|
/* 发送按钮(与Vue .send-btn 完全一致,含光泽动画)*/
|
|
4218
4191
|
.send-btn {
|
|
4192
|
+
margin-left: auto;
|
|
4219
4193
|
flex-shrink: 0;
|
|
4220
4194
|
width: 28px;
|
|
4221
4195
|
height: 28px;
|
|
@@ -4300,8 +4274,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4300
4274
|
box-shadow: 0 10px 24px rgba(15, 23, 42, 0.14);
|
|
4301
4275
|
}
|
|
4302
4276
|
.float-button:hover::before { opacity: 1; animation-play-state: initial; }
|
|
4303
|
-
.float-icon { width: 24px; height: auto; transition: none; border-radius: 50%; }
|
|
4304
|
-
.float-button:hover .float-icon { transform: none; }
|
|
4305
4277
|
|
|
4306
4278
|
/* 错误提示toast */
|
|
4307
4279
|
.error-toast {
|
|
@@ -4521,7 +4493,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4521
4493
|
.message-list { gap: 9px; }
|
|
4522
4494
|
.message-item { max-width: 100%; width: 100%; }
|
|
4523
4495
|
.message-bubble { padding: 11px 15px; font-size: 14px; }
|
|
4524
|
-
.welcome-icon { width: 48px; margin-bottom: 10px; }
|
|
4525
4496
|
.welcome-text { font-size: 22px; line-height: 1.3; margin-bottom: 9px; }
|
|
4526
4497
|
.welcome-desc { font-size: 13px; line-height: 1.55; margin-bottom: 18px; }
|
|
4527
4498
|
.quick-suggestions { gap: 10px; margin-top: 0; }
|
|
@@ -4532,7 +4503,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4532
4503
|
.message-input { font-size: 16px; padding: 10px 12px 6px; min-height: 44px; }
|
|
4533
4504
|
.send-btn { width: 28px; height: 28px; }
|
|
4534
4505
|
.float-button { height: 42px; min-width: 96px; }
|
|
4535
|
-
.float-icon { width: 22px; }
|
|
4536
4506
|
.action-icon { width: 30px; height: 30px; }
|
|
4537
4507
|
}
|
|
4538
4508
|
|
|
@@ -4618,9 +4588,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4618
4588
|
</div>
|
|
4619
4589
|
|
|
4620
4590
|
<!-- 悬浮按钮 -->
|
|
4621
|
-
<div class="float-button" id="floatBtn" title="打开AI助手">
|
|
4622
|
-
<img class="float-icon" src="${robotIcon}" alt="打开AI助手" />
|
|
4623
|
-
</div>
|
|
4591
|
+
<div class="float-button" id="floatBtn" title="打开AI助手"></div>
|
|
4624
4592
|
</div>
|
|
4625
4593
|
`;
|
|
4626
4594
|
|
|
@@ -4921,7 +4889,6 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
4921
4889
|
this._body.innerHTML = `
|
|
4922
4890
|
<div class="empty-state">
|
|
4923
4891
|
<div class="welcome-content">
|
|
4924
|
-
<img class="welcome-icon" src="${robotIcon}" alt="AI助手" />
|
|
4925
4892
|
<p class="welcome-text">${this.escapeHtml(this._config?.welcomeText || '您好!我是 AI 智能助理')}</p>
|
|
4926
4893
|
<p class="welcome-desc">${this.escapeHtml(this._config?.welcomeDesc || '我可以帮您解答系统使用问题')}</p>
|
|
4927
4894
|
${chipsHtml}
|
|
@@ -5385,6 +5352,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
5385
5352
|
const response = await this._chatClient.sendMessageStream(content, {
|
|
5386
5353
|
onMessage: chunk => {
|
|
5387
5354
|
if (!this._isPlaceholder(chunk) && !this._isEventLike(chunk)) {
|
|
5355
|
+
if (!chunk) chunk = '\n';
|
|
5388
5356
|
streamText += chunk;
|
|
5389
5357
|
this._updateMsg(msgId, streamText);
|
|
5390
5358
|
}
|
|
@@ -5620,6 +5588,7 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
5620
5588
|
// 运行时占位符过滤(对齐 portal)
|
|
5621
5589
|
_isPlaceholder(text) {
|
|
5622
5590
|
if (!text || typeof text !== 'string') return false;
|
|
5591
|
+
if (text === '\n' || text === '\n\n') return false;
|
|
5623
5592
|
const p = text.trim();
|
|
5624
5593
|
if (!p) return true;
|
|
5625
5594
|
return RUNTIME_PLACEHOLDERS.some(k => p.includes(k));
|
|
@@ -6015,6 +5984,9 @@ Please report this to https://github.com/markedjs/marked.`,e){let s="<p>An error
|
|
|
6015
5984
|
parseMarkdown(text) {
|
|
6016
5985
|
if (!text) return '';
|
|
6017
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');
|
|
6018
5990
|
// marked 解析 markdown
|
|
6019
5991
|
const rawHtml = g.parse(text);
|
|
6020
5992
|
// DOMPurify 净化HTML(防止XSS攻击)
|