@linxin666/dsh-pet 0.2.7 → 0.2.8
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 +1 -1
- package/README.zh.md +1 -1
- package/assets/whale/pet.json +54 -54
- package/assets/whale-refined/pet.json +96 -1
- package/lib/client.js +84 -14
- package/lib/client.js.map +1 -1
- package/lib/index.js +62 -58
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +23 -17
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +50 -3
- package/lib/types/client/ui-teardown.d.ts +29 -0
- package/lib/types/client/ui-teardown.d.ts.map +1 -0
- package/lib/types/client/ui-teardown.js +41 -0
- package/lib/types/registry.d.ts +5 -1
- package/lib/types/registry.d.ts.map +1 -1
- package/lib/types/registry.js +14 -10
- package/package.json +12 -9
- package/src/client/PetSprite.test.tsx +168 -26
- package/src/client/PetSprite.tsx +21 -15
- package/src/client/index.test.tsx +118 -11
- package/src/client/index.ts +51 -3
- package/src/client/ui-teardown.ts +47 -0
- package/src/registry.test.ts +14 -0
- package/src/registry.ts +14 -10
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: b3edd49ede7b31ff40195aec2082088b24255656
|
|
6
|
+
README.zh.md: 1476678e2ed514eeaea69bcf0d77dd7c71a74fe1
|
package/README.md
CHANGED
|
@@ -249,7 +249,7 @@ global React root (createRoot → document.body) <-- polling 2s -- pet-client (b
|
|
|
249
249
|
- **Registry**: the host normalizes every manifest into a full render definition (geometry, per-row frame counts, per-track durations) and serves it over `/api/pet/pets`; the browser half renders any entry from that definition and carries no per-pet code.
|
|
250
250
|
- **Selection & naming**: `petId` lives in the settings namespace; per-pet names live in `pet.json` under `names`, edited through the hover-panel rename of the active pet. Legacy installs migrate their flat `name` onto the whale girl.
|
|
251
251
|
- **Multi-session semantics**: the API and browser mount are host-global and expose no foreground-session identity. Concurrent sessions each keep their own projected state: the most recent meaningful event drives the sprite animation, while every active TOP-LEVEL session reports its stage in its own bubble (the state view's sessions list, capped at 12 most-recent). Subagent children are tracked for animation, rewards, and the single display bubble but render no bubble of their own, so N conversations never multiply into an N-plus-subagents stack. Every session's completed turns are still rewarded independently; disposing a session removes its bubble, and disposing the display session falls back to the most recent remaining one.
|
|
252
|
-
- **Mount point**: `document.body` (global React root, always shown: no session / new session / mid-session — the old mount point `conversation.composer.dock` only rendered in an active session, hiding the pet in new sessions); the component uses `createPortal` internally to render the global floating layer.
|
|
252
|
+
- **Mount point**: `document.body` (global React root, always shown: no session / new session / mid-session — the old mount point `conversation.composer.dock` only rendered in an active session, hiding the pet in new sessions); the component uses `createPortal` internally to render the global floating layer. The root follows the plugin fiber lifecycle: fiber disposal unmounts the React root, removes the container, and stops the poll loop and settings subscription; a hot-reloaded or re-injected bundle takes over the page-global slot, so the page always holds exactly one `[data-dsh-pet-root]` (issue #785).
|
|
253
253
|
- **Rendering**: CSS sprite (background-position) per-frame animation; frame durations and optional scene sequences come from the served definition. The hover panel is anchored below the pet with a pointer bridge across the gap; when the viewport leaves no room below, it flips above the pet and is lifted clear of the status bubble stack so the two never overlap.
|
|
254
254
|
- **Communication**: browser ↔ host over the same-origin `/api/pet/*` JSON endpoints (state/pets/interact/set-visible/set-config/set-name/set-pet); each pet's atlas loads from `/pet/<id>/<spritesheetPath>` — the plugin self-sufficiently provides its own API and assets (the same pattern as dsh-remote-web-ui's `/api/pair`).
|
|
255
255
|
|
package/README.zh.md
CHANGED
|
@@ -249,7 +249,7 @@ dsh-pet/
|
|
|
249
249
|
- **注册表**:宿主把每份 manifest 归一化为完整渲染定义(几何、每行帧数、每轨时长),经 `/api/pet/pets` 下发;浏览器半区用该定义渲染任意条目,不携带任何宠物专属代码。
|
|
250
250
|
- **选择与命名**:`petId` 存于设置命名空间;每只宠物的名字存于 `pet.json` 的 `names`,通过悬浮面板对当前宠物改名编辑。旧版安装的平铺 `name` 自动迁移到鲸鱼娘名下。
|
|
251
251
|
- **多会话语义**:API 与浏览器挂载都是宿主全局的,不暴露前台会话身份。并行会话各自保留投影状态:最近一次有意义事件驱动精灵动画,同时每个活动的顶层会话在独立气泡里报告自己的阶段(state 视图的 sessions 列表,最多保留最近 12 个)。子代理会话仍参与动画、计奖与单一显示气泡,但不占独立气泡位——N 个对话不会变成"N + 子代理数"的气泡堆。每个会话完成的轮次仍独立计奖;销毁会话移除它的气泡,销毁当前显示会话则回退到最近仍在活动的会话。
|
|
252
|
-
- **挂载点**:`document.body`(全局 React 根,始终显示:无会话 / 新会话 / 会话中都可见——旧挂载点 `conversation.composer.dock` 只在活动会话里渲染,新会话里宠物消失);组件内部用 `createPortal`
|
|
252
|
+
- **挂载点**:`document.body`(全局 React 根,始终显示:无会话 / 新会话 / 会话中都可见——旧挂载点 `conversation.composer.dock` 只在活动会话里渲染,新会话里宠物消失);组件内部用 `createPortal` 渲染全局浮层。根容器随插件 fiber 生命周期走:fiber 销毁时卸载 React 根、移除容器并停止轮询与设置订阅;热重载或重复注入的新 bundle 接管页面级单挂载槽,页面始终只有一个 `[data-dsh-pet-root]`(issue #785)。
|
|
253
253
|
- **渲染**:CSS 精灵(background-position)逐帧动画;帧时长和可选场景序列来自下发定义。悬浮面板锚定在宠物下方,间隙由指针桥接覆盖;当视口下方空间不足时,面板翻转到宠物上方并抬升到状态气泡栈之上,两者互不遮挡。
|
|
254
254
|
- **通信**:浏览器 ↔ 宿主走同源 `/api/pet/*` JSON 端点(state/pets/interact/set-visible/set-config/set-name/set-pet);每只宠物的图集从 `/pet/<id>/<spritesheetPath>` 加载——插件自给自足地提供自己的 API 与资源(与 dsh-remote-web-ui 的 `/api/pair` 同一模式)。
|
|
255
255
|
|
package/assets/whale/pet.json
CHANGED
|
@@ -19,95 +19,95 @@
|
|
|
19
19
|
"tracks": {
|
|
20
20
|
"idle": {
|
|
21
21
|
"durations": [
|
|
22
|
-
400,
|
|
23
|
-
400,
|
|
24
22
|
500,
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
500
|
|
23
|
+
500,
|
|
24
|
+
600,
|
|
25
|
+
500,
|
|
26
|
+
500,
|
|
27
|
+
600
|
|
28
28
|
]
|
|
29
29
|
},
|
|
30
30
|
"running-right": {
|
|
31
31
|
"durations": [
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
32
|
+
300,
|
|
33
|
+
300,
|
|
34
|
+
300,
|
|
35
|
+
300,
|
|
36
|
+
300,
|
|
37
|
+
300,
|
|
38
|
+
300,
|
|
39
|
+
400
|
|
40
40
|
]
|
|
41
41
|
},
|
|
42
42
|
"running-left": {
|
|
43
43
|
"durations": [
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
44
|
+
300,
|
|
45
|
+
300,
|
|
46
|
+
300,
|
|
47
|
+
300,
|
|
48
|
+
300,
|
|
49
|
+
300,
|
|
50
|
+
300,
|
|
51
|
+
400
|
|
52
52
|
]
|
|
53
53
|
},
|
|
54
54
|
"waving": {
|
|
55
55
|
"durations": [
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
450,
|
|
57
|
+
450,
|
|
58
|
+
450,
|
|
59
|
+
450
|
|
60
60
|
]
|
|
61
61
|
},
|
|
62
62
|
"jumping": {
|
|
63
63
|
"durations": [
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
400,
|
|
65
|
+
400,
|
|
66
|
+
400,
|
|
67
|
+
450,
|
|
68
|
+
450
|
|
69
69
|
]
|
|
70
70
|
},
|
|
71
71
|
"failed": {
|
|
72
72
|
"durations": [
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
450,
|
|
76
|
-
500,
|
|
73
|
+
550,
|
|
74
|
+
550,
|
|
77
75
|
550,
|
|
78
76
|
600,
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
650,
|
|
78
|
+
700,
|
|
79
|
+
550,
|
|
80
|
+
550
|
|
81
81
|
]
|
|
82
82
|
},
|
|
83
83
|
"waiting": {
|
|
84
84
|
"durations": [
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
85
|
+
550,
|
|
86
|
+
550,
|
|
87
|
+
600,
|
|
88
|
+
550,
|
|
89
|
+
550,
|
|
90
|
+
600
|
|
91
91
|
]
|
|
92
92
|
},
|
|
93
93
|
"running": {
|
|
94
94
|
"durations": [
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
330,
|
|
96
|
+
330,
|
|
97
|
+
330,
|
|
98
|
+
330,
|
|
99
|
+
330,
|
|
100
|
+
400
|
|
101
101
|
]
|
|
102
102
|
},
|
|
103
103
|
"review": {
|
|
104
104
|
"durations": [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
105
|
+
650,
|
|
106
|
+
650,
|
|
107
|
+
650,
|
|
108
|
+
650,
|
|
109
|
+
650,
|
|
110
|
+
650
|
|
111
111
|
]
|
|
112
112
|
}
|
|
113
113
|
}
|
|
@@ -15,7 +15,102 @@
|
|
|
15
15
|
6,
|
|
16
16
|
6,
|
|
17
17
|
6
|
|
18
|
-
]
|
|
18
|
+
],
|
|
19
|
+
"tracks": {
|
|
20
|
+
"idle": {
|
|
21
|
+
"durations": [
|
|
22
|
+
500,
|
|
23
|
+
500,
|
|
24
|
+
600,
|
|
25
|
+
500,
|
|
26
|
+
500,
|
|
27
|
+
600
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"running-right": {
|
|
31
|
+
"durations": [
|
|
32
|
+
300,
|
|
33
|
+
300,
|
|
34
|
+
300,
|
|
35
|
+
300,
|
|
36
|
+
300,
|
|
37
|
+
300,
|
|
38
|
+
300,
|
|
39
|
+
400
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
"running-left": {
|
|
43
|
+
"durations": [
|
|
44
|
+
300,
|
|
45
|
+
300,
|
|
46
|
+
300,
|
|
47
|
+
300,
|
|
48
|
+
300,
|
|
49
|
+
300,
|
|
50
|
+
300,
|
|
51
|
+
400
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"waving": {
|
|
55
|
+
"durations": [
|
|
56
|
+
450,
|
|
57
|
+
450,
|
|
58
|
+
450,
|
|
59
|
+
450
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"jumping": {
|
|
63
|
+
"durations": [
|
|
64
|
+
400,
|
|
65
|
+
400,
|
|
66
|
+
400,
|
|
67
|
+
450,
|
|
68
|
+
450
|
|
69
|
+
]
|
|
70
|
+
},
|
|
71
|
+
"failed": {
|
|
72
|
+
"durations": [
|
|
73
|
+
550,
|
|
74
|
+
550,
|
|
75
|
+
550,
|
|
76
|
+
600,
|
|
77
|
+
650,
|
|
78
|
+
700,
|
|
79
|
+
550,
|
|
80
|
+
550
|
|
81
|
+
]
|
|
82
|
+
},
|
|
83
|
+
"waiting": {
|
|
84
|
+
"durations": [
|
|
85
|
+
550,
|
|
86
|
+
550,
|
|
87
|
+
600,
|
|
88
|
+
550,
|
|
89
|
+
550,
|
|
90
|
+
600
|
|
91
|
+
]
|
|
92
|
+
},
|
|
93
|
+
"running": {
|
|
94
|
+
"durations": [
|
|
95
|
+
330,
|
|
96
|
+
330,
|
|
97
|
+
330,
|
|
98
|
+
330,
|
|
99
|
+
330,
|
|
100
|
+
400
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"review": {
|
|
104
|
+
"durations": [
|
|
105
|
+
650,
|
|
106
|
+
650,
|
|
107
|
+
650,
|
|
108
|
+
650,
|
|
109
|
+
650,
|
|
110
|
+
650
|
|
111
|
+
]
|
|
112
|
+
}
|
|
113
|
+
}
|
|
19
114
|
},
|
|
20
115
|
"description": "基于鲸鱼娘形象进行 AI 辅助二次创作、修复与细节精修的内置变体。",
|
|
21
116
|
"license": "MIT"
|
package/lib/client.js
CHANGED
|
@@ -245,26 +245,29 @@ window.__ModuleLoader__.load({
|
|
|
245
245
|
const reduceMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)")?.matches === true;
|
|
246
246
|
el.style.backgroundPosition = position(segment.from);
|
|
247
247
|
if (reduceMotion || segment.from === segment.to) return;
|
|
248
|
-
let
|
|
248
|
+
let timer = 0;
|
|
249
249
|
let index = segment.from;
|
|
250
250
|
let elapsed = 0;
|
|
251
251
|
let last = performance.now();
|
|
252
|
-
const tick = (
|
|
253
|
-
const
|
|
254
|
-
|
|
252
|
+
const tick = () => {
|
|
253
|
+
const now = performance.now();
|
|
254
|
+
const delta = now - last;
|
|
255
|
+
last = now;
|
|
255
256
|
elapsed += delta;
|
|
256
|
-
const duration = decoration.durations[index] ??
|
|
257
|
+
const duration = decoration.durations[index] ?? 120;
|
|
257
258
|
if (elapsed >= duration) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
259
|
+
do {
|
|
260
|
+
elapsed -= duration;
|
|
261
|
+
if (index < segment.to) index += 1;
|
|
262
|
+
else if (decoration.loop) index = segment.from;
|
|
263
|
+
} while (elapsed >= duration);
|
|
261
264
|
el.style.backgroundPosition = position(index);
|
|
262
265
|
}
|
|
263
266
|
if (!decoration.loop && index === segment.to) return;
|
|
264
|
-
|
|
267
|
+
timer = window.setTimeout(tick, Math.max(1, duration - elapsed));
|
|
265
268
|
};
|
|
266
|
-
|
|
267
|
-
return () =>
|
|
269
|
+
timer = window.setTimeout(tick, 0);
|
|
270
|
+
return () => window.clearTimeout(timer);
|
|
268
271
|
}, [
|
|
269
272
|
shown,
|
|
270
273
|
segmentKey,
|
|
@@ -1233,6 +1236,48 @@ window.__ModuleLoader__.load({
|
|
|
1233
1236
|
}
|
|
1234
1237
|
};
|
|
1235
1238
|
//#endregion
|
|
1239
|
+
//#region src/client/ui-teardown.ts
|
|
1240
|
+
/**
|
|
1241
|
+
* Cross-bundle-instance teardown slot for the page-global pet root
|
|
1242
|
+
* (issue #785).
|
|
1243
|
+
*
|
|
1244
|
+
* A client bundle swap (HMR rebuilt frame, plugin update, duplicate
|
|
1245
|
+
* injection) runs a new apply body while the previous instance's fiber
|
|
1246
|
+
* may still be draining. Module state does not survive the swap, so a
|
|
1247
|
+
* closure guard only sees one apply body and the previous instance's
|
|
1248
|
+
* container keeps sitting on document.body: the page shows two pets
|
|
1249
|
+
* until a full refresh. The slot rides globalThis (which does survive)
|
|
1250
|
+
* so a re-apply can find the previous instance and unmount its React
|
|
1251
|
+
* root cleanly before mounting its own; the previous fiber's later
|
|
1252
|
+
* disposal stays a no-op through the idempotent teardowns.
|
|
1253
|
+
*/
|
|
1254
|
+
const SLOT = Symbol.for("dsh-pet.client-ui-teardown");
|
|
1255
|
+
/**
|
|
1256
|
+
* Claim the page-global pet UI slot with the current instance's teardown
|
|
1257
|
+
* (React root unmount + container removal + poll stop).
|
|
1258
|
+
* @param teardown - what a later instance runs to take the slot over.
|
|
1259
|
+
* @returns a disposer that clears the slot when the current instance's
|
|
1260
|
+
* UI is torn down (settings toggle, takeover, or fiber disposal).
|
|
1261
|
+
*/
|
|
1262
|
+
function registerPetUiTeardown(teardown) {
|
|
1263
|
+
const slot = globalThis;
|
|
1264
|
+
slot[SLOT] = teardown;
|
|
1265
|
+
return () => {
|
|
1266
|
+
if (slot[SLOT] === teardown) slot[SLOT] = void 0;
|
|
1267
|
+
};
|
|
1268
|
+
}
|
|
1269
|
+
/**
|
|
1270
|
+
* Run the previous instance's teardown if one is registered, so the
|
|
1271
|
+
* re-applying instance becomes the sole owner of the page-global pet
|
|
1272
|
+
* root. No-op when the previous fiber already tore down cleanly.
|
|
1273
|
+
*/
|
|
1274
|
+
function takeoverPetUiTeardown() {
|
|
1275
|
+
const slot = globalThis;
|
|
1276
|
+
const teardown = slot[SLOT];
|
|
1277
|
+
slot[SLOT] = void 0;
|
|
1278
|
+
teardown?.();
|
|
1279
|
+
}
|
|
1280
|
+
//#endregion
|
|
1236
1281
|
//#region \0dsh-css:packages/dsh-pet/src/client/settings-card.module.css.mjs
|
|
1237
1282
|
const css$1 = ".kKk9aW_card{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);border-radius:12px;list-style:none;transition:border-color .16s,background .16s}.kKk9aW_card:hover{border-color:var(--dsw-alias-label-dimmed)}.kKk9aW_cardOpen{background:var(--dsw-alias-bg-layer-2);border-color:var(--dsw-alias-label-dimmed)}.kKk9aW_header{appearance:none;width:100%;font:inherit;color:inherit;text-align:left;cursor:pointer;background:0 0;border:0;border-radius:12px;align-items:center;gap:12px;padding:14px 16px;display:flex}.kKk9aW_header:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}.kKk9aW_headerStatic{border-radius:12px;align-items:center;gap:12px;width:100%;padding:14px 16px;display:flex}.kKk9aW_headText{flex-direction:column;flex:1;gap:4px;min-width:0;display:flex}.kKk9aW_name{color:var(--dsw-alias-label-primary);font-size:15px;font-weight:600;line-height:1.4}.kKk9aW_description{color:var(--dsw-alias-label-tertiary);font-size:13px;line-height:1.5}.kKk9aW_pending{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;flex:none;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.kKk9aW_chevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.kKk9aW_chevronOpen{transform:rotate(180deg)}.kKk9aW_body{border-top:1px solid var(--dsw-alias-border-l2);margin:0 16px;padding-bottom:8px}.kKk9aW_readOnly{color:var(--dsw-alias-label-tertiary);margin:12px 0 0;font-size:12px;line-height:1.5}.kKk9aW_notExposed{color:var(--dsw-alias-state-warn-primary);margin:12px 0 0;font-size:12px;line-height:1.5}.kKk9aW_footer{border-top:1px solid var(--dsw-alias-border-l2);justify-content:flex-end;align-items:center;gap:8px;padding:12px 0 4px;display:flex}.kKk9aW_failed{min-width:0;color:var(--dsw-alias-label-error);text-overflow:ellipsis;white-space:nowrap;flex:1;margin:0;font-size:12px;line-height:1.5;overflow:hidden}.kKk9aW_discard,.kKk9aW_save{appearance:none;font:inherit;cursor:pointer;border:1px solid #0000;border-radius:8px;padding:5px 14px;font-size:13px;line-height:1.5}.kKk9aW_discard{border-color:var(--dsw-alias-border-l2);color:var(--dsw-alias-label-secondary);background:0 0}.kKk9aW_discard:hover:not(:disabled){color:var(--dsw-alias-label-primary);border-color:var(--dsw-alias-label-dimmed)}.kKk9aW_save{background:var(--dsw-alias-label-primary);color:var(--dsw-alias-bg-layer-3)}.kKk9aW_discard:disabled,.kKk9aW_save:disabled{opacity:.4;cursor:default}.kKk9aW_discard:focus-visible,.kKk9aW_save:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px}.kKk9aW_field{flex-direction:column;gap:6px;padding:12px 0;display:flex}.kKk9aW_field+.kKk9aW_field{border-top:1px solid var(--dsw-alias-border-l2)}.kKk9aW_head{align-items:center;gap:8px;display:flex}.kKk9aW_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}.kKk9aW_badges{align-items:center;gap:8px;display:inline-flex}.kKk9aW_badge{white-space:nowrap;background:var(--dsw-alias-bg-module-platform);color:var(--dsw-alias-label-secondary);border-radius:999px;padding:1px 8px;font-size:11px;font-weight:500;line-height:17px}.kKk9aW_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.kKk9aW_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.kKk9aW_reset:disabled{cursor:default}.kKk9aW_reset:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px;outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}.kKk9aW_input,.kKk9aW_select{border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.kKk9aW_input:focus-visible,.kKk9aW_select:focus-visible{border-color:var(--dsw-alias-brand-primary);outline:none}.kKk9aW_input:disabled,.kKk9aW_select:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.kKk9aW_inputInvalid{border:1px solid var(--dsw-alias-label-error);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.kKk9aW_inputInvalid:focus-visible{outline:2px solid var(--dsw-alias-label-error);outline-offset:1px;border-color:var(--dsw-alias-label-error)}.kKk9aW_selectWrap{position:relative}.kKk9aW_selectButton{appearance:none;text-align:left;cursor:pointer;justify-content:space-between;align-items:center;gap:8px;width:100%;display:flex}.kKk9aW_selectLabel{text-overflow:ellipsis;white-space:nowrap;min-width:0;overflow:hidden}.kKk9aW_selectChevron{color:var(--dsw-alias-label-tertiary);flex:none;transition:transform .16s}.kKk9aW_selectChevronOpen{transform:rotate(180deg)}.kKk9aW_selectPopup{z-index:40;border:1px solid var(--dsw-alias-border-l2);background:var(--dsw-alias-bg-layer-3);max-height:240px;box-shadow:0 8px 24px var(--dsw-alias-bg-mask-2);opacity:0;border-radius:8px;flex-direction:column;padding:4px;transition:opacity .1s,transform .1s;display:flex;position:absolute;top:calc(100% + 4px);left:0;right:0;overflow-y:auto;transform:translateY(-4px)}.kKk9aW_selectPopupOpen{opacity:1;transform:none}.kKk9aW_selectPopupClose{opacity:0;pointer-events:none;transform:translateY(-4px)}.kKk9aW_selectOption{color:var(--dsw-alias-label-primary);cursor:pointer;white-space:nowrap;text-overflow:ellipsis;border-radius:6px;flex-shrink:0;padding:6px 10px;font-size:13px;line-height:1.5;overflow:hidden}.kKk9aW_selectOption:hover,.kKk9aW_selectOptionActive{background:var(--dsw-alias-interactive-bg-hover)}.kKk9aW_selectOptionSelected{color:var(--dsw-alias-brand-primary);background:color-mix(in srgb, var(--dsw-alias-brand-primary-new-colorprimary-new-color) 10%, transparent);font-weight:500}.kKk9aW_invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.kKk9aW_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}@media (prefers-reduced-motion:reduce){.kKk9aW_card,.kKk9aW_header,.kKk9aW_chevron,.kKk9aW_chevronOpen,.kKk9aW_discard,.kKk9aW_save,.kKk9aW_selectChevron,.kKk9aW_selectChevronOpen,.kKk9aW_selectPopup{transition:none}}";
|
|
1238
1283
|
const tagId$1 = "@linxin666/dsh-pet/settings-card.module.css";
|
|
@@ -2488,8 +2533,18 @@ window.__ModuleLoader__.load({
|
|
|
2488
2533
|
};
|
|
2489
2534
|
});
|
|
2490
2535
|
let disposeUi;
|
|
2536
|
+
let clearUiTeardown;
|
|
2537
|
+
let uiDead = false;
|
|
2538
|
+
const killUi = () => {
|
|
2539
|
+
if (uiDead) return;
|
|
2540
|
+
uiDead = true;
|
|
2541
|
+
clearUiTeardown?.();
|
|
2542
|
+
clearUiTeardown = void 0;
|
|
2543
|
+
disposeUi?.();
|
|
2544
|
+
disposeUi = void 0;
|
|
2545
|
+
};
|
|
2491
2546
|
const syncUi = () => {
|
|
2492
|
-
if (enabled() && disposeUi === void 0) {
|
|
2547
|
+
if (!uiDead && enabled() && disposeUi === void 0) {
|
|
2493
2548
|
const petStore = createPetStore().create();
|
|
2494
2549
|
const setSnapshot = petStore.actions.setSnapshot;
|
|
2495
2550
|
const setPets = petStore.actions.setPets;
|
|
@@ -2590,6 +2645,8 @@ window.__ModuleLoader__.load({
|
|
|
2590
2645
|
setFeedback(null);
|
|
2591
2646
|
}
|
|
2592
2647
|
});
|
|
2648
|
+
takeoverPetUiTeardown();
|
|
2649
|
+
for (const stale of Array.from(document.querySelectorAll("div[data-dsh-pet-root]"))) stale.remove();
|
|
2593
2650
|
const container = document.createElement("div");
|
|
2594
2651
|
container.dataset.dshPetRoot = "";
|
|
2595
2652
|
container.dataset.dshPlugin = "pet";
|
|
@@ -2599,18 +2656,31 @@ window.__ModuleLoader__.load({
|
|
|
2599
2656
|
...injected(),
|
|
2600
2657
|
t
|
|
2601
2658
|
}));
|
|
2659
|
+
let uiGone = false;
|
|
2602
2660
|
disposeUi = () => {
|
|
2661
|
+
if (uiGone) return;
|
|
2662
|
+
uiGone = true;
|
|
2663
|
+
clearUiTeardown?.();
|
|
2664
|
+
clearUiTeardown = void 0;
|
|
2603
2665
|
petRoot.unmount();
|
|
2604
2666
|
container.remove();
|
|
2605
2667
|
disposePoll();
|
|
2606
2668
|
disposeUi = void 0;
|
|
2607
2669
|
};
|
|
2608
|
-
|
|
2670
|
+
clearUiTeardown = registerPetUiTeardown(() => {
|
|
2671
|
+
uiDead = true;
|
|
2672
|
+
disposeUi?.();
|
|
2673
|
+
});
|
|
2674
|
+
} else if (!uiDead && !enabled() && disposeUi !== void 0) {
|
|
2609
2675
|
disposeUi();
|
|
2610
2676
|
disposeUi = void 0;
|
|
2611
2677
|
}
|
|
2612
2678
|
};
|
|
2613
|
-
settingsScope.subscribe(syncUi);
|
|
2679
|
+
const unsubscribeSettings = settingsScope.subscribe(syncUi);
|
|
2680
|
+
ctx.effect(() => () => {
|
|
2681
|
+
unsubscribeSettings();
|
|
2682
|
+
killUi();
|
|
2683
|
+
}, "pet: client lifecycle");
|
|
2614
2684
|
syncUi();
|
|
2615
2685
|
}
|
|
2616
2686
|
//#endregion
|