@linxin666/dsh-pet 0.2.9 → 0.3.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.
package/README.i18n.yaml CHANGED
@@ -2,5 +2,5 @@
2
2
  # side as of the last confirmed-consistent state. Both languages carry equal authority;
3
3
  # after editing either side, bring the other along and re-record with:
4
4
  # node scripts/verify-docs.mjs --write <dir>
5
- README.md: b3edd49ede7b31ff40195aec2082088b24255656
6
- README.zh.md: 1476678e2ed514eeaea69bcf0d77dd7c71a74fe1
5
+ README.md: 02e682f7c14dee40461f177660a3c976fc4bb05d
6
+ README.zh.md: d263d62d64cde1cd14a4e8656646166b944c4c0c
package/README.md CHANGED
@@ -13,7 +13,7 @@ Re-implemented from the pet feature of the Codex desktop app, as an official DSH
13
13
  | Feature | Description |
14
14
  |---|---|
15
15
  | Multi-pet registry | The host scans built-in `assets/`, the hatch-pet custom pets directory, and composed config entries; each pet is a manifest plus an atlas |
16
- | Pet selection in settings | The plugin settings card lists every registered pet; switching persists and the sprite swaps immediately |
16
+ | Pet selection in settings | The plugin settings card lists every registered pet (built-in assets plus user directories — the installed set); switching persists and the sprite swaps immediately. The card sits in the first-level Pet settings section |
17
17
  | Per-pet naming | Rename from the hover panel; each pet keeps its own name (stored per pet id, migrated from the legacy flat name) |
18
18
  | State animation | Official session activity → manifest-defined sequences of 9-state tracks; each track finishes its full duration before the sequence advances and the complete sequence loops |
19
19
  | Head-pat interaction | Click the pet → bubble feedback + affinity +1 (10s cooldown) |
package/README.zh.md CHANGED
@@ -13,7 +13,7 @@
13
13
  | 功能 | 说明 |
14
14
  |---|---|
15
15
  | 多宠物注册表 | 宿主扫描内置 `assets/`、hatch-pet 自定义宠物目录和组合配置条目;每只宠物 = manifest + 图集 |
16
- | 设置中选择宠物 | 插件设置卡片列出所有已注册宠物;切换即持久化,精灵立即更换 |
16
+ | 设置中选择宠物 | 插件设置卡片列出所有已注册宠物(内置资产 + 用户目录,即已安装集合);切换即持久化,精灵立即更换。卡片位于一级设置分区「宠物」 |
17
17
  | 每只宠物独立命名 | 在悬浮面板改名;每只宠物保存自己的名字(按宠物 id 存储,旧版平铺名字自动迁移) |
18
18
  | 状态动画 | 官方会话活动 → manifest 定义的 9 态轨道序列;每条轨道播完自身完整时长后切换,整条序列循环 |
19
19
  | 摸头互动 | 点击宠物 → 气泡反馈 + 亲密度 +1(10s 冷却) |
package/lib/client.js CHANGED
@@ -165,7 +165,7 @@ window.__ModuleLoader__.load({
165
165
  }
166
166
  //#endregion
167
167
  //#region \0dsh-css:packages/dsh-pet/src/client/pet.module.css.mjs
168
- const css$2 = ".kz2Bea_float{pointer-events:auto;-webkit-user-select:none;user-select:none;flex-direction:column;align-items:center;display:flex;position:fixed}.kz2Bea_sprite{image-rendering:auto;touch-action:none;position:relative}.kz2Bea_bubble{white-space:nowrap;color:#f4f7ff;pointer-events:none;border-radius:999px;margin-bottom:6px;padding:4px 10px;font-size:12px;line-height:1.4;animation:2.6s ease-out forwards kz2Bea_pet-bubble-pop;position:absolute;bottom:100%;box-shadow:0 2px 8px #00000040}.kz2Bea_bubblePet{background:#4d6bfef2}.kz2Bea_bubbleFeed{background:#0369a1f2}.kz2Bea_bubbleStatus{text-overflow:ellipsis;backdrop-filter:blur(8px);letter-spacing:.02em;background:linear-gradient(160deg,#131c36e6,#070b1af0);border:1px solid #7e98ff73;max-width:min(280px,100vw - 24px);padding:5px 12px;animation:.24s ease-out kz2Bea_pet-bubble-in;overflow:hidden;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.kz2Bea_bubbleWhisper{letter-spacing:.03em;animation:.32s cubic-bezier(.22,1,.36,1) kz2Bea_pet-whisper-in}.kz2Bea_bubbleWhisper:before{content:\"「\";opacity:.7;margin-right:2px}.kz2Bea_bubbleWhisper:after{content:\"」\";opacity:.7;margin-left:2px}.kz2Bea_bubbleStack{pointer-events:auto;flex-direction:column-reverse;align-items:center;gap:4px;display:flex;position:absolute;bottom:100%}.kz2Bea_bubbleAnchor{display:inline-flex;position:relative}.kz2Bea_bubbleMore{z-index:1;color:#eef2ff;cursor:pointer;background:linear-gradient(160deg,#4a68f5f2,#2f44b8f2);border:1px solid #7e98ff8c;border-radius:999px;justify-content:center;align-items:center;min-width:18px;height:18px;padding:0 5px;font-size:10px;font-weight:600;line-height:1;transition:filter .12s;display:inline-flex;position:absolute;top:-9px;right:-10px;box-shadow:0 2px 6px #02061766}.kz2Bea_bubbleMore:hover{filter:brightness(1.15)}.kz2Bea_bubbleMore:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.kz2Bea_bubbleStack .kz2Bea_bubble{pointer-events:auto;margin-bottom:0;position:relative;bottom:auto}.kz2Bea_bubbleClickable{cursor:pointer;font:inherit;text-align:center;appearance:none;transition:filter .12s,box-shadow .12s}.kz2Bea_bubbleClickable:hover{filter:brightness(1.12)}.kz2Bea_bubbleClickable:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@keyframes kz2Bea_pet-bubble-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-whisper-in{0%{opacity:0;transform:translateY(8px)scale(.9)}60%{transform:translateY(-1px)scale(1.02)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-panel-in{0%{opacity:0;transform:translateY(4px)scale(.97)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-bubble-pop{0%{opacity:0;transform:translateY(6px)scale(.85)}15%{opacity:1;transform:translateY(0)scale(1.05)}25%{transform:translateY(0)scale(1)}75%{opacity:1}to{opacity:0;transform:translateY(-8px)scale(.95)}}.kz2Bea_panel{color:#e6ebf8;backdrop-filter:blur(10px);transform-origin:50% 0;background:linear-gradient(165deg,#131c36f2,#070b1af7);border:1px solid #7e98ff4d;border-radius:12px;flex-direction:column;gap:7px;min-width:148px;margin-top:8px;padding:10px 12px;font-size:12px;animation:.2s cubic-bezier(.22,1,.36,1) kz2Bea_pet-panel-in;display:flex;position:absolute;top:100%;box-shadow:0 8px 24px #02061773,0 0 0 1px #4d6bfe1a,inset 0 1px #e2e8ff14}.kz2Bea_panel:after{content:\"\";height:14px;position:absolute;bottom:100%;left:0;right:0}.kz2Bea_panelAbove{transform-origin:50% 100%;margin-top:0;margin-bottom:8px;top:auto;bottom:100%}.kz2Bea_panelAbove:after{top:100%;bottom:auto}.kz2Bea_rankRow{white-space:nowrap;justify-content:space-between;gap:10px;display:flex}.kz2Bea_nameCell{letter-spacing:.02em;background:linear-gradient(90deg,#a9c1ff,#6c8bff 60%,#4d6bfe);color:#0000;-webkit-background-clip:text;background-clip:text;font-weight:600}.kz2Bea_statRank{color:#9db4ff;font-weight:600}.kz2Bea_statTreats{color:#7dd3fc;font-weight:600}.kz2Bea_statPoints{color:#fcd34d;font-weight:600}.kz2Bea_renameRow{align-items:center;gap:6px;display:flex}.kz2Bea_nameInput{color:#e6ebf8;background:#131c36e6;border:1px solid #7e98ff80;border-radius:6px;outline:none;flex:1;min-width:0;padding:3px 6px;font-size:12px}.kz2Bea_nameInput:focus{border-color:#4d6bfe;box-shadow:0 0 0 2px #4d6bfe73}.kz2Bea_actions{gap:6px;display:flex}.kz2Bea_action{cursor:pointer;color:#fff;background:linear-gradient(#4a68f5,#3a55e0);border:none;border-radius:6px;flex:1;padding:4px 8px;font-size:12px;font-weight:600;transition:filter .12s,box-shadow .12s,transform .12s;box-shadow:0 2px 6px #4d6bfe4d}.kz2Bea_action:hover{filter:brightness(1.08);transform:translateY(-1px);box-shadow:0 4px 10px #4d6bfe66}.kz2Bea_action:active{filter:brightness(.94);transform:translateY(0);box-shadow:0 1px 4px #4d6bfe4d}.kz2Bea_action:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.kz2Bea_summon{color:#8ea6ff;cursor:pointer;background:#070b1abf;border:1px dashed #7e98ff99;border-radius:999px;padding:2px 10px;font-size:11px;transition:border-color .12s,color .12s,background .12s,box-shadow .12s}.kz2Bea_summon:hover{color:#c3d3ff;background:#070b1ae6;border-color:#7e98fff2}.kz2Bea_summon:active{color:#8ea6ff;border-color:#7e98ffcc}.kz2Bea_summon:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@media (prefers-reduced-motion:reduce){.kz2Bea_bubble,.kz2Bea_bubbleStatus,.kz2Bea_bubbleWhisper,.kz2Bea_panel{opacity:1;animation:none}.kz2Bea_action,.kz2Bea_summon,.kz2Bea_bubbleMore{transition:none}}";
168
+ const css$2 = ".kz2Bea_float{pointer-events:auto;-webkit-user-select:none;user-select:none;will-change:transform;contain:layout style;flex-direction:column;align-items:center;display:flex;position:fixed}.kz2Bea_sprite{image-rendering:auto;touch-action:none;contain:paint}.kz2Bea_spriteWrap{flex:none;position:relative}.kz2Bea_closeButton{z-index:2;color:#f8fafc;cursor:pointer;touch-action:manipulation;background:#070b1ac7;border:1px solid #e2e8ffb8;border-radius:999px;width:24px;height:24px;padding:0;font:600 18px/20px sans-serif;transition:background .12s,box-shadow .12s;position:absolute;top:4px;right:4px}.kz2Bea_closeButton:hover{background:#2c3e7ef2}.kz2Bea_closeButton:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98fff2}.kz2Bea_bubble{white-space:nowrap;color:#f4f7ff;pointer-events:none;border-radius:999px;margin-bottom:6px;padding:4px 10px;font-size:12px;line-height:1.4;animation:2.6s ease-out forwards kz2Bea_pet-bubble-pop;position:absolute;bottom:100%;box-shadow:0 2px 8px #00000040}.kz2Bea_bubblePet{background:#4d6bfef2}.kz2Bea_bubbleFeed{background:#0369a1f2}.kz2Bea_bubbleStatus{text-overflow:ellipsis;backdrop-filter:blur(8px);letter-spacing:.02em;background:linear-gradient(160deg,#131c36e6,#070b1af0);border:1px solid #7e98ff73;max-width:min(280px,100vw - 24px);padding:5px 12px;animation:.24s ease-out kz2Bea_pet-bubble-in;overflow:hidden;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.kz2Bea_bubbleWhisper{letter-spacing:.03em;animation:.32s cubic-bezier(.22,1,.36,1) kz2Bea_pet-whisper-in}.kz2Bea_bubbleWhisper:before{content:\"「\";opacity:.7;margin-right:2px}.kz2Bea_bubbleWhisper:after{content:\"」\";opacity:.7;margin-left:2px}.kz2Bea_bubbleStack{pointer-events:auto;flex-direction:column-reverse;align-items:center;gap:4px;display:flex;position:absolute;bottom:100%}.kz2Bea_bubbleAnchor{display:inline-flex;position:relative}.kz2Bea_bubbleMore{z-index:1;color:#eef2ff;cursor:pointer;background:linear-gradient(160deg,#4a68f5f2,#2f44b8f2);border:1px solid #7e98ff8c;border-radius:999px;justify-content:center;align-items:center;min-width:18px;height:18px;padding:0 5px;font-size:10px;font-weight:600;line-height:1;transition:filter .12s;display:inline-flex;position:absolute;top:-9px;right:-10px;box-shadow:0 2px 6px #02061766}.kz2Bea_bubbleMore:hover{filter:brightness(1.15)}.kz2Bea_bubbleMore:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.kz2Bea_bubbleStack .kz2Bea_bubble{pointer-events:auto;margin-bottom:0;position:relative;bottom:auto}.kz2Bea_bubbleClickable{cursor:pointer;font:inherit;text-align:center;appearance:none;transition:filter .12s,box-shadow .12s}.kz2Bea_bubbleClickable:hover{filter:brightness(1.12)}.kz2Bea_bubbleClickable:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@keyframes kz2Bea_pet-bubble-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-whisper-in{0%{opacity:0;transform:translateY(8px)scale(.9)}60%{transform:translateY(-1px)scale(1.02)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-panel-in{0%{opacity:0;transform:translateY(4px)scale(.97)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes kz2Bea_pet-bubble-pop{0%{opacity:0;transform:translateY(6px)scale(.85)}15%{opacity:1;transform:translateY(0)scale(1.05)}25%{transform:translateY(0)scale(1)}75%{opacity:1}to{opacity:0;transform:translateY(-8px)scale(.95)}}.kz2Bea_panel{color:#e6ebf8;backdrop-filter:blur(10px);transform-origin:50% 0;background:linear-gradient(165deg,#131c36f2,#070b1af7);border:1px solid #7e98ff4d;border-radius:12px;flex-direction:column;gap:7px;min-width:148px;margin-top:8px;padding:10px 12px;font-size:12px;animation:.2s cubic-bezier(.22,1,.36,1) kz2Bea_pet-panel-in;display:flex;position:absolute;top:100%;box-shadow:0 8px 24px #02061773,0 0 0 1px #4d6bfe1a,inset 0 1px #e2e8ff14}.kz2Bea_panel:after{content:\"\";height:14px;position:absolute;bottom:100%;left:0;right:0}.kz2Bea_panelAbove{transform-origin:50% 100%;margin-top:0;margin-bottom:8px;top:auto;bottom:100%}.kz2Bea_panelAbove:after{top:100%;bottom:auto}.kz2Bea_rankRow{white-space:nowrap;justify-content:space-between;gap:10px;display:flex}.kz2Bea_nameCell{letter-spacing:.02em;background:linear-gradient(90deg,#a9c1ff,#6c8bff 60%,#4d6bfe);color:#0000;-webkit-background-clip:text;background-clip:text;font-weight:600}.kz2Bea_statRank{color:#9db4ff;font-weight:600}.kz2Bea_statTreats{color:#7dd3fc;font-weight:600}.kz2Bea_statPoints{color:#fcd34d;font-weight:600}.kz2Bea_renameRow{align-items:center;gap:6px;display:flex}.kz2Bea_nameInput{color:#e6ebf8;background:#131c36e6;border:1px solid #7e98ff80;border-radius:6px;outline:none;flex:1;min-width:0;padding:3px 6px;font-size:12px}.kz2Bea_nameInput:focus{border-color:#4d6bfe;box-shadow:0 0 0 2px #4d6bfe73}.kz2Bea_actions{gap:6px;display:flex}.kz2Bea_action{cursor:pointer;color:#fff;background:linear-gradient(#4a68f5,#3a55e0);border:none;border-radius:6px;flex:1;padding:4px 8px;font-size:12px;font-weight:600;transition:filter .12s,box-shadow .12s,transform .12s;box-shadow:0 2px 6px #4d6bfe4d}.kz2Bea_action:hover{filter:brightness(1.08);transform:translateY(-1px);box-shadow:0 4px 10px #4d6bfe66}.kz2Bea_action:active{filter:brightness(.94);transform:translateY(0);box-shadow:0 1px 4px #4d6bfe4d}.kz2Bea_action:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.kz2Bea_summon{color:#8ea6ff;cursor:pointer;background:#070b1abf;border:1px dashed #7e98ff99;border-radius:999px;padding:2px 10px;font-size:11px;transition:border-color .12s,color .12s,background .12s,box-shadow .12s}.kz2Bea_summon:hover{color:#c3d3ff;background:#070b1ae6;border-color:#7e98fff2}.kz2Bea_summon:active{color:#8ea6ff;border-color:#7e98ffcc}.kz2Bea_summon:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@media (prefers-reduced-motion:reduce){.kz2Bea_bubble,.kz2Bea_bubbleStatus,.kz2Bea_bubbleWhisper,.kz2Bea_panel{opacity:1;animation:none}.kz2Bea_action,.kz2Bea_summon,.kz2Bea_bubbleMore,.kz2Bea_closeButton{transition:none}}";
169
169
  const tagId$2 = "@linxin666/dsh-pet/pet.module.css";
170
170
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
171
171
  const tag = document.createElement("style");
@@ -186,6 +186,7 @@ window.__ModuleLoader__.load({
186
186
  "bubbleStack": "kz2Bea_bubbleStack",
187
187
  "bubbleStatus": "kz2Bea_bubbleStatus",
188
188
  "bubbleWhisper": "kz2Bea_bubbleWhisper",
189
+ "closeButton": "kz2Bea_closeButton",
189
190
  "float": "kz2Bea_float",
190
191
  "nameCell": "kz2Bea_nameCell",
191
192
  "nameInput": "kz2Bea_nameInput",
@@ -198,6 +199,7 @@ window.__ModuleLoader__.load({
198
199
  "rankRow": "kz2Bea_rankRow",
199
200
  "renameRow": "kz2Bea_renameRow",
200
201
  "sprite": "kz2Bea_sprite",
202
+ "spriteWrap": "kz2Bea_spriteWrap",
201
203
  "statPoints": "kz2Bea_statPoints",
202
204
  "statRank": "kz2Bea_statRank",
203
205
  "statTreats": "kz2Bea_statTreats",
@@ -370,7 +372,8 @@ window.__ModuleLoader__.load({
370
372
  const track = trimTrack(tracks[leadAnimation], rows[row] ?? tracks[leadAnimation].frames.length);
371
373
  const leadCol = track.frames[0];
372
374
  const lead = framePosition(cell, row, leadCol, scaleRef.current);
373
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = lead.x + "px " + lead.y + "px";
375
+ let lastPosStr = lead.x + "px " + lead.y + "px";
376
+ if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = lastPosStr;
374
377
  if (reduceMotion) return;
375
378
  let raf = 0;
376
379
  let last = performance.now();
@@ -384,7 +387,11 @@ window.__ModuleLoader__.load({
384
387
  const currentRow = rowOfTrack(current.animation);
385
388
  const col = trimTrack(tracks[current.animation], rows[currentRow] ?? tracks[current.animation].frames.length).frames[current.frameIndex];
386
389
  const pos = framePosition(cell, currentRow, col, scaleRef.current);
387
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = pos.x + "px " + pos.y + "px";
390
+ const posStr = pos.x + "px " + pos.y + "px";
391
+ if (posStr !== lastPosStr) {
392
+ lastPosStr = posStr;
393
+ if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = posStr;
394
+ }
388
395
  raf = requestAnimationFrame(tick);
389
396
  return;
390
397
  }
@@ -406,7 +413,11 @@ window.__ModuleLoader__.load({
406
413
  } else st.index = maxIndex;
407
414
  const col = track.frames[st.index];
408
415
  const pos = framePosition(cell, row, col, scaleRef.current);
409
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = pos.x + "px " + pos.y + "px";
416
+ const posStr = pos.x + "px " + pos.y + "px";
417
+ if (posStr !== lastPosStr) {
418
+ lastPosStr = posStr;
419
+ if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = posStr;
420
+ }
410
421
  raf = requestAnimationFrame(tick);
411
422
  };
412
423
  raf = requestAnimationFrame(tick);
@@ -535,30 +546,51 @@ window.__ModuleLoader__.load({
535
546
  hideTimerRef.current = window.setTimeout(() => setHovered(false), 300);
536
547
  },
537
548
  children: [
538
- /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
539
- ref: spriteRef,
540
- className: pet_module_css_default.sprite,
549
+ /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
550
+ className: pet_module_css_default.spriteWrap,
541
551
  style: {
542
552
  width: spriteWidth,
543
- height: spriteHeight,
544
- ...props.visual === void 0 ? {
545
- backgroundImage: imageReady ? "url(" + definition.atlasUrl + ")" : void 0,
546
- backgroundSize: cell.width * columns * spriteScale + "px " + cell.height * (definition.atlasRows ?? rows.length) * spriteScale + "px",
547
- backgroundRepeat: "no-repeat",
548
- backgroundPosition: "0 0"
549
- } : {},
550
- cursor: dragRef.current === null ? "grab" : "grabbing"
553
+ height: spriteHeight
551
554
  },
552
- onPointerDown,
553
- onPointerMove,
554
- onPointerUp,
555
- onClick: () => {
556
- if (draggedRef.current) return;
557
- props.onPet();
558
- },
559
- role: "button",
560
- "aria-label": definition.displayName,
561
- children: props.visual
555
+ children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
556
+ ref: spriteRef,
557
+ className: pet_module_css_default.sprite,
558
+ style: {
559
+ width: spriteWidth,
560
+ height: spriteHeight,
561
+ ...props.visual === void 0 ? {
562
+ backgroundImage: imageReady ? "url(" + definition.atlasUrl + ")" : void 0,
563
+ backgroundSize: cell.width * columns * spriteScale + "px " + cell.height * (definition.atlasRows ?? rows.length) * spriteScale + "px",
564
+ backgroundRepeat: "no-repeat",
565
+ backgroundPosition: "0 0"
566
+ } : {},
567
+ cursor: dragRef.current === null ? "grab" : "grabbing"
568
+ },
569
+ onPointerDown,
570
+ onPointerMove,
571
+ onPointerUp,
572
+ onClick: () => {
573
+ if (draggedRef.current) return;
574
+ props.onPet();
575
+ },
576
+ role: "button",
577
+ "aria-label": definition.displayName,
578
+ children: props.visual
579
+ }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
580
+ type: "button",
581
+ className: pet_module_css_default.closeButton,
582
+ "aria-label": panelLabel("hide", props.t("pet.hide")),
583
+ title: panelLabel("hide", props.t("pet.hide")),
584
+ "data-testid": "pet-close",
585
+ onPointerDown: (e) => {
586
+ e.stopPropagation();
587
+ },
588
+ onClick: (e) => {
589
+ e.stopPropagation();
590
+ props.onHide();
591
+ },
592
+ children: "×"
593
+ })]
562
594
  }),
563
595
  feedback !== null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
564
596
  ref: bubbleRef,
@@ -2063,7 +2095,7 @@ window.__ModuleLoader__.load({
2063
2095
  };
2064
2096
  //#endregion
2065
2097
  //#region \0dsh-css:packages/dsh-pet/src/client/settings-section.module.css.mjs
2066
- const css = ".t0P0pa_sectionList{margin:0;padding:0;list-style:none}.t0P0pa_diagnostics{border:1px dashed var(--dsw-alias-border-l2);color:var(--dsw-alias-label-dimmed);border-radius:8px;margin:8px 0;padding:8px 12px;font-size:12px}.t0P0pa_diagnosticsTitle{color:var(--dsw-alias-label);margin-bottom:4px;font-weight:600;display:block}.t0P0pa_diagnostics ul{margin:0;padding-left:16px}.t0P0pa_diagnostics li[data-level=error]{color:var(--dsw-alias-error,#c04848)}";
2098
+ const css = ".t0P0pa_sectionList{margin:0;padding:0;list-style:none}.t0P0pa_diagnostics{border:1px dashed var(--dsw-alias-border-l2);color:var(--dsw-alias-label-tertiary);border-radius:8px;margin:8px 0;padding:8px 12px;font-size:12px}.t0P0pa_diagnosticsTitle{color:var(--dsw-alias-label-primary);margin-bottom:4px;font-weight:600;display:block}.t0P0pa_diagnostics ul{margin:0;padding-left:16px}.t0P0pa_diagnostics li[data-level=error]{color:var(--dsw-alias-label-error,#c04848)}";
2067
2099
  const tagId = "@linxin666/dsh-pet/settings-section.module.css";
2068
2100
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId) + "]") === null) {
2069
2101
  const tag = document.createElement("style");
@@ -2100,6 +2132,9 @@ window.__ModuleLoader__.load({
2100
2132
  diagnostics = [];
2101
2133
  loaded = false;
2102
2134
  attempts = 0;
2135
+ disposed = false;
2136
+ /** Pending deferred-load or retry timer; cancelled by dispose(). */
2137
+ pendingTimer;
2103
2138
  /** @param scope - the bound settings scope for the 'pet' namespace. */
2104
2139
  constructor(scope) {
2105
2140
  this.form = new CardForm(scope, [
@@ -2112,7 +2147,9 @@ window.__ModuleLoader__.load({
2112
2147
  choiceField("petId", this.petChoices)
2113
2148
  ]);
2114
2149
  this.store = this.form.bind(() => this.projection());
2115
- window.setTimeout(() => {
2150
+ this.pendingTimer = window.setTimeout(() => {
2151
+ this.pendingTimer = void 0;
2152
+ if (this.disposed) return;
2116
2153
  this.loadPets();
2117
2154
  this.loadDiagnostics();
2118
2155
  }, 0);
@@ -2121,6 +2158,7 @@ window.__ModuleLoader__.load({
2121
2158
  async loadDiagnostics() {
2122
2159
  try {
2123
2160
  this.diagnostics = await fetchPetDiagnostics();
2161
+ if (this.disposed) return;
2124
2162
  this.store.set(this.projection());
2125
2163
  } catch {
2126
2164
  this.diagnostics = [];
@@ -2128,16 +2166,20 @@ window.__ModuleLoader__.load({
2128
2166
  }
2129
2167
  /** Resolve the registry choices once (retried a few times on failure). */
2130
2168
  async loadPets() {
2131
- if (this.loaded) return;
2169
+ if (this.loaded || this.disposed) return;
2132
2170
  try {
2133
2171
  const list = await fetchPetChoices();
2172
+ if (this.disposed) return;
2134
2173
  this.petChoices.splice(0, this.petChoices.length, ...list.map((choice) => choice.id));
2135
2174
  for (const choice of list) this.petLabels.set(choice.id, choice.displayName);
2136
2175
  this.loaded = true;
2137
2176
  this.store.set(this.projection());
2138
2177
  } catch {
2178
+ if (this.disposed) return;
2139
2179
  this.attempts += 1;
2140
- if (this.attempts < 3) window.setTimeout(() => {
2180
+ if (this.attempts < 3) this.pendingTimer = window.setTimeout(() => {
2181
+ this.pendingTimer = void 0;
2182
+ if (this.disposed) return;
2141
2183
  this.loadPets();
2142
2184
  }, 3e3);
2143
2185
  }
@@ -2170,10 +2212,16 @@ window.__ModuleLoader__.load({
2170
2212
  };
2171
2213
  }
2172
2214
  /**
2173
- * Release the card's scope subscription and bound stores; the slot
2174
- * disposer calls this on teardown.
2215
+ * Release the card's scope subscription, bound stores and pending load
2216
+ * timers; the slot disposer calls this on teardown.
2175
2217
  */
2176
2218
  dispose() {
2219
+ if (this.disposed) return;
2220
+ this.disposed = true;
2221
+ if (this.pendingTimer !== void 0) {
2222
+ window.clearTimeout(this.pendingTimer);
2223
+ this.pendingTimer = void 0;
2224
+ }
2177
2225
  this.form.dispose();
2178
2226
  }
2179
2227
  };
@@ -2507,10 +2555,16 @@ window.__ModuleLoader__.load({
2507
2555
  * @param ctx - client root context.
2508
2556
  */
2509
2557
  function apply(ctx) {
2510
- ctx.effect(() => ctx.locale.register("pet", {
2511
- zh,
2512
- en
2513
- }), "pet: dictionaries");
2558
+ ctx.effect(() => {
2559
+ try {
2560
+ return ctx.locale.register("pet", {
2561
+ zh,
2562
+ en
2563
+ });
2564
+ } catch {
2565
+ return () => {};
2566
+ }
2567
+ }, "pet: dictionaries");
2514
2568
  defaultPetRendererRegistry.register(live2dRenderer);
2515
2569
  const settingsScope = (ctx.get("webUiSettings") ?? ctx.settingsScope).bind({ namespace: PET_SETTINGS_NS });
2516
2570
  const enabled = () => {
@@ -2519,18 +2573,22 @@ window.__ModuleLoader__.load({
2519
2573
  };
2520
2574
  const petSettings = new PetSettingsCardController(settingsScope);
2521
2575
  ctx.slots.inject("settings.section", () => {
2522
- const unregister = ctx.slots.register({
2523
- name: "settings.section",
2524
- id: "pet",
2525
- order: 130,
2526
- label: () => ctx.locale.bind("pet")("settings.title"),
2527
- locale: "pet",
2528
- inject: () => petSettings.inject()
2529
- }, PetSettingsSection);
2530
- return () => {
2531
- petSettings.dispose();
2532
- unregister();
2533
- };
2576
+ try {
2577
+ const unregister = ctx.slots.register({
2578
+ name: "settings.section",
2579
+ id: "pet",
2580
+ order: 130,
2581
+ label: () => ctx.locale.bind("pet")("settings.title"),
2582
+ locale: "pet",
2583
+ inject: () => petSettings.inject()
2584
+ }, PetSettingsSection);
2585
+ return () => {
2586
+ unregister();
2587
+ petSettings.dispose();
2588
+ };
2589
+ } catch {
2590
+ return () => {};
2591
+ }
2534
2592
  });
2535
2593
  let disposeUi;
2536
2594
  let clearUiTeardown;