@linxin666/dsh-pet 0.4.7 → 0.4.9

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.
Files changed (60) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +8 -2
  3. package/README.zh.md +8 -2
  4. package/contracts/voice-pack-v1.schema.json +27 -0
  5. package/lib/client.js +144 -68
  6. package/lib/client.js.map +1 -1
  7. package/lib/index.js +160 -28
  8. package/lib/types/affinity.d.ts +26 -3
  9. package/lib/types/affinity.d.ts.map +1 -1
  10. package/lib/types/affinity.js +27 -4
  11. package/lib/types/client/PetDockEntry.d.ts +5 -0
  12. package/lib/types/client/PetDockEntry.d.ts.map +1 -1
  13. package/lib/types/client/PetDockEntry.js +1 -1
  14. package/lib/types/client/PetSprite.d.ts +11 -4
  15. package/lib/types/client/PetSprite.d.ts.map +1 -1
  16. package/lib/types/client/PetSprite.js +120 -58
  17. package/lib/types/client/index.d.ts.map +1 -1
  18. package/lib/types/client/index.js +15 -1
  19. package/lib/types/client/sequences.d.ts +9 -2
  20. package/lib/types/client/sequences.d.ts.map +1 -1
  21. package/lib/types/client/sequences.js +25 -14
  22. package/lib/types/client/spritesheet.d.ts +22 -1
  23. package/lib/types/client/spritesheet.d.ts.map +1 -1
  24. package/lib/types/client/spritesheet.js +26 -2
  25. package/lib/types/index.d.ts +1 -1
  26. package/lib/types/index.d.ts.map +1 -1
  27. package/lib/types/ledger.d.ts +10 -1
  28. package/lib/types/ledger.d.ts.map +1 -1
  29. package/lib/types/ledger.js +11 -1
  30. package/lib/types/pair-access.d.ts.map +1 -1
  31. package/lib/types/pair-access.js +26 -3
  32. package/lib/types/service.d.ts +14 -12
  33. package/lib/types/service.d.ts.map +1 -1
  34. package/lib/types/service.js +22 -17
  35. package/lib/types/voice-pack.d.ts +20 -1
  36. package/lib/types/voice-pack.d.ts.map +1 -1
  37. package/lib/types/voice-pack.js +86 -3
  38. package/package.json +24 -24
  39. package/src/affinity.test.ts +42 -0
  40. package/src/affinity.ts +46 -3
  41. package/src/client/PetDockEntry.tsx +6 -0
  42. package/src/client/PetSprite.test.tsx +304 -26
  43. package/src/client/PetSprite.tsx +123 -58
  44. package/src/client/index.test.tsx +4 -0
  45. package/src/client/index.ts +15 -1
  46. package/src/client/pet-css.test.ts +12 -0
  47. package/src/client/pet.module.css +9 -3
  48. package/src/client/sequences.test.ts +37 -1
  49. package/src/client/sequences.ts +42 -16
  50. package/src/client/spritesheet.test.ts +81 -0
  51. package/src/client/spritesheet.ts +27 -2
  52. package/src/index.ts +2 -0
  53. package/src/ledger.test.ts +19 -0
  54. package/src/ledger.ts +15 -1
  55. package/src/pair-access.ts +26 -3
  56. package/src/registry.test.ts +2 -1
  57. package/src/service.test.ts +61 -0
  58. package/src/service.ts +27 -18
  59. package/src/voice-pack.test.ts +112 -0
  60. package/src/voice-pack.ts +101 -3
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: 0cbcc24eabf828fc151228b442cecb4c765ea81d
6
- README.zh.md: 0376878bdc8f38229485b00987e586b3e92c985f
5
+ README.md: a489faab0b64a6c5736bae422f9910c7057e77a3
6
+ README.zh.md: 523014fb7ce70fd4de4cd3bc0dae40a492aa165f
package/README.md CHANGED
@@ -5,7 +5,7 @@ English | [中文](README.zh.md)
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-client-ui-pet?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -39,7 +39,7 @@ Re-engineered from desktop companion concepts into an official DSH cordis bundle
39
39
  | Status bubbles | Only one top-level session speaks by default — the session the GUI is currently on when it is reported, otherwise the most recently active one — and the rest collapse behind a +N badge on the main bubble instead of stacking a tall column; hover the bubble (or tap the badge, for touch) to fan every session's bubble out above it and click one to jump to its session; subagent sessions report through their spawning conversation and never occupy a bubble of their own; transient interaction feedback temporarily takes priority. Bubble copy comes from generous rotating pools per scene (waiting / thinking / writing / done / failed...), tool calls map onto per-family witty lines carrying the real argument hint (e.g. 跑跑 npm test), and a long-lived scene re-phrases itself every few seconds. The pet's own status bubbles can be silenced in Settings > Pet > Status bubbles, which leaves the row to a plugin driving its own bubble surface; announcements pushed through `pet.announce` keep rendering either way |
40
40
  | Inner whispers | 碎碎念: while a session streams, the pet occasionally speaks its inner voice through that session's own bubble — a fresh whisper takes over the bubble and marks it with 「」 quotes — sharing the same DeepSeek-blue glass as every status bubble, so stacked bubbles never clash — instead of stacking a second bubble — category lines woken by the SITUATION (thinking / writing / the running tool family) plus outcome lines woken only by structured results (test green from a passed test tool, error from a failed tool result, completion from a completed turn) — never from the model's words, so a discussion that merely mentions a keyword cannot wake a mood, and a whisper never quotes real content (no tool names, paths or model text); paced by cooldowns (9 s category, 5 s outcome) and an 8 s display TTL, the status copy returns after a few seconds |
41
41
  | Multi-session activity | The pet is host-global: the most recent meaningful event drives the sprite animation while every active top-level session reports its own state in a separate bubble; completed turns from every session (subagents included) contribute affinity and treats |
42
- | Voice packs and panel DIY | A per-pet voice.json plus the global $DSH_HOME/pets/.voice.json override replace every bubble word and the hover panel (button labels, stat formats, button visibility); merge precedence per-pet > global > built-in, broken packs warn and never reject a pet |
42
+ | Voice packs and panel DIY | A per-pet voice.json plus the global $DSH_HOME/pets/.voice.json override replace every bubble word and the hover panel (button labels, stat formats, button visibility, affinity rank names); merge precedence per-pet > global > built-in, broken packs warn and never reject a pet |
43
43
  | Plugin panel actions | A sibling plugin registers its own action into the hover panel's action row through the in-process pet service (`ctx.pet.registerPanelAction({ id, label, onSelect })`); the pet renders the button and dispatches the click back to the plugin's own callback, and the action goes away with the registration |
44
44
 
45
45
  ## Pet contract
@@ -128,6 +128,10 @@ Every word in the thought bubble (status / tool / whisper copy) and the hover pa
128
128
  "panel": { // hover panel; unset slots keep the plugin i18n copy
129
129
  "labels": { "feed": "Treat", "hide": "Dive", "rename": "Rename me", "confirm": "Sure" },
130
130
  "stats": { "rank": "Affinity {rank}", "treats": "Treats x{n}", "points": "{points} pts" },
131
+ "ranks": [ // display-only affinity ladder; first min must be 0
132
+ { "min": 0, "name": "小煤球", "nameEn": "Little Coal Ball" },
133
+ { "min": 25, "name": "火星伙伴", "nameEn": "Martian Buddy" }
134
+ ],
131
135
  "actions": ["feed", "rename", "hide"] // subset in canonical order; absent = all; [] = stats only
132
136
  }
133
137
  }
@@ -135,6 +139,7 @@ Every word in the thought bubble (status / tool / whisper copy) and the hover pa
135
139
 
136
140
  - Merge precedence (per slot): the pet voice.json > the global .voice.json > built-in copy. status/tools/whispers merge per key, panel merges per slot; any slot a layer misses falls through.
137
141
  - Placeholder whitelist: tools accept {tool} / {hint}; toolRemaining accepts {n}; panel.stats accept {rank} / {n} / {points}; status, whisper and panel-label lines accept no placeholders (lines carrying one are dropped with a warning).
142
+ - Rank ladder (panel.ranks): replaces the built-in whale tier names for that pet and is display-only — points, turn rewards, cooldowns and the persisted ledger are unchanged. It must be an array of 1-16 entries, start at min 0, sort ascending with unique min values, and use names of 1-24 characters. name is the default; nameEn is shown when the UI locale is English (falling back to name when omitted). An invalid ladder is dropped whole with a warning and the built-in names stay. panel.stats {rank} receives the pet's effective name.
138
143
  - Caps (warn-and-drop): at most 64 lines per pool and 160 characters per line; panel labels 40 and stats 80 characters.
139
144
  - A broken pack never breaks the pet: voice.json that is not valid JSON or whose root is not an object is ignored with a warning; every other issue drops its slot only. node scripts/dsh-pet validate <dir> fails installs on structure errors and lists content issues as warnings.
140
145
  - Semantics: an empty status/tools pool falls back to the built-in copy (a scene line always renders); an explicit empty whisper pool mutes that channel; an empty panel actions array hides all three buttons; uncovered buttons and stats keep the plugin bilingual dictionary. Legacy whispers.generic / whispers.rules fields are no longer supported and are ignored with a warning.
@@ -246,6 +251,7 @@ Settings > Pet > Status bubbles (`auto` by default, `off` to silence the pet). `
246
251
  | Registry id | Selector label | Source |
247
252
  |---|---|---|
248
253
  | `blue-throated-bee-eater` | 蓝喉蜂虎 | Companion art contributed by the repository contributor under Apache-2.0 (12 AI-illustrated pose references in the palette of the blue-throated-bee-eater skin; composed by docs/archive/blue-throated-bee-eater-pet/gen-pet.py with per-track standalone poses: perched, flight, front hover, waving, landing, droop, tilt, review; ship 小蜜蜂 as the treat name) |
254
+ | `deep-chan` | deep酱 | Sprite2d pixel-art pet contributed by Daizhdd: an 8-column x 9-row atlas of 256x288 cells (2048x2592, 57 frames) — 49 of them drawn as standalone per-frame artwork, the 8-frame walk cycle and the 5-frame jump each an independent pose, the remaining states varying by expression and small motion — plus the 8 running-left frames mirrored horizontally from running-right. deep酱 is an unofficial, fan-made derivative of the DeepSeek whale girl (鲸鱼娘): the character and all related rights belong to DeepSeek, this is fan artwork with no affiliation to or endorsement by DeepSeek, and the assets are personal non-commercial use only (see THIRD_PARTY_NOTICES.md). Repository-only, not published with the npm package |
249
255
  | `doro` | doro | Frames2d gameplay pet (contributed by stushansusu under MIT): 11 tracks / 802 frames of 42 ms webp sequences — breathing idle, a work trio, sleep, a wash mode (mood +3/s), a four-direction crawl used by random roaming, three idle-director acts (cola / orange / tongue) and a drag-only struggle loop. Doro is an unofficial, fan-made derivative of Dorothy from *Goddess of Victory: Nikke*; the character and all related rights belong to SHIFT UP — personal non-commercial use only, unofficial and not affiliated with SHIFT UP (see THIRD_PARTY_NOTICES.md) |
250
256
  | `jyn` | 女仆鲸鱼娘 | Frames2d gameplay pet (contributed by stushansusu under MIT): maid-whale desktop pet with work/sleep/touch gameplay and three selectable skins (暗夜鎏金 / 蓝海霓裳 / 冰晶公主), each with a probability-rolled click action; 暗夜鎏金 also swaps its own rest loop into the sleep gameplay |
251
257
  | `jyn-foxtail` | 鲸鱼娘·狗尾巴草 | Frames2d gameplay pet (contributed by stushansusu under MIT): papercut whale-girl with thirteen 3.00 s frame tracks (idle, tease, eat, heart, face, work, work-success, work-fail, sleep, sleeping, snack, sneeze, yawn) carrying click, work, sleep and idle-director gameplay, plus one static webp cover per track under previews/ |
package/README.zh.md CHANGED
@@ -5,7 +5,7 @@
5
5
  <p align="center">
6
6
  <img src="https://img.shields.io/npm/v/@linxin666/dsh-client-ui-pet?style=flat-square" alt="Version">
7
7
  &nbsp;
8
- <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.2-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
8
+ <img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.3-4c6ef5?style=flat-square&amp;labelColor=454a54" alt="DSH">
9
9
  &nbsp;
10
10
  <img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
11
11
  </p>
@@ -104,7 +104,7 @@ node scripts/dsh-pet install <dir> --force # 覆盖同名已安装宠物
104
104
 
105
105
  ## 语音包与面板定制(voice.json,宠物中心 M4,#677)
106
106
 
107
- 气泡里的状态/工具/碎碎念文案与悬浮面板的按钮/统计文案,都可以被一只宠物(或你本人)整体替换——宠物不再只能换图,还能换「话」与「面板」。载体是宠物目录内的可选 voice.json(随宠物分发),以及全局覆盖文件 $DSH_HOME/pets/.voice.json(不改宠物目录即可换词)。
107
+ 气泡里的状态/工具/碎碎念文案与悬浮面板的按钮/统计/等级名,都可以被一只宠物(或你本人)整体替换——宠物不再只能换图,还能换「话」与「面板」。载体是宠物目录内的可选 voice.json(随宠物分发),以及全局覆盖文件 $DSH_HOME/pets/.voice.json(不改宠物目录即可换词)。
108
108
 
109
109
  ```jsonc
110
110
  {
@@ -128,6 +128,10 @@ node scripts/dsh-pet install <dir> --force # 覆盖同名已安装宠物
128
128
  "panel": { // 悬浮面板(每槽未声明时回落插件 i18n 文案)
129
129
  "labels": { "feed": "投喂", "hide": "藏起来", "rename": "起名字", "confirm": "好的" },
130
130
  "stats": { "rank": "好感 {rank}", "treats": "鱼干 ×{n}", "points": "{points} 分" },
131
+ "ranks": [ // 仅显示用的等级阶梯;首条 min 必须为 0
132
+ { "min": 0, "name": "小煤球", "nameEn": "Little Coal Ball" },
133
+ { "min": 25, "name": "火星伙伴", "nameEn": "Martian Buddy" }
134
+ ],
131
135
  "actions": ["feed", "rename", "hide"] // 子集(按规范顺序);省略 = 全部;[] = 只显示统计行
132
136
  }
133
137
  }
@@ -135,6 +139,7 @@ node scripts/dsh-pet install <dir> --force # 覆盖同名已安装宠物
135
139
 
136
140
  - 合并优先级(逐槽):宠物自带 voice.json > 全局 .voice.json > 内置文案。status/tools/whispers 逐键合并、panel 逐槽合并,任何层缺失的槽位回落下一层。
137
141
  - 占位符白名单:tools 允许 {tool} / {hint};toolRemaining 允许 {n};panel.stats 允许 {rank} / {n} / {points};status、碎碎念与面板标签不允许任何占位符(含非法占位符的行被警告丢弃)。
142
+ - 等级阶梯(panel.ranks):替换该宠物内置的鲸鱼等级名,仅影响显示——点数、每轮奖励、冷却与持久化账本都不变。必须是 1-16 条的数组,首条 min 为 0,min 严格递增且唯一,名字 1-24 字符。name 为默认名字;nameEn 在 UI 语言为英文时显示(省略则两种语言都用 name)。非法阶梯整体丢弃并警告,沿用内置名字。panel.stats 的 {rank} 收到宠物当前等级名。
138
143
  - 上限(warn-and-drop):每池 64 行以内、每行 160 字符以内;面板标签 40 以内、统计 80 字符以内。
139
144
  - 坏包不影响宠物:voice.json 不是合法 JSON 或根不是对象 → 警告并整体忽略;其余问题逐槽警告丢弃。node scripts/dsh-pet validate <dir> 会把结构错误判为安装失败、内容问题列为警告。
140
145
  - 语义细节:status/tools 的空池回落内置文案(场景行始终有话说);whispers 的显式空数组是静音(关掉该通道);面板 actions 为空数组 = 三个按钮全部隐藏;未覆盖的按钮/统计继续使用插件双语字典。旧的 whispers.generic / whispers.rules 字段已不再支持,会被忽略并给出警告。
@@ -246,6 +251,7 @@ ctx.effect(() => ctx.pet.registerPanelAction({
246
251
  | 注册表 id | 选择器名称 | 来源 |
247
252
  |---|---|---|
248
253
  | `blue-throated-bee-eater` | 蓝喉蜂虎 | 贡献者以 Apache-2.0 贡献的伙伴插画(12 张同角色 AI 立绘素材,配色取蓝喉蜂虎皮肤同源;由 docs/archive/blue-throated-bee-eater-pet/gen-pet.py 组装,各轨道独立姿态:栖枝/飞行/正面悬停/挥翅/降落/垂头/歪头/昂首;饲料以「小蜜蜂」命名) |
254
+ | `deep-chan` | deep酱 | 由 Daizhdd 贡献的 sprite2d 像素风宠物:8 列 × 9 行、格 256×288 的图集(2048×2592,共 57 帧)——其中 49 帧为逐帧绘制的独立姿势,行走 8 帧是完整步态循环、跳跃 5 帧是独立姿势,其余状态由表情与小幅动作连续变化——另有 8 帧左走由右走水平镜像而来。deep酱 是「鲸鱼娘」的非官方同人二创形象:角色及相关权利归 DeepSeek 所有,与官方无隶属或背书关系,素材仅限个人非商业使用(见 THIRD_PARTY_NOTICES.md)。只放仓库、不随 npm 包发布 |
249
255
  | `doro` | doro | 由 stushansusu 以 MIT 许可证贡献的 frames2d 玩法宠物:11 条轨道 / 802 帧 42ms webp 序列——呼吸待机、打工三件套、睡觉、洗澡模式(心情 +3/秒)、随机漫游用的四向爬行、三个待机小动作(cola / orange / tongue)与仅拖拽期间播放的挣扎循环。Doro 是《胜利女神:妮姬》桃乐丝的非官方同人二创/梗衍生形象,角色及相关权利归 SHIFT UP 所有——仅限个人非商业使用,与官方无隶属或背书关系(见 THIRD_PARTY_NOTICES.md)。 |
250
256
  | `jyn` | 女仆鲸鱼娘 | frames2d 玩法宠物(stushansusu 以 MIT 贡献):带打工/睡觉/触摸玩法与三款可选皮肤(暗夜鎏金 / 蓝海霓裳 / 冰晶公主)的女仆鲸鱼同桌宠,每款皮肤各带一个概率掷骰点击动作;暗夜鎏金另将专属休息循环换入睡觉玩法 |
251
257
  | `jyn-foxtail` | 鲸鱼娘·狗尾巴草 | 由 stushansusu 以 MIT 贡献的 frames2d 玩法宠物:剪纸风格的鲸鱼娘,13 条 3.00s 帧序列轨道(idle / tease / eat / heart / face / work / work-success / work-fail / sleep / sleeping / snack / sneeze / yawn),带点击、打工、睡觉与四个待机小动作玩法;previews/ 下每条轨道一张静态 webp 封面 |
@@ -204,6 +204,33 @@
204
204
  ]
205
205
  },
206
206
  "description": "Subset of actions to render in canonical order; absent = all three, [] = none."
207
+ },
208
+ "ranks": {
209
+ "type": "array",
210
+ "minItems": 1,
211
+ "maxItems": 16,
212
+ "description": "Display-only affinity ladder replacing the built-in tier names for this pet. Points, rewards, cooldowns and the persisted ledger are unchanged. The first entry must be min 0; min values are unique and ascending; each name is 1-24 characters. An invalid ladder is dropped whole with a warning and the built-in names stay.",
213
+ "items": {
214
+ "type": "object",
215
+ "additionalProperties": false,
216
+ "required": ["min", "name"],
217
+ "properties": {
218
+ "min": {
219
+ "type": "integer",
220
+ "minimum": 0
221
+ },
222
+ "name": {
223
+ "type": "string",
224
+ "minLength": 1,
225
+ "maxLength": 24
226
+ },
227
+ "nameEn": {
228
+ "type": "string",
229
+ "minLength": 1,
230
+ "maxLength": 24
231
+ }
232
+ }
233
+ }
207
234
  }
208
235
  }
209
236
  },
package/lib/client.js CHANGED
@@ -213,16 +213,40 @@ window.__ModuleLoader__.load({
213
213
  return rowOf(animation);
214
214
  }
215
215
  /**
216
+ * Integer size of one cell after `scale`, in device-independent px.
217
+ *
218
+ * Rounding happens here, once, so the rendered atlas grid is integral end to
219
+ * end (issue #17): `background-size` is this size times the column/row count
220
+ * and every frame offset is an exact multiple of it. A fractional cell size
221
+ * leaves each frame on a sub-pixel boundary — 192px cells at `display.size`
222
+ * 160 scale to 147.69px — and the compositor then has to resample the whole
223
+ * scaled atlas on every frame change instead of translating an already-scaled
224
+ * bitmap by whole pixels. The pet advances a frame every 300-700 ms, so that
225
+ * resample was running continuously for a background surface the size of the
226
+ * sprite. A floor of 1px keeps a legally tiny display.size from collapsing the
227
+ * cell to zero and rendering nothing.
228
+ */
229
+ function scaledCellSize(cell, scale) {
230
+ return {
231
+ width: Math.max(1, Math.round(cell.width * scale)),
232
+ height: Math.max(1, Math.round(cell.height * scale))
233
+ };
234
+ }
235
+ /**
216
236
  * Background-position (px) of one frame cell within the scaled atlas.
217
237
  * The background image is scaled by `scale` (element size ÷ cell size), and
218
238
  * background-position offsets are applied in SCALED coordinates — using raw
219
239
  * atlas coordinates here would drift each frame by the scale factor and
220
- * render torn/overlapping frames.
240
+ * render torn/overlapping frames. The scaled cell is quantized by
241
+ * {@link scaledCellSize}, so the offset of frame N is exactly N whole cells:
242
+ * the atlas is snapped to the pixel grid and a frame change is a plain
243
+ * translate of the scaled bitmap.
221
244
  */
222
245
  function framePosition(cell, row, col, scale = 1) {
246
+ const scaled = scaledCellSize(cell, scale);
223
247
  return {
224
- x: -col * cell.width * scale,
225
- y: -row * cell.height * scale
248
+ x: -col * scaled.width,
249
+ y: -row * scaled.height
226
250
  };
227
251
  }
228
252
  /**
@@ -246,8 +270,8 @@ window.__ModuleLoader__.load({
246
270
  function createSequenceTimeline(sequence, tracks) {
247
271
  const itemDurations = sequence.map((animation) => tracks[animation].durations.reduce((sum, value) => sum + value, 0));
248
272
  const sequenceDuration = itemDurations.reduce((sum, value) => sum + value, 0);
249
- return { frameAt(elapsedMs) {
250
- let offset = Math.max(0, elapsedMs) % sequenceDuration;
273
+ const locate = (elapsedMs) => {
274
+ let offset = sequenceDuration > 0 ? Math.max(0, elapsedMs) % sequenceDuration : 0;
251
275
  let itemIndex = 0;
252
276
  while (itemIndex < sequence.length - 1 && offset >= itemDurations[itemIndex]) {
253
277
  offset -= itemDurations[itemIndex];
@@ -262,13 +286,28 @@ window.__ModuleLoader__.load({
262
286
  }
263
287
  return {
264
288
  animation,
265
- frameIndex
289
+ track,
290
+ frameIndex,
291
+ offsetInFrame: offset
266
292
  };
267
- } };
293
+ };
294
+ return {
295
+ frameAt(elapsedMs) {
296
+ const point = locate(elapsedMs);
297
+ return {
298
+ animation: point.animation,
299
+ frameIndex: point.frameIndex
300
+ };
301
+ },
302
+ remainingAt(elapsedMs) {
303
+ const point = locate(elapsedMs);
304
+ return Math.max(1, (point.track.durations[point.frameIndex] ?? 0) - point.offsetInFrame);
305
+ }
306
+ };
268
307
  }
269
308
  //#endregion
270
309
  //#region \0dsh-css:src/client/pet.module.css.mjs
271
- const css$2 = ".v78Lda_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}.v78Lda_sprite{image-rendering:auto;touch-action:none;contain:paint}.v78Lda_spriteWrap{flex:none;position:relative}.v78Lda_bubble{white-space:nowrap;padding:calc(4px * var(--pet-bubble-scale,1)) calc(10px * var(--pet-bubble-scale,1));font-size:calc(12px * var(--pet-bubble-scale,1));color:#f4f7ff;pointer-events:none;border-radius:999px;margin-bottom:6px;line-height:1.4;animation:2.6s ease-out forwards v78Lda_pet-bubble-pop;position:absolute;bottom:100%;box-shadow:0 2px 8px #00000040}.v78Lda_bubblePet{background:#4d6bfef2}.v78Lda_bubbleFeed{background:#0369a1f2}.v78Lda_bubbleStatus{max-width:min(calc(280px * var(--pet-bubble-scale,1)), calc(100vw - 24px));text-overflow:ellipsis;padding:calc(5px * var(--pet-bubble-scale,1)) calc(12px * var(--pet-bubble-scale,1));backdrop-filter:blur(8px);letter-spacing:.02em;background:linear-gradient(160deg,#131c36e6,#070b1af0);border:1px solid #7e98ff73;animation:.24s ease-out v78Lda_pet-bubble-in;overflow:hidden;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.v78Lda_bubbleWhisper{letter-spacing:.03em;animation:.32s cubic-bezier(.22,1,.36,1) v78Lda_pet-whisper-in}.v78Lda_bubbleWhisper:before{content:\"「\";opacity:.7;margin-right:2px}.v78Lda_bubbleWhisper:after{content:\"」\";opacity:.7;margin-left:2px}.v78Lda_bubbleStack{pointer-events:auto;flex-direction:column-reverse;align-items:center;gap:4px;display:flex;position:absolute;bottom:100%}.v78Lda_bubbleAnchor{display:inline-flex;position:relative}.v78Lda_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}.v78Lda_bubbleMore:hover{filter:brightness(1.15)}.v78Lda_bubbleMore:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.v78Lda_bubbleStack .v78Lda_bubble{pointer-events:auto;margin-bottom:0;position:relative;bottom:auto}.v78Lda_bubbleClickable{cursor:pointer;font:inherit;text-align:center;appearance:none;transition:filter .12s,box-shadow .12s}.v78Lda_bubbleClickable:hover{filter:brightness(1.12)}.v78Lda_bubbleClickable:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@keyframes v78Lda_pet-bubble-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes v78Lda_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 v78Lda_pet-panel-in{0%{opacity:0;transform:translateY(4px)scale(.97)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes v78Lda_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)}}.v78Lda_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) v78Lda_pet-panel-in;display:flex;position:absolute;top:100%;box-shadow:0 8px 24px #02061773,0 0 0 1px #4d6bfe1a,inset 0 1px #e2e8ff14}.v78Lda_panel:after{content:\"\";height:14px;position:absolute;bottom:100%;left:0;right:0}.v78Lda_panelAbove{transform-origin:50% 100%;margin-top:0;margin-bottom:8px;top:auto;bottom:100%}.v78Lda_panelAbove:after{top:100%;bottom:auto}.v78Lda_rankRow{white-space:nowrap;justify-content:space-between;gap:10px;display:flex}.v78Lda_nameCell{letter-spacing:.02em;background:linear-gradient(90deg,#a9c1ff,#6c8bff 60%,#4d6bfe);color:#0000;-webkit-background-clip:text;background-clip:text;font-weight:600}.v78Lda_statRank{color:#9db4ff;font-weight:600}.v78Lda_statTreats{color:#7dd3fc;font-weight:600}.v78Lda_statPoints{color:#fcd34d;font-weight:600}.v78Lda_renameRow{align-items:center;gap:6px;display:flex}.v78Lda_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}.v78Lda_nameInput:focus{border-color:#4d6bfe;box-shadow:0 0 0 2px #4d6bfe73}.v78Lda_actions{gap:6px;display:flex}.v78Lda_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}.v78Lda_action:hover{filter:brightness(1.08);transform:translateY(-1px);box-shadow:0 4px 10px #4d6bfe66}.v78Lda_action:active{filter:brightness(.94);transform:translateY(0);box-shadow:0 1px 4px #4d6bfe4d}.v78Lda_action:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.v78Lda_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}.v78Lda_summon:hover{color:#c3d3ff;background:#070b1ae6;border-color:#7e98fff2}.v78Lda_summon:active{color:#8ea6ff;border-color:#7e98ffcc}.v78Lda_summon:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@media (prefers-reduced-motion:reduce){.v78Lda_bubble,.v78Lda_bubbleStatus,.v78Lda_bubbleWhisper,.v78Lda_panel{opacity:1;animation:none}.v78Lda_action,.v78Lda_summon,.v78Lda_bubbleMore{transition:none}}.v78Lda_gameplayHud{width:0;height:0;position:absolute;bottom:0;left:0}.v78Lda_gameplayModeChip{color:#cdd7ff;white-space:nowrap;pointer-events:none;background:#7e98ff2e;border-radius:999px;padding:1px 8px;font-size:10px;position:absolute;top:0;left:0;transform:translateY(-100%)translateY(-4px)}.v78Lda_gameplayCard{color:#dfe6ff;background:#070b1aeb;border:1px solid #7e98ff40;border-radius:10px;min-width:180px;max-height:340px;padding:10px 12px;font-size:12px;position:absolute;bottom:0;left:0;overflow-y:auto;transform:none;box-shadow:0 8px 24px #0006}.v78Lda_gameplayBars{flex-direction:column;gap:4px;margin-bottom:8px;display:flex}.v78Lda_gameplayBarRow{align-items:center;gap:6px;display:flex}.v78Lda_gameplayBarLabel{color:#9aa8d8;flex-shrink:0;width:34px}.v78Lda_gameplayBarTrack{background:#7e98ff26;border-radius:3px;flex:1;height:6px;overflow:hidden}.v78Lda_gameplayBarFill{background:linear-gradient(90deg,#7e98ff,#9db4ff);border-radius:3px;height:100%;transition:width .3s;display:block}.v78Lda_gameplayActions{flex-wrap:wrap;gap:6px;display:flex}.v78Lda_gameplayShopItems{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:8px;display:grid}.v78Lda_gameplayShopItem{color:inherit;cursor:pointer;background:#7e98ff14;border:1px solid #7e98ff40;border-radius:8px;flex-direction:column;align-items:center;gap:4px;padding:8px 6px;display:flex}.v78Lda_gameplayShopItem:hover{background:#7e98ff29;border-color:#7e98ffb3}.v78Lda_gameplayShopItemImage{object-fit:contain;width:36px;height:36px;image-rendering:pixelated;pointer-events:none}.v78Lda_gameplayShopItemLabel{text-align:center;font-size:11px}.v78Lda_gameplayShopItemPrice{color:#ffd27e;font-size:10px}.v78Lda_gameplaySkinItems{flex-direction:column;gap:6px;margin-bottom:8px;display:flex}.v78Lda_gameplaySkinItem{width:100%;color:inherit;cursor:pointer;text-align:left;background:#7e98ff14;border:1px solid #7e98ff40;border-radius:8px;padding:8px 10px;font-size:12px;display:block}.v78Lda_gameplaySkinItem:hover{background:#7e98ff29;border-color:#7e98ffb3}.v78Lda_gameplaySkinItemActive{background:#7e98ff47;border-color:#7e98ffe6}.v78Lda_gameplayClose{color:#9aa8d8;cursor:pointer;background:0 0;border:none;padding:0 2px;font-size:14px;position:absolute;top:4px;right:8px}.v78Lda_gameplayClose:hover{color:#fff}.v78Lda_gameplayFloat{color:#3a2a00;white-space:nowrap;pointer-events:none;background:#ffd27eeb;border-radius:999px;padding:2px 10px;font-size:11px;animation:1.1s ease-out forwards v78Lda_pet-gameplay-float;position:absolute;top:-8px;left:50%;transform:translate(-50%)}@keyframes v78Lda_pet-gameplay-float{0%{opacity:0;transform:translate(-50%)translateY(6px)}20%{opacity:1}to{opacity:0;transform:translate(-50%)translateY(-18px)}}@media (prefers-reduced-motion:reduce){.v78Lda_gameplayFloat{opacity:1;animation:none}.v78Lda_gameplayBarFill{transition:none}}.v78Lda_bubbleUsage{white-space:nowrap;backdrop-filter:blur(8px);letter-spacing:.02em;background:linear-gradient(160deg,#131c36eb,#070b1af2);border:1px solid #7e98ff73;flex-direction:column;align-items:stretch;gap:3px;min-width:128px;max-width:min(280px,100vw - 24px);padding:6px 12px;animation:.28s cubic-bezier(.22,1,.36,1) v78Lda_pet-usage-in;display:flex;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.v78Lda_bubbleUsageHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.v78Lda_bubbleUsageTitle{text-overflow:ellipsis;opacity:.85;overflow:hidden}.v78Lda_bubbleUsageValue{font-variant-numeric:tabular-nums;flex-shrink:0;font-weight:600}.v78Lda_bubbleUsageNote{text-overflow:ellipsis;opacity:.55;font-size:10px;overflow:hidden}.v78Lda_bubbleUsageMeter{background:#e2e8ff24;border-radius:999px;height:4px;display:block;overflow:hidden}.v78Lda_bubbleUsageMeterFill{background:#6ee7b7;border-radius:999px;height:100%;transition:width .3s;display:block}.v78Lda_bubbleUsageOk{border-color:#7e98ff73}.v78Lda_bubbleUsageWarn{border-color:#fbbf248c}.v78Lda_bubbleUsageWarn .v78Lda_bubbleUsageMeterFill{background:#fbbf24}.v78Lda_bubbleUsageLow{border-color:#f8717199}.v78Lda_bubbleUsageLow .v78Lda_bubbleUsageMeterFill{background:#f87171}@keyframes v78Lda_pet-usage-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@media (prefers-reduced-motion:reduce){.v78Lda_bubbleUsage{animation:none}}";
310
+ const css$2 = ".v78Lda_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}.v78Lda_sprite{image-rendering:auto;touch-action:none;contain:paint}.v78Lda_spriteWrap{flex:none;position:relative}.v78Lda_bubble{white-space:nowrap;padding:calc(4px * var(--pet-bubble-scale,1)) calc(10px * var(--pet-bubble-scale,1));font-size:calc(12px * var(--pet-bubble-scale,1));color:#f4f7ff;pointer-events:none;border-radius:999px;margin-bottom:6px;line-height:1.4;animation:2.6s ease-out forwards v78Lda_pet-bubble-pop;position:absolute;bottom:100%;box-shadow:0 2px 8px #00000040}.v78Lda_bubblePet{background:#4d6bfef2}.v78Lda_bubbleFeed{background:#0369a1f2}.v78Lda_bubbleStatus{max-width:min(calc(280px * var(--pet-bubble-scale,1)), calc(100vw - 24px));text-overflow:ellipsis;padding:calc(5px * var(--pet-bubble-scale,1)) calc(12px * var(--pet-bubble-scale,1));letter-spacing:.02em;background:linear-gradient(160deg,#131c36e6,#070b1af0);border:1px solid #7e98ff73;animation:.24s ease-out v78Lda_pet-bubble-in;overflow:hidden;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.v78Lda_bubbleWhisper{letter-spacing:.03em;animation:.32s cubic-bezier(.22,1,.36,1) v78Lda_pet-whisper-in}.v78Lda_bubbleWhisper:before{content:\"「\";opacity:.7;margin-right:2px}.v78Lda_bubbleWhisper:after{content:\"」\";opacity:.7;margin-left:2px}.v78Lda_bubbleStack{pointer-events:auto;flex-direction:column-reverse;align-items:center;gap:4px;display:flex;position:absolute;bottom:100%}.v78Lda_bubbleAnchor{display:inline-flex;position:relative}.v78Lda_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}.v78Lda_bubbleMore:hover{filter:brightness(1.15)}.v78Lda_bubbleMore:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.v78Lda_bubbleStack .v78Lda_bubble{pointer-events:auto;margin-bottom:0;position:relative;bottom:auto}.v78Lda_bubbleClickable{cursor:pointer;font:inherit;text-align:center;appearance:none;transition:filter .12s,box-shadow .12s}.v78Lda_bubbleClickable:hover{filter:brightness(1.12)}.v78Lda_bubbleClickable:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@keyframes v78Lda_pet-bubble-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes v78Lda_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 v78Lda_pet-panel-in{0%{opacity:0;transform:translateY(4px)scale(.97)}to{opacity:1;transform:translateY(0)scale(1)}}@keyframes v78Lda_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)}}.v78Lda_panel{color:#e6ebf8;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) v78Lda_pet-panel-in;display:flex;position:absolute;top:100%;box-shadow:0 8px 24px #02061773,0 0 0 1px #4d6bfe1a,inset 0 1px #e2e8ff14}.v78Lda_panel:after{content:\"\";height:14px;position:absolute;bottom:100%;left:0;right:0}.v78Lda_panelAbove{transform-origin:50% 100%;margin-top:0;margin-bottom:8px;top:auto;bottom:100%}.v78Lda_panelAbove:after{top:100%;bottom:auto}.v78Lda_rankRow{white-space:nowrap;justify-content:space-between;gap:10px;display:flex}.v78Lda_nameCell{letter-spacing:.02em;background:linear-gradient(90deg,#a9c1ff,#6c8bff 60%,#4d6bfe);color:#0000;-webkit-background-clip:text;background-clip:text;font-weight:600}.v78Lda_statRank{color:#9db4ff;font-weight:600}.v78Lda_statTreats{color:#7dd3fc;font-weight:600}.v78Lda_statPoints{color:#fcd34d;font-weight:600}.v78Lda_renameRow{align-items:center;gap:6px;display:flex}.v78Lda_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}.v78Lda_nameInput:focus{border-color:#4d6bfe;box-shadow:0 0 0 2px #4d6bfe73}.v78Lda_actions{gap:6px;display:flex}.v78Lda_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}.v78Lda_action:hover{filter:brightness(1.08);transform:translateY(-1px);box-shadow:0 4px 10px #4d6bfe66}.v78Lda_action:active{filter:brightness(.94);transform:translateY(0);box-shadow:0 1px 4px #4d6bfe4d}.v78Lda_action:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}.v78Lda_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}.v78Lda_summon:hover{color:#c3d3ff;background:#070b1ae6;border-color:#7e98fff2}.v78Lda_summon:active{color:#8ea6ff;border-color:#7e98ffcc}.v78Lda_summon:focus-visible{outline:none;box-shadow:0 0 0 2px #7e98ffe6}@media (prefers-reduced-motion:reduce){.v78Lda_bubble,.v78Lda_bubbleStatus,.v78Lda_bubbleWhisper,.v78Lda_panel{opacity:1;animation:none}.v78Lda_action,.v78Lda_summon,.v78Lda_bubbleMore{transition:none}}.v78Lda_gameplayHud{width:0;height:0;position:absolute;bottom:0;left:0}.v78Lda_gameplayModeChip{color:#cdd7ff;white-space:nowrap;pointer-events:none;background:#7e98ff2e;border-radius:999px;padding:1px 8px;font-size:10px;position:absolute;top:0;left:0;transform:translateY(-100%)translateY(-4px)}.v78Lda_gameplayCard{color:#dfe6ff;background:#070b1aeb;border:1px solid #7e98ff40;border-radius:10px;min-width:180px;max-height:340px;padding:10px 12px;font-size:12px;position:absolute;bottom:0;left:0;overflow-y:auto;transform:none;box-shadow:0 8px 24px #0006}.v78Lda_gameplayBars{flex-direction:column;gap:4px;margin-bottom:8px;display:flex}.v78Lda_gameplayBarRow{align-items:center;gap:6px;display:flex}.v78Lda_gameplayBarLabel{color:#9aa8d8;flex-shrink:0;width:34px}.v78Lda_gameplayBarTrack{background:#7e98ff26;border-radius:3px;flex:1;height:6px;overflow:hidden}.v78Lda_gameplayBarFill{background:linear-gradient(90deg,#7e98ff,#9db4ff);border-radius:3px;height:100%;transition:width .3s;display:block}.v78Lda_gameplayActions{flex-wrap:wrap;gap:6px;display:flex}.v78Lda_gameplayShopItems{grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;margin-bottom:8px;display:grid}.v78Lda_gameplayShopItem{color:inherit;cursor:pointer;background:#7e98ff14;border:1px solid #7e98ff40;border-radius:8px;flex-direction:column;align-items:center;gap:4px;padding:8px 6px;display:flex}.v78Lda_gameplayShopItem:hover{background:#7e98ff29;border-color:#7e98ffb3}.v78Lda_gameplayShopItemImage{object-fit:contain;width:36px;height:36px;image-rendering:pixelated;pointer-events:none}.v78Lda_gameplayShopItemLabel{text-align:center;font-size:11px}.v78Lda_gameplayShopItemPrice{color:#ffd27e;font-size:10px}.v78Lda_gameplaySkinItems{flex-direction:column;gap:6px;margin-bottom:8px;display:flex}.v78Lda_gameplaySkinItem{width:100%;color:inherit;cursor:pointer;text-align:left;background:#7e98ff14;border:1px solid #7e98ff40;border-radius:8px;padding:8px 10px;font-size:12px;display:block}.v78Lda_gameplaySkinItem:hover{background:#7e98ff29;border-color:#7e98ffb3}.v78Lda_gameplaySkinItemActive{background:#7e98ff47;border-color:#7e98ffe6}.v78Lda_gameplayClose{color:#9aa8d8;cursor:pointer;background:0 0;border:none;padding:0 2px;font-size:14px;position:absolute;top:4px;right:8px}.v78Lda_gameplayClose:hover{color:#fff}.v78Lda_gameplayFloat{color:#3a2a00;white-space:nowrap;pointer-events:none;background:#ffd27eeb;border-radius:999px;padding:2px 10px;font-size:11px;animation:1.1s ease-out forwards v78Lda_pet-gameplay-float;position:absolute;top:-8px;left:50%;transform:translate(-50%)}@keyframes v78Lda_pet-gameplay-float{0%{opacity:0;transform:translate(-50%)translateY(6px)}20%{opacity:1}to{opacity:0;transform:translate(-50%)translateY(-18px)}}@media (prefers-reduced-motion:reduce){.v78Lda_gameplayFloat{opacity:1;animation:none}.v78Lda_gameplayBarFill{transition:none}}.v78Lda_bubbleUsage{white-space:nowrap;letter-spacing:.02em;background:linear-gradient(160deg,#131c36eb,#070b1af2);border:1px solid #7e98ff73;flex-direction:column;align-items:stretch;gap:3px;min-width:128px;max-width:min(280px,100vw - 24px);padding:6px 12px;animation:.28s cubic-bezier(.22,1,.36,1) v78Lda_pet-usage-in;display:flex;box-shadow:0 4px 12px #02061759,inset 0 1px #e2e8ff1a,0 0 12px #4d6bfe2e}.v78Lda_bubbleUsageHead{justify-content:space-between;align-items:baseline;gap:10px;display:flex}.v78Lda_bubbleUsageTitle{text-overflow:ellipsis;opacity:.85;overflow:hidden}.v78Lda_bubbleUsageValue{font-variant-numeric:tabular-nums;flex-shrink:0;font-weight:600}.v78Lda_bubbleUsageNote{text-overflow:ellipsis;opacity:.55;font-size:10px;overflow:hidden}.v78Lda_bubbleUsageMeter{background:#e2e8ff24;border-radius:999px;height:4px;display:block;overflow:hidden}.v78Lda_bubbleUsageMeterFill{background:#6ee7b7;border-radius:999px;height:100%;transition:width .3s;display:block}.v78Lda_bubbleUsageOk{border-color:#7e98ff73}.v78Lda_bubbleUsageWarn{border-color:#fbbf248c}.v78Lda_bubbleUsageWarn .v78Lda_bubbleUsageMeterFill{background:#fbbf24}.v78Lda_bubbleUsageLow{border-color:#f8717199}.v78Lda_bubbleUsageLow .v78Lda_bubbleUsageMeterFill{background:#f87171}@keyframes v78Lda_pet-usage-in{0%{opacity:0;transform:translateY(6px)scale(.96)}to{opacity:1;transform:translateY(0)scale(1)}}@media (prefers-reduced-motion:reduce){.v78Lda_bubbleUsage{animation:none}}";
272
311
  const tagId$2 = "@linxin666/dsh-pet/src/client/pet.module.css";
273
312
  if (typeof document !== "undefined" && document.querySelector("style[data-plugin-css=" + JSON.stringify(tagId$2) + "]") === null) {
274
313
  const tag = document.createElement("style");
@@ -479,10 +518,12 @@ window.__ModuleLoader__.load({
479
518
  });
480
519
  }
481
520
  /**
482
- * The floating pet. The spritesheet frame advances on requestAnimationFrame
483
- * with per-frame durations from the definition's tracks; the atlas image is
484
- * loaded once and the background position is written straight to the sprite
485
- * element (no per-frame React state).
521
+ * The floating pet. The spritesheet frame advances on a timer scheduled for the
522
+ * current frame's remaining time (per-frame durations come from the
523
+ * definition's tracks), so the loop wakes once per frame change instead of once
524
+ * per screen refresh; the atlas image is loaded once and the background
525
+ * position is written straight to the sprite element (no per-frame React
526
+ * state). Roaming writes the sprite's position the same way (issue #17).
486
527
  */
487
528
  function PetSprite(props) {
488
529
  const { snapshot, definition, display, feedback } = props;
@@ -514,11 +555,20 @@ window.__ModuleLoader__.load({
514
555
  const sequences = definition.sequences;
515
556
  const panel = definition.panel;
516
557
  const panelLabel = (slot, i18n) => panel?.labels?.[slot] ?? i18n;
558
+ const englishUi = (props.lang ?? (typeof document === "undefined" ? "zh" : document.documentElement.lang)).toLowerCase().startsWith("en");
559
+ const rankNameOf = () => {
560
+ const rawRank = snapshot?.affinity.rank ?? "?";
561
+ const rankEn = snapshot?.affinity.rankEn;
562
+ if (englishUi && rankEn !== void 0) return rankEn;
563
+ const rankKey = `pet.rank.name.${rawRank}`;
564
+ const localized = props.t(rankKey);
565
+ return localized !== rankKey ? localized : rawRank;
566
+ };
517
567
  const panelStat = (slot, i18nKey, values) => {
518
568
  const format = panel?.stats?.[slot] ?? props.t(i18nKey, values);
519
569
  if (panel?.stats?.[slot] === void 0) return format;
520
570
  const all = {
521
- rank: snapshot?.affinity.rank ?? "?",
571
+ rank: values.rank !== void 0 ? values.rank : rankNameOf(),
522
572
  n: snapshot?.treats.stocked ?? 0,
523
573
  points: snapshot?.affinity.points ?? 0
524
574
  };
@@ -566,6 +616,7 @@ window.__ModuleLoader__.load({
566
616
  const animation = snapshot?.animation ?? "idle";
567
617
  const scaleRef = (0, react.useRef)(spriteScale);
568
618
  scaleRef.current = spriteScale;
619
+ const paintedRef = (0, react.useRef)(null);
569
620
  (0, react.useEffect)(() => {
570
621
  if (props.visual !== void 0) return;
571
622
  const reduceMotion = typeof window !== "undefined" && window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches === true;
@@ -581,29 +632,37 @@ window.__ModuleLoader__.load({
581
632
  const leadAnimation = sequence?.[0] ?? animation;
582
633
  const row = rowOfTrack(leadAnimation);
583
634
  const track = trimTrack(tracks[leadAnimation], rows[row] ?? tracks[leadAnimation].frames.length);
584
- const leadCol = track.frames[0];
585
- const lead = framePosition(cell, row, leadCol, scaleRef.current);
586
- let lastPosStr = lead.x + "px " + lead.y + "px";
587
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = lastPosStr;
635
+ let lastPosStr = "";
636
+ const paint = (frameRow, col) => {
637
+ paintedRef.current = {
638
+ row: frameRow,
639
+ col
640
+ };
641
+ const pos = framePosition(cell, frameRow, col, scaleRef.current);
642
+ const posStr = pos.x + "px " + pos.y + "px";
643
+ if (posStr === lastPosStr) return;
644
+ lastPosStr = posStr;
645
+ if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = posStr;
646
+ };
647
+ paint(row, track.frames[0]);
588
648
  if (reduceMotion) return;
589
- let raf = 0;
649
+ let timer = 0;
590
650
  let last = performance.now();
591
651
  let sequenceElapsed = 0;
592
- const tick = (ts) => {
593
- const delta = ts - last;
594
- last = ts;
652
+ const schedule = (delay) => {
653
+ timer = window.setTimeout(tick, Math.max(1, delay));
654
+ };
655
+ const tick = () => {
656
+ timer = 0;
657
+ const now = performance.now();
658
+ const delta = now - last;
659
+ last = now;
595
660
  if (timeline !== void 0 && sequenceItems !== void 0) {
596
661
  sequenceElapsed += delta;
597
662
  const current = timeline.frameAt(sequenceElapsed);
598
663
  const item = sequenceItems.get(current.animation);
599
- const col = item.track.frames[current.frameIndex];
600
- const pos = framePosition(cell, item.row, col, scaleRef.current);
601
- const posStr = pos.x + "px " + pos.y + "px";
602
- if (posStr !== lastPosStr) {
603
- lastPosStr = posStr;
604
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = posStr;
605
- }
606
- raf = requestAnimationFrame(tick);
664
+ paint(item.row, item.track.frames[current.frameIndex]);
665
+ schedule(timeline.remainingAt(sequenceElapsed));
607
666
  return;
608
667
  }
609
668
  const st = frameRef.current;
@@ -619,22 +678,19 @@ window.__ModuleLoader__.load({
619
678
  st.index += 1;
620
679
  }
621
680
  if (st.elapsed >= (track.durations[st.index] ?? 0)) {
622
- if (track.loop) {
623
- st.elapsed = 0;
624
- st.index = 0;
625
- } else st.index = maxIndex;
626
- }
627
- const col = track.frames[st.index];
628
- const pos = framePosition(cell, row, col, scaleRef.current);
629
- const posStr = pos.x + "px " + pos.y + "px";
630
- if (posStr !== lastPosStr) {
631
- lastPosStr = posStr;
632
- if (spriteRef.current !== null) spriteRef.current.style.backgroundPosition = posStr;
681
+ if (!track.loop) {
682
+ st.index = maxIndex;
683
+ paint(row, track.frames[st.index]);
684
+ return;
685
+ }
686
+ st.elapsed = 0;
687
+ st.index = 0;
633
688
  }
634
- raf = requestAnimationFrame(tick);
689
+ paint(row, track.frames[st.index]);
690
+ schedule((track.durations[st.index] ?? 0) - st.elapsed);
635
691
  };
636
- raf = requestAnimationFrame(tick);
637
- return () => cancelAnimationFrame(raf);
692
+ schedule(0);
693
+ return () => window.clearTimeout(timer);
638
694
  }, [
639
695
  animation,
640
696
  phase,
@@ -645,6 +701,16 @@ window.__ModuleLoader__.load({
645
701
  sequences,
646
702
  props.visual
647
703
  ]);
704
+ (0, react.useLayoutEffect)(() => {
705
+ const painted = paintedRef.current;
706
+ if (props.visual !== void 0 || painted === null || spriteRef.current === null) return;
707
+ const pos = framePosition(cell, painted.row, painted.col, spriteScale);
708
+ spriteRef.current.style.backgroundPosition = pos.x + "px " + pos.y + "px";
709
+ }, [
710
+ spriteScale,
711
+ cell,
712
+ props.visual
713
+ ]);
648
714
  const feedbackDoneRef = (0, react.useRef)(props.onFeedbackDone);
649
715
  feedbackDoneRef.current = props.onFeedbackDone;
650
716
  (0, react.useEffect)(() => {
@@ -662,13 +728,13 @@ window.__ModuleLoader__.load({
662
728
  (0, react.useEffect)(() => () => clearHideTimer(), []);
663
729
  const onPointerDown = (e) => {
664
730
  if (props.dragDisabled === true) return;
665
- endWalk(false);
666
- e.preventDefault();
667
- e.target.setPointerCapture?.(e.pointerId);
668
- const current = dragPos ?? {
731
+ const current = walkTargetRef.current ?? dragPosRef.current ?? {
669
732
  right: display.right,
670
733
  bottom: display.bottom
671
734
  };
735
+ endWalk(false);
736
+ e.preventDefault();
737
+ e.target.setPointerCapture?.(e.pointerId);
672
738
  dragRef.current = {
673
739
  startX: e.clientX,
674
740
  startY: e.clientY,
@@ -699,17 +765,18 @@ window.__ModuleLoader__.load({
699
765
  if (draggedRef.current) props.onDraggingChange?.(false);
700
766
  if (dragPos !== null) props.onDragEnd(dragPos.right, dragPos.bottom);
701
767
  };
702
- const pos = dragPos ?? {
703
- right: display.right,
704
- bottom: display.bottom
705
- };
706
- const spriteWidth = Math.round(cell.width * spriteScale);
707
- const spriteHeight = Math.round(cell.height * spriteScale);
708
768
  const [facingRight, setFacingRight] = (0, react.useState)(false);
709
769
  const walkRafRef = (0, react.useRef)(0);
710
770
  const walkTargetRef = (0, react.useRef)(null);
711
771
  const dragPosRef = (0, react.useRef)(dragPos);
712
772
  dragPosRef.current = dragPos;
773
+ const pos = walkTargetRef.current ?? dragPos ?? {
774
+ right: display.right,
775
+ bottom: display.bottom
776
+ };
777
+ const scaled = scaledCellSize(cell, spriteScale);
778
+ const spriteWidth = scaled.width;
779
+ const spriteHeight = scaled.height;
713
780
  /** Stop an active walk; `persist` lands the pet on the spot it reached. */
714
781
  const endWalk = (persist) => {
715
782
  if (walkRafRef.current === 0) return;
@@ -718,7 +785,9 @@ window.__ModuleLoader__.load({
718
785
  setFacingRight(false);
719
786
  const settled = walkTargetRef.current;
720
787
  walkTargetRef.current = null;
721
- if (persist && settled !== null) props.onDragEnd(settled.right, settled.bottom);
788
+ if (settled === null) return;
789
+ setDragPos(settled);
790
+ if (persist) props.onDragEnd(settled.right, settled.bottom);
722
791
  };
723
792
  (0, react.useEffect)(() => {
724
793
  const bus = props.bus;
@@ -754,7 +823,11 @@ window.__ModuleLoader__.load({
754
823
  bottom: current.bottom + (target.bottom - current.bottom) * t
755
824
  };
756
825
  walkTargetRef.current = next;
757
- setDragPos(next);
826
+ const el = floatRef.current;
827
+ if (el !== null) {
828
+ el.style.right = next.right + "px";
829
+ el.style.bottom = next.bottom + "px";
830
+ }
758
831
  if (t < 1) {
759
832
  walkRafRef.current = window.requestAnimationFrame(step);
760
833
  return;
@@ -762,6 +835,7 @@ window.__ModuleLoader__.load({
762
835
  walkRafRef.current = 0;
763
836
  walkTargetRef.current = null;
764
837
  setFacingRight(false);
838
+ setDragPos(next);
765
839
  props.onDragEnd(next.right, next.bottom);
766
840
  };
767
841
  walkRafRef.current = window.requestAnimationFrame(step);
@@ -862,7 +936,7 @@ window.__ModuleLoader__.load({
862
936
  height: spriteHeight,
863
937
  ...props.visual === void 0 ? {
864
938
  backgroundImage: imageReady ? "url(" + definition.atlasUrl + ")" : void 0,
865
- backgroundSize: cell.width * columns * spriteScale + "px " + cell.height * (definition.atlasRows ?? rows.length) * spriteScale + "px",
939
+ backgroundSize: scaled.width * columns + "px " + scaled.height * (definition.atlasRows ?? rows.length) + "px",
866
940
  backgroundRepeat: "no-repeat",
867
941
  backgroundPosition: "0 0"
868
942
  } : {},
@@ -993,12 +1067,7 @@ window.__ModuleLoader__.load({
993
1067
  children: displayName
994
1068
  }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
995
1069
  className: pet_module_css_default.statRank,
996
- children: (() => {
997
- const rawRank = snapshot?.affinity.rank ?? "?";
998
- const rankKey = `pet.rank.name.${rawRank}`;
999
- const localized = props.t(rankKey);
1000
- return panelStat("rank", "pet.rank", { rank: localized !== rankKey ? localized : rawRank });
1001
- })()
1070
+ children: panelStat("rank", "pet.rank", { rank: rankNameOf() })
1002
1071
  })]
1003
1072
  }),
1004
1073
  /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
@@ -2010,6 +2079,7 @@ window.__ModuleLoader__.load({
2010
2079
  portalTarget: props.portalTarget,
2011
2080
  dragDisabled: snapshot.gameplay?.mode === "work",
2012
2081
  ...aux === null ? {} : { bus: aux.bus },
2082
+ lang: props.lang,
2013
2083
  ...gameplay === void 0 || aux === null ? {} : {
2014
2084
  onGameplayTap: (fx, fy) => aux.bus.tap?.(fx, fy),
2015
2085
  onGameplayMenu: () => aux.bus.openCard?.(),
@@ -4236,7 +4306,7 @@ window.__ModuleLoader__.load({
4236
4306
  /** The building package's version, when the bundle carries it. */
4237
4307
  function bakedVersion() {
4238
4308
  try {
4239
- return "0.4.7";
4309
+ return "0.4.9";
4240
4310
  } catch {
4241
4311
  return;
4242
4312
  }
@@ -4729,17 +4799,23 @@ window.__ModuleLoader__.load({
4729
4799
  container.dataset.dshPlugin = "pet";
4730
4800
  document.body.appendChild(container);
4731
4801
  const petRoot = (0, react_dom_client.createRoot)(container);
4732
- petRoot.render((0, react.createElement)(PetDockEntry, {
4733
- ...injected(),
4734
- t: ctx.locale.bind("pet"),
4735
- portalTarget: container
4736
- }));
4802
+ const renderPet = () => {
4803
+ petRoot.render((0, react.createElement)(PetDockEntry, {
4804
+ ...injected(),
4805
+ t: ctx.locale.bind("pet"),
4806
+ lang: ctx.locale.getLocale().active,
4807
+ portalTarget: container
4808
+ }));
4809
+ };
4810
+ renderPet();
4811
+ const unsubscribeLocale = ctx.locale.subscribe(renderPet);
4737
4812
  let uiGone = false;
4738
4813
  disposeUi = () => {
4739
4814
  if (uiGone) return;
4740
4815
  uiGone = true;
4741
4816
  clearUiTeardown?.();
4742
4817
  clearUiTeardown = void 0;
4818
+ unsubscribeLocale();
4743
4819
  petRoot.unmount();
4744
4820
  container.remove();
4745
4821
  disposePoll();