@linxin666/dsh-pet 0.4.5 → 0.4.7
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 +2 -2
- package/README.md +30 -3
- package/README.zh.md +30 -3
- package/lib/client.js +178 -62
- package/lib/client.js.map +1 -1
- package/lib/index.js +734 -26
- package/lib/live2d-vendor.js +129 -95
- package/lib/live2d-vendor.js.map +1 -1
- package/lib/types/announce.d.ts +16 -0
- package/lib/types/announce.d.ts.map +1 -1
- package/lib/types/announce.js +16 -0
- package/lib/types/client/PetDockEntry.d.ts +6 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +1 -1
- package/lib/types/client/PetSettingsCard.d.ts +4 -0
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +16 -1
- package/lib/types/client/PetSprite.d.ts +7 -0
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +23 -13
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +43 -11
- package/lib/types/client/locales.d.ts +4 -0
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +4 -0
- package/lib/types/client/renderers/frames2d.d.ts +5 -3
- package/lib/types/client/renderers/frames2d.d.ts.map +1 -1
- package/lib/types/client/renderers/frames2d.js +139 -33
- package/lib/types/index.d.ts +14 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +15 -2
- package/lib/types/panel-actions.d.ts +96 -0
- package/lib/types/panel-actions.d.ts.map +1 -0
- package/lib/types/panel-actions.js +134 -0
- package/lib/types/routes.d.ts.map +1 -1
- package/lib/types/routes.js +10 -0
- package/lib/types/service.d.ts +137 -9
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +151 -19
- package/package.json +26 -30
- package/src/announce.ts +17 -0
- package/src/client/PetDockEntry.test.tsx +1 -0
- package/src/client/PetDockEntry.tsx +7 -0
- package/src/client/PetSettingsCard.test.tsx +88 -0
- package/src/client/PetSettingsCard.tsx +31 -0
- package/src/client/PetSprite.test.tsx +197 -0
- package/src/client/PetSprite.tsx +56 -12
- package/src/client/index.test.tsx +74 -4
- package/src/client/index.ts +43 -11
- package/src/client/locales.ts +4 -0
- package/src/client/renderers/frames2d.test.ts +103 -1
- package/src/client/renderers/frames2d.ts +143 -30
- package/src/index.test.ts +22 -0
- package/src/index.ts +28 -2
- package/src/panel-actions.test.ts +130 -0
- package/src/panel-actions.ts +182 -0
- package/src/registry.test.ts +3 -2
- package/src/routes.ts +9 -0
- package/src/service.test.ts +128 -0
- package/src/service.ts +206 -22
- package/lib/invariant.js +0 -34
- package/lib/state-NvDEoCln.js +0 -455
- package/lib/types/invariant.d.ts +0 -10
- package/lib/types/invariant.d.ts.map +0 -1
- package/lib/types/invariant.js +0 -27
- package/src/invariant.ts +0 -40
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:
|
|
6
|
-
README.zh.md:
|
|
5
|
+
README.md: 0cbcc24eabf828fc151228b442cecb4c765ea81d
|
|
6
|
+
README.zh.md: 0376878bdc8f38229485b00987e586b3e92c985f
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.2-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -36,10 +36,11 @@ Re-engineered from desktop companion concepts into an official DSH cordis bundle
|
|
|
36
36
|
| Dragging | Hold and drag the pet to reposition; position persisted |
|
|
37
37
|
| Hide/Summon | The hover panel sits below the pet (lifted above the status bubbles when there is no room below) and provides 隐藏 (Hide); after hiding, a 召唤{name} (Summon {name}) button appears |
|
|
38
38
|
| Witty remarks | Built-in remark library (10 lines per event) plus per-pet custom lines; success lines rotate by persisted success counts and cooldown lines by persisted rejection counts |
|
|
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 |
|
|
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
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 |
|
|
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 |
|
|
43
44
|
|
|
44
45
|
## Pet contract
|
|
45
46
|
|
|
@@ -213,7 +214,32 @@ A status bubble can carry a small ornament ahead of its text (built-in: the spou
|
|
|
213
214
|
- Switch: Settings > Pet > Status decoration (on by default). The built-in whale derives from the DeepSeek wordmark (MIT); see THIRD_PARTY_NOTICES.md.
|
|
214
215
|
## Announcement bubbles (pet.announce)
|
|
215
216
|
|
|
216
|
-
Host-side sibling plugins can push one structured announcement through the `pet` cordis service (`ctx.pet.announce({ source, kind, title, ... })`); the browser half renders it as a dedicated, specially styled bubble riding the top of the session bubble stack — its own glass style with a tone accent (`ok`/`warn`/`low`), an amount pill for balance or today-spend kinds, a mini meter for plan-percent windows, and the reset instant. The payload is validated into a bounded shape (src/announce.ts): unknown fields drop, text truncates, TTL clamps to 1 s - 2 h (default 10 s; a repeating announcer declares its poll cadence so an always-mode bubble stays continuous, and the ceiling still unmounts a dead source's bubble within one missed refresh), and a malformed announcement is dropped silently. Announcements are in-memory only:
|
|
217
|
+
Host-side sibling plugins can push one structured announcement through the `pet` cordis service (`ctx.pet.announce({ source, kind, title, ... })`); the browser half renders it as a dedicated, specially styled bubble riding the top of the session bubble stack — its own glass style with a tone accent (`ok`/`warn`/`low`), an amount pill for balance or today-spend kinds, a mini meter for plan-percent windows, and the reset instant. The payload is validated into a bounded shape (src/announce.ts): unknown fields drop, text truncates, TTL clamps to 1 s - 2 h (default 10 s; a repeating announcer declares its poll cadence so an always-mode bubble stays continuous, and the ceiling still unmounts a dead source's bubble within one missed refresh), and a malformed announcement is dropped silently. Announcements are in-memory only: each publisher holds its own slot keyed by `source`, an expired one stops rendering, and neither pet.json nor the ledger is touched. There is deliberately no HTTP surface — the API is the in-process service, per the cross-plugin collaboration rule.
|
|
218
|
+
|
|
219
|
+
**Several publishers on one pet.** The contract started with a single slot, so a second announcing plugin displaced the first; `source` is now the slot key — the payload already carried it — and each publisher keeps its own TTL. Every fresh slot renders as its own bubble, stacked above the session bubbles in the order each publisher first arrived: a repeating publisher refreshes its own bubble in place, so two publishers on different cadences never swap positions and the stack never flickers. The table is bounded (`MAX_ANNOUNCEMENTS`, 4). A lapsed publisher frees its own slot; a genuinely full table hands its oldest slot to the arriving publisher rather than refusing it, so a publisher that keeps refreshing is never the one evicted. For a rolling upgrade the freshest slot is also served under the original singular `announcement` field, so a browser half predating the array keeps rendering one bubble instead of none.
|
|
220
|
+
|
|
221
|
+
## Plugin panel actions (pet.registerPanelAction)
|
|
222
|
+
|
|
223
|
+
Host-side sibling plugins can add their own button to the pet's hover panel action row, next to the built-in Feed / Rename / Hide:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
ctx.effect(() => ctx.pet.registerPanelAction({
|
|
227
|
+
id: 'pet-quota-swap', // kebab id; a click dispatches back on it
|
|
228
|
+
label: '换装', // bounded label (the row wraps past it)
|
|
229
|
+
title: '切换到下一只宠物', // optional tooltip
|
|
230
|
+
order: 0, // optional sort key within the registered block
|
|
231
|
+
onSelect: async ({ petId }) => { /* the plugin does the work */ },
|
|
232
|
+
}))
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- The pet owns the row and the plugin owns the button: the host validates every registration (src/panel-actions.ts), serves the registered actions in the state snapshot (`panelActions`), and dispatches a click from `POST /api/pet/panel-action` back to `onSelect`. Extensions render after the built-in buttons, so they survive a voice pack that hides the built-in row.
|
|
236
|
+
- Lifecycle: registering the same id again replaces the earlier action (a superseded disposer no longer owns the row), and the disposer `registerPanelAction` returns removes it — bind it to the registering plugin's fiber with `ctx.effect` as above. At most `MAX_PANEL_ACTIONS` (8) registrations fit in the row.
|
|
237
|
+
- Failures stay the plugin's: a malformed registration throws at the registering plugin's own apply (a click could not be dispatched back to it), a throwing callback answers `{ ok: false, error: 'panel-action-failed' }`, and a click on an action the plugin already disposed is a stale click (`{ ok: false, error: 'unknown-panel-action' }`). None of them surfaces as pet breakage.
|
|
238
|
+
- Like `pet.announce`, registration is a host-side (in-process) contract. A browser-half plugin drives the pet through the existing `/api/pet/*` endpoints instead.
|
|
239
|
+
|
|
240
|
+
## Status bubble switch (statusBubbles)
|
|
241
|
+
|
|
242
|
+
Settings > Pet > Status bubbles (`auto` by default, `off` to silence the pet). `off` hides ONLY the pet's own session/status bubbles — the per-session stack (正在思考 / 正在使用 ...) and the legacy single status bubble — while the interaction feedback bubble and a sibling plugin's announcement bubble keep rendering, which is what a plugin that drives its own bubble surface needs. The state snapshot still carries the bubble facts either way: only the rendering is gated, so switching it back on restores them immediately, and a host that predates the field serves no mode at all, which reads as `auto`.
|
|
217
243
|
|
|
218
244
|
## Built-in pets
|
|
219
245
|
|
|
@@ -223,6 +249,7 @@ Host-side sibling plugins can push one structured announcement through the `pet`
|
|
|
223
249
|
| `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) |
|
|
224
250
|
| `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 |
|
|
225
251
|
| `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/ |
|
|
252
|
+
| `jyn-loli` | 鲸鱼娘·萝莉 | Frames2d gameplay pet (contributed by stushansusu under MIT): the whale-girl's loli form, ten 2.88 s tracks of 40 ms webp (idle, scratch-head, whale-pillow, lollipop, dance-sway, work, work-success, work-fail, rest, resting), 720 frames in all, every track cut from one 764×1172 box so the character neither jumps size nor position when the state changes, carrying stats, four idle-director acts, three touch zones, work with 50% success rolls, sleep and lying-down energy regen, passive income and a shop, plus one GIF cover per track under previews/. Like jyn, jyn-foxtail and doro it ships in the repository only (see assets/jyn-loli/README.md) |
|
|
226
253
|
| `ouo-neko` | OUO Neko | Pink-sakura cat-eared companion contributed by `Pessimist0906` under MIT |
|
|
227
254
|
| `whale-girl` | 鲸鱼娘(原版) | The repository's original whale-girl atlas |
|
|
228
255
|
| `whale-girl-refined` | 鲸鱼娘(精致版) | An AI-assisted derivative with repaired and refined details, based on the whale-girl design direction |
|
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
|
|
|
8
|
-
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.
|
|
8
|
+
<img src="https://img.shields.io/badge/DSH-%3E%3D0.2.1--rc.2-4c6ef5?style=flat-square&labelColor=454a54" alt="DSH">
|
|
9
9
|
|
|
10
10
|
<img src="https://img.shields.io/badge/license-Apache--2.0-blue?style=flat-square" alt="License">
|
|
11
11
|
</p>
|
|
@@ -36,10 +36,11 @@
|
|
|
36
36
|
| 拖动 | 按住拖动宠物换位置;位置持久化 |
|
|
37
37
|
| 隐藏/召唤 | 悬浮面板位于宠物下方(下方空间不足时上移到状态气泡之上)并提供 隐藏;隐藏后出现 召唤{name} 按钮 |
|
|
38
38
|
| 妙语库 | 内置默认妙语库(每类事件 10 句)+ 宠物自定义台词;成功文案按持久化成功次数轮换,冷却文案按持久化拒绝次数轮换 |
|
|
39
|
-
| 状态气泡 | 默认只有一个顶层会话说话——上报 GUI 当前会话时优先它,否则是最近活动的一个——其余会话收进主气泡右上角的 +N 角标,不再叠出一长列;悬停气泡(触屏点按角标)即可向上展开所有会话的气泡,点击任一气泡跳转到对应会话;子代理会话借由其发起会话体现,不占用独立气泡;瞬时互动反馈临时优先。气泡文案按场景准备了大量轮换词库(等待 / 思考 / 整理 / 完成 / 失败……),工具调用按工具族映射俏皮文案并带上真实参数(如 跑跑 npm test
|
|
39
|
+
| 状态气泡 | 默认只有一个顶层会话说话——上报 GUI 当前会话时优先它,否则是最近活动的一个——其余会话收进主气泡右上角的 +N 角标,不再叠出一长列;悬停气泡(触屏点按角标)即可向上展开所有会话的气泡,点击任一气泡跳转到对应会话;子代理会话借由其发起会话体现,不占用独立气泡;瞬时互动反馈临时优先。气泡文案按场景准备了大量轮换词库(等待 / 思考 / 整理 / 完成 / 失败……),工具调用按工具族映射俏皮文案并带上真实参数(如 跑跑 npm test),同一场景持续数秒会自动换一种说法。宠物自带的这些状态气泡可在 设置 → 宠物 → 状态气泡 关掉,此时整行气泡留给自建气泡面的插件;通过 `pet.announce` 推送的公告气泡两种模式下都照常渲染 |
|
|
40
40
|
| 碎碎念 | 会话流式输出期间,宠物会偶尔借该会话自己的气泡说出内心独白——新鲜的碎碎念接管所属会话的气泡并以「」引号标记——与状态气泡共用同一片 DeepSeek 蓝黑玻璃,气泡栈内颜色统一不再色差——不再叠出第二只气泡——分类台词由「正在干什么」触发(思考 / 写回复 / 正在跑的工具族),结果台词只由结构化结果触发(测试工具通过 → 全绿、工具失败 → 报错、回合完成 → 收工)——决不读模型说的话,讨论里提到关键词也不会误触发心境;碎碎念也从不引用真实内容(无工具名、路径、模型原文);分类冷却 9 秒、结果冷却 5 秒,展示 8 秒后气泡恢复状态文案 |
|
|
41
41
|
| 多会话活动 | 宠物是宿主全局的:最近一次有意义事件驱动精灵动画,同时每个活动的顶层会话用自己的气泡报告各自状态;每个会话(含子代理)完成的轮次都计入亲密度与小鱼干 |
|
|
42
42
|
| 语音包与面板 DIY | 宠物目录 voice.json + 全局 $DSH_HOME/pets/.voice.json 覆盖气泡全部文案与悬浮面板(按钮标签/统计格式/按钮显隐);合并优先级 宠物自带 > 全局 > 内置,坏包警告不拒载 |
|
|
43
|
+
| 面板动作扩展点 | 兄弟插件通过进程内 pet 服务(`ctx.pet.registerPanelAction({ id, label, onSelect })`)把自己的动作注册进悬浮面板的动作行;宠物渲染按钮并把点击派发回插件自己的回调,动作随注册一起回收 |
|
|
43
44
|
|
|
44
45
|
## 宠物契约
|
|
45
46
|
|
|
@@ -213,7 +214,32 @@ frames2d 宠物可声明 `gameplay` 块——从 miku 桌宠泛化而来的可
|
|
|
213
214
|
- 开关:设置 → 宠物 → 状态装饰(默认开)。内置鲸鱼素材派生自 DeepSeek wordmark(MIT),完整声明见 THIRD_PARTY_NOTICES.md。
|
|
214
215
|
## 公告气泡(pet.announce)
|
|
215
216
|
|
|
216
|
-
宿主侧的兄弟插件可通过 `pet` cordis 服务推送一条结构化公告(`ctx.pet.announce({ source, kind, title, ... })`);客户端半区将其渲染为一只专用、特别设计的气泡,挂在会话气泡栈顶部——独立玻璃样式与色调描边(`ok`/`warn`/`low`)、余额与今日消费类金额胶囊、套餐百分比窗口带微型计量条、展示重置时间。载荷经有界校验(src/announce.ts):未知字段丢弃、超长文本截断、TTL 收敛到 1 秒 - 2 小时(默认 10 秒;周期型发布方按自身轮询节奏声明 TTL
|
|
217
|
+
宿主侧的兄弟插件可通过 `pet` cordis 服务推送一条结构化公告(`ctx.pet.announce({ source, kind, title, ... })`);客户端半区将其渲染为一只专用、特别设计的气泡,挂在会话气泡栈顶部——独立玻璃样式与色调描边(`ok`/`warn`/`low`)、余额与今日消费类金额胶囊、套餐百分比窗口带微型计量条、展示重置时间。载荷经有界校验(src/announce.ts):未知字段丢弃、超长文本截断、TTL 收敛到 1 秒 - 2 小时(默认 10 秒;周期型发布方按自身轮询节奏声明 TTL,常驻气泡因此跨轮询连续,上限仍保证失活来源的气泡至多一个刷新周期内消失),畸形公告静默丢弃。公告仅存内存:每个发布方按 `source` 各占一个槽位,各自持有自己的 TTL,过期即不再渲染,不触碰 pet.json 与台账。刻意不提供 HTTP 面——按跨插件协作规则,API 就是进程内服务。
|
|
218
|
+
|
|
219
|
+
**一只宠物上的多个发布方。** 该契约最初只有一个槽位,第二个公告插件会把第一个顶掉;现在 `source`(载荷本来就带)就是槽位键,各发布方 TTL 独立。每条新鲜槽位各渲染一只气泡,按各发布方首次到达的顺序叠在会话气泡之上——周期型发布方就地刷新自己那只,两个节奏不同的发布方不会互换位置,气泡栈也不会抖动。槽位表有上限(`MAX_ANNOUNCEMENTS` = 4):过期发布方的槽位自动释放;表真的满时,新来的发布方拿走沉默最久的那只而不是被拒绝,因此持续刷新的发布方永远不会被挤掉。为兼容灰度升级,最新鲜的那条同时仍以旧的单数字段 `announcement` 下发,旧浏览器半区照常渲染一只气泡而不会空白。
|
|
220
|
+
|
|
221
|
+
## 面板动作扩展点(pet.registerPanelAction)
|
|
222
|
+
|
|
223
|
+
宿主侧的兄弟插件可以往宠物悬浮面板的动作行里追加自己的按钮,与内置的喂食 / 改名 / 隐藏并存:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
ctx.effect(() => ctx.pet.registerPanelAction({
|
|
227
|
+
id: 'pet-quota-swap', // kebab id,点击按它派发回插件
|
|
228
|
+
label: '换装', // 有界标签(超过就会撑换行)
|
|
229
|
+
title: '切换到下一只宠物', // 可选 tooltip
|
|
230
|
+
order: 0, // 可选:在已注册动作块内的排序键
|
|
231
|
+
onSelect: async ({ petId }) => { /* 插件自己做事 */ },
|
|
232
|
+
}))
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- 宠物拥有这一行,插件拥有这个按钮:宿主对每次注册做校验(src/panel-actions.ts),把已注册动作放进状态快照(`panelActions`)下发,点击经 `POST /api/pet/panel-action` 派发回 `onSelect`。扩展动作渲染在内置按钮之后,因此语音包隐藏内置动作行时它们依然可见。
|
|
236
|
+
- 生命周期:同一 id 再次注册会替换旧动作(被替换的 disposer 不再拥有这一行),`registerPanelAction` 返回的 disposer 负责移除它——按上面的写法用 `ctx.effect` 绑到注册插件自己的 fiber 上即可。动作行最多容纳 `MAX_PANEL_ACTIONS`(8)个注册。
|
|
237
|
+
- 失败只算插件自己的问题:畸形注册会在注册插件自己的 apply 里抛错(点击无法派发回它),回调抛错返回 `{ ok: false, error: 'panel-action-failed' }`,点击一个插件已经注销的动作属于过期点击(`{ ok: false, error: 'unknown-panel-action' }`),都不会表现为宠物故障。
|
|
238
|
+
- 与 `pet.announce` 一样,注册是宿主侧(进程内)契约;浏览器半区的插件走既有的 `/api/pet/*` 端点驱动宠物即可。
|
|
239
|
+
|
|
240
|
+
## 状态气泡开关(statusBubbles)
|
|
241
|
+
|
|
242
|
+
设置 → 宠物 → 状态气泡(默认 `auto`,改为 `off` 即让宠物闭嘴)。`off` 只隐藏宠物自带的会话/状态气泡——每个会话的气泡栈(正在思考 / 正在使用……)与旧式单状态气泡——互动反馈气泡与兄弟插件通过公告契约推送的气泡照常渲染,这正是自建气泡面的插件需要的。两种模式下状态快照都照常携带气泡数据:只有渲染被关掉,随时切回即刻恢复;早于该字段的宿主不带模式,读取时按 `auto` 处理。
|
|
217
243
|
|
|
218
244
|
## 内置宠物
|
|
219
245
|
|
|
@@ -223,6 +249,7 @@ frames2d 宠物可声明 `gameplay` 块——从 miku 桌宠泛化而来的可
|
|
|
223
249
|
| `doro` | doro | 由 stushansusu 以 MIT 许可证贡献的 frames2d 玩法宠物:11 条轨道 / 802 帧 42ms webp 序列——呼吸待机、打工三件套、睡觉、洗澡模式(心情 +3/秒)、随机漫游用的四向爬行、三个待机小动作(cola / orange / tongue)与仅拖拽期间播放的挣扎循环。Doro 是《胜利女神:妮姬》桃乐丝的非官方同人二创/梗衍生形象,角色及相关权利归 SHIFT UP 所有——仅限个人非商业使用,与官方无隶属或背书关系(见 THIRD_PARTY_NOTICES.md)。 |
|
|
224
250
|
| `jyn` | 女仆鲸鱼娘 | frames2d 玩法宠物(stushansusu 以 MIT 贡献):带打工/睡觉/触摸玩法与三款可选皮肤(暗夜鎏金 / 蓝海霓裳 / 冰晶公主)的女仆鲸鱼同桌宠,每款皮肤各带一个概率掷骰点击动作;暗夜鎏金另将专属休息循环换入睡觉玩法 |
|
|
225
251
|
| `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 封面 |
|
|
252
|
+
| `jyn-loli` | 鲸鱼娘·萝莉 | 由 stushansusu 以 MIT 贡献的 frames2d 玩法宠物:鲸鱼娘的萝莉形态,10 条 2.88s 轨道共 720 帧 40ms webp(idle / scratch-head / whale-pillow / lollipop / dance-sway / work / work-success / work-fail / rest / resting),十轨共用一个 764×1172 裁切框,切状态时角色既不跳大小也不跳位置;带 stats、四个待机小动作、三个触摸区、五成成败判定的打工、睡觉与躺下回能、挂机收益与商店玩法,previews/ 下每条轨道一张 GIF 封面。与 jyn、jyn-foxtail、doro 一样只放仓库、不随 npm 包发布(见 assets/jyn-loli/README.md) |
|
|
226
253
|
| `ouo-neko` | OUO Neko | `Pessimist0906` 以 MIT 许可证贡献的粉色樱花猫耳伙伴 |
|
|
227
254
|
| `whale-girl` | 鲸鱼娘(原版) | 仓库原有的鲸鱼娘图集 |
|
|
228
255
|
| `whale-girl-refined` | 鲸鱼娘(精致版) | 以鲸鱼娘设计方向为基础,经 AI 辅助二次创作、修复和细节精修的衍生版本 |
|
package/lib/client.js
CHANGED
|
@@ -784,13 +784,15 @@ window.__ModuleLoader__.load({
|
|
|
784
784
|
spriteWidth
|
|
785
785
|
]);
|
|
786
786
|
const bubbleScale = bubbleScaleFor(display);
|
|
787
|
-
const
|
|
787
|
+
const statusBubblesOn = (snapshot?.statusBubbles ?? "auto") !== "off";
|
|
788
|
+
const sessionBubbles = statusBubblesOn ? snapshot?.sessions ?? [] : [];
|
|
788
789
|
const stackOpen = stackPeek || stackPinned;
|
|
789
790
|
const visibleSessions = !stackOpen && sessionBubbles.length > 1 ? sessionBubbles.slice(0, 1) : sessionBubbles;
|
|
790
|
-
const statusBubble = feedback === null && sessionBubbles.length === 0 ? snapshot?.bubble : void 0;
|
|
791
|
-
const
|
|
792
|
-
const
|
|
793
|
-
const
|
|
791
|
+
const statusBubble = statusBubblesOn && feedback === null && sessionBubbles.length === 0 ? snapshot?.bubble : void 0;
|
|
792
|
+
const announced = snapshot?.announcements ?? (snapshot?.announcement !== void 0 ? [snapshot.announcement] : []);
|
|
793
|
+
const now = Date.now();
|
|
794
|
+
const usageAnnouncements = feedback === null ? announced.filter((entry) => announcementFresh(entry, now)) : [];
|
|
795
|
+
const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== void 0 || usageAnnouncements.length > 0;
|
|
794
796
|
const displayName = snapshot?.name ?? definition.displayName;
|
|
795
797
|
const decoration = snapshot?.decoration;
|
|
796
798
|
(0, react.useEffect)(() => {
|
|
@@ -889,7 +891,7 @@ window.__ModuleLoader__.load({
|
|
|
889
891
|
className: clsx(pet_module_css_default.bubble, feedback.kind === "feed" ? pet_module_css_default.bubbleFeed : pet_module_css_default.bubblePet),
|
|
890
892
|
children: feedback.text
|
|
891
893
|
}, feedback.at),
|
|
892
|
-
feedback === null && (sessionBubbles.length > 0 || statusBubble !== void 0 ||
|
|
894
|
+
feedback === null && (sessionBubbles.length > 0 || statusBubble !== void 0 || usageAnnouncements.length > 0) && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
893
895
|
ref: bubbleRef,
|
|
894
896
|
className: pet_module_css_default.bubbleStack,
|
|
895
897
|
onPointerEnter: () => setStackPeek(true),
|
|
@@ -935,7 +937,7 @@ window.__ModuleLoader__.load({
|
|
|
935
937
|
phase
|
|
936
938
|
}), statusBubble]
|
|
937
939
|
}, "status"),
|
|
938
|
-
|
|
940
|
+
usageAnnouncements.map((entry) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(UsageAnnouncementBubble, { announcement: entry }, entry.source))
|
|
939
941
|
]
|
|
940
942
|
}),
|
|
941
943
|
hovered && dragRef.current === null && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
@@ -1039,7 +1041,17 @@ window.__ModuleLoader__.load({
|
|
|
1039
1041
|
className: pet_module_css_default.action,
|
|
1040
1042
|
onClick: props.onGameplayMenu,
|
|
1041
1043
|
children: props.t("pet.gameplay.menu")
|
|
1042
|
-
})
|
|
1044
|
+
}),
|
|
1045
|
+
(snapshot?.panelActions ?? []).map((action) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)("button", {
|
|
1046
|
+
type: "button",
|
|
1047
|
+
className: pet_module_css_default.action,
|
|
1048
|
+
"data-dsh-pet-panel-action": action.id,
|
|
1049
|
+
...action.title === void 0 ? {} : { title: action.title },
|
|
1050
|
+
onClick: () => {
|
|
1051
|
+
props.onPanelAction(action.id);
|
|
1052
|
+
},
|
|
1053
|
+
children: action.label
|
|
1054
|
+
}, action.id))
|
|
1043
1055
|
]
|
|
1044
1056
|
})
|
|
1045
1057
|
] })
|
|
@@ -1992,6 +2004,7 @@ window.__ModuleLoader__.load({
|
|
|
1992
2004
|
onHide: props.hide,
|
|
1993
2005
|
onDragEnd: props.dragEnd,
|
|
1994
2006
|
onRename: props.rename,
|
|
2007
|
+
onPanelAction: props.panelAction,
|
|
1995
2008
|
onOpenSession: props.openSession,
|
|
1996
2009
|
onFeedbackDone: props.feedbackDone,
|
|
1997
2010
|
portalTarget: props.portalTarget,
|
|
@@ -2321,9 +2334,11 @@ window.__ModuleLoader__.load({
|
|
|
2321
2334
|
* - Canvas bitmap buffer (default where createImageBitmap/fetch/2D context
|
|
2322
2335
|
* exist): frames are decoded once into an ImageBitmap on demand, with a
|
|
2323
2336
|
* bounded look-ahead window over the playing track, and drawn onto one
|
|
2324
|
-
* <canvas
|
|
2325
|
-
*
|
|
2326
|
-
*
|
|
2337
|
+
* <canvas>. Steady-state playback issues zero DOM mutations and re-decodes
|
|
2338
|
+
* only what the retention budget evicted: decoded frames are held under
|
|
2339
|
+
* MAX_RETAINED_BYTES, so a long-lived pet that plays every track of every
|
|
2340
|
+
* skin cannot pin every bitmap for the life of the page (measured hotspot:
|
|
2341
|
+
* swapping <img>.src per frame drove image decode + invalidation every tick).
|
|
2327
2342
|
* - Classic <img> fallback (jsdom/tests or missing APIs): identical to the
|
|
2328
2343
|
* historical behavior - cache-warm Image elements plus guarded src swaps,
|
|
2329
2344
|
* so environments without modern decoding keep working unchanged.
|
|
@@ -2332,6 +2347,19 @@ window.__ModuleLoader__.load({
|
|
|
2332
2347
|
*/
|
|
2333
2348
|
/** Stall watchdog period: a looping track stuck longer re-kicks its chain. */
|
|
2334
2349
|
const WATCHDOG_MS = 1200;
|
|
2350
|
+
/**
|
|
2351
|
+
* Retention budget for decoded frame bitmaps, in bytes.
|
|
2352
|
+
*
|
|
2353
|
+
* The budget is expressed in bytes rather than in frames because a frame's
|
|
2354
|
+
* decoded footprint is `width * height * 4` and published pets differ by more
|
|
2355
|
+
* than an order of magnitude (a 512x683 frame is 1.33 MB, a 128x128 frame is
|
|
2356
|
+
* 64 KB): a frame count would be either useless for small atlases or too tight
|
|
2357
|
+
* for large ones. 128 MiB holds this repository's longest shipped track (78
|
|
2358
|
+
* frames, 104 MB) in full, so a running loop still re-decodes nothing, while
|
|
2359
|
+
* capping a pet that played every track of every skin at roughly a tenth of
|
|
2360
|
+
* the ~1.7 GB the unbounded memo reached.
|
|
2361
|
+
*/
|
|
2362
|
+
const MAX_RETAINED_BYTES = 134217728;
|
|
2335
2363
|
function isRecord(value) {
|
|
2336
2364
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
2337
2365
|
}
|
|
@@ -2396,6 +2424,19 @@ window.__ModuleLoader__.load({
|
|
|
2396
2424
|
...skins === void 0 ? {} : { skins }
|
|
2397
2425
|
};
|
|
2398
2426
|
}
|
|
2427
|
+
/**
|
|
2428
|
+
* Release one decoded frame. `close()` is browser-only and idempotent, so the
|
|
2429
|
+
* call is guarded for exotic hosts and for frames that were already released;
|
|
2430
|
+
* the `<img>` fallback has no close, where dropping the reference is the
|
|
2431
|
+
* release.
|
|
2432
|
+
*/
|
|
2433
|
+
function releaseFrame(frame) {
|
|
2434
|
+
if (frame === void 0) return;
|
|
2435
|
+
try {
|
|
2436
|
+
const maybeClose = frame.source.close;
|
|
2437
|
+
if (typeof maybeClose === "function") maybeClose.call(frame.source);
|
|
2438
|
+
} catch {}
|
|
2439
|
+
}
|
|
2399
2440
|
const frames2dRenderer = {
|
|
2400
2441
|
id: "frames2d",
|
|
2401
2442
|
apiVersion: PET_RENDERER_API_VERSION,
|
|
@@ -2438,7 +2479,7 @@ window.__ModuleLoader__.load({
|
|
|
2438
2479
|
ctx.container.appendChild(img);
|
|
2439
2480
|
}
|
|
2440
2481
|
const decoding = /* @__PURE__ */ new Map();
|
|
2441
|
-
|
|
2482
|
+
let retainedBytes = 0;
|
|
2442
2483
|
const FRAME_POOL_LIMIT = 8;
|
|
2443
2484
|
const frameQueue = [];
|
|
2444
2485
|
let activeFrames = 0;
|
|
@@ -2484,30 +2525,83 @@ window.__ModuleLoader__.load({
|
|
|
2484
2525
|
if (index > 0) frameQueue.unshift(frameQueue.splice(index, 1)[0]);
|
|
2485
2526
|
}
|
|
2486
2527
|
const cached = decoding.get(url);
|
|
2487
|
-
if (cached !== void 0)
|
|
2528
|
+
if (cached !== void 0) {
|
|
2529
|
+
decoding.delete(url);
|
|
2530
|
+
decoding.set(url, cached);
|
|
2531
|
+
return cached.job;
|
|
2532
|
+
}
|
|
2488
2533
|
let release;
|
|
2489
2534
|
const job = new Promise((resolve) => {
|
|
2490
2535
|
release = resolve;
|
|
2491
2536
|
}).then(() => disposed ? void 0 : decodeFrame(url));
|
|
2537
|
+
const entry = { job };
|
|
2492
2538
|
job.then((frame) => {
|
|
2493
|
-
if (frame === void 0)
|
|
2539
|
+
if (frame === void 0) {
|
|
2540
|
+
decoding.delete(url);
|
|
2541
|
+
return;
|
|
2542
|
+
}
|
|
2543
|
+
if (disposed) {
|
|
2544
|
+
releaseFrame(frame);
|
|
2545
|
+
decoding.delete(url);
|
|
2546
|
+
return;
|
|
2547
|
+
}
|
|
2548
|
+
entry.frame = frame;
|
|
2549
|
+
entry.bytes = frame.width * frame.height * 4;
|
|
2550
|
+
retainedBytes += entry.bytes;
|
|
2551
|
+
enforceRetentionBudget();
|
|
2494
2552
|
}, () => decoding.delete(url));
|
|
2495
2553
|
job.finally(() => {
|
|
2496
2554
|
activeFrames -= 1;
|
|
2497
2555
|
pumpFrames();
|
|
2498
2556
|
});
|
|
2499
|
-
decoding.set(url,
|
|
2500
|
-
|
|
2501
|
-
const entry = {
|
|
2557
|
+
decoding.set(url, entry);
|
|
2558
|
+
const queued = {
|
|
2502
2559
|
url,
|
|
2503
2560
|
release
|
|
2504
2561
|
};
|
|
2505
|
-
if (jump) frameQueue.unshift(
|
|
2506
|
-
else frameQueue.push(
|
|
2562
|
+
if (jump) frameQueue.unshift(queued);
|
|
2563
|
+
else frameQueue.push(queued);
|
|
2507
2564
|
pumpFrames();
|
|
2508
2565
|
return job;
|
|
2509
2566
|
};
|
|
2510
2567
|
/**
|
|
2568
|
+
* Release decoded bitmaps until the retained footprint is back under
|
|
2569
|
+
* MAX_RETAINED_BYTES. Two properties keep this from breaking playback:
|
|
2570
|
+
*
|
|
2571
|
+
* - The playing track's look-ahead window, plus the frame a draw is waiting
|
|
2572
|
+
* on, are never released. Releasing one would hand a closed bitmap to
|
|
2573
|
+
* `drawImage`, and re-decoding it would stall the next tick.
|
|
2574
|
+
* - Frames of any other track go first. That is what keeps a running loop
|
|
2575
|
+
* warm under a budget smaller than two whole tracks: eviction reclaims the
|
|
2576
|
+
* track the pet left instead of eating the cycle it is playing.
|
|
2577
|
+
*
|
|
2578
|
+
* When the protected window alone exceeds the budget nothing is released —
|
|
2579
|
+
* a pet whose frames are that large cannot be bounded further without
|
|
2580
|
+
* breaking playback, and the overshoot is then exactly one window.
|
|
2581
|
+
*/
|
|
2582
|
+
function enforceRetentionBudget() {
|
|
2583
|
+
if (retainedBytes <= MAX_RETAINED_BYTES) return;
|
|
2584
|
+
const def = config.tracks[track];
|
|
2585
|
+
const playing = new Set(def === void 0 ? [] : def.frames);
|
|
2586
|
+
const protectedUrls = /* @__PURE__ */ new Set();
|
|
2587
|
+
if (pinned !== void 0) protectedUrls.add(pinned);
|
|
2588
|
+
if (def !== void 0) {
|
|
2589
|
+
const end = Math.min(def.frames.length, frameIndex + 1 + PREFETCH_AHEAD);
|
|
2590
|
+
for (let index = frameIndex; index < end; index += 1) {
|
|
2591
|
+
const url = def.frames[index];
|
|
2592
|
+
if (url !== void 0) protectedUrls.add(url);
|
|
2593
|
+
}
|
|
2594
|
+
}
|
|
2595
|
+
for (const foreignOnly of [true, false]) for (const [url, entry] of decoding) {
|
|
2596
|
+
if (retainedBytes <= MAX_RETAINED_BYTES) return;
|
|
2597
|
+
if (entry.bytes === void 0 || protectedUrls.has(url)) continue;
|
|
2598
|
+
if (foreignOnly && playing.has(url)) continue;
|
|
2599
|
+
releaseFrame(entry.frame);
|
|
2600
|
+
retainedBytes -= entry.bytes;
|
|
2601
|
+
decoding.delete(url);
|
|
2602
|
+
}
|
|
2603
|
+
}
|
|
2604
|
+
/**
|
|
2511
2605
|
* Bounded look-ahead window: decode only the frames playback is about to
|
|
2512
2606
|
* need. The historical warm pass decoded every frame of every track up
|
|
2513
2607
|
* front - a shipped pet carries ~1.1k 512x683 frames, so that pass pulls
|
|
@@ -2536,6 +2630,7 @@ window.__ModuleLoader__.load({
|
|
|
2536
2630
|
let baseIdle = config.phases.idle;
|
|
2537
2631
|
let drawToken = 0;
|
|
2538
2632
|
let lastDrawnUrl;
|
|
2633
|
+
let pinned;
|
|
2539
2634
|
const trackForPhase = (phase) => {
|
|
2540
2635
|
const mapped = config.phases[phase];
|
|
2541
2636
|
if (mapped === void 0) return baseIdle;
|
|
@@ -2546,7 +2641,9 @@ window.__ModuleLoader__.load({
|
|
|
2546
2641
|
const paintCanvas = (url) => {
|
|
2547
2642
|
if (context2d === null || canvas === null) return;
|
|
2548
2643
|
const myToken = ++drawToken;
|
|
2644
|
+
pinned = url;
|
|
2549
2645
|
loadFrame(url, true).then((frame) => {
|
|
2646
|
+
if (pinned === url) pinned = void 0;
|
|
2550
2647
|
if (disposed || frame === void 0 || myToken !== drawToken) return;
|
|
2551
2648
|
if (lastDrawnUrl === url) return;
|
|
2552
2649
|
lastDrawnUrl = url;
|
|
@@ -2555,7 +2652,9 @@ window.__ModuleLoader__.load({
|
|
|
2555
2652
|
canvas.height = frame.height;
|
|
2556
2653
|
} else context2d.clearRect(0, 0, canvas.width, canvas.height);
|
|
2557
2654
|
context2d.drawImage(frame.source, 0, 0);
|
|
2558
|
-
}).catch(() => {
|
|
2655
|
+
}).catch(() => {
|
|
2656
|
+
if (pinned === url) pinned = void 0;
|
|
2657
|
+
});
|
|
2559
2658
|
};
|
|
2560
2659
|
const show = (trackId, index) => {
|
|
2561
2660
|
const url = config.tracks[trackId]?.frames[index];
|
|
@@ -2627,15 +2726,9 @@ window.__ModuleLoader__.load({
|
|
|
2627
2726
|
if (timer !== void 0) clearTimeout(timer);
|
|
2628
2727
|
if (watchdog !== void 0) clearInterval(watchdog);
|
|
2629
2728
|
for (const queued of frameQueue.splice(0)) queued.release();
|
|
2630
|
-
|
|
2631
|
-
|
|
2632
|
-
|
|
2633
|
-
const maybeClose = (frame?.source)?.close;
|
|
2634
|
-
if (typeof maybeClose === "function" && frame !== void 0) maybeClose.call(frame.source);
|
|
2635
|
-
} catch {}
|
|
2636
|
-
}).catch(() => {});
|
|
2637
|
-
decoding.clear();
|
|
2638
|
-
});
|
|
2729
|
+
for (const entry of decoding.values()) releaseFrame(entry.frame);
|
|
2730
|
+
decoding.clear();
|
|
2731
|
+
retainedBytes = 0;
|
|
2639
2732
|
canvas?.remove();
|
|
2640
2733
|
img?.remove();
|
|
2641
2734
|
};
|
|
@@ -3525,6 +3618,12 @@ window.__ModuleLoader__.load({
|
|
|
3525
3618
|
var settings_section_module_css_default = { "sectionList": "c5M8OW_sectionList" };
|
|
3526
3619
|
//#endregion
|
|
3527
3620
|
//#region src/client/PetSettingsCard.tsx
|
|
3621
|
+
/**
|
|
3622
|
+
* The bubble modes this card can write, in render order. Mirrors the host
|
|
3623
|
+
* schema's union (see PetStatusBubbleMode); the browser half never imports the
|
|
3624
|
+
* host module for a value, so the accepted set is spelled here as literals.
|
|
3625
|
+
*/
|
|
3626
|
+
const STATUS_BUBBLE_CHOICES = ["auto", "off"];
|
|
3528
3627
|
/** Fetch the registry list (the same data the sprite renders from). */
|
|
3529
3628
|
async function fetchPetChoices() {
|
|
3530
3629
|
const response = await fetch("/api/pet/pets");
|
|
@@ -3564,6 +3663,7 @@ window.__ModuleLoader__.load({
|
|
|
3564
3663
|
this.form = new CardForm(scope, [
|
|
3565
3664
|
booleanField("enabled"),
|
|
3566
3665
|
booleanField("decorationEnabled"),
|
|
3666
|
+
choiceField("statusBubbles", STATUS_BUBBLE_CHOICES),
|
|
3567
3667
|
booleanField("visible"),
|
|
3568
3668
|
numberField("size"),
|
|
3569
3669
|
numberField("right"),
|
|
@@ -3689,6 +3789,7 @@ window.__ModuleLoader__.load({
|
|
|
3689
3789
|
petSelectionFallback: fallback,
|
|
3690
3790
|
enabled: this.form.field("enabled"),
|
|
3691
3791
|
decorationEnabled: this.form.field("decorationEnabled"),
|
|
3792
|
+
statusBubbles: this.form.field("statusBubbles"),
|
|
3692
3793
|
visible: fallback ? this.fallbackVisible() : this.form.field("visible"),
|
|
3693
3794
|
size: this.form.field("size"),
|
|
3694
3795
|
right: this.form.field("right"),
|
|
@@ -3816,6 +3917,27 @@ window.__ModuleLoader__.load({
|
|
|
3816
3917
|
props.resetField("decorationEnabled");
|
|
3817
3918
|
}
|
|
3818
3919
|
}),
|
|
3920
|
+
state.petSelectionFallback ? null : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
|
|
3921
|
+
id: "settings-pet-status-bubbles",
|
|
3922
|
+
label: t("settings.statusBubbles"),
|
|
3923
|
+
hint: t("settings.statusBubblesHint"),
|
|
3924
|
+
inheritLabel: t("settings.inherit"),
|
|
3925
|
+
...fieldProps,
|
|
3926
|
+
...state.statusBubbles,
|
|
3927
|
+
choices: [{
|
|
3928
|
+
value: STATUS_BUBBLE_CHOICES[0],
|
|
3929
|
+
label: t("settings.on")
|
|
3930
|
+
}, {
|
|
3931
|
+
value: STATUS_BUBBLE_CHOICES[1],
|
|
3932
|
+
label: t("settings.off")
|
|
3933
|
+
}],
|
|
3934
|
+
onEdit: (text) => {
|
|
3935
|
+
props.edit("statusBubbles", text);
|
|
3936
|
+
},
|
|
3937
|
+
onReset: () => {
|
|
3938
|
+
props.resetField("statusBubbles");
|
|
3939
|
+
}
|
|
3940
|
+
}),
|
|
3819
3941
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(ChoiceField, {
|
|
3820
3942
|
id: "settings-pet-pet",
|
|
3821
3943
|
label: t("settings.pet"),
|
|
@@ -3979,6 +4101,8 @@ window.__ModuleLoader__.load({
|
|
|
3979
4101
|
"settings.enabledHint": "关闭后隐藏宠物并停止轮询,可在设置里重新启用。",
|
|
3980
4102
|
"settings.decoration": "状态装饰",
|
|
3981
4103
|
"settings.decorationHint": "在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。",
|
|
4104
|
+
"settings.statusBubbles": "状态气泡",
|
|
4105
|
+
"settings.statusBubblesHint": "宠物自带的会话/状态气泡(正在思考、正在使用 xxx)。关掉后只剩第三方插件通过公告契约推送的气泡与互动反馈气泡;默认开启。",
|
|
3982
4106
|
"settings.visible": "显示宠物",
|
|
3983
4107
|
"settings.visibleHint": "关闭后宠物隐藏,可从聊天输入区重新召唤。",
|
|
3984
4108
|
"settings.size": "大小(px)",
|
|
@@ -4061,6 +4185,8 @@ window.__ModuleLoader__.load({
|
|
|
4061
4185
|
"settings.enabledHint": "When off, the pet hides and polling stops; re-enable it here.",
|
|
4062
4186
|
"settings.decoration": "Status decoration",
|
|
4063
4187
|
"settings.decorationHint": "Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.",
|
|
4188
|
+
"settings.statusBubbles": "Status bubbles",
|
|
4189
|
+
"settings.statusBubblesHint": "The pet's own session/status bubbles (thinking, using ...). Turning them off leaves only bubbles a third-party plugin pushes through the announcement contract, plus the interaction feedback bubble; on by default.",
|
|
4064
4190
|
"settings.visible": "Show the pet",
|
|
4065
4191
|
"settings.visibleHint": "When off, the pet hides; summon it again from the input row.",
|
|
4066
4192
|
"settings.size": "Size (px)",
|
|
@@ -4087,28 +4213,6 @@ window.__ModuleLoader__.load({
|
|
|
4087
4213
|
"settings.saveFailed": "The deployment did not accept these values; they were left for you to correct.",
|
|
4088
4214
|
"settings.invalidNumber": "Enter a number, or leave blank to use the default."
|
|
4089
4215
|
};
|
|
4090
|
-
/**
|
|
4091
|
-
* Active dictionary, picked by the document language at call time. The pet
|
|
4092
|
-
* mounts as a global floating surface (not a session-scoped slot), so it has
|
|
4093
|
-
* no framework locale seat and resolves its copy the same tiny way the
|
|
4094
|
-
* task-board's DOM-injected surface does.
|
|
4095
|
-
*/
|
|
4096
|
-
function dictionary() {
|
|
4097
|
-
return (typeof document !== "undefined" ? document.documentElement.lang : "zh").toLowerCase().startsWith("en") ? en : zh;
|
|
4098
|
-
}
|
|
4099
|
-
/**
|
|
4100
|
-
* Translate a key with optional `{name}` template params. Mirrors the slot
|
|
4101
|
-
* `Translate` contract `(key, params?) => string` so it can be handed to the
|
|
4102
|
-
* same components that used to receive the framework-injected `t` seat. The
|
|
4103
|
-
* key is typed loosely (`string`) so the function is assignable to the slot's
|
|
4104
|
-
* `TranslateNS<'pet'>` (whose key domain also spans the shared common
|
|
4105
|
-
* vocabulary); a missing key degrades to the key itself rather than throwing.
|
|
4106
|
-
*/
|
|
4107
|
-
function t(key, params) {
|
|
4108
|
-
let text = dictionary()[key] ?? key;
|
|
4109
|
-
if (params !== void 0) for (const [name, value] of Object.entries(params)) text = text.replaceAll(`{${name}}`, String(value));
|
|
4110
|
-
return text;
|
|
4111
|
-
}
|
|
4112
4216
|
//#endregion
|
|
4113
4217
|
//#region src/client/main-session.ts
|
|
4114
4218
|
/**
|
|
@@ -4132,7 +4236,7 @@ window.__ModuleLoader__.load({
|
|
|
4132
4236
|
/** The building package's version, when the bundle carries it. */
|
|
4133
4237
|
function bakedVersion() {
|
|
4134
4238
|
try {
|
|
4135
|
-
return "0.4.
|
|
4239
|
+
return "0.4.7";
|
|
4136
4240
|
} catch {
|
|
4137
4241
|
return;
|
|
4138
4242
|
}
|
|
@@ -4215,6 +4319,7 @@ window.__ModuleLoader__.load({
|
|
|
4215
4319
|
setConfig: (patch) => petFetch("/api/pet/set-config", patch),
|
|
4216
4320
|
setName: (name) => petFetch("/api/pet/set-name", { name }),
|
|
4217
4321
|
setPet: (petId) => petFetch("/api/pet/set-pet", { petId }),
|
|
4322
|
+
panelAction: (id) => petFetch("/api/pet/panel-action", { id }),
|
|
4218
4323
|
setSkin: (skin) => petFetch("/api/pet/set-skin", skin === void 0 ? {} : { skin }),
|
|
4219
4324
|
gameplayTouch: (zone) => petFetch("/api/pet/gameplay/touch", zone === void 0 ? {} : { zone }),
|
|
4220
4325
|
gameplaySetMode: (mode) => petFetch("/api/pet/gameplay/mode", { mode }),
|
|
@@ -4251,8 +4356,7 @@ window.__ModuleLoader__.load({
|
|
|
4251
4356
|
base: void 0,
|
|
4252
4357
|
user: void 0,
|
|
4253
4358
|
revision: void 0,
|
|
4254
|
-
writable: false
|
|
4255
|
-
mode: "host"
|
|
4359
|
+
writable: false
|
|
4256
4360
|
};
|
|
4257
4361
|
}
|
|
4258
4362
|
/**
|
|
@@ -4291,13 +4395,19 @@ window.__ModuleLoader__.load({
|
|
|
4291
4395
|
else if (this.current === void 0) this.adoptFallback();
|
|
4292
4396
|
}
|
|
4293
4397
|
/**
|
|
4294
|
-
* True
|
|
4295
|
-
*
|
|
4296
|
-
*
|
|
4398
|
+
* True only once the shared mirror answers for the pet namespace itself.
|
|
4399
|
+
*
|
|
4400
|
+
* 'ready' is the only state that answers (#1813). A host-persisted row starts
|
|
4401
|
+
* out as 'loading' — the mirror has published no view yet — and that is not
|
|
4402
|
+
* an answer: adopting it on sight drops the retry window, and under the
|
|
4403
|
+
* aggregate, which serves only the renamed 'web-ui-pet' row, the form then
|
|
4404
|
+
* settles into 'unavailable' and the page stays "not exposed" for good. So
|
|
4405
|
+
* 'loading' and 'unavailable' both keep the window open and let the binder be
|
|
4406
|
+
* adopted the moment the aggregate publishes it.
|
|
4297
4407
|
*/
|
|
4298
4408
|
fallbackSettled() {
|
|
4299
4409
|
try {
|
|
4300
|
-
return this.fallback.getSnapshot().status
|
|
4410
|
+
return this.fallback.getSnapshot().status === "ready";
|
|
4301
4411
|
} catch {
|
|
4302
4412
|
return false;
|
|
4303
4413
|
}
|
|
@@ -4342,9 +4452,10 @@ window.__ModuleLoader__.load({
|
|
|
4342
4452
|
return true;
|
|
4343
4453
|
}
|
|
4344
4454
|
/**
|
|
4345
|
-
* Adopt the shared per-entry form. It is used immediately unless it
|
|
4346
|
-
*
|
|
4347
|
-
* and the retry window takes over
|
|
4455
|
+
* Adopt the shared per-entry form. It is used immediately unless it cannot
|
|
4456
|
+
* answer yet (still loading, or reporting the namespace unavailable), in which
|
|
4457
|
+
* case the binder may still be on its way and the retry window takes over
|
|
4458
|
+
* (see scheduleRetry).
|
|
4348
4459
|
*/
|
|
4349
4460
|
adoptFallback() {
|
|
4350
4461
|
this.current = this.fallback;
|
|
@@ -4583,6 +4694,11 @@ window.__ModuleLoader__.load({
|
|
|
4583
4694
|
if (result.ok) pollNow();
|
|
4584
4695
|
}, () => {});
|
|
4585
4696
|
},
|
|
4697
|
+
panelAction: (id) => {
|
|
4698
|
+
petApi.panelAction(id).then((result) => {
|
|
4699
|
+
if (result.ok) pollNow();
|
|
4700
|
+
}, () => {});
|
|
4701
|
+
},
|
|
4586
4702
|
feedbackDone: () => {
|
|
4587
4703
|
setFeedback(null);
|
|
4588
4704
|
},
|
|
@@ -4615,7 +4731,7 @@ window.__ModuleLoader__.load({
|
|
|
4615
4731
|
const petRoot = (0, react_dom_client.createRoot)(container);
|
|
4616
4732
|
petRoot.render((0, react.createElement)(PetDockEntry, {
|
|
4617
4733
|
...injected(),
|
|
4618
|
-
t,
|
|
4734
|
+
t: ctx.locale.bind("pet"),
|
|
4619
4735
|
portalTarget: container
|
|
4620
4736
|
}));
|
|
4621
4737
|
let uiGone = false;
|