dsh-soul 0.6.1 → 0.7.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.
- package/README.md +12 -7
- package/README_EN.md +12 -7
- package/assets/icon.svg +21 -0
- package/client/index.mjs +505 -93
- package/index.mjs +163 -33
- package/lib/config.mjs +15 -3
- package/lib/injection.mjs +44 -0
- package/lib/personas.mjs +172 -0
- package/package.json +8 -4
- package/scripts/verify-compat.mjs +89 -6
- package/scripts/verify-config.mjs +438 -0
- package/scripts/verify-nav-icon.mjs +451 -0
- package/scripts/verify-trail.mjs +413 -0
package/client/index.mjs
CHANGED
|
@@ -3,11 +3,12 @@
|
|
|
3
3
|
// 在设置页面添加「个性化」栏目:
|
|
4
4
|
// - 启用/禁用个性化设置
|
|
5
5
|
// - 「关于你」(昵称/职业/介绍)、回复风格和语调、特质、输出语言、自定义指令
|
|
6
|
-
// -
|
|
6
|
+
// - 人设预设:6 个内置人设(随插件提供、不可删除,行尾标「内置」)+ 保存当前为预设、一键使用(★ 标记当前匹配项)、删除
|
|
7
7
|
// - Agent 工具:set_persona 确认模式开关
|
|
8
8
|
// - 输入框光轨:Agent 回复中时输入框边框的流光动效(颜色 / 速度 / 粗细 + 实时示例)
|
|
9
9
|
// - dirty 检测(无改动禁用保存)、统一 toast 提示
|
|
10
|
-
// -
|
|
10
|
+
// - 提示词预览(只读):无未保存编辑时显示「当前生效提示词」,有编辑时改为编译草稿
|
|
11
|
+
// —— 展示保存后真正会注入的内容,并在保存/重置/应用预设后自动刷新
|
|
11
12
|
//
|
|
12
13
|
// 光轨另注册到 conversation.input.overlay 槽位(输入框卡片内部),
|
|
13
14
|
// 运行时按会话 running 状态在卡片上挂载/隐藏 SVG 环,见 SoulTrail。
|
|
@@ -47,7 +48,7 @@ window.__ModuleLoader__.load({
|
|
|
47
48
|
// -------------------------------------------------------------------------
|
|
48
49
|
|
|
49
50
|
const NS = 'soul'
|
|
50
|
-
const VERSION = '0.
|
|
51
|
+
const VERSION = '0.7.0'
|
|
51
52
|
const INITIAL = {
|
|
52
53
|
enabled: true,
|
|
53
54
|
nickname: '',
|
|
@@ -56,6 +57,8 @@ window.__ModuleLoader__.load({
|
|
|
56
57
|
style: 'professional',
|
|
57
58
|
headingLists: 'default',
|
|
58
59
|
emoji: 'default',
|
|
60
|
+
tables: 'default',
|
|
61
|
+
replyLength: 'normal',
|
|
59
62
|
language: 'zh',
|
|
60
63
|
customInstructions: '',
|
|
61
64
|
// set_persona 确认模式(v0.5.0)
|
|
@@ -113,9 +116,22 @@ window.__ModuleLoader__.load({
|
|
|
113
116
|
// (旋转 conic-gradient 的角速度恒定,但周长线速度会随位置变化,故不采用)。
|
|
114
117
|
// 渐隐拖尾:8 层等长 dash 依次错位叠加、透明度递减 —— 头部各层重叠最亮,
|
|
115
118
|
// 向后剩余层数递减形成拖尾;所有层共用同一时长,整体仍严格匀速。
|
|
116
|
-
// 与边框重合:stroke
|
|
117
|
-
//
|
|
119
|
+
// 与边框重合:stroke 中心线落在宿主边框盒边缘;外半圈由「外扩盒」容纳
|
|
120
|
+
// (见 TRAIL_PAD),不再依赖 overflow:visible;光轨开启时隐藏宿主自身细边框,
|
|
118
121
|
// 保证边界上只有一条线。
|
|
122
|
+
//
|
|
123
|
+
// ⚠️ 隔离不变量(v0.6.2 修复 issue #2 的尺寸正反馈环):
|
|
124
|
+
// 环是「写在宿主内部、尺寸随宿主变化」的绝对定位元素。一旦它进入宿主布局流
|
|
125
|
+
// (例如类规则里的 position:absolute 被第三方皮肤/主题的更具体选择器或
|
|
126
|
+
// !important 覆盖),就会闭合成环:卡片变高 → ResizeObserver → 按新尺寸改写
|
|
127
|
+
// SVG → 元素自身再变高 → 卡片再变高 → …(实测 60 次 sync 即可把 134px 撑到 9202px)。
|
|
128
|
+
// 故本实现用三层独立手段保证它绝不参与宿主的任何尺寸测量:
|
|
129
|
+
// 1) 挂载点优先选卡片内那个 `position:absolute;height:0` 的 overlay 锚点 ——
|
|
130
|
+
// 锚点高度写死为 0,环即使退回常规流也撑不动卡片;
|
|
131
|
+
// 2) 关键几何(position/left/top/width/height/contain)全部内联 ——
|
|
132
|
+
// 内联样式只可能被 !important 击败,比单类选择器可靠得多;
|
|
133
|
+
// 3) contain:strict(含 size/layout/paint)+ 墨迹全部收进自身盒内,
|
|
134
|
+
// 尺寸、布局、绘制都与外部彻底隔离。
|
|
119
135
|
|
|
120
136
|
const TRAIL_DASH = 12
|
|
121
137
|
const TRAIL_LAYERS = 8
|
|
@@ -126,6 +142,13 @@ window.__ModuleLoader__.load({
|
|
|
126
142
|
const TRAIL_COLOR_PATTERN = /^#[0-9a-fA-F]{6}$/
|
|
127
143
|
const TRAIL_SPEED_VALUES = ['slow', 'normal', 'fast']
|
|
128
144
|
const TRAIL_WIDTH_VALUES = ['thin', 'normal', 'thick']
|
|
145
|
+
// 最粗描边(4px)的一半:环的外盒比宿主边框盒每边外扩这么多,
|
|
146
|
+
// 好让描边的外半圈也落在 SVG 自己的盒内(contain:paint 会按盒裁切)。
|
|
147
|
+
// 这样就不需要 overflow:visible —— 墨迹不再外溢,不可能被祖先的 scrollHeight 计入。
|
|
148
|
+
const TRAIL_PAD = 2
|
|
149
|
+
// 失控熔断:输入框卡片不可能达到这个量级;命中即停止同步并隐藏,防止未知宿主
|
|
150
|
+
// 测高逻辑把环拖进任何残余的正反馈(正常路径下永不触发)。
|
|
151
|
+
const TRAIL_MAX_SIDE = 20000
|
|
129
152
|
|
|
130
153
|
// 颜色容错:输入中途(如只打了 #6)回退到默认色,避免示例与提示丢失;
|
|
131
154
|
// 统一大写,与宿主归一化结果及调色板取值一致
|
|
@@ -157,39 +180,156 @@ window.__ModuleLoader__.load({
|
|
|
157
180
|
return svg
|
|
158
181
|
}
|
|
159
182
|
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
183
|
+
// 环外盒相对挂载锚点的偏移。锚点的 padding box 原点与宿主的 padding box 原点重合,
|
|
184
|
+
// 因此左/上各再减「宿主边框宽度 + TRAIL_PAD」,才能把外盒对到宿主边框盒上。
|
|
185
|
+
function trailBoxOffset(host) {
|
|
186
|
+
let borderLeft = 0
|
|
187
|
+
let borderTop = 0
|
|
188
|
+
try {
|
|
189
|
+
const style = typeof globalThis.getComputedStyle === 'function' ? globalThis.getComputedStyle(host) : null
|
|
190
|
+
if (style) {
|
|
191
|
+
borderLeft = parseFloat(style.borderLeftWidth) || 0
|
|
192
|
+
borderTop = parseFloat(style.borderTopWidth) || 0
|
|
193
|
+
}
|
|
194
|
+
} catch {
|
|
195
|
+
// 取不到计算样式就按无边框处理(DSH 输入框卡片 border:0)
|
|
196
|
+
}
|
|
197
|
+
return { left: -borderLeft - TRAIL_PAD, top: -borderTop - TRAIL_PAD }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// 让环与宿主「边框盒」逐像素对齐:外盒 = 宿主边框盒 + TRAIL_PAD×2,
|
|
201
|
+
// viewBox 以像素为单位,描边中心线因此正好压在宿主边框盒边缘;
|
|
202
|
+
// 圆角半径与宿主输入框卡片一致。尺寸未变时不重复写(避免多余样式写入)。
|
|
203
|
+
function sizeTrailSvg(svg, host, width, height) {
|
|
204
|
+
if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return false
|
|
205
|
+
const boxWidth = width + TRAIL_PAD * 2
|
|
206
|
+
const boxHeight = height + TRAIL_PAD * 2
|
|
207
|
+
const offset = trailBoxOffset(host)
|
|
208
|
+
const key = `${width}x${height}@${offset.left},${offset.top}`
|
|
209
|
+
if (svg.dataset.trailKey === key) return false
|
|
210
|
+
svg.dataset.trailKey = key
|
|
211
|
+
svg.style.left = `${offset.left}px`
|
|
212
|
+
svg.style.top = `${offset.top}px`
|
|
213
|
+
svg.style.width = `${boxWidth}px`
|
|
214
|
+
svg.style.height = `${boxHeight}px`
|
|
215
|
+
svg.setAttribute('viewBox', `0 0 ${boxWidth} ${boxHeight}`)
|
|
167
216
|
for (const rect of svg.querySelectorAll('.soul-trail-layer')) {
|
|
168
|
-
rect.setAttribute('x',
|
|
169
|
-
rect.setAttribute('y',
|
|
217
|
+
rect.setAttribute('x', String(TRAIL_PAD))
|
|
218
|
+
rect.setAttribute('y', String(TRAIL_PAD))
|
|
170
219
|
rect.setAttribute('width', String(width))
|
|
171
220
|
rect.setAttribute('height', String(height))
|
|
172
221
|
rect.setAttribute('rx', String(TRAIL_RADIUS))
|
|
173
222
|
}
|
|
223
|
+
return true
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
// 在卡片内解析环的挂载点:必须是卡片内一个「零高度容器」——DSH composer 的
|
|
227
|
+
// .overlayAnchor 与设置页示例的 .soul-trail-anchor 都是这个形态。零高度容器
|
|
228
|
+
// 即便环退回常规流也撑不动卡片(issue #2 的第一层隔离),且其 padding box 原点
|
|
229
|
+
// 与卡片的 padding box 原点重合,环才能与卡片边框盒对齐。
|
|
230
|
+
// 两种落点:
|
|
231
|
+
// 1) anchor 本身就是卡片的直接子元素(设置页示例)→ 就是它;
|
|
232
|
+
// 2) anchor 渲染在卡片内的某个容器里(线上:conversation.input.overlay 槽位
|
|
233
|
+
// 把组件挂在 DSH 的 .overlayAnchor 内)→ 取「anchor 的、作为卡片直接子元素的祖先」。
|
|
234
|
+
// 判据只看 DOM 结构、不看计算样式:样式表失效恰恰是最需要零高挂载点的时刻,
|
|
235
|
+
// 那种场景下 anchor 的计算样式反而不可信。两者都不满足时退回卡片本身,
|
|
236
|
+
// 由内联 position/contain 兜底。
|
|
237
|
+
function resolveTrailMountPoint(card, anchor) {
|
|
238
|
+
if (anchor && anchor.parentElement === card) return anchor
|
|
239
|
+
const parent = anchor && anchor.parentElement
|
|
240
|
+
if (!parent) return card
|
|
241
|
+
let node = parent
|
|
242
|
+
while (node !== card && node.parentElement && node.parentElement !== card) node = node.parentElement
|
|
243
|
+
if (node !== card && node.parentElement === card) return node
|
|
244
|
+
return card
|
|
174
245
|
}
|
|
175
246
|
|
|
176
|
-
//
|
|
177
|
-
function mountTrailRing(host) {
|
|
247
|
+
// 把环挂到宿主卡片(内部锚点)上并跟随宿主尺寸变化;返回 { svg, setVisible, unmount }
|
|
248
|
+
function mountTrailRing(host, anchor) {
|
|
178
249
|
const svg = buildTrailSvg()
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
250
|
+
// 关键几何内联:position 若被样式表覆盖,环会退回常规流并触发尺寸正反馈环,
|
|
251
|
+
// 后果是整页布局被撑爆,因此不能只依赖类规则(见渲染层「隔离不变量」注释)
|
|
252
|
+
svg.style.cssText = [
|
|
253
|
+
'position:absolute',
|
|
254
|
+
'display:none',
|
|
255
|
+
'pointer-events:none',
|
|
256
|
+
'contain:strict',
|
|
257
|
+
'overflow:hidden',
|
|
258
|
+
'margin:0',
|
|
259
|
+
'padding:0',
|
|
260
|
+
'border:0',
|
|
261
|
+
'transform:none',
|
|
262
|
+
'animation:none',
|
|
263
|
+
'max-width:none',
|
|
264
|
+
'max-height:none'
|
|
265
|
+
].join(';')
|
|
266
|
+
;(anchor || host).appendChild(svg)
|
|
267
|
+
|
|
268
|
+
let stopped = false
|
|
182
269
|
let observer = null
|
|
270
|
+
let geometryChecked = false
|
|
271
|
+
|
|
272
|
+
// 停用并留下线索:与其画出巨大错位的图形或拖垮布局,不如安静退出
|
|
273
|
+
const disable = (reason) => {
|
|
274
|
+
stopped = true
|
|
275
|
+
svg.style.display = 'none'
|
|
276
|
+
if (observer) observer.disconnect()
|
|
277
|
+
if (typeof console !== 'undefined' && typeof console.warn === 'function') {
|
|
278
|
+
console.warn(`[dsh-soul] 已停用输入框光轨:${reason}`)
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const sync = () => {
|
|
283
|
+
if (stopped) return
|
|
284
|
+
// 用 offsetWidth/Height(边框盒)而非 clientWidth/Height(内边距盒),
|
|
285
|
+
// 环才能与宿主边框盒对齐
|
|
286
|
+
const width = host.offsetWidth
|
|
287
|
+
const height = host.offsetHeight
|
|
288
|
+
if (width > TRAIL_MAX_SIDE || height > TRAIL_MAX_SIDE) {
|
|
289
|
+
disable('输入框尺寸异常(疑似尺寸正反馈)')
|
|
290
|
+
return
|
|
291
|
+
}
|
|
292
|
+
if (!sizeTrailSvg(svg, host, width, height)) return
|
|
293
|
+
if (geometryChecked) return
|
|
294
|
+
geometryChecked = true
|
|
295
|
+
// 自检:样式表若用更具体的选择器或 !important 把 position 改回常规流,
|
|
296
|
+
// 环就会重新参与宿主排版(这正是 issue #2 的成因),此时主动停用
|
|
297
|
+
if (typeof globalThis.getComputedStyle !== 'function') return
|
|
298
|
+
let position = 'absolute'
|
|
299
|
+
try {
|
|
300
|
+
position = globalThis.getComputedStyle(svg).position
|
|
301
|
+
} catch {
|
|
302
|
+
return
|
|
303
|
+
}
|
|
304
|
+
if (position !== 'absolute') disable(`光轨样式被第三方样式表覆盖(position: ${position})`)
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
sync()
|
|
183
308
|
if (typeof ResizeObserver === 'function') {
|
|
184
309
|
observer = new ResizeObserver(sync)
|
|
185
310
|
observer.observe(host)
|
|
186
311
|
} else if (typeof globalThis.addEventListener === 'function') {
|
|
187
312
|
globalThis.addEventListener('resize', sync)
|
|
188
313
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
314
|
+
// 首帧同步就可能已判定停用(尺寸异常 / 样式被覆盖),此时不必再观察
|
|
315
|
+
if (stopped && observer) observer.disconnect()
|
|
316
|
+
|
|
317
|
+
// 显隐也走内联:不只依赖 `[data-soul-trail="off"]` 类规则,
|
|
318
|
+
// 样式表被覆盖时不至于把环留在页面上
|
|
319
|
+
const setVisible = (visible) => {
|
|
320
|
+
if (stopped) return
|
|
321
|
+
svg.style.display = visible ? 'block' : 'none'
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
return {
|
|
325
|
+
svg,
|
|
326
|
+
setVisible,
|
|
327
|
+
unmount: () => {
|
|
328
|
+
stopped = true
|
|
329
|
+
if (observer) observer.disconnect()
|
|
330
|
+
else if (typeof globalThis.removeEventListener === 'function') globalThis.removeEventListener('resize', sync)
|
|
331
|
+
svg.remove()
|
|
332
|
+
}
|
|
193
333
|
}
|
|
194
334
|
}
|
|
195
335
|
|
|
@@ -209,6 +349,8 @@ window.__ModuleLoader__.load({
|
|
|
209
349
|
s.style = config.style
|
|
210
350
|
s.headingLists = config.headingLists || 'default'
|
|
211
351
|
s.emoji = config.emoji || 'default'
|
|
352
|
+
s.tables = config.tables || 'default'
|
|
353
|
+
s.replyLength = config.replyLength || 'normal'
|
|
212
354
|
s.language = config.language || 'zh'
|
|
213
355
|
s.customInstructions = config.customInstructions
|
|
214
356
|
s.requireToolConfirmation = config.requireToolConfirmation === true
|
|
@@ -325,6 +467,14 @@ window.__ModuleLoader__.load({
|
|
|
325
467
|
return payload
|
|
326
468
|
}
|
|
327
469
|
|
|
470
|
+
// 预览「未保存的编辑」编译出的提示词:POST 草稿字段,服务端以已保存配置为底
|
|
471
|
+
// 覆盖后编译。不落盘、不注入 —— 返回的 invalid 列出未通过校验、因而未计入
|
|
472
|
+
// 预览的字段名,供界面如实提示,避免用户以为改动已生效。
|
|
473
|
+
async previewPrompt(draft) {
|
|
474
|
+
const payload = await this.postJSON('/api/soul/prompt/preview', draft)
|
|
475
|
+
return payload
|
|
476
|
+
}
|
|
477
|
+
|
|
328
478
|
async dispose() {
|
|
329
479
|
this.disposed = true
|
|
330
480
|
}
|
|
@@ -391,7 +541,8 @@ window.__ModuleLoader__.load({
|
|
|
391
541
|
'.soul-persona-row{display:flex;align-items:center;gap:8px;padding:6px 0;border-bottom:1px dashed var(--dsw-alias-border-l2);font-size:12px}',
|
|
392
542
|
'.soul-persona-name{color:var(--dsw-alias-label-primary);font-weight:500;white-space:nowrap}',
|
|
393
543
|
'.soul-persona-meta{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;color:var(--dsw-alias-label-secondary)}',
|
|
394
|
-
'.soul-persona-actions{display:flex;gap:10px;white-space:nowrap}',
|
|
544
|
+
'.soul-persona-actions{display:flex;gap:10px;white-space:nowrap;align-items:center}',
|
|
545
|
+
'.soul-persona-badge{font-size:11px;line-height:16px;padding:0 6px;border:1px solid var(--dsw-alias-border-l2);border-radius:8px;color:var(--dsw-alias-label-secondary);white-space:nowrap}',
|
|
395
546
|
'.soul-persona-save{display:flex;gap:8px}',
|
|
396
547
|
'.soul-persona-save input[type=text]{flex:1}',
|
|
397
548
|
'.soul-prompt-link{background:none;border:none;padding:0;font-size:12px;color:var(--dsw-alias-label-secondary);cursor:pointer;text-decoration:underline}',
|
|
@@ -403,8 +554,11 @@ window.__ModuleLoader__.load({
|
|
|
403
554
|
'.soul-toast-error{background:#fff1f0;border:1px solid #ffa39e;color:#f5222d}',
|
|
404
555
|
'@keyframes fadeInOut{0%{opacity:0;transform:translate(-50%,-50%) scale(0.9)}15%{opacity:1;transform:translate(-50%,-50%) scale(1)}85%{opacity:1;transform:translate(-50%,-50%) scale(1)}100%{opacity:0;transform:translate(-50%,-50%) scale(0.9)}}',
|
|
405
556
|
// —— 输入框光轨 ——
|
|
406
|
-
//
|
|
407
|
-
|
|
557
|
+
// 几何规则(position/尺寸/contain)同时内联在元素上,见 mountTrailRing;
|
|
558
|
+
// 这里保留一份等价声明作为兜底,并让样式可读、可被第三方主题安全覆盖(仅颜色/速度/粗细)
|
|
559
|
+
'.soul-trail-svg{position:absolute;display:block;pointer-events:none;contain:strict;overflow:hidden;margin:0;padding:0;border:0}',
|
|
560
|
+
// 设置页示例用的零高度挂载锚点:只定位占坑,不参与任何尺寸计算
|
|
561
|
+
'.soul-trail-anchor{position:absolute;inset:0 0 auto;height:0;pointer-events:none}',
|
|
408
562
|
// 速度档位(整体比首版慢一档):normal 3.6s / slow 4.8s / fast 2.4s
|
|
409
563
|
'.soul-trail-layer{fill:none;stroke:var(--soul-trail-color,#679EFE);stroke-width:2.5;stroke-linecap:butt;animation-name:soul-trail-run-0;animation-duration:3.6s;animation-timing-function:linear;animation-iteration-count:infinite}',
|
|
410
564
|
'.soul-trail-layer[data-layer="0"]{opacity:1;stroke-linecap:round}',
|
|
@@ -427,6 +581,7 @@ window.__ModuleLoader__.load({
|
|
|
427
581
|
'[data-soul-trail-speed="fast"] .soul-trail-layer{animation-duration:2.4s}',
|
|
428
582
|
'[data-soul-trail-width="thin"] .soul-trail-layer{stroke-width:1.5}',
|
|
429
583
|
'[data-soul-trail-width="thick"] .soul-trail-layer{stroke-width:4}',
|
|
584
|
+
// 显隐的兜底规则(主路径由 mountTrailRing 的 setVisible 写内联 display)
|
|
430
585
|
'[data-soul-trail="off"] .soul-trail-svg{display:none}',
|
|
431
586
|
// 光轨开启时隐藏宿主输入框自身的细边框(保留 1px 占位,避免布局跳动),
|
|
432
587
|
// 使边界上只存在光轨一条线
|
|
@@ -491,6 +646,10 @@ window.__ModuleLoader__.load({
|
|
|
491
646
|
'hint.headingLists': '在回复风格和语调的基础上选择额外的自定义特质项。控制回答中标题和列表的使用程度。',
|
|
492
647
|
'field.emoji': '表情符号',
|
|
493
648
|
'hint.emoji': '在回复风格和语调的基础上选择额外的自定义特质项。控制表情符号的使用程度。',
|
|
649
|
+
'field.tables': '表格',
|
|
650
|
+
'hint.tables': '在回复风格和语调的基础上选择额外的自定义特质项。控制回答中表格的使用程度。',
|
|
651
|
+
'field.replyLength': '回复长度',
|
|
652
|
+
'hint.replyLength': '控制回答的篇幅。选「适中」时不额外约束,由 Agent 自行判断。',
|
|
494
653
|
'field.language': '输出语言',
|
|
495
654
|
'hint.language': '设置 Agent 回复你使用的语言,同时影响 /soul 命令的输出语言。',
|
|
496
655
|
'field.instructions': '自定义指令',
|
|
@@ -503,6 +662,8 @@ window.__ModuleLoader__.load({
|
|
|
503
662
|
'personas.delete': '删除',
|
|
504
663
|
'personas.confirmDelete': '确定删除预设「{name}」?',
|
|
505
664
|
'personas.empty': '暂无人设预设,保存当前配置后可一键切换',
|
|
665
|
+
'personas.builtin': '内置',
|
|
666
|
+
'personas.hint': '内置预设随插件提供,不可删除;保存当前配置可创建自己的预设',
|
|
506
667
|
'style.professional': '专业严谨',
|
|
507
668
|
'style.casual': '轻松自然',
|
|
508
669
|
'style.humorous': '幽默风趣',
|
|
@@ -514,6 +675,23 @@ window.__ModuleLoader__.load({
|
|
|
514
675
|
'trait.emoji.default': '默认',
|
|
515
676
|
'trait.emoji.more': '增强(使用较多表情符号)',
|
|
516
677
|
'trait.emoji.less': '减弱(尽量减少使用表情符号)',
|
|
678
|
+
'trait.tables.default': '默认',
|
|
679
|
+
'trait.tables.more': '增强(优先用表格呈现对比与多字段信息)',
|
|
680
|
+
'trait.tables.less': '减弱(避免使用表格,改用列表或段落)',
|
|
681
|
+
'trait.replyLength.concise': '简洁(只讲要点,不展开)',
|
|
682
|
+
'trait.replyLength.normal': '适中(不额外约束)',
|
|
683
|
+
'trait.replyLength.detailed': '详尽(充分展开背景与推理)',
|
|
684
|
+
// 预设行摘要用的短标签(trait.* 的完整说明太长,一行放不下)
|
|
685
|
+
'meta.replyLength.concise': '简洁',
|
|
686
|
+
'meta.replyLength.detailed': '详尽',
|
|
687
|
+
'meta.headingLists.more': '多列表',
|
|
688
|
+
'meta.headingLists.less': '少列表',
|
|
689
|
+
'meta.emoji.more': '多表情',
|
|
690
|
+
'meta.emoji.less': '少表情',
|
|
691
|
+
'meta.tables.more': '多用表格',
|
|
692
|
+
'meta.tables.less': '少用表格',
|
|
693
|
+
'meta.language.zh': '中文',
|
|
694
|
+
'meta.language.en': '英文',
|
|
517
695
|
'group.tool': 'Agent 工具',
|
|
518
696
|
'field.toolConfirm': '人设变更需确认',
|
|
519
697
|
'hint.toolConfirm': '开启后,Agent 通过 set_persona 工具做出的修改不会立即生效,需在会话中使用 /soul confirm 确认或 /soul reject 拒绝。',
|
|
@@ -538,6 +716,9 @@ window.__ModuleLoader__.load({
|
|
|
538
716
|
'prompt.loading': '提示词加载中...',
|
|
539
717
|
'prompt.empty': '(个性化已禁用,提示词为空)',
|
|
540
718
|
'prompt.chars': '当前字符数:{n}',
|
|
719
|
+
'prompt.titleDraft': '保存后将生效的提示词',
|
|
720
|
+
'prompt.summaryDraft': '{n} 字符 · 未保存',
|
|
721
|
+
'prompt.invalid': '以下字段未通过校验,未计入本次预览:{fields}',
|
|
541
722
|
'toast.saveFailed': '❌ 保存失败,请检查配置',
|
|
542
723
|
'trail.title': '输入框光轨',
|
|
543
724
|
'trail.enable': '启用输入框光轨',
|
|
@@ -582,6 +763,10 @@ window.__ModuleLoader__.load({
|
|
|
582
763
|
'hint.headingLists': 'An extra trait layered on top of style & tone. Controls how much answers rely on headings and lists.',
|
|
583
764
|
'field.emoji': 'Emoji',
|
|
584
765
|
'hint.emoji': 'An extra trait layered on top of style & tone. Controls how many emojis answers use.',
|
|
766
|
+
'field.tables': 'Tables',
|
|
767
|
+
'hint.tables': 'An extra trait layered on top of style & tone. Controls how much answers rely on tables.',
|
|
768
|
+
'field.replyLength': 'Reply length',
|
|
769
|
+
'hint.replyLength': 'Controls how long answers are. "Balanced" adds no constraint and lets the agent decide.',
|
|
585
770
|
'field.language': 'Output language',
|
|
586
771
|
'hint.language': 'Sets the language the agent replies in; also affects the /soul command output.',
|
|
587
772
|
'field.instructions': 'Custom instructions',
|
|
@@ -594,6 +779,8 @@ window.__ModuleLoader__.load({
|
|
|
594
779
|
'personas.delete': 'Delete',
|
|
595
780
|
'personas.confirmDelete': 'Delete persona "{name}"?',
|
|
596
781
|
'personas.empty': 'No personas yet — save the current config to switch with one click',
|
|
782
|
+
'personas.builtin': 'Built-in',
|
|
783
|
+
'personas.hint': 'Built-in personas ship with the plugin and cannot be deleted; save the current config to create your own',
|
|
597
784
|
'style.professional': 'Professional',
|
|
598
785
|
'style.casual': 'Casual',
|
|
599
786
|
'style.humorous': 'Humorous',
|
|
@@ -605,6 +792,23 @@ window.__ModuleLoader__.load({
|
|
|
605
792
|
'trait.emoji.default': 'Default',
|
|
606
793
|
'trait.emoji.more': 'More (frequent emoji usage)',
|
|
607
794
|
'trait.emoji.less': 'Less (minimal emoji usage)',
|
|
795
|
+
'trait.tables.default': 'Default',
|
|
796
|
+
'trait.tables.more': 'More (prefer tables for comparisons and multi-field data)',
|
|
797
|
+
'trait.tables.less': 'Less (avoid tables; use lists or paragraphs)',
|
|
798
|
+
'trait.replyLength.concise': 'Concise (key points only)',
|
|
799
|
+
'trait.replyLength.normal': 'Balanced (no extra constraint)',
|
|
800
|
+
'trait.replyLength.detailed': 'Detailed (expand background and reasoning)',
|
|
801
|
+
// Short labels for the persona row summary (trait.* full text is too long)
|
|
802
|
+
'meta.replyLength.concise': 'Concise',
|
|
803
|
+
'meta.replyLength.detailed': 'Detailed',
|
|
804
|
+
'meta.headingLists.more': 'More lists',
|
|
805
|
+
'meta.headingLists.less': 'Fewer lists',
|
|
806
|
+
'meta.emoji.more': 'More emoji',
|
|
807
|
+
'meta.emoji.less': 'Less emoji',
|
|
808
|
+
'meta.tables.more': 'More tables',
|
|
809
|
+
'meta.tables.less': 'Fewer tables',
|
|
810
|
+
'meta.language.zh': 'Chinese',
|
|
811
|
+
'meta.language.en': 'English',
|
|
608
812
|
'group.tool': 'Agent tools',
|
|
609
813
|
'field.toolConfirm': 'Require confirmation for persona changes',
|
|
610
814
|
'hint.toolConfirm': 'When enabled, changes made by the agent through the set_persona tool do not apply immediately — confirm with /soul confirm or reject with /soul reject in the conversation.',
|
|
@@ -629,6 +833,9 @@ window.__ModuleLoader__.load({
|
|
|
629
833
|
'prompt.loading': 'Loading prompt...',
|
|
630
834
|
'prompt.empty': '(personalization disabled — the prompt is empty)',
|
|
631
835
|
'prompt.chars': 'Current character count: {n}',
|
|
836
|
+
'prompt.titleDraft': 'Prompt after saving',
|
|
837
|
+
'prompt.summaryDraft': '{n} chars · unsaved',
|
|
838
|
+
'prompt.invalid': 'These fields failed validation and are excluded from this preview: {fields}',
|
|
632
839
|
'toast.saveFailed': '❌ Save failed — please check the config',
|
|
633
840
|
'trail.title': 'Composer light trail',
|
|
634
841
|
'trail.enable': 'Enable composer light trail',
|
|
@@ -670,6 +877,28 @@ window.__ModuleLoader__.load({
|
|
|
670
877
|
// 选项取值(label 走词典;取值与 lib/config.mjs 的合法值保持一致)
|
|
671
878
|
const STYLE_VALUES = ['professional', 'casual', 'humorous', 'roast', 'efficient']
|
|
672
879
|
const TRAIT_VALUES = ['default', 'more', 'less']
|
|
880
|
+
// 回复长度偏好(与宿主 lib/config.mjs 的 REPLY_LENGTH_VALUES 对齐)
|
|
881
|
+
const REPLY_LENGTH_VALUES = ['concise', 'normal', 'detailed']
|
|
882
|
+
// 输出语言(与宿主 lib/config.mjs 的 LANGUAGE_VALUES 对齐)
|
|
883
|
+
const LANGUAGE_VALUES = ['zh', 'en']
|
|
884
|
+
|
|
885
|
+
// 预设行摘要只显示「与默认值不同」的字段——若把 10 个字段全列出来,每行都是
|
|
886
|
+
// 一长串「默认 / 适中」,反而看不出两个预设到底差在哪。默认值须与宿主
|
|
887
|
+
// lib/config.mjs 的 DEFAULT_CONFIG 保持一致。
|
|
888
|
+
const META_FIELD_VALUES = {
|
|
889
|
+
replyLength: REPLY_LENGTH_VALUES,
|
|
890
|
+
headingLists: TRAIT_VALUES,
|
|
891
|
+
emoji: TRAIT_VALUES,
|
|
892
|
+
tables: TRAIT_VALUES,
|
|
893
|
+
language: LANGUAGE_VALUES
|
|
894
|
+
}
|
|
895
|
+
const META_FIELD_DEFAULTS = {
|
|
896
|
+
replyLength: 'normal',
|
|
897
|
+
headingLists: 'default',
|
|
898
|
+
emoji: 'default',
|
|
899
|
+
tables: 'default',
|
|
900
|
+
language: 'zh'
|
|
901
|
+
}
|
|
673
902
|
// 输出语言选项(两种 UI 语言下均自解释,不进词典)
|
|
674
903
|
const LANGUAGE_OPTIONS = [
|
|
675
904
|
{ value: 'zh', label: '中文' },
|
|
@@ -677,7 +906,12 @@ window.__ModuleLoader__.load({
|
|
|
677
906
|
]
|
|
678
907
|
|
|
679
908
|
// 表单字段与 store 字段的一一对应(dirty 检测与保存载荷共用)
|
|
680
|
-
const FIELD_KEYS = ['enabled', 'nickname', 'occupation', 'bio', 'style', 'headingLists', 'emoji', 'language', 'customInstructions', 'requireToolConfirmation', 'trailEnabled', 'trailColor', 'trailSpeed', 'trailWidth']
|
|
909
|
+
const FIELD_KEYS = ['enabled', 'nickname', 'occupation', 'bio', 'style', 'headingLists', 'emoji', 'tables', 'replyLength', 'language', 'customInstructions', 'requireToolConfirmation', 'trailEnabled', 'trailColor', 'trailSpeed', 'trailWidth']
|
|
910
|
+
|
|
911
|
+
// 其中真正参与 compilePrompt 的字段子集。
|
|
912
|
+
// 提示词预览只依赖它们:改光轨颜色 / 粗细、切换 set_persona 确认模式都不会改变
|
|
913
|
+
// 编译结果,不该因此重新请求,也不该让预览被标成「未保存」。
|
|
914
|
+
const PROMPT_FIELD_KEYS = ['enabled', 'nickname', 'occupation', 'bio', 'style', 'headingLists', 'emoji', 'tables', 'replyLength', 'language', 'customInstructions']
|
|
681
915
|
|
|
682
916
|
// 提示词小图标:hover 展示说明文字
|
|
683
917
|
function SoulHint(props) {
|
|
@@ -753,7 +987,7 @@ window.__ModuleLoader__.load({
|
|
|
753
987
|
// 渲染器按槽位 locale 命名空间注入 t(随语言切换更新);缺失时回退中文
|
|
754
988
|
const t = typeof props.t === 'function' ? props.t : FALLBACK_T
|
|
755
989
|
const state = useSoulController((state) => state)
|
|
756
|
-
const { enabled, nickname, occupation, bio, style, headingLists, emoji, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth, personas, activePersona, loading, saving, error } = state
|
|
990
|
+
const { enabled, nickname, occupation, bio, style, headingLists, emoji, tables, replyLength, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth, personas, activePersona, loading, saving, error } = state
|
|
757
991
|
|
|
758
992
|
const [localEnabled, setLocalEnabled] = React.useState(enabled)
|
|
759
993
|
const [localNickname, setLocalNickname] = React.useState(nickname || '')
|
|
@@ -762,6 +996,8 @@ window.__ModuleLoader__.load({
|
|
|
762
996
|
const [localStyle, setLocalStyle] = React.useState(style)
|
|
763
997
|
const [localHeadingLists, setLocalHeadingLists] = React.useState(headingLists)
|
|
764
998
|
const [localEmoji, setLocalEmoji] = React.useState(emoji)
|
|
999
|
+
const [localTables, setLocalTables] = React.useState(tables)
|
|
1000
|
+
const [localReplyLength, setLocalReplyLength] = React.useState(replyLength)
|
|
765
1001
|
const [localLanguage, setLocalLanguage] = React.useState(language || 'zh')
|
|
766
1002
|
const [localInstructions, setLocalInstructions] = React.useState(customInstructions)
|
|
767
1003
|
const [localToolConfirm, setLocalToolConfirm] = React.useState(requireToolConfirmation === true)
|
|
@@ -775,6 +1011,10 @@ window.__ModuleLoader__.load({
|
|
|
775
1011
|
const [promptText, setPromptText] = React.useState('')
|
|
776
1012
|
const [promptLoading, setPromptLoading] = React.useState(false)
|
|
777
1013
|
const [promptError, setPromptError] = React.useState(null)
|
|
1014
|
+
// 当前预览的是「未保存的编辑」编译结果(true)还是已生效的提示词(false)
|
|
1015
|
+
const [promptIsDraft, setPromptIsDraft] = React.useState(false)
|
|
1016
|
+
// 未通过校验、因而未计入预览的字段名(服务端返回 invalid)
|
|
1017
|
+
const [promptInvalid, setPromptInvalid] = React.useState([])
|
|
778
1018
|
const [openSection, setOpenSection] = React.useState(() => {
|
|
779
1019
|
try {
|
|
780
1020
|
return globalThis.localStorage?.getItem('dsh-soul:open-section') || 'about'
|
|
@@ -801,6 +1041,8 @@ window.__ModuleLoader__.load({
|
|
|
801
1041
|
setLocalStyle(style)
|
|
802
1042
|
setLocalHeadingLists(headingLists)
|
|
803
1043
|
setLocalEmoji(emoji)
|
|
1044
|
+
setLocalTables(tables)
|
|
1045
|
+
setLocalReplyLength(replyLength)
|
|
804
1046
|
setLocalLanguage(language || 'zh')
|
|
805
1047
|
setLocalInstructions(customInstructions)
|
|
806
1048
|
setLocalToolConfirm(requireToolConfirmation === true)
|
|
@@ -808,7 +1050,7 @@ window.__ModuleLoader__.load({
|
|
|
808
1050
|
setLocalTrailColor(trailColor || TRAIL_COLOR_FALLBACK)
|
|
809
1051
|
setLocalTrailSpeed(trailSpeed || 'slow')
|
|
810
1052
|
setLocalTrailWidth(trailWidth || 'thin')
|
|
811
|
-
}, [enabled, nickname, occupation, bio, style, headingLists, emoji, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth])
|
|
1053
|
+
}, [enabled, nickname, occupation, bio, style, headingLists, emoji, tables, replyLength, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth])
|
|
812
1054
|
|
|
813
1055
|
// toast 自动消失
|
|
814
1056
|
React.useEffect(() => {
|
|
@@ -819,16 +1061,36 @@ window.__ModuleLoader__.load({
|
|
|
819
1061
|
}, [toast])
|
|
820
1062
|
|
|
821
1063
|
// dirty 检测:本地表单与已保存配置逐字段比较
|
|
822
|
-
const savedMap = { enabled, nickname, occupation, bio, style, headingLists, emoji, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth }
|
|
823
|
-
const localMap = { enabled: localEnabled, nickname: localNickname, occupation: localOccupation, bio: localBio, style: localStyle, headingLists: localHeadingLists, emoji: localEmoji, language: localLanguage, customInstructions: localInstructions, requireToolConfirmation: localToolConfirm, trailEnabled: localTrailEnabled, trailColor: localTrailColor, trailSpeed: localTrailSpeed, trailWidth: localTrailWidth }
|
|
1064
|
+
const savedMap = { enabled, nickname, occupation, bio, style, headingLists, emoji, tables, replyLength, language, customInstructions, requireToolConfirmation, trailEnabled, trailColor, trailSpeed, trailWidth }
|
|
1065
|
+
const localMap = { enabled: localEnabled, nickname: localNickname, occupation: localOccupation, bio: localBio, style: localStyle, headingLists: localHeadingLists, emoji: localEmoji, tables: localTables, replyLength: localReplyLength, language: localLanguage, customInstructions: localInstructions, requireToolConfirmation: localToolConfirm, trailEnabled: localTrailEnabled, trailColor: localTrailColor, trailSpeed: localTrailSpeed, trailWidth: localTrailWidth }
|
|
824
1066
|
const dirty = FIELD_KEYS.some((key) => savedMap[key] !== localMap[key])
|
|
825
1067
|
|
|
1068
|
+
// 预览是否反映未保存的编辑:只看参与编译的字段(见 PROMPT_FIELD_KEYS)。
|
|
1069
|
+
// 这里用 localMap/savedMap 逐字段比,而不是复用上面的 dirty —— 改光轨颜色会让
|
|
1070
|
+
// dirty 为真,但那不影响提示词,此时预览仍是「已生效内容」,标成草稿反而误导。
|
|
1071
|
+
const promptDirty = PROMPT_FIELD_KEYS.some((key) => savedMap[key] !== localMap[key])
|
|
1072
|
+
// 草稿指纹:仅在影响编译的字段真的变化时才重新预览
|
|
1073
|
+
const promptDraftKey = PROMPT_FIELD_KEYS.map((key) => String(localMap[key])).join('\u0000')
|
|
1074
|
+
|
|
1075
|
+
// 只把参与编译的字段发给预览端点:光轨等字段的校验失败不该出现在提示词预览里
|
|
1076
|
+
const promptDraft = () => {
|
|
1077
|
+
const out = {}
|
|
1078
|
+
for (const key of PROMPT_FIELD_KEYS) out[key] = localMap[key]
|
|
1079
|
+
return out
|
|
1080
|
+
}
|
|
1081
|
+
|
|
1082
|
+
// 有未保存编辑时预览草稿(=保存后真正会注入的内容),否则预览已生效提示词
|
|
826
1083
|
const loadPrompt = async () => {
|
|
1084
|
+
const asDraft = promptDirty
|
|
827
1085
|
setPromptLoading(true)
|
|
828
1086
|
setPromptError(null)
|
|
829
1087
|
try {
|
|
830
|
-
const payload =
|
|
1088
|
+
const payload = asDraft
|
|
1089
|
+
? await controller.previewPrompt(promptDraft())
|
|
1090
|
+
: await controller.fetchPrompt()
|
|
831
1091
|
setPromptText(payload.prompt || '')
|
|
1092
|
+
setPromptInvalid(Array.isArray(payload.invalid) ? payload.invalid : [])
|
|
1093
|
+
setPromptIsDraft(asDraft)
|
|
832
1094
|
} catch (err) {
|
|
833
1095
|
setPromptError(messageOf(err))
|
|
834
1096
|
} finally {
|
|
@@ -836,11 +1098,8 @@ window.__ModuleLoader__.load({
|
|
|
836
1098
|
}
|
|
837
1099
|
}
|
|
838
1100
|
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
setShowPrompt(next)
|
|
842
|
-
if (next) await loadPrompt()
|
|
843
|
-
}
|
|
1101
|
+
// 展开/收起只切状态;编译由下方 effect 统一驱动(唯一入口,避免重复请求)
|
|
1102
|
+
const togglePrompt = () => setShowPrompt((open) => !open)
|
|
844
1103
|
|
|
845
1104
|
const loadPersonas = async () => {
|
|
846
1105
|
try {
|
|
@@ -876,6 +1135,28 @@ window.__ModuleLoader__.load({
|
|
|
876
1135
|
}
|
|
877
1136
|
}, [controller, dirty, saving])
|
|
878
1137
|
|
|
1138
|
+
// 提示词预览的编译入口(唯一)。
|
|
1139
|
+
// 展开时立即编译一次;此后只要影响编译的字段或脏状态变化,停止 400ms 再编译 —
|
|
1140
|
+
// 边改边看保存后真正会注入的内容。
|
|
1141
|
+
// promptSettled 用来区分「刚展开」与「展开后字段又变了」:否则展开这一动作自身
|
|
1142
|
+
// 会先立即编译一次、再被防抖重复编译一次。
|
|
1143
|
+
// 依赖里刻意不放 loadPrompt(组件体内每次渲染都会重建函数,放进去会无限循环);
|
|
1144
|
+
// 两个依赖项任一变化都会让 effect 带着最新闭包重跑,闭包不会过期。
|
|
1145
|
+
const promptSettled = React.useRef(false)
|
|
1146
|
+
React.useEffect(() => {
|
|
1147
|
+
if (!showPrompt) {
|
|
1148
|
+
promptSettled.current = false
|
|
1149
|
+
return
|
|
1150
|
+
}
|
|
1151
|
+
if (!promptSettled.current) {
|
|
1152
|
+
promptSettled.current = true
|
|
1153
|
+
void loadPrompt()
|
|
1154
|
+
return
|
|
1155
|
+
}
|
|
1156
|
+
const timer = setTimeout(() => { void loadPrompt() }, 400)
|
|
1157
|
+
return () => clearTimeout(timer)
|
|
1158
|
+
}, [showPrompt, promptDraftKey, promptDirty])
|
|
1159
|
+
|
|
879
1160
|
const handleSave = async () => {
|
|
880
1161
|
const payload = await controller.saveConfig(localMap)
|
|
881
1162
|
// saveConfig 失败时内部已记录 error 并返回 undefined:给出失败提示,而非误报「无变化」
|
|
@@ -887,13 +1168,15 @@ window.__ModuleLoader__.load({
|
|
|
887
1168
|
text: Array.isArray(payload.changed) && payload.changed.length > 0 ? t('toast.saved') : t('toast.noChanges'),
|
|
888
1169
|
kind: 'success'
|
|
889
1170
|
})
|
|
890
|
-
|
|
1171
|
+
// 预览刷新交由下方 effect 统一驱动(保存 / 重置 / 应用预设都会改变
|
|
1172
|
+
// promptDraftKey 或 promptDirty,effect 自会带上最新闭包重编译)
|
|
891
1173
|
}
|
|
892
1174
|
|
|
893
1175
|
const handleReset = async () => {
|
|
894
1176
|
await controller.resetConfig()
|
|
895
1177
|
setToast({ text: t('toast.reset'), kind: 'success' })
|
|
896
|
-
|
|
1178
|
+
// 预览刷新交由下方 effect 统一驱动(保存 / 重置 / 应用预设都会改变
|
|
1179
|
+
// promptDraftKey 或 promptDirty,effect 自会带上最新闭包重编译)
|
|
897
1180
|
}
|
|
898
1181
|
|
|
899
1182
|
const handleSavePersona = async () => {
|
|
@@ -914,7 +1197,8 @@ window.__ModuleLoader__.load({
|
|
|
914
1197
|
const payload = await controller.usePersona(name)
|
|
915
1198
|
await loadPersonas()
|
|
916
1199
|
setToast({ text: payload && payload.unchanged ? t('toast.personaUnchanged') : t('toast.personaUsed'), kind: 'success' })
|
|
917
|
-
|
|
1200
|
+
// 预览刷新交由下方 effect 统一驱动(保存 / 重置 / 应用预设都会改变
|
|
1201
|
+
// promptDraftKey 或 promptDirty,effect 自会带上最新闭包重编译)
|
|
918
1202
|
} catch (err) {
|
|
919
1203
|
setToast({ text: messageOf(err), kind: 'error' })
|
|
920
1204
|
}
|
|
@@ -934,24 +1218,44 @@ window.__ModuleLoader__.load({
|
|
|
934
1218
|
const styleOptions = STYLE_VALUES.map((value) => ({ value, label: t(`style.${value}`) }))
|
|
935
1219
|
const headingListsOptions = TRAIT_VALUES.map((value) => ({ value, label: t(`trait.headingLists.${value}`) }))
|
|
936
1220
|
const emojiOptions = TRAIT_VALUES.map((value) => ({ value, label: t(`trait.emoji.${value}`) }))
|
|
937
|
-
const
|
|
1221
|
+
const tablesOptions = TRAIT_VALUES.map((value) => ({ value, label: t(`trait.tables.${value}`) }))
|
|
1222
|
+
const replyLengthOptions = REPLY_LENGTH_VALUES.map((value) => ({ value, label: t(`trait.replyLength.${value}`) }))
|
|
1223
|
+
// 内置预设排在前面(沿用宿主返回的定义顺序,便于发现),用户预设紧随其后。
|
|
1224
|
+
// Array.prototype.sort 自 ES2019 起保证稳定,同类项因此维持原有插入顺序。
|
|
1225
|
+
const personaNames = personas
|
|
1226
|
+
? Object.keys(personas).sort((a, b) => {
|
|
1227
|
+
const aBuiltin = personas[a] && personas[a].builtin ? 0 : 1
|
|
1228
|
+
const bBuiltin = personas[b] && personas[b].builtin ? 0 : 1
|
|
1229
|
+
return aBuiltin - bBuiltin
|
|
1230
|
+
})
|
|
1231
|
+
: null
|
|
938
1232
|
const aboutFilled = [localNickname, localOccupation, localBio].filter(Boolean).length
|
|
939
1233
|
const aboutSummary = aboutFilled > 0 ? `${aboutFilled}/3 ${t('accordion.filled')}` : t('accordion.empty')
|
|
940
1234
|
const traitsSummary = t(`style.${localStyle}`)
|
|
941
1235
|
const personasSummary = personas === null ? t('status.loading') : `${Object.keys(personas).length} ${t('accordion.personas')}`
|
|
942
1236
|
const toolSummary = localToolConfirm ? t('accordion.on') : t('accordion.off')
|
|
943
1237
|
const promptSummary = promptText.length > 0
|
|
944
|
-
? t('prompt.summaryChars', { n: String(promptText.length) })
|
|
1238
|
+
? t(promptIsDraft ? 'prompt.summaryDraft' : 'prompt.summaryChars', { n: String(promptText.length) })
|
|
945
1239
|
: (enabled ? t('prompt.summaryEnabled') : t('prompt.summaryDisabled'))
|
|
946
1240
|
const toggleSection = (section) => () => {
|
|
947
1241
|
setOpenSection(current => current === section ? null : section)
|
|
948
1242
|
}
|
|
949
1243
|
|
|
1244
|
+
// 预设行摘要:风格 + 昵称 + 所有「偏离默认值」的维度。
|
|
1245
|
+
// 内置预设刻意不声明昵称等用户自有信息,所以它们只显示风格与维度差异——
|
|
1246
|
+
// 这恰好也是比较两个预设时最需要看到的信息。
|
|
950
1247
|
const personaRowMeta = (entry) => {
|
|
1248
|
+
const row = entry || {}
|
|
951
1249
|
const parts = []
|
|
952
|
-
if (
|
|
953
|
-
else if (
|
|
954
|
-
if (
|
|
1250
|
+
if (STYLE_VALUES.includes(row.style)) parts.push(t(`style.${row.style}`))
|
|
1251
|
+
else if (row.style) parts.push(row.style)
|
|
1252
|
+
if (row.nickname) parts.push(row.nickname)
|
|
1253
|
+
for (const [field, allowed] of Object.entries(META_FIELD_VALUES)) {
|
|
1254
|
+
const value = row[field]
|
|
1255
|
+
if (!value || value === META_FIELD_DEFAULTS[field]) continue
|
|
1256
|
+
if (!allowed.includes(value)) continue
|
|
1257
|
+
parts.push(t(`meta.${field}.${value}`))
|
|
1258
|
+
}
|
|
955
1259
|
return parts.join(' · ')
|
|
956
1260
|
}
|
|
957
1261
|
|
|
@@ -1056,6 +1360,32 @@ window.__ModuleLoader__.load({
|
|
|
1056
1360
|
...emojiOptions.map(opt => e('option', { key: opt.value, value: opt.value }, opt.label))
|
|
1057
1361
|
)
|
|
1058
1362
|
),
|
|
1363
|
+
e('div', { className: 'soul-field' },
|
|
1364
|
+
e('label', { htmlFor: 'soul-tables' },
|
|
1365
|
+
t('field.tables'),
|
|
1366
|
+
e(SoulHint, { text: t('hint.tables') })
|
|
1367
|
+
),
|
|
1368
|
+
e('select', {
|
|
1369
|
+
id: 'soul-tables',
|
|
1370
|
+
value: localTables,
|
|
1371
|
+
onChange: (ev) => setLocalTables(ev.target.value)
|
|
1372
|
+
},
|
|
1373
|
+
...tablesOptions.map(opt => e('option', { key: opt.value, value: opt.value }, opt.label))
|
|
1374
|
+
)
|
|
1375
|
+
),
|
|
1376
|
+
e('div', { className: 'soul-field' },
|
|
1377
|
+
e('label', { htmlFor: 'soul-replyLength' },
|
|
1378
|
+
t('field.replyLength'),
|
|
1379
|
+
e(SoulHint, { text: t('hint.replyLength') })
|
|
1380
|
+
),
|
|
1381
|
+
e('select', {
|
|
1382
|
+
id: 'soul-replyLength',
|
|
1383
|
+
value: localReplyLength,
|
|
1384
|
+
onChange: (ev) => setLocalReplyLength(ev.target.value)
|
|
1385
|
+
},
|
|
1386
|
+
...replyLengthOptions.map(opt => e('option', { key: opt.value, value: opt.value }, opt.label))
|
|
1387
|
+
)
|
|
1388
|
+
),
|
|
1059
1389
|
e('div', { className: 'soul-field' },
|
|
1060
1390
|
e('label', { htmlFor: 'soul-language' },
|
|
1061
1391
|
t('field.language'),
|
|
@@ -1098,12 +1428,16 @@ window.__ModuleLoader__.load({
|
|
|
1098
1428
|
: e(Fragment, null,
|
|
1099
1429
|
...personaNames.map((name) => {
|
|
1100
1430
|
const entry = personas[name] || {}
|
|
1431
|
+
// 内置预设不提供删除(后端也会拒绝),在 actions 区原删除按钮的
|
|
1432
|
+
// 位置显示「内置」标记,行宽因此不会跳动。
|
|
1433
|
+
const builtin = !!entry.builtin
|
|
1101
1434
|
return e('div', { className: 'soul-persona-row', key: name },
|
|
1102
1435
|
e('span', { className: 'soul-persona-name' }, name === activePersona ? `★ ${name}` : name),
|
|
1103
1436
|
e('span', { className: 'soul-persona-meta' }, personaRowMeta(entry)),
|
|
1104
1437
|
e('span', { className: 'soul-persona-actions' },
|
|
1438
|
+
builtin && e('span', { className: 'soul-persona-badge' }, t('personas.builtin')),
|
|
1105
1439
|
e('button', { type: 'button', className: 'soul-prompt-link', onClick: () => handleUsePersona(name) }, t('personas.use')),
|
|
1106
|
-
e('button', { type: 'button', className: 'soul-prompt-link soul-persona-danger', onClick: () => handleDeletePersona(name) }, t('personas.delete'))
|
|
1440
|
+
!builtin && e('button', { type: 'button', className: 'soul-prompt-link soul-persona-danger', onClick: () => handleDeletePersona(name) }, t('personas.delete'))
|
|
1107
1441
|
)
|
|
1108
1442
|
)
|
|
1109
1443
|
})
|
|
@@ -1121,7 +1455,8 @@ window.__ModuleLoader__.load({
|
|
|
1121
1455
|
onClick: handleSavePersona,
|
|
1122
1456
|
disabled: saving || !personaName.trim()
|
|
1123
1457
|
}, t('personas.save'))
|
|
1124
|
-
)
|
|
1458
|
+
),
|
|
1459
|
+
e('div', { className: 'soul-status' }, t('personas.hint'))
|
|
1125
1460
|
),
|
|
1126
1461
|
|
|
1127
1462
|
e(SoulAccordion, {
|
|
@@ -1222,7 +1557,7 @@ window.__ModuleLoader__.load({
|
|
|
1222
1557
|
|
|
1223
1558
|
e(SoulAccordion, {
|
|
1224
1559
|
id: 'soul-prompt',
|
|
1225
|
-
title: t('prompt.title'),
|
|
1560
|
+
title: t(promptIsDraft ? 'prompt.titleDraft' : 'prompt.title'),
|
|
1226
1561
|
summary: promptSummary,
|
|
1227
1562
|
open: showPrompt,
|
|
1228
1563
|
onToggle: togglePrompt
|
|
@@ -1233,7 +1568,9 @@ window.__ModuleLoader__.load({
|
|
|
1233
1568
|
? e('div', { className: 'soul-error' }, promptError)
|
|
1234
1569
|
: e(Fragment, null,
|
|
1235
1570
|
e('pre', { className: 'soul-prompt-pre' }, promptText || t('prompt.empty')),
|
|
1236
|
-
e('div', { className: 'soul-status' }, t('prompt.chars', { n: String(promptText.length) }))
|
|
1571
|
+
e('div', { className: 'soul-status' }, t('prompt.chars', { n: String(promptText.length) })),
|
|
1572
|
+
promptInvalid.length > 0 && e('div', { className: 'soul-error' },
|
|
1573
|
+
t('prompt.invalid', { fields: promptInvalid.join('、') }))
|
|
1237
1574
|
))
|
|
1238
1575
|
),
|
|
1239
1576
|
|
|
@@ -1266,18 +1603,31 @@ window.__ModuleLoader__.load({
|
|
|
1266
1603
|
// 输入框光轨:组件
|
|
1267
1604
|
// -------------------------------------------------------------------------
|
|
1268
1605
|
|
|
1269
|
-
//
|
|
1270
|
-
//
|
|
1606
|
+
// 设置页内的实时示例:与线上光轨共用同一渲染层、同一挂载点解析(resolveTrailMountPoint)
|
|
1607
|
+
// 与同一份 CSS,因此「示例所见」即「回复时所得」;颜色/速度/粗细随表单实时联动。
|
|
1271
1608
|
function SoulTrailPreview(props) {
|
|
1272
1609
|
const t = typeof props.t === 'function' ? props.t : FALLBACK_T
|
|
1273
1610
|
const hostRef = React.useRef(null)
|
|
1611
|
+
const anchorRef = React.useRef(null)
|
|
1612
|
+
const mountedRef = React.useRef(null)
|
|
1274
1613
|
|
|
1275
1614
|
React.useEffect(() => {
|
|
1276
1615
|
const host = hostRef.current
|
|
1277
1616
|
if (!host) return undefined
|
|
1278
|
-
|
|
1617
|
+
// 与线上 SoulTrail 同一条路径:解析出的挂载点即示例内的零高度锚点 .soul-trail-anchor
|
|
1618
|
+
const mounted = mountTrailRing(host, resolveTrailMountPoint(host, anchorRef.current))
|
|
1619
|
+
mountedRef.current = mounted
|
|
1620
|
+
return () => {
|
|
1621
|
+
mountedRef.current = null
|
|
1622
|
+
mounted.unmount()
|
|
1623
|
+
}
|
|
1279
1624
|
}, [])
|
|
1280
1625
|
|
|
1626
|
+
React.useEffect(() => {
|
|
1627
|
+
const mounted = mountedRef.current
|
|
1628
|
+
if (mounted) mounted.setVisible(props.enabled !== false)
|
|
1629
|
+
}, [props.enabled])
|
|
1630
|
+
|
|
1281
1631
|
return e('div', {
|
|
1282
1632
|
ref: hostRef,
|
|
1283
1633
|
className: 'soul-trail-preview',
|
|
@@ -1286,6 +1636,8 @@ window.__ModuleLoader__.load({
|
|
|
1286
1636
|
'data-soul-trail-width': props.width || 'thin',
|
|
1287
1637
|
style: { '--soul-trail-color': safeTrailColor(props.color) }
|
|
1288
1638
|
},
|
|
1639
|
+
// 零高度挂载锚点(与 DSH composer 的 .overlayAnchor 同形态):环挂在这里,见 resolveTrailMountPoint
|
|
1640
|
+
e('div', { ref: anchorRef, className: 'soul-trail-anchor', 'aria-hidden': 'true' }),
|
|
1289
1641
|
e('span', { className: 'soul-trail-preview-text' }, t('trail.previewText'))
|
|
1290
1642
|
)
|
|
1291
1643
|
}
|
|
@@ -1307,36 +1659,44 @@ window.__ModuleLoader__.load({
|
|
|
1307
1659
|
React.useEffect(() => {
|
|
1308
1660
|
const anchor = anchorRef.current
|
|
1309
1661
|
// 组件位于卡片内的 overlay 锚点中,closest 定位可避免全局查询误命中
|
|
1310
|
-
const
|
|
1662
|
+
const card = anchor && typeof anchor.closest === 'function'
|
|
1311
1663
|
? anchor.closest('[data-composer-card]')
|
|
1312
1664
|
: null
|
|
1313
|
-
if (!
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
//
|
|
1317
|
-
|
|
1665
|
+
if (!card) return undefined
|
|
1666
|
+
|
|
1667
|
+
// 环挂到卡片内那个零高度的 overlay 锚点上(锚点高度写死为 0,环退回常规流
|
|
1668
|
+
// 也撑不动卡片);退回卡片本身时仍由内联 position/contain 兜底,
|
|
1669
|
+
// 见渲染层「隔离不变量」注释
|
|
1670
|
+
const mountPoint = resolveTrailMountPoint(card, anchor)
|
|
1671
|
+
const mounted = mountTrailRing(card, mountPoint)
|
|
1672
|
+
mountedRef.current = { card, mounted }
|
|
1673
|
+
// 先置为隐藏:效果在首帧绘制后执行,先隐藏可避免挂载瞬间闪出一帧光轨
|
|
1674
|
+
card.setAttribute('data-soul-trail', 'off')
|
|
1675
|
+
mounted.setVisible(false)
|
|
1318
1676
|
return () => {
|
|
1319
|
-
const
|
|
1677
|
+
const current = mountedRef.current
|
|
1320
1678
|
mountedRef.current = null
|
|
1321
|
-
if (!
|
|
1322
|
-
mounted.unmount()
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1679
|
+
if (!current) return
|
|
1680
|
+
current.mounted.unmount()
|
|
1681
|
+
current.card.removeAttribute('data-soul-trail')
|
|
1682
|
+
current.card.removeAttribute('data-soul-trail-speed')
|
|
1683
|
+
current.card.removeAttribute('data-soul-trail-width')
|
|
1684
|
+
current.card.style.removeProperty('--soul-trail-color')
|
|
1327
1685
|
}
|
|
1328
1686
|
}, [])
|
|
1329
1687
|
|
|
1330
1688
|
// 显隐与外观同步:仅「Agent 回复中 + 光轨开关开启」时显示
|
|
1331
1689
|
React.useEffect(() => {
|
|
1332
|
-
const
|
|
1333
|
-
if (!
|
|
1334
|
-
const {
|
|
1690
|
+
const current = mountedRef.current
|
|
1691
|
+
if (!current) return
|
|
1692
|
+
const { card, mounted } = current
|
|
1335
1693
|
const enabled = state !== null && state.trailEnabled === true
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1694
|
+
const visible = running && enabled
|
|
1695
|
+
card.setAttribute('data-soul-trail', visible ? 'on' : 'off')
|
|
1696
|
+
card.setAttribute('data-soul-trail-speed', (state && state.trailSpeed) || 'slow')
|
|
1697
|
+
card.setAttribute('data-soul-trail-width', (state && state.trailWidth) || 'thin')
|
|
1698
|
+
card.style.setProperty('--soul-trail-color', safeTrailColor(state && state.trailColor))
|
|
1699
|
+
mounted.setVisible(visible)
|
|
1340
1700
|
}, [running, state])
|
|
1341
1701
|
|
|
1342
1702
|
return e('span', { ref: anchorRef, hidden: true, 'aria-hidden': true })
|
|
@@ -1364,11 +1724,79 @@ window.__ModuleLoader__.load({
|
|
|
1364
1724
|
// 导航 label / 图标替换用的翻译函数(bind 返回的函数在调用时读取当前语言)
|
|
1365
1725
|
const navT = ctx.locale.bind(NS)
|
|
1366
1726
|
|
|
1367
|
-
// DSH
|
|
1368
|
-
//
|
|
1727
|
+
// DSH 的设置导航图标是壳层硬编码的 id → 图标映射(见 ui-settings-general 的
|
|
1728
|
+
// navIcon():account/models/agent-presets/plugins/archived-sessions,其余一律
|
|
1729
|
+
// 回退成设置齿轮),插件无法通过槽位声明自己的图标(settings.section 的选项
|
|
1730
|
+
// 只有 id / order / label)。因此改用 DOM 替换,把齿轮换成与插件图标同一套
|
|
1731
|
+
// 几何的「灵魂火花 + 光轨」(类似 dsh-better-sidebar 的方案)。
|
|
1369
1732
|
const SOUL_NAV_MARKER = 'data-soul-settings-nav'
|
|
1370
1733
|
const SOUL_ICON_MARKER = 'data-soul-icon-replaced'
|
|
1371
1734
|
|
|
1735
|
+
// 与 assets/icon.svg(插件图标)同源几何:同一条光轨与火花路径。
|
|
1736
|
+
// 客户端读不到文件系统,只能内联一份;verify-nav-icon.mjs 有断言核对二者的
|
|
1737
|
+
// 路径数据逐字一致,防止漂移。
|
|
1738
|
+
//
|
|
1739
|
+
// 与插件图标有两处**有意差异**,都是为了与设置导航里的兄弟栏目看齐:
|
|
1740
|
+
// 1) 颜色——插件图标是彩色渐变,而导航栏那一排图标全是单色线描(壳层
|
|
1741
|
+
// navIcon() 生成的宿主机图标用 stroke="currentColor")。这里同样用
|
|
1742
|
+
// currentColor:既与邻居统一,又能自动跟随主题、选中态与禁用态,
|
|
1743
|
+
// 不必自己判断暗色模式。
|
|
1744
|
+
// 2) 显示窗口——icon.svg 用 `0 0 36 36`(图形含描边占 26.8 单位,留白适合
|
|
1745
|
+
// 列表里的大图标)。导航栏旁的宿主图标实测几乎满格——16px 下墨迹跨度
|
|
1746
|
+
// 14.25px(占 89%),所以沿用 36 网格会让这个小图标显得又小又轻。这里把
|
|
1747
|
+
// 窗口收紧到「同一个中心 (18,18)、边长 28.4」,让墨迹跨度落到 ~14px。
|
|
1748
|
+
// 数值是量出来的:预览探针把两种图标渲染到 canvas 逐像素统计。
|
|
1749
|
+
const NAV_ICON_VIEW_BOX = '3.8 3.8 28.4 28.4'
|
|
1750
|
+
const NAV_ICON_TRAIL_D = 'M18 6A12 12 0 1 1 6.72 22.1'
|
|
1751
|
+
const NAV_ICON_SPARK_D = 'M18 11.6C18.52 15.15 20.85 17.48 24.4 18C20.85 18.52 18.52 20.85 18 24.4C17.48 20.85 15.15 18.52 11.6 18C15.15 17.48 17.48 15.15 18 11.6Z'
|
|
1752
|
+
// 线宽按**显示后的像素**与邻居对齐:宿主图标是 16 网格 + 1.3 线宽,而我们
|
|
1753
|
+
// 的窗口是 28.4 单位宽、显示成 16px(缩放 16 ÷ 28.4 ≈ 0.5634),所以取
|
|
1754
|
+
// 1.3 ÷ 0.5634 ≈ 2.3。照搬 icon.svg 的 2.8 会让弧线比邻居粗一圈。
|
|
1755
|
+
const NAV_ICON_STROKE_WIDTH = '2.3'
|
|
1756
|
+
// 宿主按 size=16 渲染,宽高是 svg 的属性(不是 CSS)。万一将来改由 CSS 控制尺寸,
|
|
1757
|
+
// 我们也补一个 16——否则 svg 会退回 300×150 的默认尺寸,把导航栏撑坏。
|
|
1758
|
+
const NAV_ICON_FALLBACK_SIZE = '16'
|
|
1759
|
+
const SVG_NS = 'http://www.w3.org/2000/svg'
|
|
1760
|
+
|
|
1761
|
+
/** 建一个 SVG 元素并铺上属性(避免 innerHTML,无需解析)。 */
|
|
1762
|
+
const svgNode = (name, attributes) => {
|
|
1763
|
+
const node = document.createElementNS(SVG_NS, name)
|
|
1764
|
+
for (const [key, value] of Object.entries(attributes)) node.setAttribute(key, value)
|
|
1765
|
+
return node
|
|
1766
|
+
}
|
|
1767
|
+
|
|
1768
|
+
/**
|
|
1769
|
+
* 把导航按钮里宿主生成的齿轮图标改画成插件图标(单色版)。
|
|
1770
|
+
*
|
|
1771
|
+
* 只替换 <svg> 的内容与 viewBox,保留节点本身——宿主的 className
|
|
1772
|
+
* (…navIcon,flex:none)、width/height(size=16)与 aria-hidden 因此
|
|
1773
|
+
* 原样生效,不必自己复刻一套尺寸规则;只有宿主将来不给宽高时才补默认值。
|
|
1774
|
+
*
|
|
1775
|
+
* 宿主 svg 上挂着 fill="none" 与 stroke-width(medium 为 1.3),这两条会
|
|
1776
|
+
* 向下继承,所以每条 path 都写全自身样式:光轨只要描边,火花只要填充。
|
|
1777
|
+
* 颜色一律 currentColor,取到的是按钮文字色——与旁边几个图标同一个值。
|
|
1778
|
+
*/
|
|
1779
|
+
const paintSoulNavIcon = (svg) => {
|
|
1780
|
+
svg.setAttribute('viewBox', NAV_ICON_VIEW_BOX)
|
|
1781
|
+
if (!svg.getAttribute('width')) svg.setAttribute('width', NAV_ICON_FALLBACK_SIZE)
|
|
1782
|
+
if (!svg.getAttribute('height')) svg.setAttribute('height', NAV_ICON_FALLBACK_SIZE)
|
|
1783
|
+
|
|
1784
|
+
const trail = svgNode('path', {
|
|
1785
|
+
d: NAV_ICON_TRAIL_D,
|
|
1786
|
+
fill: 'none',
|
|
1787
|
+
stroke: 'currentColor',
|
|
1788
|
+
'stroke-width': NAV_ICON_STROKE_WIDTH,
|
|
1789
|
+
'stroke-linecap': 'round'
|
|
1790
|
+
})
|
|
1791
|
+
const spark = svgNode('path', {
|
|
1792
|
+
d: NAV_ICON_SPARK_D,
|
|
1793
|
+
fill: 'currentColor',
|
|
1794
|
+
stroke: 'none'
|
|
1795
|
+
})
|
|
1796
|
+
|
|
1797
|
+
svg.replaceChildren(trail, spark)
|
|
1798
|
+
}
|
|
1799
|
+
|
|
1372
1800
|
const registerSettingsNavIcon = () => {
|
|
1373
1801
|
let disposed = false
|
|
1374
1802
|
|
|
@@ -1384,28 +1812,12 @@ window.__ModuleLoader__.load({
|
|
|
1384
1812
|
// 检查是否已经替换过图标
|
|
1385
1813
|
if (button.hasAttribute(SOUL_ICON_MARKER)) continue
|
|
1386
1814
|
|
|
1387
|
-
//
|
|
1815
|
+
// 把宿主给未知 id 用的设置齿轮,改画成插件自身的图标
|
|
1388
1816
|
const existingIcon = button.querySelector('svg')
|
|
1389
1817
|
if (existingIcon) {
|
|
1390
|
-
//
|
|
1818
|
+
// 标记已替换;React 重建按钮时标记随之消失,会重新画一次
|
|
1391
1819
|
button.setAttribute(SOUL_ICON_MARKER, 'true')
|
|
1392
|
-
|
|
1393
|
-
// 创建星形图标(跟随主题色)
|
|
1394
|
-
const starSvg = document.createElementNS('http://www.w3.org/2000/svg', 'svg')
|
|
1395
|
-
starSvg.setAttribute('viewBox', '0 0 24 24')
|
|
1396
|
-
starSvg.setAttribute('fill', 'none')
|
|
1397
|
-
starSvg.setAttribute('stroke', 'currentColor')
|
|
1398
|
-
starSvg.setAttribute('stroke-width', '2')
|
|
1399
|
-
starSvg.setAttribute('stroke-linecap', 'round')
|
|
1400
|
-
starSvg.setAttribute('stroke-linejoin', 'round')
|
|
1401
|
-
starSvg.style.width = '16px'
|
|
1402
|
-
starSvg.style.height = '16px'
|
|
1403
|
-
|
|
1404
|
-
const path = document.createElementNS('http://www.w3.org/2000/svg', 'path')
|
|
1405
|
-
path.setAttribute('d', 'M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z')
|
|
1406
|
-
starSvg.appendChild(path)
|
|
1407
|
-
|
|
1408
|
-
existingIcon.replaceWith(starSvg)
|
|
1820
|
+
paintSoulNavIcon(existingIcon)
|
|
1409
1821
|
}
|
|
1410
1822
|
} else {
|
|
1411
1823
|
button.removeAttribute(SOUL_NAV_MARKER)
|