dsh-live2dwaifu 2.1.0 → 2.2.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 CHANGED
@@ -231,6 +231,7 @@ python tools/export-dsh-meme.py
231
231
  | 自动播放动作 | 本机 | 开 | 模型带动作文件时,隔一会儿播一个 |
232
232
  | 说话带电子音 | 本机 | 开 | 每个字一声短音 |
233
233
  | 复述聊天内容 | 本机 | 开 | 聊天窗口出现新回复时,由她念出来 |
234
+ | 表情包出现的位置 | 本机 | 文字左边 | 文字左边 / 文字上方 / 卡片左上角 / 说话不配图 |
234
235
  | 闲置主动说话的间隔 | 服务端 | 30 分钟 | 关闭 / 30 分钟 / 1 小时 / 2 小时 / 4 小时 |
235
236
  | 回复附带选项按钮 | 服务端 | 开 | 她觉得需要选择时,气泡上方出现可点按钮 |
236
237
  | 记住聊过的内容 | 服务端 | 开 | 关掉就不带记忆、不压缩 |
@@ -371,6 +372,12 @@ curl -X POST http://127.0.0.1:<端口>/dsh-live2d/api/push \
371
372
 
372
373
  版本号怎么走:动了功能和结构就抬第二位(1.2.0),只补洞和小修就抬第三位(1.2.1)。
373
374
 
375
+ ### 2.2.0
376
+
377
+ - 加:表情包出在哪儿可以选。默认「文字左边」——图跟文字并排,图不再把文字往下顶。另有三档:「文字上方」(旧样子)、「卡片左上角」(单独浮一张,不挤气泡)、「说话不配图」。⚙ 第一栏就能改,改完正在显示的那张也会挪过去。
378
+ - 修:气泡每 9 秒会被固定台词(「嗯。」「在的。」「今天还行。」)顶掉,她刚说的话、配的图都会被盖没。现在 45 秒内有过新话、或者气泡还挂着,就不插嘴。
379
+ - 修:答题式的固定台词也换成只在她确实安静的时候才冒一句。
380
+
374
381
  ### 2.1.0
375
382
 
376
383
  「随机主动消息」这一块基本重做了。之前那版有两个毛病,都是真的。
@@ -20,7 +20,18 @@
20
20
  opacity: 0; transition: opacity .35s ease; cursor: grab; user-select: none;
21
21
  max-height: 42%; overflow: hidden; touch-action: none; }
22
22
  #bubble:active { cursor: grabbing; }
23
- .bub-img { display: block; max-width: 70%; max-height: 88px; border-radius: 10px; margin-bottom: 7px; object-fit: contain; }
23
+ /* 图跟文字并排:图在左,文字右,文字不被顶下去 */
24
+ #bubble.img-side { display: flex; align-items: flex-start; gap: 9px; }
25
+ #bubble.img-above { display: flex; flex-direction: column; gap: 7px; }
26
+ .bub-txt { flex: 1 1 auto; min-width: 0; }
27
+ .bub-img { display: block; border-radius: 10px; object-fit: contain; flex: none; }
28
+ #bubble.img-side .bub-img { max-width: 45%; max-height: 96px; }
29
+ #bubble.img-above .bub-img { max-width: 70%; max-height: 88px; }
30
+ /* 单独浮一张,不占气泡 */
31
+ #sticker { position: absolute; left: 10px; top: 10px; max-width: 38%; max-height: 32%;
32
+ opacity: 0; transition: opacity .35s ease; pointer-events: none; }
33
+ #sticker .stk-img { display: block; max-width: 100%; max-height: 100%; border-radius: 12px;
34
+ box-shadow: 0 8px 22px rgba(0,0,0,.45); object-fit: contain; }
24
35
  #hint { position: absolute; inset: 0; display: none; align-items: center; justify-content: center;
25
36
  text-align: center; padding: 24px; color: #98a0ad; }
26
37
  #hint.show { display: flex; }
@@ -70,6 +81,7 @@
70
81
  </head>
71
82
  <body>
72
83
  <canvas id="stage"></canvas>
84
+ <div id="sticker"></div>
73
85
  <div id="bottom">
74
86
  <div id="choices"></div>
75
87
  <div id="bubble"></div>
package/assets/viewer.js CHANGED
@@ -44316,6 +44316,7 @@ void main(void)\r
44316
44316
  var gazeY = 0;
44317
44317
  var pokeAt = 0;
44318
44318
  var sayFade = 0;
44319
+ var lastSayAt = 0;
44319
44320
  var motionGroups = [];
44320
44321
  var nextMotionAt = 0;
44321
44322
  var POKE_HEAD = ["\u5514\u3002", "\u522B\u6478\u3002", "\u5934\u53D1\u4E71\u4E86\u3002", "\u55EF\u2026\u2026", "\u4F60\u624B\u51C9\u3002"];
@@ -44383,6 +44384,40 @@ void main(void)\r
44383
44384
  row.appendChild(document.createTextNode(label));
44384
44385
  box.appendChild(row);
44385
44386
  }
44387
+ const hp = document.createElement("h3");
44388
+ hp.textContent = "\u8868\u60C5\u5305\u51FA\u73B0\u7684\u4F4D\u7F6E";
44389
+ box.appendChild(hp);
44390
+ const posWrap = document.createElement("div");
44391
+ posWrap.className = "opt-col";
44392
+ const posSlider = document.createElement("input");
44393
+ posSlider.type = "range";
44394
+ posSlider.min = "0";
44395
+ posSlider.max = String(IMG_POS.length - 1);
44396
+ posSlider.step = "1";
44397
+ const curPos = Math.max(0, IMG_POS.indexOf(imgPos()));
44398
+ posSlider.value = String(curPos);
44399
+ const posLab = document.createElement("div");
44400
+ posLab.className = "opt-lab";
44401
+ posLab.textContent = IMG_POS_LABELS[curPos];
44402
+ posSlider.oninput = () => {
44403
+ posLab.textContent = IMG_POS_LABELS[Number(posSlider.value)];
44404
+ };
44405
+ posSlider.onchange = () => {
44406
+ setImgPos(IMG_POS[Number(posSlider.value)]);
44407
+ const bubble = $2("bubble");
44408
+ const shown = bubble ? bubble.querySelector(".bub-img") : null;
44409
+ const pushed = $2("sticker") ? $2("sticker").querySelector(".stk-img") : null;
44410
+ const src = shown && shown.src || pushed && pushed.src || "";
44411
+ if (shown && shown.parentNode) shown.parentNode.removeChild(shown);
44412
+ if (src && bubble) placeImage(bubble, src);
44413
+ };
44414
+ const posNote = document.createElement("div");
44415
+ posNote.className = "opt-note";
44416
+ posNote.textContent = "\u8BF4\u8BDD\u65F6\u914D\u56FE\u51FA\u5728\u54EA\u513F\u3002\u8D34\u5728\u6587\u5B57\u5DE6\u8FB9\u6216\u4E0A\u65B9\u90FD\u8DDF\u6C14\u6CE1\u4E00\u8D77\u8D70\uFF1B\u5361\u7247\u5DE6\u4E0A\u89D2\u662F\u5355\u72EC\u6D6E\u4E00\u5F20\uFF0C\u4E0D\u6324\u6C14\u6CE1\u3002";
44417
+ posWrap.appendChild(posSlider);
44418
+ posWrap.appendChild(posLab);
44419
+ posWrap.appendChild(posNote);
44420
+ box.appendChild(posWrap);
44386
44421
  const h2 = document.createElement("h3");
44387
44422
  h2.textContent = "\u5BF9\u8BDD\u4E0E\u884C\u4E3A\uFF08\u5B58\u670D\u52A1\u7AEF\uFF09";
44388
44423
  box.appendChild(h2);
@@ -44704,6 +44739,47 @@ void main(void)\r
44704
44739
  await refresh(true);
44705
44740
  $2("drawer").classList.remove("show");
44706
44741
  }
44742
+ var IMG_POS = ["side", "above", "corner", "off"];
44743
+ var IMG_POS_LABELS = ["\u6587\u5B57\u5DE6\u8FB9", "\u6587\u5B57\u4E0A\u65B9", "\u5361\u7247\u5DE6\u4E0A\u89D2", "\u8BF4\u8BDD\u4E0D\u914D\u56FE"];
44744
+ function imgPos() {
44745
+ let v2 = "";
44746
+ try {
44747
+ v2 = localStorage.getItem("dsh-l2d-imgpos") || "";
44748
+ } catch {
44749
+ v2 = "";
44750
+ }
44751
+ return IMG_POS.indexOf(v2) >= 0 ? v2 : "side";
44752
+ }
44753
+ function setImgPos(v2) {
44754
+ try {
44755
+ localStorage.setItem("dsh-l2d-imgpos", v2);
44756
+ } catch {
44757
+ }
44758
+ }
44759
+ function hideSticker() {
44760
+ const st = $2("sticker");
44761
+ if (st) st.style.opacity = "0";
44762
+ }
44763
+ function placeImage(bubble, image) {
44764
+ const pos = imgPos();
44765
+ hideSticker();
44766
+ bubble.classList.toggle("img-above", pos === "above");
44767
+ bubble.classList.toggle("img-side", pos === "side");
44768
+ if (!image || pos === "off") return;
44769
+ const img = document.createElement("img");
44770
+ img.src = String(image);
44771
+ if (pos === "corner") {
44772
+ const st = $2("sticker");
44773
+ if (!st) return;
44774
+ img.className = "stk-img";
44775
+ st.innerHTML = "";
44776
+ st.appendChild(img);
44777
+ st.style.opacity = "1";
44778
+ return;
44779
+ }
44780
+ img.className = "bub-img";
44781
+ bubble.insertBefore(img, bubble.firstChild);
44782
+ }
44707
44783
  function say(text, m2, image) {
44708
44784
  if (m2) applyMood(m2);
44709
44785
  const bubble = $2("bubble");
@@ -44711,14 +44787,11 @@ void main(void)\r
44711
44787
  if (s2.length > 180) s2 = s2.slice(0, 178) + "\u2026";
44712
44788
  bubble.textContent = "";
44713
44789
  bubble.style.opacity = "1";
44790
+ lastSayAt = Date.now();
44714
44791
  clearTimeout(sayFade);
44715
- if (image) {
44716
- const img = document.createElement("img");
44717
- img.className = "bub-img";
44718
- img.src = String(image);
44719
- bubble.appendChild(img);
44720
- }
44792
+ placeImage(bubble, image);
44721
44793
  const holder = document.createElement("div");
44794
+ holder.className = "bub-txt";
44722
44795
  bubble.appendChild(holder);
44723
44796
  const chars = Array.from(s2);
44724
44797
  let i2 = 0;
@@ -44729,6 +44802,7 @@ void main(void)\r
44729
44802
  if (chars.length) blip(tone.base * 0.82, tone.dur * 1.6, tone.type);
44730
44803
  sayFade = setTimeout(() => {
44731
44804
  bubble.style.opacity = "0";
44805
+ hideSticker();
44732
44806
  }, Math.min(14e3, 4e3 + chars.length * 110));
44733
44807
  return;
44734
44808
  }
@@ -44743,6 +44817,9 @@ void main(void)\r
44743
44817
  }
44744
44818
  var idleIdx = 0;
44745
44819
  function idleTick() {
44820
+ const bubble = $2("bubble");
44821
+ if (Date.now() - lastSayAt < 45e3) return;
44822
+ if (bubble && bubble.style.opacity !== "0" && bubble.textContent.trim()) return;
44746
44823
  const line = IDLE_LINES[idleIdx++ % IDLE_LINES.length];
44747
44824
  if (line) say(line, mood);
44748
44825
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-live2dwaifu",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "给 DSH 网页右下角请一个 Live2D 角色:会眨眼、会呼吸、视线跟着鼠标、点她有反应、说话时嘴动、心情变了眉毛跟着动。模型不用内置——谁装谁放自己的文件夹;支持自定义 .exp3.json 表情和 .motion3.json 动作,卡片能拖能缩,背景可换。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",