@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/lib/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","names":["styles","styles","css","sectionCss"],"sources":["../../../packages/dsh-pet/src/client/pet-store.ts","../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../../../packages/dsh-pet/src/state.ts","../../../packages/dsh-pet/src/client/spritesheet.ts","../../../packages/dsh-pet/src/client/sequences.ts","../../../packages/dsh-pet/src/client/PetSprite.tsx","../../../packages/dsh-pet/src/client/renderers/registry.ts","../../../packages/dsh-pet/src/client/phase-stream.ts","../../../packages/dsh-pet/src/client/renderers/live2d/Live2dVisualMount.tsx","../../../packages/dsh-pet/src/client/renderers/PetRendererSwitch.tsx","../../../packages/dsh-pet/src/client/PetDockEntry.tsx","../../../packages/dsh-pet/src/contracts/renderer.ts","../../../packages/dsh-pet/src/client/renderers/live2d/runtime.ts","../../../packages/dsh-pet/src/client/renderers/live2d.ts","../../../packages/dsh-pet/src/client/PluginSettingsCard.tsx","../../../packages/dsh-pet/src/client/settings-form.ts","../../../packages/dsh-pet/src/client/PetSettingsCard.tsx","../../../packages/dsh-pet/src/client/locales.ts","../../../packages/dsh-pet/src/client/index.ts"],"sourcesContent":["/**\n * Browser-side pet store: the pet state snapshot plus transient UI feedback\n * (reaction bubbles), written only through the store's audit actions. The\n * RPC polling and interactions live in the plugin apply body; components\n * only ever read snapshots.\n * @module @linxin666/dsh-pet/client/pet-store\n */\n\nimport { defineStore } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { EngineStoreHandle, EngineStoreInstance } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { PetStateView } from '../service.ts'\nimport type { PetInteraction } from '../affinity.ts'\nimport type { PetDefinition } from '../registry.ts'\n\n/** One transient reaction bubble on the pet. */\nexport interface PetFeedback {\n /** Bubble copy. */\n text: string\n /** Interaction kind driving the reaction animation. */\n kind: PetInteraction | 'none'\n /** Epoch ms when the bubble appeared (for expiry). */\n at: number\n}\n\n/** Pet UI state as consumers see it. */\nexport interface PetUiState {\n /** Latest host snapshot; null before the first successful fetch. */\n snapshot: PetStateView | null\n /** The registry list the host serves (atlas URLs + geometry + tracks). */\n pets: PetDefinition[]\n /** Fetch lifecycle. */\n state: 'loading' | 'ready' | 'error'\n /** Transport error message (for the debug surface), when any. */\n error: string | null\n /** Active reaction bubble, if any. */\n feedback: PetFeedback | null\n}\n\n/** Store write set. */\nexport type PetUiActions = {\n /** Replace the host snapshot (poll result). */\n setSnapshot: (draft: PetUiState, snapshot: PetStateView) => void\n /** Replace the registry list. */\n setPets: (draft: PetUiState, pets: PetDefinition[]) => void\n /** Mark the fetch lifecycle. */\n setState: (draft: PetUiState, state: PetUiState['state'], error: string | null) => void\n /** Show a reaction bubble. */\n setFeedback: (draft: PetUiState, feedback: PetFeedback | null) => void\n}\n\n/** Create the pet store handle (apply world only; never module-level). */\nexport function createPetStore(): EngineStoreHandle<PetUiState, PetUiActions> {\n return defineStore({\n init: (): PetUiState => ({\n snapshot: null,\n pets: [],\n state: 'loading',\n error: null,\n feedback: null,\n }),\n actions: {\n setSnapshot: (draft, snapshot) => {\n draft.snapshot = snapshot\n draft.state = 'ready'\n draft.error = null\n },\n setPets: (draft, pets) => {\n draft.pets = pets\n },\n setState: (draft, state, error) => {\n draft.state = state\n draft.error = error\n },\n setFeedback: (draft, feedback) => {\n draft.feedback = feedback\n },\n },\n })\n}\n\nexport type { PetInteraction }\n\n/**\n * A live pet store instance (one per host, owned by the plugin apply body —\n * the pet itself is host-global, so its UI state must not ride the slot\n * system's per-session store scoping).\n */\nexport type PetStoreInstance = EngineStoreInstance<PetUiState, PetUiActions>\n\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","/**\n * Pet state machine — pure, clock-injected. Maps official DSH session activity\n * and the legacy `activity/status` vocabulary onto the 9-state Codex pet\n * animation contract, plus turn-end celebration and no-session idle.\n *\n * The machine is deliberately dumb: it holds the last input phase, the\n * animation decision, and a one-shot \"celebration\" window after `done` so the\n * pet visibly jumps before settling back to idle. Everything here is a pure\n * function of (input, nowMs); persistence and RPC live in the service.\n * @module @linxin666/dsh-pet/state\n */\n\n/** Activity phases understood by the pet host. */\nexport type ActivityPhase = 'idle' | 'waiting' | 'thinking' | 'tool' | 'review' | 'done' | 'failed'\n\n/** The Codex-compatible 9-state animation contract (spritesheet rows). */\nexport type PetAnimation =\n | 'idle'\n | 'running-right'\n | 'running-left'\n | 'waving'\n | 'jumping'\n | 'failed'\n | 'waiting'\n | 'running'\n | 'review'\n\n/** One input snapshot consumed by the machine. */\nexport interface PetStateInput {\n /** Current activity phase of the active session. */\n phase: ActivityPhase\n /** Human-readable status line (plain text). */\n line?: string\n /** Playful phrase from the activity tracker, when any. */\n phrase?: string\n}\n\n/** Animation decision plus the copy the pet should show. */\nexport interface PetStateSnapshot {\n /** Which animation track to play. */\n animation: PetAnimation\n /** Optional status bubble copy (line or phrase), shown while active. */\n bubble?: string\n /** Wall-clock ms this animation started (client can sync loops). */\n animationStartedAt: number\n /** Raw phase, for debugging and client-side rendering decisions. */\n phase: ActivityPhase\n /** True when there is an active session (pet mounted). */\n sessionActive: boolean\n}\n\n/** Machine configuration. */\nexport interface PetStateConfig {\n /** Celebration window after `done` before settling to idle, ms (default 2400). */\n celebrateMs: number\n /** Failure display window before settling to idle, ms (default 2400). */\n failureMs: number\n}\n\nexport const defaultPetStateConfig: PetStateConfig = { celebrateMs: 2400, failureMs: 2400 }\n\n/**\n * Map one activity phase onto the animation contract.\n * - thinking → `running` and tool → `running-right` (focused work).\n * - review → `review` while answer text is streaming.\n * - waiting → `waiting` (expectant pose, needs user input).\n * - done → `jumping` (celebration), then back to `idle` after the window.\n * - failed → `failed` briefly, then back to `idle`.\n * - idle → `idle` (calm breathing loop).\n */\nexport function animationForPhase(phase: ActivityPhase): PetAnimation {\n switch (phase) {\n case 'thinking': return 'running'\n case 'tool': return 'running-right'\n case 'review': return 'review'\n case 'waiting': return 'waiting'\n case 'done': return 'jumping'\n case 'failed': return 'failed'\n case 'idle': return 'idle'\n }\n}\n\n/** The spritesheet row index for one animation track. */\nexport function rowOf(animation: PetAnimation): number {\n const rows: Record<PetAnimation, number> = {\n 'idle': 0,\n 'running-right': 1,\n 'running-left': 2,\n 'waving': 3,\n 'jumping': 4,\n 'failed': 5,\n 'waiting': 6,\n 'running': 7,\n 'review': 8,\n }\n return rows[animation]\n}\n\n/**\n * PetStateMachine — one instance per host process. Holds only the latest\n * input snapshot and terminal-state timing; no storage, no side effects.\n */\nexport class PetStateMachine {\n private phase: ActivityPhase = 'idle'\n private line: string | undefined\n private phrase: string | undefined\n private sessionActive = false\n private doneAt: number | undefined\n private failedAt: number | undefined\n private readonly config: PetStateConfig\n\n constructor(\n config: Partial<PetStateConfig> = defaultPetStateConfig,\n private readonly now: () => number = Date.now,\n ) {\n this.config = { ...defaultPetStateConfig, ...config }\n }\n\n /** Consume one projected activity update. */\n onActivityStatus(input: PetStateInput): void {\n this.phase = input.phase\n this.line = input.line\n this.phrase = input.phrase\n this.doneAt = input.phase === 'done' ? this.now() : undefined\n this.failedAt = input.phase === 'failed' ? this.now() : undefined\n }\n\n /** A session became the active one (or a fresh session started). */\n onSessionActive(): void {\n this.sessionActive = true\n }\n\n /** The active session was disposed (or none left). */\n onSessionDisposed(): void {\n this.sessionActive = false\n this.phase = 'idle'\n this.line = undefined\n this.phrase = undefined\n this.doneAt = undefined\n this.failedAt = undefined\n }\n\n /** Render the current animation decision. */\n render(): PetStateSnapshot {\n const nowMs = this.now()\n let animation = animationForPhase(this.phase)\n const doneSettled = this.phase === 'done'\n && this.doneAt !== undefined\n && nowMs - this.doneAt >= this.config.celebrateMs\n const failedSettled = this.phase === 'failed'\n && this.failedAt !== undefined\n && nowMs - this.failedAt >= this.config.failureMs\n if (doneSettled || failedSettled) animation = 'idle'\n // Settled sessions never bubble: idle (e.g. an aborted/stopped turn),\n // completed celebration expiry, and failed display expiry all fall silent.\n const settled = this.phase === 'idle' || doneSettled || failedSettled\n const bubble = settled ? undefined : this.phrase ?? this.line\n return {\n animation,\n ...(bubble === undefined ? {} : { bubble }),\n animationStartedAt: nowMs,\n phase: this.phase,\n sessionActive: this.sessionActive,\n }\n }\n}\n","/**\n * Spritesheet geometry helpers — parameterized by the pet definition the\n * host serves over '/api/pet/pets', so the browser half renders any registry\n * entry without per-pet code. The per-track tables (frames, durations, loop,\n * fallback) also come from the registry; these helpers only place frames,\n * guard track lengths, and map the fixed 9-row animation contract.\n * @module @linxin666/dsh-pet/client/spritesheet\n */\n\nimport { rowOf, type PetAnimation } from '../state.ts'\nimport type { PetCell, PetTrackDef } from '../registry.ts'\n\n/** Animation track shape the frame loop consumes. */\nexport type TrackDef = PetTrackDef\n\n/** Row index of one animation track (the fixed 9-row contract). */\nexport function rowOfTrack(animation: PetAnimation): number {\n // The table itself lives in state.ts (rowOf) — the single source of truth.\n return rowOf(animation)\n}\n\n/**\n * Background-position (px) of one frame cell within the scaled atlas.\n * The background image is scaled by `scale` (element size ÷ cell size), and\n * background-position offsets are applied in SCALED coordinates — using raw\n * atlas coordinates here would drift each frame by the scale factor and\n * render torn/overlapping frames.\n */\nexport function framePosition(cell: PetCell, row: number, col: number, scale = 1): { x: number; y: number } {\n return { x: -col * cell.width * scale, y: -row * cell.height * scale }\n}\n\n/**\n * Trim a track to the actual frame count of its row (the manifest's per-row\n * counts are authoritative; this is a last-line guard against a definition\n * whose row count disagrees with its track table). A row with 0 detected\n * frames degrades to the first frame so the pet never renders blank.\n */\nexport function trimTrack(track: TrackDef, frameCount: number): TrackDef {\n const n = Math.max(1, Math.min(frameCount, track.frames.length, track.durations.length))\n return {\n frames: track.frames.slice(0, n),\n durations: track.durations.slice(0, n),\n loop: track.loop,\n ...(track.fallback === undefined ? {} : { fallback: track.fallback }),\n }\n}\n","/** Pure timing helpers for manifest-defined scene animation sequences. */\n\nimport type { PetTrackDef } from '../registry.ts'\nimport type { PetAnimation } from '../state.ts'\n\nexport interface SequenceFrame {\n animation: PetAnimation\n frameIndex: number\n}\n\n/** Resolve the active track and frame after elapsed milliseconds of a looping sequence. */\nexport function sequenceFrameAt(\n sequence: readonly PetAnimation[],\n tracks: Record<PetAnimation, PetTrackDef>,\n elapsedMs: number,\n): SequenceFrame {\n const itemDurations = sequence.map(animation => tracks[animation].durations.reduce((sum, value) => sum + value, 0))\n const sequenceDuration = itemDurations.reduce((sum, value) => sum + value, 0)\n let offset = Math.max(0, elapsedMs) % sequenceDuration\n let itemIndex = 0\n while (itemIndex < sequence.length - 1 && offset >= itemDurations[itemIndex]!) {\n offset -= itemDurations[itemIndex]!\n itemIndex += 1\n }\n const animation = sequence[itemIndex]!\n const track = tracks[animation]\n let frameIndex = 0\n while (frameIndex < track.frames.length - 1 && offset >= track.durations[frameIndex]!) {\n offset -= track.durations[frameIndex]!\n frameIndex += 1\n }\n return { animation, frameIndex }\n}\n","/**\n * Pet sprite companion component — the browser half's centerpiece. Renders a\n * fixed-position floating sprite (React portal onto document.body), plays\n * the track matching the host animation snapshot, and exposes the\n * interaction surface: click to pet, hover panel with feed/rename/hide, drag\n * to reposition (persisted via setConfig). Everything visual comes from the\n * pet definition the host serves ('/api/pet/pets' + the state snapshot's\n * pet id), so one component renders every registry entry.\n * @module @linxin666/dsh-pet/client/PetSprite\n */\n\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { CSSProperties, PointerEvent as ReactPointerEvent, ReactElement, ReactNode, ReactPortal } from 'react'\nimport { createPortal } from 'react-dom'\nimport clsx from 'clsx'\nimport type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetStateView } from '../service.ts'\nimport type { PetDefinition } from '../registry.ts'\nimport type { DecorationView } from '../contracts/status-decoration.ts'\nimport type { PetFeedback } from './pet-store.ts'\nimport { framePosition, rowOfTrack, trimTrack } from './spritesheet.ts'\nimport { sequenceFrameAt } from './sequences.ts'\nimport { animationForPhase, type ActivityPhase, type PetAnimation } from '../state.ts'\nimport { NS } from './locales.ts'\nimport styles from './pet.module.css'\n\n/** Props injected by the plugin apply body (store actions + locale). */\nexport interface PetSpriteProps {\n /** Latest host snapshot; null while loading. */\n snapshot: PetStateView | null\n /** The selected pet's registry definition (atlas URL + geometry + tracks). */\n definition: PetDefinition\n /** Display configuration (persisted by the host). */\n display: PetDisplayConfig\n /** Active reaction bubble, if any. */\n feedback: PetFeedback | null\n /** Pet the sprite (click). */\n onPet: () => void\n /** Feed the sprite (panel button). */\n onFeed: () => void\n /** Hide the sprite (panel button). */\n onHide: () => void\n /** Persist a drag position. */\n onDragEnd: (right: number, bottom: number) => void\n /** Rename the selected pet (persisted by the host). */\n onRename: (name: string) => void\n /** Navigate to the session one status bubble reports on. */\n onOpenSession: (sessionId: string) => void\n /** Clear the reaction bubble (after its CSS animation). */\n onFeedbackDone: () => void\n /**\n * Custom visual replacing the sprite2d atlas animation (pet-center M3).\n * The chrome (drag, bubbles, panel, tap economy) is untouched: the visual\n * renders inside the sprite box, and the atlas load + frame loop skip.\n */\n visual?: ReactNode\n /** Locale translate seat (namespace-bound). */\n t: TranslateNS<typeof NS>\n}\n\n/** Clamp a drag offset inside the viewport with a margin. */\nfunction clampOffset(value: number, max: number): number {\n return Math.max(0, Math.min(max, value))\n}\n\n/**\n * The status decoration ornament (pet-center M5, #567). Renders the active\n * phase's frame segment as a CSS-background strip at a compact bubble\n * height; prefers-reduced-motion holds the segment's first frame, and a\n * missing or undecodable asset simply paints nothing (CSS background\n * failure) — the bubble text is never disturbed. The span is aria-hidden;\n * the bubble keeps its own semantics untouched.\n */\nfunction StatusOrnament(props: { decoration: DecorationView; phase: ActivityPhase }): ReactElement | null {\n const { decoration, phase } = props\n const segment = decoration.phases[phase]\n const shown = segment !== undefined && segment !== 'hide'\n const segmentKey = segment !== undefined && segment !== 'hide' ? segment.from + ':' + segment.to : 'none'\n const spanRef = useRef<HTMLSpanElement | null>(null)\n const scale = 18 / decoration.cell.height\n const frameWidth = Math.round(decoration.cell.width * scale)\n const stripWidth = decoration.columns * frameWidth\n // Value-stable dependency key: the host serves a fresh DecorationView\n // object on every state poll (2 s), so the effect must not depend on the\n // object identity — otherwise each poll would cancel and restart the\n // frame loop and the animation would jump back to its first frame.\n const durationsKey = decoration.durations.join(',')\n useEffect(() => {\n if (segment === undefined || segment === 'hide') return\n const el = spanRef.current\n if (el === null) return\n const position = (index: number): string => (-index * frameWidth) + 'px 0px'\n const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true\n el.style.backgroundPosition = position(segment.from)\n // A single-frame segment (from === to) has nothing to animate: with\n // loop=true the wrap branch would reset index to the same frame and the\n // tick would keep rescheduling a no-op rAF forever. Settle on the one\n // frame instead — same as the reduced-motion static hold.\n if (reduceMotion || segment.from === segment.to) return\n let raf = 0\n let index = segment.from\n let elapsed = 0\n let last = performance.now()\n const tick = (ts: number): void => {\n const delta = ts - last\n last = ts\n elapsed += delta\n const duration = decoration.durations[index] ?? 160\n if (elapsed >= duration) {\n elapsed = 0\n if (index < segment.to) index += 1\n else if (decoration.loop) index = segment.from\n // Only advance the background when the frame actually changes:\n // the segment's frame rate (duration ms, typically 90-160) is far\n // below the rAF cadence, so writing the same position every frame\n // would churn style recalculations for no visual change.\n el.style.backgroundPosition = position(index)\n }\n // A non-looping segment settles on its last frame; stop scheduling\n // instead of repainting the same position every frame.\n if (!decoration.loop && index === segment.to) return\n raf = requestAnimationFrame(tick)\n }\n raf = requestAnimationFrame(tick)\n return () => cancelAnimationFrame(raf)\n }, [shown, segmentKey, frameWidth, decoration.loop, durationsKey])\n if (!shown) return null\n return (\n <span\n ref={spanRef}\n aria-hidden=\"true\"\n data-dsh-pet-decoration={decoration.id}\n style={{\n display: 'inline-block',\n width: frameWidth,\n height: 18,\n marginRight: 6,\n verticalAlign: 'middle',\n flexShrink: 0,\n backgroundImage: 'url(' + decoration.entryUrl + ')',\n backgroundSize: stripWidth + 'px 18px',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: '0px 0px',\n }}\n />\n )\n}\n\n/**\n * The floating pet. The spritesheet frame advances on requestAnimationFrame\n * with per-frame durations from the definition's tracks; the atlas image is\n * loaded once and the background position is written straight to the sprite\n * element (no per-frame React state).\n */\nexport function PetSprite(props: PetSpriteProps): ReactPortal {\n const { snapshot, definition, display, feedback } = props\n const spriteRef = useRef<HTMLDivElement | null>(null)\n const floatRef = useRef<HTMLDivElement | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n // Whichever bubble surface is currently rendered (feedback, the session\n // stack, or the legacy status bubble) — only one exists at a time.\n const bubbleRef = useRef<HTMLDivElement | null>(null)\n const [imageReady, setImageReady] = useState(false)\n const [hovered, setHovered] = useState(false)\n // Multi-session bubble stack: collapsed by default (only the display\n // session's bubble + a '+N' badge), expanded on stack hover (peek) or by\n // tapping the badge (pinned, for touch). The display session's bubble\n // anchors the bottom of the stack and never moves when extras open above\n // it, so the pointer target cannot flicker.\n const [stackPeek, setStackPeek] = useState(false)\n const [stackPinned, setStackPinned] = useState(false)\n const [renaming, setRenaming] = useState(false)\n const [panelAbove, setPanelAbove] = useState(false)\n // Extra margin-bottom for the above-panel so it stacks clear of the\n // bubbles instead of overlapping them (both anchor at the sprite's top).\n const [panelLift, setPanelLift] = useState(0)\n const [nameDraft, setNameDraft] = useState('')\n // Explicit IME composition tracking: some input methods (WeChat IME on\n // Windows) report keydowns with isComposing === false mid-composition, so\n // the native flag alone is not a safe submit/cancel guard (#303).\n const composingRef = useRef(false)\n const [dragPos, setDragPos] = useState<{ right: number; bottom: number } | null>(null)\n const dragRef = useRef<{ startX: number; startY: number; right: number; bottom: number } | null>(null)\n const hideTimerRef = useRef<number | null>(null)\n const frameRef = useRef<{ track: PetAnimation | null; index: number; elapsed: number }>({\n track: null,\n index: 0,\n elapsed: 0,\n })\n\n const cell = definition.cell\n const columns = definition.columns\n const rows = definition.rows\n const tracks = definition.tracks\n const sequences = definition.sequences\n // Hover-panel chrome from the pet's voice pack (pet-center M4, issue\n // #677): every slot falls back to the i18n dictionary when unset. Stat\n // formats carry {rank}/{n}/{points} placeholders the host validated.\n const panel = definition.panel\n const panelLabel = (slot: 'feed' | 'rename' | 'hide' | 'confirm', i18n: string): string =>\n panel?.labels?.[slot] ?? i18n\n const panelStat = (\n slot: 'rank' | 'treats' | 'points',\n i18nKey: 'pet.rank' | 'pet.treats' | 'pet.points',\n values: Record<string, string | number>,\n ): string => {\n const format = panel?.stats?.[slot] ?? props.t(i18nKey, values)\n if (panel?.stats?.[slot] === undefined) return format\n // The host whitelists {rank}/{n}/{points} in every stat slot, so a pack\n // format may reference any of them; substitute all three live values\n // (the slot's own value plus the siblings) instead of only the slot's.\n const all: Record<string, string | number> = {\n rank: snapshot?.affinity.rank ?? '?',\n n: snapshot?.treats.stocked ?? 0,\n points: snapshot?.affinity.points ?? 0,\n }\n let text = format\n for (const [name, value] of Object.entries(all)) text = text.replaceAll('{' + name + '}', String(value))\n return text\n }\n const panelShows = (action: 'feed' | 'rename' | 'hide'): boolean =>\n panel?.actions === undefined || panel.actions.includes(action)\n\n // Load the atlas once; the definition carries the authoritative per-row\n // frame counts and per-track durations, so nothing else is fetched. A\n // custom visual (pet-center M3) replaces the atlas entirely.\n useEffect(() => {\n if (props.visual !== undefined) return\n let cancelled = false\n const img = new Image()\n img.onload = () => {\n if (!cancelled) setImageReady(true)\n }\n img.src = definition.atlasUrl\n return () => {\n cancelled = true\n img.onload = null\n }\n }, [definition.atlasUrl, props.visual])\n\n // Frame loop: advance the current track and write background-position.\n // Offsets must be in SCALED coordinates (background-position applies to the\n // scaled background image), so the current sprite scale rides a ref that\n // the loop reads every tick. Under prefers-reduced-motion the sprite holds\n // its track's first frame instead of animating (presentation-only; the\n // animation state machine is untouched).\n const spriteScale = display.size / cell.height\n const phase = snapshot?.phase ?? 'idle'\n const animation = snapshot?.animation ?? 'idle'\n const scaleRef = useRef(spriteScale)\n scaleRef.current = spriteScale\n useEffect(() => {\n if (props.visual !== undefined) return\n const reduceMotion = typeof window !== 'undefined'\n && window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true\n const sequence = animation === animationForPhase(phase) ? sequences?.[phase] : undefined\n const leadAnimation = sequence?.[0] ?? animation\n const row = rowOfTrack(leadAnimation)\n const track = trimTrack(tracks[leadAnimation], rows[row] ?? tracks[leadAnimation].frames.length)\n // Paint one static sprite frame up front either way, so the pet is never\n // blank while the loop heat-up runs.\n const leadCol = track.frames[0]!\n const lead = framePosition(cell, row, leadCol, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = lead.x + 'px ' + lead.y + 'px'\n }\n if (reduceMotion) return\n let raf = 0\n let last = performance.now()\n let sequenceElapsed = 0\n const tick = (ts: number): void => {\n const delta = ts - last\n last = ts\n if (sequence !== undefined) {\n sequenceElapsed += delta\n const current = sequenceFrameAt(sequence, tracks, sequenceElapsed)\n const currentRow = rowOfTrack(current.animation)\n const currentTrack = trimTrack(\n tracks[current.animation],\n rows[currentRow] ?? tracks[current.animation].frames.length,\n )\n const col = currentTrack.frames[current.frameIndex]!\n const pos = framePosition(cell, currentRow, col, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = pos.x + 'px ' + pos.y + 'px'\n }\n raf = requestAnimationFrame(tick)\n return\n }\n // row/track come from the effect scope: they were computed once above\n // and this effect re-runs when animation/tracks/rows change, so the\n // per-frame recompute (trimTrack slices fresh arrays) is pure waste.\n const st = frameRef.current\n if (st.track !== animation) {\n st.track = animation\n st.index = 0\n st.elapsed = 0\n }\n st.elapsed += delta\n const maxIndex = track.frames.length - 1\n while (st.elapsed >= (track.durations[st.index] ?? 0) && st.index < maxIndex) {\n st.elapsed -= track.durations[st.index] ?? 0\n st.index += 1\n }\n if (st.elapsed >= (track.durations[st.index] ?? 0)) {\n if (track.loop) {\n st.elapsed = 0\n st.index = 0\n } else {\n st.index = maxIndex // hold the final frame; the host switches tracks\n }\n }\n const col = track.frames[st.index]!\n const pos = framePosition(cell, row, col, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = pos.x + 'px ' + pos.y + 'px'\n }\n raf = requestAnimationFrame(tick)\n }\n raf = requestAnimationFrame(tick)\n return () => cancelAnimationFrame(raf)\n }, [animation, phase, cell, columns, rows, tracks, sequences, props.visual])\n\n // Auto-clear the feedback bubble after its CSS animation. The callback\n // rides a ref so re-renders never reset the timer: the 2s poll rebuilds\n // `props` every tick, and depending on it would starve the timeout.\n const feedbackDoneRef = useRef(props.onFeedbackDone)\n feedbackDoneRef.current = props.onFeedbackDone\n useEffect(() => {\n if (feedback === null) return\n const timer = window.setTimeout(() => feedbackDoneRef.current(), 2600)\n return () => window.clearTimeout(timer)\n }, [feedback])\n\n // Dragging: pointer events on the sprite; position is right/bottom based.\n // `draggedRef` records whether the pointer actually moved, so the browser's\n // trailing click (fired after pointerup) does not pet the sprite.\n const draggedRef = useRef(false)\n const clearHideTimer = (): void => {\n if (hideTimerRef.current !== null) {\n window.clearTimeout(hideTimerRef.current)\n hideTimerRef.current = null\n }\n }\n\n // Clear any pending auto-hide timer on unmount: a stray callback after\n // teardown reads window through react-dom and failed CI runs with\n // \"window is not defined\" (slow-runner timing, PetSprite.test.tsx).\n useEffect(() => () => clearHideTimer(), [])\n\n const onPointerDown = (e: ReactPointerEvent<HTMLDivElement>): void => {\n e.preventDefault()\n ;(e.target as HTMLElement).setPointerCapture?.(e.pointerId)\n const current = dragPos ?? { right: display.right, bottom: display.bottom }\n dragRef.current = { startX: e.clientX, startY: e.clientY, ...current }\n draggedRef.current = false\n setHovered(false)\n }\n const onPointerMove = (e: ReactPointerEvent<HTMLDivElement>): void => {\n const drag = dragRef.current\n if (drag === null) return\n const dx = e.clientX - drag.startX\n const dy = e.clientY - drag.startY\n if (Math.abs(dx) > 4 || Math.abs(dy) > 4) draggedRef.current = true\n const right = clampOffset(drag.right - dx, window.innerWidth - 40)\n const bottom = clampOffset(drag.bottom - dy, window.innerHeight - 40)\n setDragPos({ right, bottom })\n }\n const onPointerUp = (): void => {\n if (dragRef.current === null) return\n dragRef.current = null\n if (dragPos !== null) props.onDragEnd(dragPos.right, dragPos.bottom)\n }\n\n const pos = dragPos ?? { right: display.right, bottom: display.bottom }\n const spriteWidth = Math.round(cell.width * spriteScale)\n const spriteHeight = Math.round(cell.height * spriteScale)\n\n // Concurrent sessions share one bubble slot: only the display session\n // speaks by default, and the rest hide behind a '+N' badge until the stack\n // is hovered/pinned open. The legacy single 'bubble' is the fallback when\n // the host serves no per-session list. The hover panel normally sits below\n // the sprite, so the bubbles stay visible and clickable — no region swap.\n const sessionBubbles = snapshot?.sessions ?? []\n const stackOpen = stackPeek || stackPinned\n const collapsed = !stackOpen && sessionBubbles.length > 1\n const visibleSessions = collapsed ? sessionBubbles.slice(0, 1) : sessionBubbles\n const statusBubble = feedback === null && sessionBubbles.length === 0\n ? snapshot?.bubble\n : undefined\n // The display session's inner whisper (碎碎念) — short inner-voice copy\n // woken by the model's output. Instead of a second bubble of its own, a\n // fresh whisper takes over the display session's bubble (the stack top, or\n // the single status bubble) and re-tints it, so the pet never wears two\n // voices at once. Interaction feedback takes over the whole bubble area\n // while it plays, so whispers yield to it like status copy.\n const whisper = feedback === null ? snapshot?.whisper : undefined\n const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== undefined || whisper !== undefined\n const displayName = snapshot?.name ?? definition.displayName\n // The host-served status decoration (M5, #567); absent = text-only bubbles.\n const decoration = snapshot?.decoration\n\n // A settled session list can no longer stay pinned open.\n useEffect(() => {\n if (sessionBubbles.length <= 1) setStackPinned(false)\n }, [sessionBubbles.length])\n\n useLayoutEffect(() => {\n if (!hovered) {\n setPanelAbove(false)\n setPanelLift(0)\n return\n }\n const updatePanelPlacement = (): void => {\n const sprite = spriteRef.current\n const panel = panelRef.current\n if (sprite === null || panel === null) return\n const availableBelow = window.innerHeight - sprite.getBoundingClientRect().bottom\n const above = availableBelow < panel.getBoundingClientRect().height + 8\n setPanelAbove(above)\n // The fallback above-placement shares the sprite's top edge with the\n // bubble(s); lift the panel by the bubble area's height so the two\n // never overlap (8px base gap + 6px clearance above the top bubble).\n const bubbleHeight = above ? bubbleRef.current?.getBoundingClientRect().height ?? 0 : 0\n setPanelLift(bubbleHeight > 0 ? Math.ceil(bubbleHeight) + 14 : 0)\n }\n updatePanelPlacement()\n window.addEventListener('resize', updatePanelPlacement)\n return () => window.removeEventListener('resize', updatePanelPlacement)\n }, [hovered, renaming, pos.right, pos.bottom, display.size, bubblePresent, sessionBubbles.length, stackOpen, feedback])\n\n const float = (\n <div\n ref={floatRef}\n className={styles.float}\n style={{ right: pos.right, bottom: pos.bottom, zIndex: 2147483000 }}\n onPointerEnter={() => {\n clearHideTimer()\n setHovered(true)\n }}\n onPointerLeave={(e) => {\n // The panel renders OUTSIDE the container's box (absolute, below\n // the sprite), so moving onto it fires pointerleave on the container.\n // Treat a target still inside the container's DOM (the overflowed\n // panel) as \"still hovering\"; otherwise give the pointer a short\n // grace period to reach the panel across the gap below the sprite.\n // The bridge ('.panel::after') keeps the pointer inside the hit\n // area, and the grace period covers a slow mouse crossing the\n // remaining sliver.\n const next = e.relatedTarget\n if (next instanceof Node && floatRef.current?.contains(next)) return\n // Never auto-hide while the rename box is open: moving the pointer\n // onto an IME candidate window (an OS-level window outside the\n // webview) fires pointerleave, and unmounting the input mid-IME-\n // composition crashes some input methods / the renderer (#303).\n if (renaming) return\n clearHideTimer()\n hideTimerRef.current = window.setTimeout(() => setHovered(false), 300)\n }}\n >\n <div\n ref={spriteRef}\n className={styles.sprite}\n style={{\n width: spriteWidth,\n height: spriteHeight,\n ...(props.visual === undefined\n ? {\n backgroundImage: imageReady ? 'url(' + definition.atlasUrl + ')' : undefined,\n backgroundSize: (cell.width * columns * spriteScale) + 'px ' + (cell.height * (definition.atlasRows ?? rows.length) * spriteScale) + 'px',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: '0 0',\n }\n : {}),\n cursor: dragRef.current === null ? 'grab' : 'grabbing',\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onClick={() => {\n // A pointer sequence that moved (dragged) still fires a trailing\n // click; skip the pet when that happened.\n if (draggedRef.current) return\n props.onPet()\n }}\n role=\"button\"\n aria-label={definition.displayName}\n >\n {props.visual}\n </div>\n {feedback !== null && (\n <div key={feedback.at} ref={bubbleRef} className={clsx(styles.bubble, feedback.kind === 'feed' ? styles.bubbleFeed : styles.bubblePet)}>\n {feedback.text}\n </div>\n )}\n {feedback === null && (sessionBubbles.length > 0 || statusBubble !== undefined || whisper !== undefined) && (\n <div\n ref={bubbleRef}\n className={styles.bubbleStack}\n onPointerEnter={() => setStackPeek(true)}\n onPointerLeave={() => setStackPeek(false)}\n >\n {visibleSessions.map((session, index) => {\n // The whisper rides the display session's bubble — the stack's\n // primary entry (DOM-first, rendered bottom-most by the reversed\n // column so it stays glued to the sprite when extras open above).\n // The key swap restarts the entrance animation so the mood change\n // reads as the bubble re-speaking.\n const speaksWhisper = index === 0 && whisper !== undefined\n const bubble = (\n <button\n key={speaksWhisper ? 'whisper:' + whisper : session.sessionId}\n type=\"button\"\n className={clsx(\n styles.bubble,\n styles.bubbleStatus,\n styles.bubbleClickable,\n speaksWhisper && styles.bubbleWhisper,\n )}\n title={props.t('pet.openSessionHint')}\n onClick={() => { props.onOpenSession(session.sessionId) }}\n >\n {index === 0 && !speaksWhisper && decoration !== undefined && (\n <StatusOrnament decoration={decoration} phase={phase} />\n )}\n {speaksWhisper ? whisper : session.bubble}\n </button>\n )\n // The primary bubble carries the '+N' badge while other sessions\n // hide behind it; the badge toggles the pinned (touch) expansion.\n if (index !== 0 || sessionBubbles.length <= 1) return bubble\n return (\n <span key=\"primary\" className={styles.bubbleAnchor}>\n {bubble}\n <button\n type=\"button\"\n className={styles.bubbleMore}\n title={stackOpen\n ? props.t('pet.collapseSessions')\n : props.t('pet.moreSessions', { n: sessionBubbles.length - 1 })}\n aria-label={stackOpen\n ? props.t('pet.collapseSessions')\n : props.t('pet.moreSessions', { n: sessionBubbles.length - 1 })}\n aria-expanded={stackOpen}\n onClick={(e) => {\n e.stopPropagation()\n setStackPinned(open => !open)\n }}\n >\n {stackOpen ? '×' : '+' + String(sessionBubbles.length - 1)}\n </button>\n </span>\n )\n })}\n {sessionBubbles.length === 0 && (statusBubble !== undefined || whisper !== undefined) && (\n // The key swap (status copy <-> whisper) restarts the entrance\n // animation on every mood change.\n <div\n key={whisper === undefined ? 'status' : 'whisper:' + whisper}\n className={clsx(styles.bubble, styles.bubbleStatus, whisper !== undefined && styles.bubbleWhisper)}\n role=\"status\"\n aria-live=\"polite\"\n >\n {whisper === undefined && decoration !== undefined && (\n <StatusOrnament decoration={decoration} phase={phase} />\n )}\n {whisper ?? statusBubble}\n </div>\n )}\n </div>\n )}\n {hovered && dragRef.current === null && (\n <div\n ref={panelRef}\n className={clsx(styles.panel, panelAbove && styles.panelAbove)}\n data-placement={panelAbove ? 'above' : 'below'}\n style={panelAbove && panelLift > 0\n ? ({ marginBottom: panelLift } as CSSProperties)\n : undefined}\n onPointerEnter={() => {\n // Reaching the panel (or its bridge) must cancel any hide timer\n // the container's pointerleave may have armed while the pointer\n // crossed the sliver between the sprite and the panel.\n clearHideTimer()\n }}\n >\n {renaming ? (\n <div className={styles.renameRow}>\n <input\n className={styles.nameInput}\n value={nameDraft}\n maxLength={20}\n placeholder={props.t('pet.namePlaceholder')}\n autoFocus\n onChange={(e) => setNameDraft(e.target.value)}\n onCompositionStart={() => { composingRef.current = true }}\n onCompositionEnd={() => { composingRef.current = false }}\n onKeyDown={(e) => {\n // While an IME composition is active (e.g. selecting a\n // Chinese candidate), Enter/Escape keydowns belong to the\n // input method: ignore them so candidate selection can\n // neither submit the draft nor close the rename box. The\n // explicit ref and the 'Process' key cover IMEs that mark\n // composition keydowns with isComposing === false (#303).\n if (composingRef.current || e.nativeEvent.isComposing || e.key === 'Process') return\n if (e.key === 'Enter') {\n const trimmed = nameDraft.trim()\n if (trimmed !== '') {\n props.onRename(trimmed)\n setRenaming(false)\n }\n } else if (e.key === 'Escape') {\n setRenaming(false)\n }\n }}\n />\n <button\n type=\"button\"\n className={styles.action}\n onClick={() => {\n const trimmed = nameDraft.trim()\n if (trimmed !== '') {\n props.onRename(trimmed)\n setRenaming(false)\n }\n }}\n >\n {panelLabel('confirm', props.t('pet.confirm'))}\n </button>\n </div>\n ) : (\n <>\n <div className={styles.rankRow}>\n <span className={styles.nameCell}>{displayName}</span>\n <span className={styles.statRank}>{panelStat('rank', 'pet.rank', { rank: snapshot?.affinity.rank ?? '?' })}</span>\n </div>\n <div className={styles.rankRow}>\n <span className={styles.statTreats}>{panelStat('treats', 'pet.treats', { n: snapshot?.treats.stocked ?? 0 })}</span>\n <span className={styles.statPoints}>{panelStat('points', 'pet.points', { points: snapshot?.affinity.points ?? 0 })}</span>\n </div>\n <div className={styles.actions}>\n {panelShows('feed') && (\n <button type=\"button\" className={styles.action} onClick={props.onFeed}>\n {panelLabel('feed', props.t('pet.feed'))}\n </button>\n )}\n {panelShows('rename') && (\n <button\n type=\"button\"\n className={styles.action}\n onClick={() => {\n // Cancel any pending hide so the rename box cannot\n // unmount right as the user starts typing (#303).\n clearHideTimer()\n setNameDraft(displayName)\n setRenaming(true)\n }}\n >\n {panelLabel('rename', props.t('pet.rename'))}\n </button>\n )}\n {panelShows('hide') && (\n <button type=\"button\" className={styles.action} onClick={props.onHide}>\n {panelLabel('hide', props.t('pet.hide'))}\n </button>\n )}\n </div>\n </>\n )}\n </div>\n )}\n </div>\n )\n\n return createPortal(float, document.body)\n}\n","/**\n * Renderer registry — dispatches a manifest's renderer kind to its\n * implementation (pet-center M2 P4, issue #623). Unknown kinds never blank\n * the pet: a fallback card names the problem and reports the kinds this\n * build actually supports.\n * @module @linxin666/dsh-pet/client/renderers/registry\n */\n\nimport type { PetRenderer, PetRendererContext, PetRendererHandle } from '../../contracts/renderer.ts'\n\n/** Renderer dispatch table. */\nexport class RendererRegistry {\n private readonly renderers = new Map<string, PetRenderer>()\n\n /** Register one renderer implementation (id wins on re-register). */\n register(renderer: PetRenderer): void {\n this.renderers.set(renderer.id, renderer)\n }\n\n /** Whether a renderer kind is available in this build. */\n has(id: string): boolean {\n return this.renderers.has(id)\n }\n\n /** The registered renderer kinds (for diagnostics). */\n kinds(): string[] {\n return [...this.renderers.keys()].sort()\n }\n\n /** Remove every registration (tests; the client index registers once). */\n clear(): void {\n this.renderers.clear()\n }\n\n /**\n * Mount a renderer for one activation. An unknown kind renders a clear\n * diagnostic card into the container instead of failing silently.\n */\n mount(kind: string, ctx: PetRendererContext, config: unknown): PetRendererHandle {\n const renderer = this.renderers.get(kind)\n if (renderer === undefined) {\n const note = document.createElement('div')\n note.dataset.dshPetRendererFallback = kind\n note.textContent = 'Pet renderer \"' + kind + '\" is not available in this build (supported: ' + this.kinds().join(', ') + ').'\n ctx.container.appendChild(note)\n ctx.onCleanup(() => note.remove())\n return { dispose: () => note.remove() }\n }\n return renderer.mount(ctx, renderer.validateConfig(config))\n }\n}\n\n/**\n * The plugin-wide renderer registry. The client entry registers the\n * built-in renderers at apply time; the renderer switch and the live2d\n * bridge dispatch through this instance.\n */\nexport const defaultPetRendererRegistry = new RendererRegistry()\n","/**\n * Phase stream — bridges the polled host snapshots onto the renderer\n * contract's { get, subscribe } shape (pet-center M2 P4, issue #623). The\n * existing poll loop pushes each snapshot's ActivityPhase; subscribers are\n * dispatched on CHANGE only (phase transitions are sparse — done/failed hold\n * a timed window before falling back to idle — and renderers like Live2D pay\n * per transition, not per tick).\n * @module @linxin666/dsh-pet/client/phase-stream\n */\n\nimport type { ActivityPhase } from '../state.ts'\n\n/** The renderer-facing phase stream. */\nexport interface PhaseStream {\n /** The latest pushed phase. */\n get(): ActivityPhase\n /** Subscribe to phase changes; returns the unsubscribe. */\n subscribe(listener: (phase: ActivityPhase) => void): () => void\n /** Feed a fresh snapshot phase; no-op when unchanged. */\n push(phase: ActivityPhase): void\n}\n\n/** Create the stream (one per pet entry lifetime, owned by the plugin body). */\nexport function createPhaseStream(initial: ActivityPhase = 'idle'): PhaseStream {\n let current = initial\n const listeners = new Set<(phase: ActivityPhase) => void>()\n return {\n get: () => current,\n subscribe(listener) {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n push(phase) {\n if (phase === current) return\n current = phase\n for (const listener of [...listeners]) listener(phase)\n },\n }\n}\n","/**\n * Live2D visual mount (pet-center M3) — the React bridge between the pet\n * center chrome and the imperative live2d renderer. The bridge owns the\n * contract context (asset base, phase stream, interaction write-back,\n * activation cleanups), feeds the polled phase into the stream, forwards\n * sub-4px taps as hit-test coordinates, and renders the localized error\n * card when the renderer reports a fatal boot failure.\n * @module @linxin666/dsh-pet/client/renderers/live2d/Live2dVisualMount\n */\n\nimport { useEffect, useRef, useState, type ReactElement } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDefinition } from '../../../registry.ts'\nimport type { ActivityPhase } from '../../../state.ts'\nimport { createPhaseStream, type PhaseStream } from '../../phase-stream.ts'\nimport type { PetRendererContext } from '../../../contracts/renderer.ts'\nimport { defaultPetRendererRegistry } from '../registry.ts'\nimport type { Live2dErrorCode, Live2dRendererHandle } from '../live2d.ts'\nimport type { NS } from '../../locales.ts'\n\n/** Mount the live2d renderer as the sprite's visual (inside the chrome). */\nexport function Live2dVisualMount(props: {\n definition: PetDefinition\n phase: ActivityPhase\n onPet: () => void\n t: PropsLocale<typeof NS>['t']\n}): ReactElement {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const streamRef = useRef<PhaseStream | null>(null)\n const handleRef = useRef<Live2dRendererHandle | null>(null)\n const downRef = useRef<{ x: number; y: number } | null>(null)\n const [error, setError] = useState<Live2dErrorCode | null>(null)\n\n // One activation per pet definition: build the contract context and mount.\n useEffect(() => {\n setError(null)\n const container = containerRef.current\n const live2d = props.definition.live2d\n if (container === null || live2d === undefined) return undefined\n streamRef.current ??= createPhaseStream(props.phase)\n const cleanups: (() => void)[] = []\n const ctx: PetRendererContext = {\n petId: props.definition.id,\n assetBase: '/pet/' + encodeURIComponent(props.definition.id),\n container,\n phase: streamRef.current,\n interact: props.onPet,\n onCleanup: (fn) => { cleanups.push(fn) },\n }\n let handle: Live2dRendererHandle\n try {\n handle = defaultPetRendererRegistry.mount('live2d', ctx, live2d) as Live2dRendererHandle\n } catch {\n setError('load-failed')\n return () => { for (const fn of cleanups.splice(0)) fn() }\n }\n handleRef.current = handle\n handle.onError?.(setError)\n return () => {\n handleRef.current = null\n for (const fn of cleanups.splice(0)) fn()\n handle.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- one activation per pet identity\n }, [props.definition])\n\n // Feed the polled phase into the activation's stream (change-only).\n useEffect(() => {\n streamRef.current?.push(props.phase)\n }, [props.phase])\n\n return (\n <div\n ref={containerRef}\n data-dsh-pet-live2d={props.definition.id}\n style={{ width: '100%', height: '100%' }}\n onPointerDown={(e) => { downRef.current = { x: e.clientX, y: e.clientY } }}\n onPointerUp={(e) => {\n const down = downRef.current\n downRef.current = null\n if (down === null) return\n // A moved pointer is a drag (the chrome owns it), not a tap.\n if (Math.abs(e.clientX - down.x) > 4 || Math.abs(e.clientY - down.y) > 4) return\n const rect = e.currentTarget.getBoundingClientRect()\n handleRef.current?.tap(e.clientX - rect.left, e.clientY - rect.top)\n }}\n >\n {error !== null && (\n <span data-dsh-pet-live2d-error={error}>\n {error === 'core-missing'\n ? props.t('pet.live2d.core-missing')\n : error === 'vendor-missing'\n ? props.t('pet.live2d.vendor-missing')\n : props.t('pet.live2d.load-failed')}\n </span>\n )}\n </div>\n )\n}\n","/**\n * Renderer switch — the client dispatch seam of the pet center (issue #623,\n * milestone M2 P5 / M3). The pet's manifest picks the renderer: sprite2d\n * hands straight through to the sprite; live2d injects its visual INTO the\n * sprite chrome (the dock, bubbles and panel belong to the pet center, not\n * the renderer); a renderer this build cannot serve renders a clear\n * diagnostic card instead of blanking.\n * @module @linxin666/dsh-pet/client/renderers/PetRendererSwitch\n */\n\nimport { cloneElement, isValidElement, type ReactElement, type ReactNode } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDefinition } from '../../registry.ts'\nimport type { ActivityPhase } from '../../state.ts'\nimport type { PetSpriteProps } from '../PetSprite.tsx'\nimport { defaultPetRendererRegistry } from './registry.ts'\nimport { Live2dVisualMount } from './live2d/Live2dVisualMount.tsx'\nimport type { NS } from '../locales.ts'\n\n/** Dispatch one pet definition to its renderer; unknown kinds get a card. */\nexport function PetRendererSwitch(props: {\n definition: PetDefinition\n /** Current activity phase (fed to renderer visuals). */\n phase: ActivityPhase\n /** The chrome's pet interaction (affinity write-back owner). */\n onPet: () => void\n t: PropsLocale<typeof NS>['t']\n children?: ReactNode\n}): ReactElement {\n const renderer = props.definition.renderer ?? 'sprite2d'\n if (renderer === 'sprite2d') return <>{props.children}</>\n if (renderer === 'live2d' && defaultPetRendererRegistry.has('live2d') && isValidElement<PetSpriteProps>(props.children)) {\n const visual = (\n <Live2dVisualMount\n definition={props.definition}\n phase={props.phase}\n onPet={props.onPet}\n t={props.t}\n />\n )\n return cloneElement(props.children, { visual })\n }\n return (\n <span data-dsh-pet-renderer-fallback={renderer}>\n {props.t('pet.renderer.unavailable', { renderer })}\n </span>\n )\n}\n","/**\n * Global floating pet entry. The pet is host-global (its state, display and\n * interactions live on '/api/pet/*' endpoints with no session dimension), so\n * it must not ride a session-scoped slot — on the new-conversation screen no\n * session exists to scope a slot by, and the pet would vanish (issue #48).\n * The client half therefore mounts this entry straight onto 'document.body'\n * (see index.ts): while visible it renders the floating PetSprite (a\n * portal), while hidden it renders a fixed-position summon button. Which\n * sprite renders is decided by the host snapshot's pet id resolved against\n * the registry list — no per-pet component exists.\n * @module @linxin666/dsh-pet/client/PetDockEntry\n */\n\nimport { useEffect, useSyncExternalStore, type ReactElement } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetStoreInstance } from './pet-store.ts'\nimport { PetSprite } from './PetSprite.tsx'\nimport { PetRendererSwitch } from './renderers/PetRendererSwitch.tsx'\nimport { NS } from './locales.ts'\nimport styles from './pet.module.css'\n\n/** Injected actions handed to the dock entry component. */\nexport interface PetInjected {\n /** The app-wide pet store instance (snapshot + registry list + feedback). */\n store: PetStoreInstance\n /** Ensure the first snapshot (and registry list) is fetched (called on mount). */\n ensure: () => void\n /** Pet the sprite (click). */\n pet: () => void\n /** Feed the sprite. */\n feed: () => void\n /** Hide the sprite. */\n hide: () => void\n /** Summon the hidden sprite back. */\n summon: () => void\n /** Persist a drag position. */\n dragEnd: (right: number, bottom: number) => void\n /** Rename the selected pet (persisted by the host). */\n rename: (name: string) => void\n /** Navigate the GUI to the session a bubble reports on. */\n openSession: (sessionId: string) => void\n /** Clear the reaction bubble. */\n feedbackDone: () => void\n}\n\n/** Composed props of the global pet entry (locale + injected; no slot runtime share). */\nexport type PetDockEntryProps =\n PetInjected\n & PropsLocale<typeof NS>\n\nconst DEFAULT_DISPLAY: PetDisplayConfig = { visible: true, size: 160, right: 24, bottom: 20 }\n\n/**\n * Dock entry: while the pet is visible, mount the floating PetSprite (it\n * portals itself onto document.body); while hidden, render the summon\n * button so the pet can always come back. The store is the plugin-owned\n * single instance — the slot system provides none because the pet is\n * host-global, not session-scoped.\n */\nexport function PetDockEntry(props: PetDockEntryProps): ReactElement {\n const { store, ensure } = props\n const ui = useSyncExternalStore(store.subscribe, store.getSnapshot)\n const snapshot = ui.snapshot\n const feedback = ui.feedback\n const definition = ui.pets.find(entry => entry.id === snapshot?.pet.id) ?? null\n const visible = snapshot?.display.visible ?? true\n\n useEffect(() => {\n ensure()\n }, [ensure])\n\n if (visible) {\n return (\n <span data-pet-dock data-testid=\"pet-dock\">\n {snapshot === null || definition === null\n ? null\n : (\n <PetRendererSwitch\n definition={definition}\n phase={snapshot?.phase ?? 'idle'}\n onPet={props.pet}\n t={props.t}\n >\n <PetSprite\n snapshot={snapshot}\n definition={definition}\n display={snapshot.display}\n feedback={feedback}\n onPet={props.pet}\n onFeed={props.feed}\n onHide={props.hide}\n onDragEnd={props.dragEnd}\n onRename={props.rename}\n onOpenSession={props.openSession}\n onFeedbackDone={props.feedbackDone}\n t={props.t}\n />\n </PetRendererSwitch>\n )}\n </span>\n )\n }\n const display = snapshot?.display ?? DEFAULT_DISPLAY\n return (\n <button\n type=\"button\"\n className={styles.summon}\n style={{\n position: 'fixed',\n right: display.right,\n bottom: display.bottom,\n zIndex: 2147483000,\n }}\n onClick={props.summon}\n data-testid=\"pet-summon\"\n data-dsh-part=\"summon-button\"\n >\n {props.t('pet.summon', { name: snapshot?.name ?? '' })}\n </button>\n )\n}\n","/**\n * Renderer contract — the seam between the pet center and its renderers\n * (issue #623, milestone M2 P4). Renderers never see the DSH session, the\n * registry, or the network: they receive exactly three capabilities — an\n * asset base URL, the ActivityPhase stream, and the interaction write-back —\n * inside a center-owned container. Every mount is a fresh activation whose\n * cleanups must be idempotent.\n *\n * This contract only serves real consumers: sprite2d (existing) and live2d\n * (M3). Speculative capabilities join only when a renderer actually needs\n * them.\n * @module @linxin666/dsh-pet/contracts/renderer\n */\n\nimport type { ActivityPhase } from '../state.ts'\n\n/** Contract version renderers declare against (independent of the manifest). */\nexport const PET_RENDERER_API_VERSION = 'x-org.linxin666.pet-center/v1alpha1'\n\n/** What the pet center hands a renderer on mount. */\nexport interface PetRendererContext {\n /** The selected pet's id. */\n readonly petId: string\n /** Same-origin URL prefix of this pet's assets ('/pet/<id>'). */\n readonly assetBase: string\n /** Center-owned mount root; renderers must not attach to document.body. */\n readonly container: HTMLElement\n /** The ActivityPhase stream (pet-center owned; renderers subscribe). */\n readonly phase: {\n get(): ActivityPhase\n subscribe(listener: (phase: ActivityPhase) => void): () => void\n }\n /** The single interaction write-back into the affinity economy. */\n readonly interact: (kind: 'tap') => void\n /** Register an activation-scoped cleanup; run on dispose, idempotently. */\n onCleanup(fn: () => void): void\n}\n\n/** A mounted renderer activation. */\nexport interface PetRendererHandle {\n /** Tear the activation down; may be called 0/1/N times. */\n dispose(): void\n}\n\n/**\n * One renderer implementation. validateConfig is fail-closed over the\n * renderer-specific manifest block (schema v2 'sprite2d'/'live2d' blocks).\n */\nexport interface PetRenderer<Config = unknown> {\n readonly id: string\n readonly apiVersion: string\n validateConfig(config: unknown): Config\n mount(ctx: PetRendererContext, config: Config): PetRendererHandle\n}\n","/**\n * Live2D runtime loading (pet-center M3) — the two scripts a live2d mount\n * needs, fetched lazily through the plugin's own runtime route: the\n * user-supplied Cubism Core (proprietary; the plugin never bundles or\n * downloads it — issue #623 M1 §0) and the plugin-shipped MIT vendor bundle\n * (pixi.js + untitled-pixi-live2d-engine). Each loads at most once per page;\n * concurrent mounts share the in-flight promise, and a failure is cached as\n * 'absent' so a broken install stops retrying the network every mount.\n *\n * The vendor surface below is the structural slice the renderer consumes;\n * the real objects come from 'window.__dshPetLive2d' (lib/live2d-vendor.js),\n * so this module never imports pixi — the client bundle stays lean.\n * @module @linxin666/dsh-pet/client/renderers/live2d/runtime\n */\n\n/** Runtime file URLs the host serves ('/api/pet/runtime/<name>', M3-2). */\nconst CORE_URL = '/api/pet/runtime/live2dcubismcore.min.js'\nconst VENDOR_URL = '/api/pet/runtime/live2d-vendor.js'\n\n/** The pixi Application slice the renderer uses. */\nexport interface Live2dVendorApp {\n canvas: HTMLCanvasElement\n stage: { addChild(child: unknown): unknown }\n renderer: {\n readonly width: number\n readonly height: number\n resize(width: number, height: number): void\n }\n init(options: Record<string, unknown>): Promise<void>\n destroy(rendererOptions?: boolean | { removeView?: boolean; releaseGlobalResources?: boolean }, options?: Record<string, unknown>): void\n}\n\n/** The Live2DModel slice the renderer uses. */\nexport interface Live2dVendorModel {\n automator: { autoUpdate: boolean }\n anchor: { set(x: number, y?: number): void }\n position: { set(x: number, y: number): void }\n scale: { set(x: number, y?: number): void }\n readonly width: number\n readonly height: number\n internalModel: {\n settings: {\n motions?: Record<string, unknown[]>\n hitAreas?: readonly { Name?: string }[]\n }\n }\n motion(group: string, index?: number): Promise<unknown>\n expression(name?: string): unknown\n hitTest(x: number, y: number): string[]\n on(event: string, fn: () => void): unknown\n destroy(options?: { children?: boolean; texture?: boolean; baseTexture?: boolean }): void\n}\n\n/** The vendor bundle global (window.__dshPetLive2d). */\nexport interface Live2dVendor {\n Application: new () => Live2dVendorApp\n extensions: { add(...items: unknown[]): void }\n Live2DPlugin: unknown\n configureCubismSDK(options: Record<string, unknown>): void\n Live2DModel: { from(source: string, options?: Record<string, unknown>): Promise<Live2dVendorModel> }\n}\n\ndeclare global {\n interface Window {\n Live2DCubismCore?: unknown\n __dshPetLive2d?: Live2dVendor\n }\n}\n\n/** Injects one classic script tag; resolves on load, rejects on error. */\ntype ScriptInjector = (src: string) => Promise<void>\n\nconst defaultInjector: ScriptInjector = (src) => new Promise<void>((resolve, reject) => {\n const tag = document.createElement('script')\n tag.src = src\n tag.onload = () => resolve()\n tag.onerror = () => reject(new Error('script failed to load: ' + src))\n document.head.appendChild(tag)\n})\n\n/** Test seam: swap the network for a stub injector. */\nexport interface Live2dRuntimeProbe {\n inject?: ScriptInjector\n}\n\nlet corePromise: Promise<boolean> | undefined\nlet vendorPromise: Promise<Live2dVendor | undefined> | undefined\n\n/**\n * Ensure the Cubism Core global exists, injecting the runtime-route script\n * once when absent. Resolves false when the user has not installed the core\n * (a normal state — the renderer turns it into install guidance).\n */\nexport function ensureCubismCore(probe: Live2dRuntimeProbe = {}): Promise<boolean> {\n if (typeof window !== 'undefined' && window.Live2DCubismCore !== undefined) return Promise.resolve(true)\n if (probe.inject !== undefined) {\n return probe.inject(CORE_URL)\n .then(() => typeof window !== 'undefined' && window.Live2DCubismCore !== undefined)\n .catch(() => false)\n }\n corePromise ??= defaultInjector(CORE_URL)\n .then(() => typeof window !== 'undefined' && window.Live2DCubismCore !== undefined)\n .catch(() => false)\n return corePromise\n}\n\n/** Ensure the plugin vendor bundle global exists (same caching discipline). */\nexport function ensureLive2dVendor(probe: Live2dRuntimeProbe = {}): Promise<Live2dVendor | undefined> {\n if (typeof window !== 'undefined' && window.__dshPetLive2d !== undefined) return Promise.resolve(window.__dshPetLive2d)\n if (probe.inject !== undefined) {\n return probe.inject(VENDOR_URL)\n .then(() => typeof window !== 'undefined' ? window.__dshPetLive2d : undefined)\n .catch(() => undefined)\n }\n vendorPromise ??= defaultInjector(VENDOR_URL)\n .then(() => typeof window !== 'undefined' ? window.__dshPetLive2d : undefined)\n .catch(() => undefined)\n return vendorPromise\n}\n\n/** Reset the cached script promises (tests). */\nexport function resetLive2dRuntime(): void {\n corePromise = undefined\n vendorPromise = undefined\n}\n","/**\n * Live2D renderer (pet-center M3, issue #623) — mounts a Cubism model into\n * the center-owned container through the lazy vendor stack. The mount call\n * itself is synchronous per the renderer contract: the boot (core script →\n * vendor script → pixi → model) continues asynchronously and reports fatal\n * failures through the handle's error sink, so the React bridge can render\n * localized guidance. Disposing mid-boot is race-safe.\n *\n * Interaction model: the center chrome owns the affinity economy (its click\n * handler fires the pet interaction exactly like sprite2d); this renderer's\n * 'tap' affordance only drives the model's hit-area motion feedback. The\n * contract's interact write-back stays available for future standalone\n * mounts and is intentionally not invoked here.\n *\n * Motion mapping: manifests map ActivityPhases to motion GROUP names; every\n * unmapped phase (and any mapped-but-absent group) falls back to the idle\n * group — official sample models only ship Idle/TapBody, so the fallback is\n * mandatory. Groups with multiple motions pick a random entry, and a tap\n * that hits a declared hit area plays the conventional 'TapBody' group,\n * returning to the phase's group when the tap motion finishes.\n * @module @linxin666/dsh-pet/client/renderers/live2d\n */\n\nimport type { ActivityPhase } from '../../state.ts'\nimport {\n PET_RENDERER_API_VERSION,\n type PetRenderer,\n type PetRendererContext,\n type PetRendererHandle,\n} from '../../contracts/renderer.ts'\nimport {\n ensureCubismCore,\n ensureLive2dVendor,\n type Live2dVendor,\n type Live2dVendorApp,\n type Live2dVendorModel,\n} from './live2d/runtime.ts'\n\n/** Renderer config: the client-visible live2d block (fail-closed validated). */\nexport interface PetLive2dConfig {\n modelUrl: string\n scale?: number\n translate?: { x?: number; y?: number }\n motions: Partial<Record<ActivityPhase, string>> & { idle: string }\n expressions?: Partial<Record<ActivityPhase, string>>\n hitAreas?: string[]\n}\n\n/** Fatal mount failure codes the bridge localizes. */\nexport type Live2dErrorCode = 'core-missing' | 'vendor-missing' | 'load-failed'\n\n/** The live2d activation handle: contract dispose plus tap + error sink. */\nexport interface Live2dRendererHandle extends PetRendererHandle {\n /** Forward a chrome tap in container coordinates; plays the hit motion. */\n tap(x: number, y: number): void\n /** Subscribe to fatal mount errors (at most one fires per activation). */\n onError(listener: (code: Live2dErrorCode) => void): void\n}\n\n/** The de-facto tap-motion group of Cubism sample models. */\nconst TAP_GROUP = 'TapBody'\n\n/**\n * Keep one screen-appropriate atlas LOD instead of asking Pixi for the\n * engine's default full mip chain. A user model can legitimately carry an\n * 8192px texture while the pet itself is only a few hundred pixels tall;\n * `single-auto` preserves the source for larger renders and generates one\n * downsampled atlas only when the effective on-screen scale warrants it.\n */\nconst TEXTURE_OPTIONS = { lod: 'single-auto' } as const\n/** Recursively release the activation without invalidating shared texture caches. */\nconst DESTROY_OPTIONS = { children: true } as const\n/** Remove only this activation's canvas; `true` would release Pixi globals. */\nconst RENDERER_DESTROY_OPTIONS = { removeView: true } as const\n\ninterface Live2dModelSize {\n width: number\n height: number\n}\n\n/** Ignore hidden/zero boxes and keep Pixi dimensions stable and integral. */\nfunction normalizeRendererSize(width: number, height: number): Live2dModelSize | undefined {\n if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return undefined\n return {\n width: Math.max(1, Math.round(width)),\n height: Math.max(1, Math.round(height)),\n }\n}\n\n/** Fit the model from its unscaled dimensions into the current Pixi screen. */\nfunction layoutModel(\n app: Live2dVendorApp,\n model: Live2dVendorModel,\n sourceSize: Live2dModelSize,\n config: PetLive2dConfig,\n): void {\n const fit = Math.min(\n app.renderer.width / sourceSize.width,\n app.renderer.height / sourceSize.height,\n ) * 0.92\n model.scale.set(fit * (config.scale ?? 1))\n model.anchor.set(0.5)\n model.position.set(\n app.renderer.width / 2 + (config.translate?.x ?? 0),\n app.renderer.height / 2 + (config.translate?.y ?? 0),\n )\n}\n\nlet vendorConfigured = false\n\n/** Configure pixi extensions + the Cubism SDK once per page. */\nfunction configureOnce(vendor: Live2dVendor): void {\n if (vendorConfigured) return\n vendorConfigured = true\n vendor.extensions.add(vendor.Live2DPlugin)\n vendor.configureCubismSDK({ memorySizeMB: 32 })\n}\n\n/** Reset module state (tests). */\nexport function resetLive2dRenderer(): void {\n vendorConfigured = false\n}\n\n/** Fail-closed config validation (contract: unknown manifest block in). */\nfunction validateLive2dConfig(config: unknown): PetLive2dConfig {\n if (typeof config !== 'object' || config === null) throw new Error('live2d config is not an object')\n const source = config as Record<string, unknown>\n if (typeof source.modelUrl !== 'string' || source.modelUrl === '') throw new Error('live2d config modelUrl is required')\n const motions = source.motions\n if (typeof motions !== 'object' || motions === null || typeof (motions as Record<string, unknown>).idle !== 'string') {\n throw new Error('live2d config motions.idle is required')\n }\n return config as PetLive2dConfig\n}\n\n/** The live2d renderer implementation. */\nexport const live2dRenderer: PetRenderer<PetLive2dConfig> = {\n id: 'live2d',\n apiVersion: PET_RENDERER_API_VERSION,\n validateConfig: validateLive2dConfig,\n mount(ctx: PetRendererContext, config: PetLive2dConfig): Live2dRendererHandle {\n let disposed = false\n let app: Live2dVendorApp | undefined\n let model: Live2dVendorModel | undefined\n let modelAttached = false\n let modelSourceSize: Live2dModelSize | undefined\n let resizeObserver: ResizeObserver | undefined\n let resizeTracking = false\n let errorListener: ((code: Live2dErrorCode) => void) | undefined\n let unsubscribe: (() => void) | undefined\n /** The motion group the current phase maps to (resume target after taps). */\n let phaseGroup: string = config.motions.idle\n let tapPlaying = false\n\n const stopResizeTracking = (): void => {\n resizeTracking = false\n resizeObserver?.disconnect()\n resizeObserver = undefined\n }\n\n const resizeRenderer = (pixiApp: Live2dVendorApp, width: number, height: number): void => {\n const next = normalizeRendererSize(width, height)\n if (disposed || !resizeTracking || next === undefined) return\n if (pixiApp.renderer.width === next.width && pixiApp.renderer.height === next.height) return\n pixiApp.renderer.resize(next.width, next.height)\n if (model !== undefined && modelSourceSize !== undefined) {\n layoutModel(pixiApp, model, modelSourceSize, config)\n }\n }\n\n const trackContainerSize = (pixiApp: Live2dVendorApp): void => {\n if (typeof ResizeObserver === 'undefined') return\n resizeTracking = true\n resizeObserver = new ResizeObserver((entries) => {\n const entry = entries.find(candidate => candidate.target === ctx.container)\n if (entry === undefined) return\n resizeRenderer(pixiApp, entry.contentRect.width, entry.contentRect.height)\n })\n resizeObserver.observe(ctx.container)\n // Catch a synchronous layout change between init() and observe().\n resizeRenderer(pixiApp, ctx.container.clientWidth, ctx.container.clientHeight)\n }\n\n /** Release every resource currently owned by this activation exactly once. */\n const destroyResources = (): void => {\n stopResizeTracking()\n unsubscribe?.()\n unsubscribe = undefined\n const currentApp = app\n const currentModel = model\n const modelOwnedByApp = currentApp !== undefined && modelAttached\n app = undefined\n model = undefined\n modelSourceSize = undefined\n modelAttached = false\n try {\n if (currentModel !== undefined && !modelOwnedByApp) currentModel.destroy(DESTROY_OPTIONS)\n } finally {\n currentApp?.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS)\n }\n }\n\n const playGroup = (group: string): void => {\n if (model === undefined) return\n const groups = model.internalModel.settings.motions ?? {}\n const count = Array.isArray(groups[group]) ? groups[group]!.length : 0\n if (count === 0) {\n // A mapped-but-absent group falls back to idle (never blank motion).\n if (group !== config.motions.idle) playGroup(config.motions.idle)\n return\n }\n const index = count > 1 ? Math.floor(Math.random() * count) : 0\n void model.motion(group, index)\n }\n\n const applyPhase = (phase: ActivityPhase): void => {\n phaseGroup = config.motions[phase] ?? config.motions.idle\n playGroup(phaseGroup)\n const expression = config.expressions?.[phase]\n if (expression !== undefined && model !== undefined) void model.expression(expression)\n }\n\n const boot = async (): Promise<void> => {\n if (!await ensureCubismCore()) {\n if (!disposed) errorListener?.('core-missing')\n return\n }\n const vendor = await ensureLive2dVendor()\n if (vendor === undefined) {\n if (!disposed) errorListener?.('vendor-missing')\n return\n }\n configureOnce(vendor)\n const pixiApp = new vendor.Application()\n const initialSize = normalizeRendererSize(ctx.container.clientWidth, ctx.container.clientHeight) ?? {\n width: 160,\n height: 174,\n }\n try {\n await pixiApp.init({\n width: initialSize.width,\n height: initialSize.height,\n backgroundAlpha: 0,\n antialias: true,\n autoDensity: true,\n preference: 'webgl',\n })\n } catch (error) {\n // init() can fail after allocating a partial renderer; cleanup is\n // best-effort because Pixi may not consider that partial app ready.\n try { pixiApp.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS) } catch {}\n throw error\n }\n if (disposed) {\n pixiApp.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS)\n return\n }\n app = pixiApp\n pixiApp.canvas.style.display = 'block'\n pixiApp.canvas.style.width = '100%'\n pixiApp.canvas.style.height = '100%'\n ctx.container.appendChild(pixiApp.canvas)\n // Keep a model that rejects during setup off Ticker.shared; from()\n // does not expose that partial instance to callers for disposal.\n trackContainerSize(pixiApp)\n const loaded = await vendor.Live2DModel.from(config.modelUrl, {\n autoUpdate: false,\n autoHitTest: false,\n autoFocus: false,\n textureOptions: TEXTURE_OPTIONS,\n })\n model = loaded\n if (disposed) {\n destroyResources()\n return\n }\n modelSourceSize = {\n width: Math.max(1, loaded.width),\n height: Math.max(1, loaded.height),\n }\n // Auto-fit the model into the container; the manifest scale multiplies\n // the fit and translate offsets from the center anchor.\n layoutModel(pixiApp, loaded, modelSourceSize, config)\n pixiApp.stage.addChild(loaded)\n modelAttached = true\n loaded.automator.autoUpdate = true\n // Resume the phase group once a tap motion finishes playing.\n loaded.on('motionFinish', () => {\n if (tapPlaying) {\n tapPlaying = false\n playGroup(phaseGroup)\n }\n })\n applyPhase(ctx.phase.get())\n unsubscribe = ctx.phase.subscribe(applyPhase)\n }\n\n void boot().catch(() => {\n try {\n destroyResources()\n } finally {\n if (!disposed) errorListener?.('load-failed')\n }\n })\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n destroyResources()\n },\n tap(x: number, y: number) {\n const current = model\n if (disposed || current === undefined) return\n const hits = current.hitTest(x, y)\n const allowed = config.hitAreas\n const hit = allowed === undefined ? hits.length > 0 : hits.some(name => allowed.includes(name))\n if (!hit) return\n const groups = current.internalModel.settings.motions ?? {}\n const group = groups[TAP_GROUP]\n if (!Array.isArray(group) || group.length === 0) return\n tapPlaying = true\n const index = group.length > 1 ? Math.floor(Math.random() * group.length) : 0\n void current.motion(TAP_GROUP, index)\n },\n onError(listener: (code: Live2dErrorCode) => void) {\n errorListener = listener\n },\n }\n },\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/settings/PluginSettingsCard.tsx. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Family-shared chrome for plugin settings cards: a disclosure header naming\n * the plugin and what its settings govern, the controls inside, and the save\n * that writes them. Renders nothing while the namespace is unavailable — a\n * deployment that does not compose the owning plugin should show no trace of\n * it. Inlined into each consumer's client bundle; mirrors the official\n * ui-plugin-config PluginCard in a self-contained slice.\n */\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'\nimport type { CardShell } from './settings-form.ts'\nimport css from './settings-card.module.css'\n\n/** Copy keys the card chrome itself reads; every consumer locale carries this shared vocabulary. */\nexport const CARD_COPY_KEYS = [\n 'settings.collapse',\n 'settings.expand',\n 'settings.notExposed',\n 'settings.unsaved',\n 'settings.readOnly',\n 'settings.saveFailed',\n 'settings.discard',\n 'settings.save',\n 'settings.saving',\n] as const\n\n/** Copy key the card chrome itself reads. */\nexport type CardCopyKey = (typeof CARD_COPY_KEYS)[number]\n\n/** Key domain for the plugin's own copy (inferred per consumer). */\nexport type SettingsCardKey<TKey extends string = string> = TKey | CardCopyKey\n\n/** Card chrome shared by every plugin settings card. */\nexport interface PluginSettingsCardProps<TKey extends string = string> {\n /** Locale reader for this card's copy. */\n t: (key: SettingsCardKey<TKey>, params?: Record<string, string | number>) => string\n /** Locale key of the plugin's name. */\n titleKey: TKey\n /** Locale key of the line describing what this plugin's settings govern. */\n descriptionKey: TKey\n /** The card's form state: availability, writability, and what a save would do. */\n state: CardShell\n /** Write every staged edit. */\n onSave: () => void\n /** Drop every staged edit. */\n onDiscard: () => void\n /**\n * Render the controls expanded on arrival (still collapsible). Defaults to\n * true: promoted first-level sections show their settings immediately.\n */\n defaultOpen?: boolean\n /**\n * Render without the collapse affordance: a static header and an always\n * visible body. Used by first-level settings sections whose nav entry\n * already provides the selection.\n */\n alwaysOpen?: boolean\n /**\n * Hide the save/discard footer: cards whose body applies its own changes\n * immediately (an embedded external settings section) have no staged\n * edits, so the footer would sit there permanently disabled.\n */\n hideFooter?: boolean\n /** The plugin's controls. */\n children: ReactNode\n}\n\n/**\n * Render one plugin settings card.\n * @param props - the plugin's copy keys, its form state, and its controls.\n * @returns the card, or nothing while the namespace is still loading.\n */\nexport function PluginSettingsCard<TKey extends string = string>(props: PluginSettingsCardProps<TKey>) {\n const [open, setOpen] = useState(props.defaultOpen ?? true)\n const { state, alwaysOpen } = props\n if (!state.available) return null\n const title = props.t(props.titleKey)\n const description = props.t(props.descriptionKey)\n const blocked = !state.dirty || state.invalid || state.saving\n const expanded = alwaysOpen === true || open\n const cardClass = expanded ? `${css.cardOpen} ${css.card}` : css.card\n // With alwaysOpen the nav entry already provides the selection, so the\n // header is a static title row instead of a disclosure button.\n const header = alwaysOpen === true\n ? (\n <div className={css.headerStatic}>\n <span className={css.headText}>\n <span className={css.name} title={title}>{title}</span>\n <span className={css.description} title={description}>{description}</span>\n </span>\n {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}\n </div>\n )\n : (\n <button\n type=\"button\"\n className={css.header}\n aria-expanded={open}\n aria-label={`${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`}\n onClick={() => { setOpen(!open) }}\n >\n <span className={css.headText}>\n <span className={css.name} title={title}>{title}</span>\n <span className={css.description} title={description}>{description}</span>\n </span>\n {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={open ? `${css.chevron} ${css.chevronOpen}` : css.chevron}\n >\n <path\n d=\"M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n )\n // The namespace exists but the Host does not serve it to this client (the\n // official settings allowlist omits third-party namespaces): show a card\n // that explains the gap instead of vanishing, so a missing card never\n // reads as a missing plugin.\n if (!state.exposed) {\n return (\n <li className={cardClass}>\n {header}\n {expanded\n ? (\n <div className={css.body}>\n <p className={css.notExposed} role=\"status\">{props.t('settings.notExposed')}</p>\n </div>\n )\n : null}\n </li>\n )\n }\n return (\n <li className={cardClass}>\n {header}\n {expanded\n ? (\n <div className={css.body}>\n {!state.writable ? <p className={css.readOnly} role=\"status\">{props.t('settings.readOnly')}</p> : null}\n {props.children}\n {props.hideFooter === true\n ? null\n : (\n <div className={css.footer}>\n {state.failed\n ? (\n <p className={css.failed} role=\"status\">\n {props.t('settings.saveFailed')}{state.failedReason ? ' - ' + state.failedReason : ''}\n </p>\n )\n : null}\n <button\n type=\"button\"\n className={css.discard}\n disabled={!state.dirty || state.saving}\n onClick={props.onDiscard}\n >\n {props.t('settings.discard')}\n </button>\n <button\n type=\"button\"\n className={css.save}\n disabled={blocked}\n onClick={props.onSave}\n >\n {props.t(!state.saving ? 'settings.save' : 'settings.saving')}\n </button>\n </div>\n )}\n </div>\n )\n : null}\n </li>\n )\n}\n\n/** Props every field control needs regardless of its value type. */\nexport interface FieldProps {\n /** Stable id associating the label with its control. */\n id: string\n /** Visible label. */\n label: string\n /** One-line explanation rendered under the control. */\n hint: string\n /** Draft text this control renders. */\n text: string\n /** True when saving would leave a user-layer entry for this field. */\n overridden: boolean\n /** True when the draft is not a value this field accepts. */\n invalid: boolean\n /** Copy for the overridden badge. */\n overriddenLabel: string\n /** Copy for the reset control. */\n resetLabel: string\n /** Copy shown in place of the hint while the draft is invalid. */\n invalidLabel: string\n /** Disables every control (read-only document, or an unavailable namespace). */\n disabled: boolean\n /** Stage draft text. */\n onEdit: (text: string) => void\n /** Stage a clear so the field re-inherits the composition layer. */\n onReset: () => void\n}\n\n/** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */\nexport function ValueField(props: FieldProps & {\n /** Hints a numeric keypad without narrowing what the control accepts. */\n numeric?: boolean\n /** Placeholder shown while the draft is empty. */\n placeholder?: string\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <input\n id={props.id}\n className={props.invalid ? css.inputInvalid : css.input}\n type=\"text\"\n {...props.numeric === true ? { inputMode: 'numeric' as const } : {}}\n {...props.invalid ? { 'aria-invalid': true } : {}}\n value={props.text}\n placeholder={props.placeholder ?? ''}\n disabled={props.disabled}\n onChange={(event) => { props.onEdit(event.target.value) }}\n />\n <p className={props.invalid ? css.invalid : css.hint}>\n {props.invalid ? props.invalidLabel : props.hint}\n </p>\n </div>\n )\n}\n\nconst NON_SKIN_BODY_MARKERS = new Set(['dshSkinCenter', 'dshSidebarCollapsed'])\n// 检测使用使用皮肤,用了皮肤退回原生select样式,防止样式冲突。默认外观下使用优化后的select样式。\nfunction isSkinActive(): boolean {\n const datasetList = Object.keys(document.body.dataset)\n const isActive = datasetList.some(key => key.startsWith('dsh') && !NON_SKIN_BODY_MARKERS.has(key))\n return isActive\n}\n\ninterface SelectOption {\n value: string\n label: string\n}\n\nconst SELECT_CLOSE_MS = 100\n\n/**\n * The shared dual-mode select control. While an appearance skin is active it\n * renders the legacy native `<select>` untouched, so element-level skin\n * selectors keep working; under the default appearance it renders a\n * self-drawn `role=\"listbox\"` popup whose open/close is transition-animated.\n * Staged cards reach it through BooleanField/ChoiceField; immediate-apply\n * editors (the side-card prefs) bind it directly through onEdit.\n * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。\n */\nexport function SelectField(props: {\n id: string\n options: ReadonlyArray<SelectOption>\n value: string\n disabled: boolean\n invalid: boolean\n onEdit: (text: string) => void\n}) {\n const { id, options, value } = props\n const [open, setOpen] = useState(false)\n const [closing, setClosing] = useState(false)\n const [phase, setPhase] = useState<'initial' | 'open'>('initial')\n const [activeIndex, setActiveIndex] = useState(0)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const wrapRef = useRef<HTMLDivElement | null>(null)\n const popupRef = useRef<HTMLDivElement | null>(null)\n\n const currentIndex = () => {\n const index = options.findIndex(option => option.value === value)\n return index >= 0 ? index : 0\n }\n\n const close = useCallback(() => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n setClosing(true)\n closeTimer.current = setTimeout(() => {\n setClosing(false)\n setOpen(false)\n }, SELECT_CLOSE_MS)\n }, [])\n\n const openPopup = () => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n setActiveIndex(currentIndex())\n setPhase('initial')\n setClosing(false)\n setOpen(true)\n }\n\n const commit = (index: number) => {\n const option = options[index]\n if (option) props.onEdit(option.value)\n close()\n }\n\n const onTriggerClick = () => {\n if (props.disabled) return\n if (open && !closing) close()\n else openPopup()\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (props.disabled) return\n const count = options.length\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n case 'Enter':\n case ' ':\n event.preventDefault()\n if (!open) {\n openPopup()\n } else if (!closing) {\n if (event.key === 'ArrowDown') setActiveIndex(index => (index + 1) % count)\n else if (event.key === 'ArrowUp') setActiveIndex(index => (index - 1 + count) % count)\n else commit(activeIndex)\n }\n break\n case 'Escape':\n if (open) {\n event.preventDefault()\n event.stopPropagation()\n close()\n }\n break\n case 'Tab':\n if (open) close()\n break\n }\n }\n\n useEffect(() => () => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n }, [])\n useLayoutEffect(() => {\n if (open && !closing && phase === 'initial') {\n void popupRef.current?.offsetHeight\n setPhase('open')\n }\n }, [open, closing, phase])\n\n useEffect(() => {\n if (!open) return\n const onPointerDown = (event: PointerEvent) => {\n const target = event.target\n if (target instanceof Node && !wrapRef.current?.contains(target)) close()\n }\n document.addEventListener('pointerdown', onPointerDown)\n return () => document.removeEventListener('pointerdown', onPointerDown)\n }, [open, close])\n\n useEffect(() => {\n if (props.disabled && open) close()\n }, [props.disabled, open, close])\n\n // 使用了皮肤则退回原生select样式防止样式冲突。\n if (isSkinActive()) {\n return (\n <select\n id={id}\n className={css.select}\n value={value}\n disabled={props.disabled}\n onChange={(event) => { props.onEdit(event.target.value) }}\n >\n {options.map(option => (\n <option key={option.value} value={option.value}>{option.label}</option>\n ))}\n </select>\n )\n }\n\n const label = options.find(option => option.value === value)?.label ?? ''\n const popupClass = closing\n ? `${css.selectPopup} ${css.selectPopupClose}`\n : phase === 'open'\n ? `${css.selectPopup} ${css.selectPopupOpen}`\n : css.selectPopup\n return (\n <div className={css.selectWrap} ref={wrapRef}>\n <button\n type=\"button\"\n id={id}\n className={`${css.select} ${css.selectButton}`}\n disabled={props.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-activedescendant={open ? `${id}-o${activeIndex}` : undefined}\n aria-invalid={props.invalid || undefined}\n onClick={onTriggerClick}\n onKeyDown={onKeyDown}\n >\n <span className={css.selectLabel}>{label}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={open ? `${css.selectChevron} ${css.selectChevronOpen}` : css.selectChevron}\n aria-hidden=\"true\"\n >\n <path\n d=\"M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n {open\n ? (\n <div className={popupClass} role=\"listbox\" ref={popupRef}>\n {options.map((option, index) => (\n <div\n key={option.value}\n id={`${id}-o${index}`}\n role=\"option\"\n aria-selected={option.value === value}\n className={`${css.selectOption}${option.value === value ? ` ${css.selectOptionSelected}` : ''}${index === activeIndex && !closing ? ` ${css.selectOptionActive}` : ''}`}\n onClick={() => { commit(index) }}\n >\n {option.label}\n </div>\n ))}\n </div>\n )\n : null}\n </div>\n )\n}\n\n/** A staged boolean field: 继承 / 开 / 关. */\nexport function BooleanField(props: FieldProps & {\n /** Copy for the inherit option. */\n inheritLabel: string\n /** Copy for the on option. */\n onLabel: string\n /** Copy for the off option. */\n offLabel: string\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <SelectField\n id={props.id}\n options={[\n { value: '', label: props.inheritLabel },\n { value: 'true', label: props.onLabel },\n { value: 'false', label: props.offLabel },\n ]}\n value={props.text}\n disabled={props.disabled}\n invalid={props.invalid}\n onEdit={props.onEdit}\n />\n <p className={css.hint}>{props.hint}</p>\n </div>\n )\n}\n\n/** A staged enumerated field rendered as a select. */\nexport function ChoiceField(props: FieldProps & {\n /** Copy for the inherit option (draft text is the empty string). */\n inheritLabel: string\n /** Choices rendered in order; `value` is the draft/stored text. */\n choices: ReadonlyArray<{ value: string; label: string }>\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <SelectField\n id={props.id}\n options={[{ value: '', label: props.inheritLabel }, ...props.choices]}\n value={props.text}\n disabled={props.disabled}\n invalid={props.invalid}\n onEdit={props.onEdit}\n />\n <p className={props.invalid ? css.invalid : css.hint}>\n {props.invalid ? props.invalidLabel : props.hint}\n </p>\n </div>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/settings/settings-form.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Staged form model behind the plugin settings card. A card stages what the\n * user types and writes it only when they save — the settings write is a\n * durable, revision-fenced document mutation, so staging keeps what is on\n * screen exactly what a save would store. Family-shared slice inlined into\n * each plugin's client bundle; mirrors the official ui-plugin-config\n * card-store pattern.\n */\n\nimport type { SettingsScope, SettingsScopeSnapshot, SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\nimport { createSnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\n\n/** The write one field's staged text performs when the card is saved. */\nexport type FieldWrite =\n | { kind: 'set'; value: unknown }\n | { kind: 'clear' }\n\n/** How one field converts between its stored value and its draft text. */\nexport interface FieldSpec {\n /** Field name inside the namespace section. */\n field: string\n /**\n * Whether the Host treats this field as a secret and redacts its value from\n * the read-back (role('secret') in the section schema). Redacted secrets are\n * never compared against the draft on save; the field lands when the scope\n * reports the write succeeded (its secret-set marker under the bridge), so\n * a successful secret save is not misreported as failed.\n */\n secret?: boolean\n /** Render a stored value as draft text; the empty string when the section carries none. */\n format: (value: unknown) => string\n /**\n * The write this draft text stages, or undefined when the text is not a\n * value this field accepts — which blocks the save rather than discarding it.\n */\n parse: (text: string) => FieldWrite | undefined\n}\n\n/** One field as the card renders it. */\nexport interface FieldState {\n /** Draft text the control renders. */\n text: string\n /** Whether saving would leave a user-layer entry for this field. */\n overridden: boolean\n /** Whether the draft is not a value this field accepts, which blocks saving. */\n invalid: boolean\n}\n\n/** Form state every plugin settings card shares. */\nexport interface CardShell {\n /** False while the namespace is still loading; the card renders nothing. */\n available: boolean\n /**\n * Whether the namespace is actually served to this client. False when the\n * Host deployment does not expose it (e.g. the official apiproxy settings\n * allowlist omits third-party namespaces): the card renders an explanation\n * instead of its form, so a missing namespace never looks like a missing\n * plugin.\n */\n exposed: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Whether the form holds edits that a save would write. */\n dirty: boolean\n /** Whether any staged draft is invalid, which blocks the save. */\n invalid: boolean\n /** Whether a save is crossing the wire. */\n saving: boolean\n /** Whether the last save did not land as staged; cleared by the next edit or save. */\n failed: boolean\n /**\n * The rejection code/message the Host returned for the last failed save,\n * surfaced next to the generic failure text. Undefined while no save has\n * failed (or the failure carried no server reason).\n */\n failedReason?: string\n}\n\n/** The write actions the card's slot entry injects. */\nexport interface CardActions {\n /** Stage draft text for one field. */\n edit: (field: string, text: string) => void\n /** Stage a clear, so saving lets the field re-inherit the composition layer. */\n resetField: (field: string) => void\n /** Write every staged edit, then re-seed from what the Host accepted. */\n save: () => void\n /** Drop every staged edit. */\n discard: () => void\n}\n\n/** One field's staged edit. */\ninterface StagedEdit {\n /** Draft text the control renders. */\n text: string\n /** True when this edit clears the field whatever text it shows. */\n clear: boolean\n}\n\n/** One staged edit resolved into the write a save performs. */\ninterface PlannedWrite {\n /** Field this entry writes. */\n field: string\n /** The durable write this entry performs, described for a batched scope. */\n op: BatchedWrite\n /** Perform the write and report whether the Host holds the staged value afterwards. */\n run: (() => Promise<boolean>) | undefined\n}\n\n/** One durable write a batched settings scope performs. */\nexport interface BatchedWrite {\n /** Field this entry writes. */\n field: string\n /** set stores a value; unset drops the leaf. */\n op: 'set' | 'unset'\n /** Value for op set (absent for unset). */\n value?: unknown\n}\n\n/** Per-field outcome of one batched scope write. */\nexport interface BatchedFieldResult {\n /** Field this entry writes. */\n field: string\n /** Whether the Host accepted this field's write (per the read-back view). */\n landed: boolean\n}\n\n/**\n * Result of a batched scope write. The bridge scope posts every planned write\n * in one /mutate so the Host validate hook judges baseURL+model together; a\n * batched refusal fails the whole save rather than per-field.\n */\nexport interface BatchResult {\n /** Whether the whole mutate was accepted. */\n ok: boolean\n /** Per-field success, in the request order (always present when ok). */\n fields: BatchedFieldResult[]\n /** Host rejection code (mutate refused). */\n code?: string\n /** Host rejection message (mutate refused). */\n message?: string\n}\n\n/** The optional batch surface the bridge scope adds over the SettingsScope contract. */\ninterface BatchedSettingsScope {\n /** Write every operation in one scope mutation, reporting per-field success. */\n mutate: (writes: BatchedWrite[]) => Promise<BatchResult>\n}\n\n/** Constraints a numeric field's accepted drafts must satisfy, mirroring the host schema. */\nexport interface NumberConstraints {\n /** The accepted value must be a whole number. */\n integer?: boolean\n /** The accepted value must be at least this. */\n min?: number\n}\n\n/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */\nexport function numberField(field: string, constraints: NumberConstraints = {}): FieldSpec {\n const { integer = false, min } = constraints\n return {\n field,\n format: value => typeof value === 'number' ? String(value) : '',\n parse: (text) => {\n const trimmed = text.trim()\n if (trimmed === '') return { kind: 'clear' }\n const parsed = Number(trimmed)\n if (!Number.isFinite(parsed)) return undefined\n if (integer && !Number.isInteger(parsed)) return undefined\n if (min !== undefined && parsed < min) return undefined\n return { kind: 'set', value: parsed }\n },\n }\n}\n\n/** A free-text field. An empty draft clears the field. */\nexport function textField(field: string): FieldSpec {\n return {\n field,\n format: value => typeof value === 'string' ? value : '',\n parse: (text) => {\n const trimmed = text.trim()\n return trimmed === '' ? { kind: 'clear' } : { kind: 'set', value: trimmed }\n },\n }\n}\n\n/**\n * A free-text field the Host treats as a secret and redacts from the read-back\n * (role('secret') in the section schema). The card still edits it like text,\n * but a save never compares the redacted value back and relies on the scope\n * reporting the write landed.\n */\nexport function secretField(field: string): FieldSpec {\n return { ...textField(field), secret: true }\n}\n\n/** A boolean field, edited through true/false draft text. */\nexport function booleanField(field: string): FieldSpec {\n return {\n field,\n format: value => typeof value === 'boolean' ? String(value) : '',\n parse: (text) => {\n const trimmed = text.trim()\n if (trimmed === '') return { kind: 'clear' }\n if (trimmed === 'true') return { kind: 'set', value: true }\n if (trimmed === 'false') return { kind: 'set', value: false }\n return undefined\n },\n }\n}\n\n/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */\nexport function choiceField(field: string, choices: readonly string[]): FieldSpec {\n return {\n field,\n format: value => typeof value === 'string' && choices.includes(value) ? value : '',\n parse: (text) => {\n if (text === '') return { kind: 'clear' }\n return choices.includes(text) ? { kind: 'set', value: text } : undefined\n },\n }\n}\n\n/**\n * Stages one card's edits over one settings namespace and writes them on save.\n *\n * The Host is the only authority on whether a value was accepted — its\n * validators own the constraints no schema can express — so the outcome is\n * read back from the section rather than predicted here. A save that did not\n * land keeps its drafts, so the user can correct them instead of retyping.\n */\nexport class CardForm<T> {\n private readonly specs: Map<string, FieldSpec>\n private readonly staged = new Map<string, StagedEdit>()\n private readonly listeners = new Set<() => void>()\n /** The scope subscription installed in the constructor; released by dispose(). */\n private readonly disposeScope: () => void\n private disposed = false\n private saving = false\n private failed = false\n private failedReason: string | undefined\n\n /** @param scope - the bound settings scope for this card's namespace. */\n constructor(\n private readonly scope: SettingsScope<T>,\n specs: FieldSpec[],\n ) {\n this.specs = new Map(specs.map(spec => [spec.field, spec]))\n this.disposeScope = scope.subscribe(() => { this.publish() })\n }\n\n /**\n * Release the scope subscription and every bound store listener. The card\n * must call this on teardown; later calls are no-ops.\n */\n dispose(): void {\n if (this.disposed) return\n this.disposed = true\n this.disposeScope()\n this.listeners.clear()\n }\n\n /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */\n bind<S>(project: () => S): SnapshotStore<S> {\n const store = createSnapshotStore(project())\n this.listeners.add(() => { store.set(project()) })\n return store\n }\n\n /** Read the card-level state: what the Host serves, and what a save would do. */\n shell(): CardShell {\n const snapshot = this.scope.getSnapshot()\n const plan = this.plan()\n return {\n available: snapshot.status !== 'loading',\n exposed: snapshot.status === 'ready',\n writable: snapshot.writable,\n dirty: plan.length > 0,\n invalid: plan.some(item => item.run === undefined),\n saving: this.saving,\n failed: this.failed,\n ...this.failedReason === undefined ? {} : { failedReason: this.failedReason },\n }\n }\n\n /** Read one field's state from the effective section and its staged draft. */\n field(field: string): FieldState {\n const spec = this.specOf(field)\n const staged = this.staged.get(field)\n if (staged === undefined) {\n return { text: spec.format(this.sectionValue(field)), overridden: this.stored(field), invalid: false }\n }\n const write = staged.clear ? { kind: 'clear' as const } : spec.parse(staged.text)\n return {\n text: staged.text,\n overridden: write?.kind === 'set',\n invalid: write === undefined,\n }\n }\n\n /** The actions the card's slot registration injects. */\n actions(): CardActions {\n return {\n edit: (field, text) => { this.stage(field, { text, clear: false }) },\n resetField: (field) => {\n this.stage(field, { text: this.specOf(field).format(this.baseValue(field)), clear: true })\n },\n save: () => { void this.save() },\n discard: () => {\n if (this.staged.size === 0 && !this.failed) return\n this.staged.clear()\n this.failed = false\n this.failedReason = undefined\n this.publish()\n },\n }\n }\n\n /**\n * Write every staged edit, then re-seed from what the Host accepted.\n *\n * When the scope carries the optional batch surface (the dsh-web-ui\n * bridge scope), every planned write rides one mutation so cross-field\n * validate hooks (baseURL+model) judge the batch as a unit instead of\n * deadlocking on per-field writes. Otherwise the per-field loop runs.\n * A field lands only when the Host reports it held the staged value; a\n * landed field's draft is dropped, a failed one stays staged for the user.\n * @returns settlement after every write and the read-back.\n */\n async save(): Promise<void> {\n const plan = this.plan()\n const valid = plan.filter(item => item.run !== undefined)\n if (plan.length === 0 || this.saving || valid.length !== plan.length) return\n const plannedWrites = valid.map(item => item.op)\n // Snapshot the staged entries this save writes, so an edit staged while it\n // is in flight (which replaces the same key) survives: only delete the key\n // when the entry is still the one this save started from.\n const pending = new Map<string, StagedEdit | undefined>()\n for (const item of plan) pending.set(item.field, this.staged.get(item.field))\n this.saving = true\n this.failed = false\n this.failedReason = undefined\n this.publish()\n const landed = new Set<string>()\n const batch = this.batchedScope()\n if (batch !== undefined) {\n const result = await batch.mutate(plannedWrites)\n if (result.ok) {\n for (const field of result.fields) {\n if (field.landed) landed.add(field.field)\n }\n } else {\n this.failedReason = result.message\n }\n } else {\n for (const item of valid) {\n if (await item.run!()) landed.add(item.field)\n }\n }\n for (const [field, before] of pending) {\n if (landed.has(field) && this.staged.get(field) === before) this.staged.delete(field)\n }\n this.saving = false\n this.failed = landed.size !== pending.size\n this.publish()\n }\n\n /** The scope's batch surface when it supports one; undefined conservatively otherwise. */\n private batchedScope(): BatchedSettingsScope | undefined {\n const candidate = this.scope as unknown as BatchedSettingsScope | undefined\n return typeof candidate?.mutate === 'function' ? candidate : undefined\n }\n\n /**\n * Every staged edit a save would write. An entry whose draft is not a value\n * its field accepts carries no write: the form is still dirty, and the save\n * refuses rather than dropping the edit. A staged edit that matches the\n * effective section is not a write at all.\n * @returns the planned writes, in the order the fields were staged.\n */\n private plan(): PlannedWrite[] {\n const plan: PlannedWrite[] = []\n for (const [field, staged] of this.staged) {\n const spec = this.specOf(field)\n if (staged.clear) {\n if (this.stored(field)) plan.push({ field, op: { field, op: 'unset' }, run: () => this.clear(field) })\n continue\n }\n if (staged.text === spec.format(this.sectionValue(field))) continue\n const write = spec.parse(staged.text)\n if (write === undefined) plan.push({ field, op: { field, op: 'unset' }, run: undefined })\n else if (write.kind === 'clear') plan.push({ field, op: { field, op: 'unset' }, run: () => this.clear(field) })\n else plan.push({ field, op: { field, op: 'set', value: write.value }, run: () => this.store(field, write.value) })\n }\n return plan\n }\n\n private async clear(field: string): Promise<boolean> {\n await this.scope.unset(field)\n return !this.stored(field)\n }\n\n private async store(field: string, value: unknown): Promise<boolean> {\n await this.scope.set(field, value)\n // A redacted secret never appears in the user layer read-back; judging it\n // by value would misreport a successful secret save as failed. The bridge\n // reports secret writes through its secret-set markers (batch path); on\n // the per-field path the scope resolved, so the write is landed.\n if (this.specOf(field).secret) return true\n return this.userLayer()?.[field] === value\n }\n\n private stage(field: string, edit: StagedEdit): void {\n this.staged.set(field, edit)\n this.failed = false\n this.failedReason = undefined\n this.publish()\n }\n\n private specOf(field: string): FieldSpec {\n const spec = this.specs.get(field)\n // Every call site names a field this card declared; a missing one is a\n // wiring mistake that must not degrade into a silently inert control.\n if (spec === undefined) throw new Error(`settings card has no field ${field}`)\n return spec\n }\n\n private snapshotOf(): SettingsScopeSnapshot<T> {\n return this.scope.getSnapshot()\n }\n\n private sectionValue(field: string): unknown {\n return (this.snapshotOf().value as Record<string, unknown> | undefined)?.[field]\n }\n\n private baseValue(field: string): unknown {\n return (this.snapshotOf().base as Record<string, unknown> | undefined)?.[field]\n }\n\n private userLayer(): Record<string, unknown> | undefined {\n return this.snapshotOf().user as Record<string, unknown> | undefined\n }\n\n private stored(field: string): boolean {\n const user = this.userLayer()\n return user !== undefined && Object.hasOwn(user, field)\n }\n\n private publish(): void {\n for (const listener of this.listeners) listener()\n }\n}\n","/**\n * The pet settings card: pet selection plus display layout, bound to the\n * 'pet' settings namespace the host plugin registers. Rendered as an\n * always-open first-level settings page; the section wrapper below mounts it\n * as the content of the top-level 'settings.section' nav entry. The petId\n * choices come from the registry endpoint ('/api/pet/pets') — the same list\n * the sprite renders from — so the card carries no per-pet knowledge.\n */\n\nimport type { ReactNode } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { SettingsScope, SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\n// Type-only: pulls the settings-surface SlotMap merge (the 'settings.section' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport { PluginSettingsCard, ValueField, BooleanField, ChoiceField } from './PluginSettingsCard.tsx'\nimport { CardForm, booleanField, choiceField, numberField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'\nimport sectionCss from './settings-section.module.css'\n\n/** The pet's settings fields this card edits (the namespace's full schema). */\nexport interface PetSettings {\n /** Master switch for the plugin. */\n enabled?: boolean\n /** Master switch. */\n visible?: boolean\n /** Scale of the rendered pet in px (sprite cell height). */\n size?: number\n /** Horizontal inset from the viewport right edge, px. */\n right?: number\n /** Vertical inset from the viewport bottom edge, px. */\n bottom?: number\n /** Selected pet id (a registry entry). */\n petId?: string\n /** Status-decoration master switch (pet-center M5, #567). */\n decorationEnabled?: boolean\n}\n\n/** What the pet settings card renders. */\nexport interface PetSettingsCardState extends CardShell {\n /** Plugin master switch. */\n enabled: CardFieldState\n /** Master switch. */\n visible: CardFieldState\n /** Pet scale. */\n size: CardFieldState\n /** Right inset. */\n right: CardFieldState\n /** Bottom inset. */\n bottom: CardFieldState\n /** Selected pet. */\n petId: CardFieldState\n /** Status-decoration master switch. */\n decorationEnabled: CardFieldState\n /** Pet choices (registry ids + display names), loaded from the host. */\n petChoices: readonly { value: string; label: string }[]\n /** Registry diagnostics (v1 migration hints, invalid entries), host-served. */\n petDiagnostics: readonly PetDiagnosticView[]\n}\n\n/** The registration-side face the card's slot entry injects. */\nexport interface PetSettingsCardFace extends CardActions {\n hooks: {\n /** Card snapshot bound by the renderer as usePetSettingsCard. */\n petSettingsCard: SnapshotStore<PetSettingsCardState>\n }\n}\n\n/** One registry choice as served by '/api/pet/pets'. */\ninterface PetChoice {\n id: string\n displayName: string\n}\n\n/** One registry diagnostic as served by '/api/pet/diagnostics' (#623). */\nexport interface PetDiagnosticView {\n level: 'error' | 'warning'\n message: string\n}\n\n/** Fetch the registry list (the same data the sprite renders from). */\nasync function fetchPetChoices(): Promise<PetChoice[]> {\n const response = await fetch('/api/pet/pets')\n if (!response.ok) throw new Error('pet pets failed: ' + response.status)\n return (await response.json()) as PetChoice[]\n}\n\n/** Fetch the registry diagnostics (v1 migration hints, invalid entries). */\nasync function fetchPetDiagnostics(): Promise<PetDiagnosticView[]> {\n const response = await fetch('/api/pet/diagnostics')\n if (!response.ok) throw new Error('pet diagnostics failed: ' + response.status)\n const body = (await response.json()) as { diagnostics?: PetDiagnosticView[] }\n return body.diagnostics ?? []\n}\n\n/** Bridges the 'pet' scope onto the card's staged form. */\nexport class PetSettingsCardController {\n private readonly form: CardForm<PetSettings>\n private readonly store: SnapshotStore<PetSettingsCardState>\n // The choice list rides a mutable array shared with the choiceField spec,\n // so loading the registry re-validates and re-formats the petId field\n // without rebuilding the form.\n private readonly petChoices: string[] = []\n private readonly petLabels = new Map<string, string>()\n private diagnostics: PetDiagnosticView[] = []\n private loaded = false\n private attempts = 0\n\n /** @param scope - the bound settings scope for the 'pet' namespace. */\n constructor(scope: SettingsScope<PetSettings>) {\n this.form = new CardForm(scope, [\n booleanField('enabled'),\n booleanField('decorationEnabled'),\n booleanField('visible'),\n numberField('size'),\n numberField('right'),\n numberField('bottom'),\n choiceField('petId', this.petChoices),\n ])\n this.store = this.form.bind(() => this.projection())\n // Client plugins are applied synchronously during shell startup. Defer\n // the first registry request until that pass completes so transport\n // plugins (notably remote-web-ui on a paired non-loopback origin) can\n // install their fetch channel before /api/pet/pets is issued.\n window.setTimeout(() => {\n void this.loadPets()\n void this.loadDiagnostics()\n }, 0)\n }\n\n /** Fetch registry diagnostics once (soft-fail: an empty list on error). */\n private async loadDiagnostics(): Promise<void> {\n try {\n this.diagnostics = await fetchPetDiagnostics()\n this.store.set(this.projection())\n } catch {\n this.diagnostics = []\n }\n }\n\n /** Resolve the registry choices once (retried a few times on failure). */\n private async loadPets(): Promise<void> {\n if (this.loaded) return\n try {\n const list = await fetchPetChoices()\n this.petChoices.splice(0, this.petChoices.length, ...list.map(choice => choice.id))\n for (const choice of list) this.petLabels.set(choice.id, choice.displayName)\n this.loaded = true\n this.store.set(this.projection())\n } catch {\n this.attempts += 1\n if (this.attempts < 3) {\n window.setTimeout(() => { void this.loadPets() }, 3000)\n }\n }\n }\n\n private projection(): PetSettingsCardState {\n return {\n ...this.form.shell(),\n enabled: this.form.field('enabled'),\n decorationEnabled: this.form.field('decorationEnabled'),\n visible: this.form.field('visible'),\n size: this.form.field('size'),\n right: this.form.field('right'),\n bottom: this.form.field('bottom'),\n petId: this.form.field('petId'),\n petChoices: this.petChoices.map(id => ({ value: id, label: this.petLabels.get(id) ?? id })),\n petDiagnostics: this.diagnostics,\n }\n }\n\n /**\n * Build the face the card's slot registration injects.\n * @returns the card's snapshot and its form actions.\n */\n inject(): PetSettingsCardFace {\n return { hooks: { petSettingsCard: this.store }, ...this.form.actions() }\n }\n\n /**\n * Release the card's scope subscription and bound stores; the slot\n * disposer calls this on teardown.\n */\n dispose(): void {\n this.form.dispose()\n }\n}\n\n/** Props the renderer binds for the pet settings card. */\nexport type PetSettingsCardProps =\n PropsLocale<'pet'>\n & InjectFace<PetSettingsCardFace>\n\n/**\n * Render the pet settings card.\n * @param props - locale copy, the card snapshot, and its form actions.\n * @returns the card.\n */\nexport function PetSettingsCard(props: PetSettingsCardProps) {\n const { t } = props\n const state = props.usePetSettingsCard(snapshot => snapshot)\n const disabled = !state.writable\n const fieldProps = {\n overriddenLabel: t('settings.overridden'),\n resetLabel: t('settings.reset'),\n invalidLabel: t('settings.invalidNumber'),\n disabled,\n }\n return (\n <PluginSettingsCard\n t={t}\n titleKey=\"settings.title\"\n descriptionKey=\"settings.description\"\n state={state}\n onSave={props.save}\n onDiscard={props.discard}\n alwaysOpen\n >\n <BooleanField\n id=\"settings-pet-enabled\"\n label={t('settings.enabled')}\n hint={t('settings.enabledHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.enabled}\n onEdit={(text) => { props.edit('enabled', text) }}\n onReset={() => { props.resetField('enabled') }}\n />\n <BooleanField\n id=\"settings-pet-decoration\"\n label={t('settings.decoration')}\n hint={t('settings.decorationHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.decorationEnabled}\n onEdit={(text) => { props.edit('decorationEnabled', text) }}\n onReset={() => { props.resetField('decorationEnabled') }}\n />\n <ChoiceField\n id=\"settings-pet-pet\"\n label={t('settings.pet')}\n hint={t('settings.petHint')}\n inheritLabel={t('settings.inherit')}\n {...fieldProps}\n {...state.petId}\n choices={state.petChoices}\n onEdit={(text) => { props.edit('petId', text) }}\n onReset={() => { props.resetField('petId') }}\n />\n {state.petDiagnostics.length === 0 ? null : (\n <li className={sectionCss.diagnostics} data-dsh-part=\"diagnostics\">\n <span className={sectionCss.diagnosticsTitle}>{t('settings.diagnosticsTitle')}</span>\n <ul>\n {state.petDiagnostics.map((diagnostic, index) => (\n <li key={index} data-level={diagnostic.level}>{diagnostic.message}</li>\n ))}\n </ul>\n </li>\n )}\n <BooleanField\n id=\"settings-pet-visible\"\n label={t('settings.visible')}\n hint={t('settings.visibleHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.visible}\n onEdit={(text) => { props.edit('visible', text) }}\n onReset={() => { props.resetField('visible') }}\n />\n <ValueField\n id=\"settings-pet-size\"\n label={t('settings.size')}\n hint={t('settings.sizeHint')}\n numeric\n {...fieldProps}\n {...state.size}\n onEdit={(text) => { props.edit('size', text) }}\n onReset={() => { props.resetField('size') }}\n />\n <ValueField\n id=\"settings-pet-right\"\n label={t('settings.right')}\n hint={t('settings.rightHint')}\n numeric\n {...fieldProps}\n {...state.right}\n onEdit={(text) => { props.edit('right', text) }}\n onReset={() => { props.resetField('right') }}\n />\n <ValueField\n id=\"settings-pet-bottom\"\n label={t('settings.bottom')}\n hint={t('settings.bottomHint')}\n numeric\n {...fieldProps}\n {...state.bottom}\n onEdit={(text) => { props.edit('bottom', text) }}\n onReset={() => { props.resetField('bottom') }}\n />\n </PluginSettingsCard>\n )\n}\n\n/** Props the settings section binds for the pet card page. */\nexport type PetSettingsSectionProps =\n PropsRuntime<'settings.section'>\n & PropsLocale<'pet'>\n & InjectFace<PetSettingsCardFace>\n\n/** Render the pet settings card as a first-level settings page. */\nexport function PetSettingsSection(props: PetSettingsSectionProps): ReactNode {\n const { t, usePetSettingsCard, save, discard, edit, resetField } = props\n return (\n <ul className={sectionCss.sectionList}>\n <PetSettingsCard t={t} usePetSettingsCard={usePetSettingsCard} save={save} discard={discard} edit={edit} resetField={resetField} />\n </ul>\n )\n}\n","/**\n * dsh-pet locale dictionaries (zh/en).\n * @module @linxin666/dsh-pet/client/locales\n */\n\n/** Dictionary namespace this package registers. */\nexport const NS = 'pet'\n\n/** Chinese copy. */\nexport const zh = {\n 'pet.feed': '喂食',\n 'pet.hide': '隐藏',\n 'pet.rename': '改名',\n 'pet.confirm': '确定',\n 'pet.namePlaceholder': '输入新名字',\n 'pet.summon': '召唤{name}',\n 'pet.rank': '亲密度 {rank}',\n 'pet.points': '{points} 点',\n 'pet.treats': '小鱼干 ×{n}',\n 'pet.state.loading': '宠物正在赶来…',\n 'pet.state.error': '宠物迷路了(连接失败)',\n 'pet.renderer.unavailable': '这只宠物需要的渲染器({renderer})在当前版本不可用。',\n 'pet.live2d.core-missing': 'Live2D 核心未安装:请把官方 live2dcubismcore.min.js 放入 $DSH_HOME/pets/.runtime/ 后刷新(步骤见宠物插件 README)。',\n 'pet.live2d.vendor-missing': 'Live2D 组件缺失,请升级宠物插件。',\n 'pet.live2d.load-failed': 'Live2D 模型加载失败,请检查该宠物目录的完整性。',\n 'pet.openSessionHint': '点击跳转到对应会话',\n 'pet.moreSessions': '展开其余 {n} 个会话的气泡',\n 'pet.collapseSessions': '收起会话气泡',\n // 一级设置页(settings.section 席位)。\n 'settings.title': '宠物',\n 'settings.diagnosticsTitle': '宠物目录诊断',\n 'settings.description': '选择宠物并调整它的显示布局。',\n 'settings.pet': '宠物',\n 'settings.petHint': '选择显示哪只宠物;每只宠物独立命名,可在宠物悬浮面板改名。',\n 'settings.enabled': '启用宠物',\n 'settings.enabledHint': '关闭后隐藏宠物并停止轮询,可在设置里重新启用。',\n 'settings.decoration': '状态装饰',\n 'settings.decorationHint': '在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。',\n 'settings.visible': '显示宠物',\n 'settings.visibleHint': '关闭后宠物隐藏,可从聊天输入区重新召唤。',\n 'settings.size': '大小(px)',\n 'settings.sizeHint': '精灵单元高度,范围 32–512。',\n 'settings.right': '距右侧(px)',\n 'settings.rightHint': '距视口右边缘的水平内缩距离。',\n 'settings.bottom': '距底部(px)',\n 'settings.bottomHint': '距视口底边的垂直内缩距离。',\n 'settings.inherit': '继承',\n 'settings.on': '开',\n 'settings.off': '关',\n 'settings.overridden': '已覆盖',\n 'settings.reset': '恢复默认',\n 'settings.notExposed': '当前 DSH 版本未向设置页暴露本插件的配置命名空间,表单不可用。可编辑 ~/.dsh/settings.yaml 直接配置,或为 dsh-host-apiproxy 的 WEB_SETTINGS_NAMESPACES 白名单补充本命名空间后重启。',\n 'settings.readOnly': '当前部署的设置只读。',\n 'settings.expand': '展开设置',\n 'settings.collapse': '收起设置',\n 'settings.save': '保存',\n 'settings.saving': '保存中…',\n 'settings.discard': '放弃',\n 'settings.unsaved': '未保存',\n 'settings.saveFailed': '部署未接受这些值,已保留供你修改。',\n 'settings.invalidNumber': '请输入数字,留空则使用默认值。',\n} as const\n\n/** English copy. */\nexport const en = {\n 'pet.feed': 'Feed',\n 'pet.hide': 'Hide',\n 'pet.rename': 'Rename',\n 'pet.confirm': 'OK',\n 'pet.namePlaceholder': 'Enter a new name',\n 'pet.summon': 'Summon {name}',\n 'pet.rank': 'Affinity {rank}',\n 'pet.points': '{points} pts',\n 'pet.treats': 'Treats ×{n}',\n 'pet.state.loading': 'The pet is on its way…',\n 'pet.state.error': 'The pet is lost (connection failed)',\n 'pet.renderer.unavailable': 'This pet needs a renderer ({renderer}) that is not available in this build.',\n 'pet.live2d.core-missing': 'Live2D Cubism Core is not installed: place the official live2dcubismcore.min.js under $DSH_HOME/pets/.runtime/ and refresh (see the pet plugin README).',\n 'pet.live2d.vendor-missing': 'The Live2D component is missing; please update the pet plugin.',\n 'pet.live2d.load-failed': 'The Live2D model failed to load; check the pet directory is complete.',\n 'pet.openSessionHint': 'Click to jump to this session',\n 'pet.moreSessions': 'Expand {n} more session bubbles',\n 'pet.collapseSessions': 'Collapse session bubbles',\n // First-level settings section (the `settings.section` seat).\n 'settings.title': 'Pet',\n 'settings.diagnosticsTitle': 'Pet directory diagnostics',\n 'settings.description': 'Pick a pet and tune its display layout.',\n 'settings.pet': 'Pet',\n 'settings.petHint': 'Choose which pet shows. Names are stored per pet; rename from the pet hover panel.',\n 'settings.enabled': 'Enable the pet',\n 'settings.enabledHint': 'When off, the pet hides and polling stops; re-enable it here.',\n 'settings.decoration': 'Status decoration',\n 'settings.decorationHint': 'Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.',\n 'settings.visible': 'Show the pet',\n 'settings.visibleHint': 'When off, the pet hides; summon it again from the input row.',\n 'settings.size': 'Size (px)',\n 'settings.sizeHint': 'Sprite cell height, 32\\u2013512.',\n 'settings.right': 'Right inset (px)',\n 'settings.rightHint': 'Horizontal inset from the viewport right edge.',\n 'settings.bottom': 'Bottom inset (px)',\n 'settings.bottomHint': 'Vertical inset from the viewport bottom edge.',\n 'settings.inherit': 'Inherit',\n 'settings.on': 'On',\n 'settings.off': 'Off',\n 'settings.overridden': 'Overridden',\n 'settings.reset': 'Reset to default',\n 'settings.notExposed': 'This DSH version does not expose this plugin\\'s settings namespace to the configuration page, so the form is unavailable. Edit ~/.dsh/settings.yaml directly, or add the namespace to dsh-host-apiproxy\\'s WEB_SETTINGS_NAMESPACES allowlist and restart.',\n 'settings.readOnly': 'This deployment stores settings read-only.',\n 'settings.expand': 'Show settings',\n 'settings.collapse': 'Hide settings',\n 'settings.save': 'Save',\n 'settings.saving': 'Saving\\u2026',\n 'settings.discard': 'Discard',\n 'settings.unsaved': 'Unsaved',\n 'settings.saveFailed': 'The deployment did not accept these values; they were left for you to correct.',\n 'settings.invalidNumber': 'Enter a number, or leave blank to use the default.',\n} as const\n\n/** Key union for this namespace. */\nexport type PetKey = keyof typeof zh\n\n/** The settings-card slice of the pet dictionary. */\nexport type SettingsCardKey = PetKey\n\n/**\n * Active dictionary, picked by the document language at call time. The pet\n * mounts as a global floating surface (not a session-scoped slot), so it has\n * no framework locale seat and resolves its copy the same tiny way the\n * task-board's DOM-injected surface does.\n */\nexport function dictionary(): Record<PetKey, string> {\n const lang = typeof document !== 'undefined' ? document.documentElement.lang : 'zh'\n return lang.toLowerCase().startsWith('en') ? en : zh\n}\n\n/**\n * Translate a key with optional `{name}` template params. Mirrors the slot\n * `Translate` contract `(key, params?) => string` so it can be handed to the\n * same components that used to receive the framework-injected `t` seat. The\n * key is typed loosely (`string`) so the function is assignable to the slot's\n * `TranslateNS<'pet'>` (whose key domain also spans the shared common\n * vocabulary); a missing key degrades to the key itself rather than throwing.\n */\nexport function t(key: string, params?: Record<string, unknown>): string {\n let text: string = (dictionary() as Record<string, string>)[key] ?? key\n if (params !== undefined) {\n for (const [name, value] of Object.entries(params)) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n }\n return text\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** dsh-pet UI copy. */\n pet: PetKey\n }\n}\n","/**\n * dsh-pet browser half — mounts the selected pet as a global floating\n * surface and drives it from the host's same-origin '/api/pet/*' JSON\n * endpoints: fetch the registry list once, poll the host snapshot (~2 s),\n * forward interactions, persist drag positions. The pet is host-global (no\n * session dimension), so it mounts directly onto 'document.body' via a\n * single React root rather than a session-scoped slot — on the\n * new-conversation screen no session exists, and a dock-mounted pet would\n * vanish there (issue #48). When the pet is hidden the entry becomes a\n * fixed-position summon button.\n * @module @linxin666/dsh-pet/client\n */\n\nimport type { ClientContext, ISessions, SessionId, SettingsScope, SettingsScopeSpec } from '@deepseek-ai/dsh-client-runtime/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the settings-surface Context merge (ctx.settingsScope).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-slots'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetInteractResult, PetStateView } from '../service.ts'\nimport type { PetInteraction } from '../affinity.ts'\nimport type { PetDefinition } from '../registry.ts'\nimport { createElement } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport { createPetStore, type PetStoreInstance } from './pet-store.ts'\nimport { PetDockEntry, type PetInjected } from './PetDockEntry.tsx'\nimport { defaultPetRendererRegistry } from './renderers/registry.ts'\nimport { live2dRenderer } from './renderers/live2d.ts'\nimport { PetSettingsSection, PetSettingsCardController, type PetSettings } from './PetSettingsCard.tsx'\nimport { NS, en, zh, t } from './locales.ts'\n\n/** The host pet API as the browser sees it (same-origin JSON endpoints). */\ninterface PetHttpApi {\n state(): Promise<PetStateView>\n pets(): Promise<PetDefinition[]>\n interact(kind: PetInteraction): Promise<PetInteractResult>\n setVisible(visible: boolean): Promise<{ ok: true; display: PetDisplayConfig }>\n setConfig(patch: Partial<PetDisplayConfig>): Promise<{ ok: true; display: PetDisplayConfig }>\n setName(name: string): Promise<{ ok: true; name: string } | { ok: false; error: string }>\n setPet(petId: string): Promise<{ ok: true; petId: string } | { ok: false; error: string }>\n}\n\n/** Same-origin JSON fetch helper (GET without body, POST with JSON body). */\nasync function petFetch<T>(path: string, body?: unknown): Promise<T> {\n const response = await fetch(path, body === undefined\n ? {}\n : {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw new Error('pet ' + path + ' failed: ' + response.status)\n }\n return (await response.json()) as T\n}\n\n/** The live host API instance (always defined; failures surface per call). */\nconst petApi: PetHttpApi = {\n state: () => petFetch('/api/pet/state'),\n pets: () => petFetch('/api/pet/pets'),\n interact: (kind) => petFetch('/api/pet/interact', { kind }),\n setVisible: (visible) => petFetch('/api/pet/set-visible', { visible }),\n setConfig: (patch) => petFetch('/api/pet/set-config', patch),\n setName: (name) => petFetch('/api/pet/set-name', { name }),\n setPet: (petId) => petFetch('/api/pet/set-pet', { petId }),\n}\n\n/** Poll interval for the host snapshot. */\nconst POLL_MS = 2000\n\n/** Settings namespace the pet settings card edits (the Host plugin registers it). */\nconst PET_SETTINGS_NS = 'pet'\n\n/** Required services (sessions powers bubble-to-session navigation). */\nexport const inject = ['slots', 'locale', 'connection', 'settingsScope', 'remote', 'sessions']\n\n/** Re-exported for consumers that type against the injected face. */\nexport type { PetInjected, PetDockEntryProps } from './PetDockEntry.tsx'\nexport type { PetSpriteProps } from './PetSprite.tsx'\nexport type { PetUiState, PetFeedback } from './pet-store.ts'\nexport type { PetSettingsCardFace, PetSettingsCardState } from './PetSettingsCard.tsx'\nexport type { PetSettingsSectionProps } from './PetSettingsCard.tsx'\nexport type { PetDefinition } from '../registry.ts'\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /**\n * Optional rc.6 compatibility binder provided by dsh-web-ui-settings;\n * absent when that group plugin is not installed, so callers fall back to\n * the official settings scope.\n */\n webUiSettings?: { bind<S>(spec: SettingsScopeSpec<S>): SettingsScope<S> }\n }\n}\n\n/**\n * Client plugin body: register dictionaries, mount the global pet entry and\n * poll loop while the plugin is enabled, and seat the settings card as a\n * first-level settings section.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'pet: dictionaries')\n\n // Built-in renderers dispatch through the plugin-wide registry (pet-center\n // M3). Registration is idempotent (id wins), so re-applies stay clean.\n defaultPetRendererRegistry.register(live2dRenderer)\n\n const binder = ctx.get('webUiSettings') ?? ctx.settingsScope\n const settingsScope = binder.bind<PetSettings>({ namespace: PET_SETTINGS_NS })\n const enabled = (): boolean => {\n const snapshot = settingsScope.getSnapshot()\n return snapshot.status === 'ready'\n ? snapshot.value?.enabled ?? true\n : snapshot.status === 'unavailable'\n }\n\n // First-level settings section: one staged form over the 'pet' settings\n // namespace, registered as a top-level settings page. The controller loads\n // the petId choices from the registry endpoint itself.\n const petSettings = new PetSettingsCardController(settingsScope)\n ctx.slots.inject('settings.section', () => {\n const unregister = ctx.slots.register({\n name: 'settings.section',\n id: 'pet',\n order: 130,\n label: () => ctx.locale.bind('pet')('settings.title'),\n locale: 'pet',\n inject: () => petSettings.inject(),\n }, PetSettingsSection)\n return () => {\n petSettings.dispose()\n unregister()\n }\n })\n\n // The global pet entry, its store, and the poll loop live while the plugin\n // is enabled; toggling the setting off hides the pet and stops polling.\n let disposeUi: (() => void) | undefined\n const syncUi = (): void => {\n if (enabled() && disposeUi === undefined) {\n // ONE store instance for the whole app, owned by this apply body. The\n // pet is host-global (state/display/interactions are /api/pet/*\n // endpoints with no session dimension), so the slot system's per-session\n // store scoping would only reset the pet on session switches and leave\n // it stateless on the new-conversation screen (no session to scope by).\n const petStore: PetStoreInstance = createPetStore().create()\n const setSnapshot = petStore.actions.setSnapshot\n const setPets = petStore.actions.setPets\n const setState = petStore.actions.setState\n const setFeedback = petStore.actions.setFeedback\n\n // The registry list is fetched lazily with retries baked into the poll\n // cycle: until it lands, the dock entry renders nothing and every 2s\n // tick tries again. After it lands, one list feeds both the sprite and\n // the settings card's choices.\n let petsLoaded = false\n // Latest-wins guard: the 2s tick, visibility recovery, and\n // interaction-triggered refreshes can overlap; only the newest\n // response may publish, so a slow older one can never roll the\n // snapshot back.\n let stateSeq = 0\n const pollNow = (): void => {\n if (!petsLoaded) {\n petApi.pets().then((list) => {\n petsLoaded = true\n setPets(list)\n }, () => {\n // Retry on the next poll tick.\n })\n }\n const seq = stateSeq + 1\n stateSeq = seq\n petApi.state().then((snapshot) => {\n if (seq !== stateSeq) return\n setSnapshot(snapshot)\n }, () => {\n if (seq !== stateSeq) return\n setState('error', 'pet.state transport error')\n })\n }\n\n const disposePoll = ctx.effect(() => {\n // Poll only while the tab is visible: the host snapshot does not\n // change while the page is hidden, so a background interval would\n // only burn RPCs (browser throttling is an unreliable backstop).\n // Coming back to the tab refreshes the pet immediately instead of\n // waiting out the next 2 s cycle.\n let timer: number | undefined\n const stop = (): void => {\n if (timer !== undefined) {\n window.clearInterval(timer)\n timer = undefined\n }\n }\n const start = (): void => {\n if (timer === undefined && document.visibilityState === 'visible') {\n timer = window.setInterval(pollNow, POLL_MS)\n }\n }\n const onVisibility = (): void => {\n if (document.visibilityState === 'visible') {\n pollNow()\n start()\n } else {\n stop()\n }\n }\n start()\n document.addEventListener('visibilitychange', onVisibility)\n return () => {\n stop()\n document.removeEventListener('visibilitychange', onVisibility)\n }\n }, 'pet: poll')\n\n // Clicking a session bubble jumps the GUI to that session. A bubble\n // can outlive its disposed session by one poll tick, and the sessions\n // service fails loud on unknown ids, so consult the live list first.\n // The pet's type program also loads the host-side dsh-session package\n // through the service types, whose Context merge declares a different\n // 'sessions' face; pin the browser runtime's outward face here.\n const sessions = ctx.sessions as unknown as ISessions\n const openSession = (sessionId: string): void => {\n const list = sessions.list.getSnapshot()\n if (list.byId[sessionId as SessionId] === undefined) return\n sessions.open(sessionId as SessionId)\n }\n\n const injected = (): PetInjected => ({\n store: petStore,\n ensure: pollNow,\n openSession,\n pet: () => {\n petApi.interact('pet').then((result) => {\n setFeedback({\n text: result.reaction,\n kind: 'pet',\n at: Date.now(),\n })\n }, () => {\n // Ignore transport errors on interactions; the next poll resyncs.\n })\n },\n feed: () => {\n petApi.interact('feed').then((result) => {\n setFeedback({\n text: result.reaction,\n kind: 'feed',\n at: Date.now(),\n })\n }, () => {\n // Ignore transport errors on interactions; the next poll resyncs.\n })\n },\n hide: () => {\n petApi.setVisible(false).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n summon: () => {\n petApi.setVisible(true).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n dragEnd: (right, bottom) => {\n petApi.setConfig({ right, bottom }).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n rename: (name) => {\n petApi.setName(name).then((result) => {\n if (result.ok) pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n feedbackDone: () => {\n setFeedback(null)\n },\n })\n\n // The pet is host-global (its state/display/interactions have no session\n // dimension), and the official rc.6 shell declares no root-scoped slot\n // for a global floating surface — the dock is session-scoped, so a pet\n // mounted there would vanish on the new-conversation screen (issue #48).\n // The entry therefore mounts straight onto document.body via a single\n // React root for the page lifetime: PetSprite portals itself to body\n // when visible, and the hidden-state summon button is fixed-positioned.\n const container = document.createElement('div')\n container.dataset.dshPetRoot = ''\n container.dataset.dshPlugin = 'pet'\n document.body.appendChild(container)\n const petRoot = createRoot(container)\n petRoot.render(createElement(PetDockEntry, { ...injected(), t }))\n\n disposeUi = () => {\n petRoot.unmount()\n container.remove()\n disposePoll()\n disposeUi = undefined\n }\n } else if (!enabled() && disposeUi !== undefined) {\n disposeUi()\n disposeUi = undefined\n }\n }\n settingsScope.subscribe(syncUi)\n syncUi()\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;;;;;;;;;;EAmDA,SAAgB,iBAA8D;GAC5E,QAAA,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W;KAChD,UAAU;KACV,YAAY,KAAA;IACd;GACF;GACA,cAAc,UAAU,MAAM;GAC9B,OAAO;EACT"}
|
|
1
|
+
{"version":3,"file":"client.js","names":["styles","styles","css","sectionCss"],"sources":["../../../packages/dsh-pet/src/client/pet-store.ts","../../../node_modules/.pnpm/clsx@2.1.1/node_modules/clsx/dist/clsx.mjs","../../../packages/dsh-pet/src/state.ts","../../../packages/dsh-pet/src/client/spritesheet.ts","../../../packages/dsh-pet/src/client/sequences.ts","../../../packages/dsh-pet/src/client/PetSprite.tsx","../../../packages/dsh-pet/src/client/renderers/registry.ts","../../../packages/dsh-pet/src/client/phase-stream.ts","../../../packages/dsh-pet/src/client/renderers/live2d/Live2dVisualMount.tsx","../../../packages/dsh-pet/src/client/renderers/PetRendererSwitch.tsx","../../../packages/dsh-pet/src/client/PetDockEntry.tsx","../../../packages/dsh-pet/src/contracts/renderer.ts","../../../packages/dsh-pet/src/client/renderers/live2d/runtime.ts","../../../packages/dsh-pet/src/client/renderers/live2d.ts","../../../packages/dsh-pet/src/client/ui-teardown.ts","../../../packages/dsh-pet/src/client/PluginSettingsCard.tsx","../../../packages/dsh-pet/src/client/settings-form.ts","../../../packages/dsh-pet/src/client/PetSettingsCard.tsx","../../../packages/dsh-pet/src/client/locales.ts","../../../packages/dsh-pet/src/client/index.ts"],"sourcesContent":["/**\n * Browser-side pet store: the pet state snapshot plus transient UI feedback\n * (reaction bubbles), written only through the store's audit actions. The\n * RPC polling and interactions live in the plugin apply body; components\n * only ever read snapshots.\n * @module @linxin666/dsh-pet/client/pet-store\n */\n\nimport { defineStore } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { EngineStoreHandle, EngineStoreInstance } from '@deepseek-ai/dsh-client-runtime/client'\nimport type { PetStateView } from '../service.ts'\nimport type { PetInteraction } from '../affinity.ts'\nimport type { PetDefinition } from '../registry.ts'\n\n/** One transient reaction bubble on the pet. */\nexport interface PetFeedback {\n /** Bubble copy. */\n text: string\n /** Interaction kind driving the reaction animation. */\n kind: PetInteraction | 'none'\n /** Epoch ms when the bubble appeared (for expiry). */\n at: number\n}\n\n/** Pet UI state as consumers see it. */\nexport interface PetUiState {\n /** Latest host snapshot; null before the first successful fetch. */\n snapshot: PetStateView | null\n /** The registry list the host serves (atlas URLs + geometry + tracks). */\n pets: PetDefinition[]\n /** Fetch lifecycle. */\n state: 'loading' | 'ready' | 'error'\n /** Transport error message (for the debug surface), when any. */\n error: string | null\n /** Active reaction bubble, if any. */\n feedback: PetFeedback | null\n}\n\n/** Store write set. */\nexport type PetUiActions = {\n /** Replace the host snapshot (poll result). */\n setSnapshot: (draft: PetUiState, snapshot: PetStateView) => void\n /** Replace the registry list. */\n setPets: (draft: PetUiState, pets: PetDefinition[]) => void\n /** Mark the fetch lifecycle. */\n setState: (draft: PetUiState, state: PetUiState['state'], error: string | null) => void\n /** Show a reaction bubble. */\n setFeedback: (draft: PetUiState, feedback: PetFeedback | null) => void\n}\n\n/** Create the pet store handle (apply world only; never module-level). */\nexport function createPetStore(): EngineStoreHandle<PetUiState, PetUiActions> {\n return defineStore({\n init: (): PetUiState => ({\n snapshot: null,\n pets: [],\n state: 'loading',\n error: null,\n feedback: null,\n }),\n actions: {\n setSnapshot: (draft, snapshot) => {\n draft.snapshot = snapshot\n draft.state = 'ready'\n draft.error = null\n },\n setPets: (draft, pets) => {\n draft.pets = pets\n },\n setState: (draft, state, error) => {\n draft.state = state\n draft.error = error\n },\n setFeedback: (draft, feedback) => {\n draft.feedback = feedback\n },\n },\n })\n}\n\nexport type { PetInteraction }\n\n/**\n * A live pet store instance (one per host, owned by the plugin apply body —\n * the pet itself is host-global, so its UI state must not ride the slot\n * system's per-session store scoping).\n */\nexport type PetStoreInstance = EngineStoreInstance<PetUiState, PetUiActions>\n\n","function r(e){var t,f,n=\"\";if(\"string\"==typeof e||\"number\"==typeof e)n+=e;else if(\"object\"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=\" \"),n+=f)}else for(f in e)e[f]&&(n&&(n+=\" \"),n+=f);return n}export function clsx(){for(var e,t,f=0,n=\"\",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=\" \"),n+=t);return n}export default clsx;","/**\n * Pet state machine — pure, clock-injected. Maps official DSH session activity\n * and the legacy `activity/status` vocabulary onto the 9-state Codex pet\n * animation contract, plus turn-end celebration and no-session idle.\n *\n * The machine is deliberately dumb: it holds the last input phase, the\n * animation decision, and a one-shot \"celebration\" window after `done` so the\n * pet visibly jumps before settling back to idle. Everything here is a pure\n * function of (input, nowMs); persistence and RPC live in the service.\n * @module @linxin666/dsh-pet/state\n */\n\n/** Activity phases understood by the pet host. */\nexport type ActivityPhase = 'idle' | 'waiting' | 'thinking' | 'tool' | 'review' | 'done' | 'failed'\n\n/** The Codex-compatible 9-state animation contract (spritesheet rows). */\nexport type PetAnimation =\n | 'idle'\n | 'running-right'\n | 'running-left'\n | 'waving'\n | 'jumping'\n | 'failed'\n | 'waiting'\n | 'running'\n | 'review'\n\n/** One input snapshot consumed by the machine. */\nexport interface PetStateInput {\n /** Current activity phase of the active session. */\n phase: ActivityPhase\n /** Human-readable status line (plain text). */\n line?: string\n /** Playful phrase from the activity tracker, when any. */\n phrase?: string\n}\n\n/** Animation decision plus the copy the pet should show. */\nexport interface PetStateSnapshot {\n /** Which animation track to play. */\n animation: PetAnimation\n /** Optional status bubble copy (line or phrase), shown while active. */\n bubble?: string\n /** Wall-clock ms this animation started (client can sync loops). */\n animationStartedAt: number\n /** Raw phase, for debugging and client-side rendering decisions. */\n phase: ActivityPhase\n /** True when there is an active session (pet mounted). */\n sessionActive: boolean\n}\n\n/** Machine configuration. */\nexport interface PetStateConfig {\n /** Celebration window after `done` before settling to idle, ms (default 2400). */\n celebrateMs: number\n /** Failure display window before settling to idle, ms (default 2400). */\n failureMs: number\n}\n\nexport const defaultPetStateConfig: PetStateConfig = { celebrateMs: 2400, failureMs: 2400 }\n\n/**\n * Map one activity phase onto the animation contract.\n * - thinking → `running` and tool → `running-right` (focused work).\n * - review → `review` while answer text is streaming.\n * - waiting → `waiting` (expectant pose, needs user input).\n * - done → `jumping` (celebration), then back to `idle` after the window.\n * - failed → `failed` briefly, then back to `idle`.\n * - idle → `idle` (calm breathing loop).\n */\nexport function animationForPhase(phase: ActivityPhase): PetAnimation {\n switch (phase) {\n case 'thinking': return 'running'\n case 'tool': return 'running-right'\n case 'review': return 'review'\n case 'waiting': return 'waiting'\n case 'done': return 'jumping'\n case 'failed': return 'failed'\n case 'idle': return 'idle'\n }\n}\n\n/** The spritesheet row index for one animation track. */\nexport function rowOf(animation: PetAnimation): number {\n const rows: Record<PetAnimation, number> = {\n 'idle': 0,\n 'running-right': 1,\n 'running-left': 2,\n 'waving': 3,\n 'jumping': 4,\n 'failed': 5,\n 'waiting': 6,\n 'running': 7,\n 'review': 8,\n }\n return rows[animation]\n}\n\n/**\n * PetStateMachine — one instance per host process. Holds only the latest\n * input snapshot and terminal-state timing; no storage, no side effects.\n */\nexport class PetStateMachine {\n private phase: ActivityPhase = 'idle'\n private line: string | undefined\n private phrase: string | undefined\n private sessionActive = false\n private doneAt: number | undefined\n private failedAt: number | undefined\n private readonly config: PetStateConfig\n\n constructor(\n config: Partial<PetStateConfig> = defaultPetStateConfig,\n private readonly now: () => number = Date.now,\n ) {\n this.config = { ...defaultPetStateConfig, ...config }\n }\n\n /** Consume one projected activity update. */\n onActivityStatus(input: PetStateInput): void {\n this.phase = input.phase\n this.line = input.line\n this.phrase = input.phrase\n this.doneAt = input.phase === 'done' ? this.now() : undefined\n this.failedAt = input.phase === 'failed' ? this.now() : undefined\n }\n\n /** A session became the active one (or a fresh session started). */\n onSessionActive(): void {\n this.sessionActive = true\n }\n\n /** The active session was disposed (or none left). */\n onSessionDisposed(): void {\n this.sessionActive = false\n this.phase = 'idle'\n this.line = undefined\n this.phrase = undefined\n this.doneAt = undefined\n this.failedAt = undefined\n }\n\n /** Render the current animation decision. */\n render(): PetStateSnapshot {\n const nowMs = this.now()\n let animation = animationForPhase(this.phase)\n const doneSettled = this.phase === 'done'\n && this.doneAt !== undefined\n && nowMs - this.doneAt >= this.config.celebrateMs\n const failedSettled = this.phase === 'failed'\n && this.failedAt !== undefined\n && nowMs - this.failedAt >= this.config.failureMs\n if (doneSettled || failedSettled) animation = 'idle'\n // Settled sessions never bubble: idle (e.g. an aborted/stopped turn),\n // completed celebration expiry, and failed display expiry all fall silent.\n const settled = this.phase === 'idle' || doneSettled || failedSettled\n const bubble = settled ? undefined : this.phrase ?? this.line\n return {\n animation,\n ...(bubble === undefined ? {} : { bubble }),\n animationStartedAt: nowMs,\n phase: this.phase,\n sessionActive: this.sessionActive,\n }\n }\n}\n","/**\n * Spritesheet geometry helpers — parameterized by the pet definition the\n * host serves over '/api/pet/pets', so the browser half renders any registry\n * entry without per-pet code. The per-track tables (frames, durations, loop,\n * fallback) also come from the registry; these helpers only place frames,\n * guard track lengths, and map the fixed 9-row animation contract.\n * @module @linxin666/dsh-pet/client/spritesheet\n */\n\nimport { rowOf, type PetAnimation } from '../state.ts'\nimport type { PetCell, PetTrackDef } from '../registry.ts'\n\n/** Animation track shape the frame loop consumes. */\nexport type TrackDef = PetTrackDef\n\n/** Row index of one animation track (the fixed 9-row contract). */\nexport function rowOfTrack(animation: PetAnimation): number {\n // The table itself lives in state.ts (rowOf) — the single source of truth.\n return rowOf(animation)\n}\n\n/**\n * Background-position (px) of one frame cell within the scaled atlas.\n * The background image is scaled by `scale` (element size ÷ cell size), and\n * background-position offsets are applied in SCALED coordinates — using raw\n * atlas coordinates here would drift each frame by the scale factor and\n * render torn/overlapping frames.\n */\nexport function framePosition(cell: PetCell, row: number, col: number, scale = 1): { x: number; y: number } {\n return { x: -col * cell.width * scale, y: -row * cell.height * scale }\n}\n\n/**\n * Trim a track to the actual frame count of its row (the manifest's per-row\n * counts are authoritative; this is a last-line guard against a definition\n * whose row count disagrees with its track table). A row with 0 detected\n * frames degrades to the first frame so the pet never renders blank.\n */\nexport function trimTrack(track: TrackDef, frameCount: number): TrackDef {\n const n = Math.max(1, Math.min(frameCount, track.frames.length, track.durations.length))\n return {\n frames: track.frames.slice(0, n),\n durations: track.durations.slice(0, n),\n loop: track.loop,\n ...(track.fallback === undefined ? {} : { fallback: track.fallback }),\n }\n}\n","/** Pure timing helpers for manifest-defined scene animation sequences. */\n\nimport type { PetTrackDef } from '../registry.ts'\nimport type { PetAnimation } from '../state.ts'\n\nexport interface SequenceFrame {\n animation: PetAnimation\n frameIndex: number\n}\n\n/** Resolve the active track and frame after elapsed milliseconds of a looping sequence. */\nexport function sequenceFrameAt(\n sequence: readonly PetAnimation[],\n tracks: Record<PetAnimation, PetTrackDef>,\n elapsedMs: number,\n): SequenceFrame {\n const itemDurations = sequence.map(animation => tracks[animation].durations.reduce((sum, value) => sum + value, 0))\n const sequenceDuration = itemDurations.reduce((sum, value) => sum + value, 0)\n let offset = Math.max(0, elapsedMs) % sequenceDuration\n let itemIndex = 0\n while (itemIndex < sequence.length - 1 && offset >= itemDurations[itemIndex]!) {\n offset -= itemDurations[itemIndex]!\n itemIndex += 1\n }\n const animation = sequence[itemIndex]!\n const track = tracks[animation]\n let frameIndex = 0\n while (frameIndex < track.frames.length - 1 && offset >= track.durations[frameIndex]!) {\n offset -= track.durations[frameIndex]!\n frameIndex += 1\n }\n return { animation, frameIndex }\n}\n","/**\n * Pet sprite companion component — the browser half's centerpiece. Renders a\n * fixed-position floating sprite (React portal onto document.body), plays\n * the track matching the host animation snapshot, and exposes the\n * interaction surface: click to pet, hover panel with feed/rename/hide, drag\n * to reposition (persisted via setConfig). Everything visual comes from the\n * pet definition the host serves ('/api/pet/pets' + the state snapshot's\n * pet id), so one component renders every registry entry.\n * @module @linxin666/dsh-pet/client/PetSprite\n */\n\nimport { useEffect, useLayoutEffect, useRef, useState } from 'react'\nimport type { CSSProperties, PointerEvent as ReactPointerEvent, ReactElement, ReactNode, ReactPortal } from 'react'\nimport { createPortal } from 'react-dom'\nimport clsx from 'clsx'\nimport type { TranslateNS } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetStateView } from '../service.ts'\nimport type { PetDefinition } from '../registry.ts'\nimport type { DecorationView } from '../contracts/status-decoration.ts'\nimport type { PetFeedback } from './pet-store.ts'\nimport { framePosition, rowOfTrack, trimTrack } from './spritesheet.ts'\nimport { sequenceFrameAt } from './sequences.ts'\nimport { animationForPhase, type ActivityPhase, type PetAnimation } from '../state.ts'\nimport { NS } from './locales.ts'\nimport styles from './pet.module.css'\n\n/** Props injected by the plugin apply body (store actions + locale). */\nexport interface PetSpriteProps {\n /** Latest host snapshot; null while loading. */\n snapshot: PetStateView | null\n /** The selected pet's registry definition (atlas URL + geometry + tracks). */\n definition: PetDefinition\n /** Display configuration (persisted by the host). */\n display: PetDisplayConfig\n /** Active reaction bubble, if any. */\n feedback: PetFeedback | null\n /** Pet the sprite (click). */\n onPet: () => void\n /** Feed the sprite (panel button). */\n onFeed: () => void\n /** Hide the sprite (panel button). */\n onHide: () => void\n /** Persist a drag position. */\n onDragEnd: (right: number, bottom: number) => void\n /** Rename the selected pet (persisted by the host). */\n onRename: (name: string) => void\n /** Navigate to the session one status bubble reports on. */\n onOpenSession: (sessionId: string) => void\n /** Clear the reaction bubble (after its CSS animation). */\n onFeedbackDone: () => void\n /**\n * Custom visual replacing the sprite2d atlas animation (pet-center M3).\n * The chrome (drag, bubbles, panel, tap economy) is untouched: the visual\n * renders inside the sprite box, and the atlas load + frame loop skip.\n */\n visual?: ReactNode\n /** Locale translate seat (namespace-bound). */\n t: TranslateNS<typeof NS>\n}\n\n/** Clamp a drag offset inside the viewport with a margin. */\nfunction clampOffset(value: number, max: number): number {\n return Math.max(0, Math.min(max, value))\n}\n\n/**\n * The status decoration ornament (pet-center M5, #567). Renders the active\n * phase's frame segment as a CSS-background strip at a compact bubble\n * height; prefers-reduced-motion holds the segment's first frame, and a\n * missing or undecodable asset simply paints nothing (CSS background\n * failure) — the bubble text is never disturbed. The span is aria-hidden;\n * the bubble keeps its own semantics untouched.\n */\nfunction StatusOrnament(props: { decoration: DecorationView; phase: ActivityPhase }): ReactElement | null {\n const { decoration, phase } = props\n const segment = decoration.phases[phase]\n const shown = segment !== undefined && segment !== 'hide'\n const segmentKey = segment !== undefined && segment !== 'hide' ? segment.from + ':' + segment.to : 'none'\n const spanRef = useRef<HTMLSpanElement | null>(null)\n const scale = 18 / decoration.cell.height\n const frameWidth = Math.round(decoration.cell.width * scale)\n const stripWidth = decoration.columns * frameWidth\n // Value-stable dependency key: the host serves a fresh DecorationView\n // object on every state poll (2 s), so the effect must not depend on the\n // object identity — otherwise each poll would cancel and restart the\n // frame loop and the animation would jump back to its first frame.\n const durationsKey = decoration.durations.join(',')\n useEffect(() => {\n if (segment === undefined || segment === 'hide') return\n const el = spanRef.current\n if (el === null) return\n const position = (index: number): string => (-index * frameWidth) + 'px 0px'\n const reduceMotion = window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true\n el.style.backgroundPosition = position(segment.from)\n // A single-frame segment (from === to) has nothing to animate: with\n // loop=true the wrap branch would reset index to the same frame and the\n // tick would keep rescheduling a no-op rAF forever. Settle on the one\n // frame instead — same as the reduced-motion static hold.\n if (reduceMotion || segment.from === segment.to) return\n let timer = 0\n let index = segment.from\n let elapsed = 0\n let last = performance.now()\n const tick = (): void => {\n const now = performance.now()\n const delta = now - last\n last = now\n elapsed += delta\n const duration = decoration.durations[index] ?? 120\n // The segment's frame rate (duration ms, typically 90-160) is far\n // below the rAF cadence, so a 60fps loop would spend ~90% of its\n // ticks doing nothing. Schedule by the remaining time to the next\n // frame instead — the ornament wakes once per frame, not once per\n // screen refresh. A late wake (background tab, jank) carries extra\n // elapsed time, so catch up every due frame like the sprite loop.\n if (elapsed >= duration) {\n do {\n elapsed -= duration\n if (index < segment.to) index += 1\n else if (decoration.loop) index = segment.from\n } while (elapsed >= duration)\n // Only advance the background when the frame actually changes.\n el.style.backgroundPosition = position(index)\n }\n // A non-looping segment settles on its last frame; stop scheduling\n // instead of repainting the same position every frame.\n if (!decoration.loop && index === segment.to) return\n timer = window.setTimeout(tick, Math.max(1, duration - elapsed))\n }\n timer = window.setTimeout(tick, 0)\n return () => window.clearTimeout(timer)\n }, [shown, segmentKey, frameWidth, decoration.loop, durationsKey])\n if (!shown) return null\n return (\n <span\n ref={spanRef}\n aria-hidden=\"true\"\n data-dsh-pet-decoration={decoration.id}\n style={{\n display: 'inline-block',\n width: frameWidth,\n height: 18,\n marginRight: 6,\n verticalAlign: 'middle',\n flexShrink: 0,\n backgroundImage: 'url(' + decoration.entryUrl + ')',\n backgroundSize: stripWidth + 'px 18px',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: '0px 0px',\n }}\n />\n )\n}\n\n/**\n * The floating pet. The spritesheet frame advances on requestAnimationFrame\n * with per-frame durations from the definition's tracks; the atlas image is\n * loaded once and the background position is written straight to the sprite\n * element (no per-frame React state).\n */\nexport function PetSprite(props: PetSpriteProps): ReactPortal {\n const { snapshot, definition, display, feedback } = props\n const spriteRef = useRef<HTMLDivElement | null>(null)\n const floatRef = useRef<HTMLDivElement | null>(null)\n const panelRef = useRef<HTMLDivElement | null>(null)\n // Whichever bubble surface is currently rendered (feedback, the session\n // stack, or the legacy status bubble) — only one exists at a time.\n const bubbleRef = useRef<HTMLDivElement | null>(null)\n const [imageReady, setImageReady] = useState(false)\n const [hovered, setHovered] = useState(false)\n // Multi-session bubble stack: collapsed by default (only the display\n // session's bubble + a '+N' badge), expanded on stack hover (peek) or by\n // tapping the badge (pinned, for touch). The display session's bubble\n // anchors the bottom of the stack and never moves when extras open above\n // it, so the pointer target cannot flicker.\n const [stackPeek, setStackPeek] = useState(false)\n const [stackPinned, setStackPinned] = useState(false)\n const [renaming, setRenaming] = useState(false)\n const [panelAbove, setPanelAbove] = useState(false)\n // Extra margin-bottom for the above-panel so it stacks clear of the\n // bubbles instead of overlapping them (both anchor at the sprite's top).\n const [panelLift, setPanelLift] = useState(0)\n const [nameDraft, setNameDraft] = useState('')\n // Explicit IME composition tracking: some input methods (WeChat IME on\n // Windows) report keydowns with isComposing === false mid-composition, so\n // the native flag alone is not a safe submit/cancel guard (#303).\n const composingRef = useRef(false)\n const [dragPos, setDragPos] = useState<{ right: number; bottom: number } | null>(null)\n const dragRef = useRef<{ startX: number; startY: number; right: number; bottom: number } | null>(null)\n const hideTimerRef = useRef<number | null>(null)\n const frameRef = useRef<{ track: PetAnimation | null; index: number; elapsed: number }>({\n track: null,\n index: 0,\n elapsed: 0,\n })\n\n const cell = definition.cell\n const columns = definition.columns\n const rows = definition.rows\n const tracks = definition.tracks\n const sequences = definition.sequences\n // Hover-panel chrome from the pet's voice pack (pet-center M4, issue\n // #677): every slot falls back to the i18n dictionary when unset. Stat\n // formats carry {rank}/{n}/{points} placeholders the host validated.\n const panel = definition.panel\n const panelLabel = (slot: 'feed' | 'rename' | 'hide' | 'confirm', i18n: string): string =>\n panel?.labels?.[slot] ?? i18n\n const panelStat = (\n slot: 'rank' | 'treats' | 'points',\n i18nKey: 'pet.rank' | 'pet.treats' | 'pet.points',\n values: Record<string, string | number>,\n ): string => {\n const format = panel?.stats?.[slot] ?? props.t(i18nKey, values)\n if (panel?.stats?.[slot] === undefined) return format\n // The host whitelists {rank}/{n}/{points} in every stat slot, so a pack\n // format may reference any of them; substitute all three live values\n // (the slot's own value plus the siblings) instead of only the slot's.\n const all: Record<string, string | number> = {\n rank: snapshot?.affinity.rank ?? '?',\n n: snapshot?.treats.stocked ?? 0,\n points: snapshot?.affinity.points ?? 0,\n }\n let text = format\n for (const [name, value] of Object.entries(all)) text = text.replaceAll('{' + name + '}', String(value))\n return text\n }\n const panelShows = (action: 'feed' | 'rename' | 'hide'): boolean =>\n panel?.actions === undefined || panel.actions.includes(action)\n\n // Load the atlas once; the definition carries the authoritative per-row\n // frame counts and per-track durations, so nothing else is fetched. A\n // custom visual (pet-center M3) replaces the atlas entirely.\n useEffect(() => {\n if (props.visual !== undefined) return\n let cancelled = false\n const img = new Image()\n img.onload = () => {\n if (!cancelled) setImageReady(true)\n }\n img.src = definition.atlasUrl\n return () => {\n cancelled = true\n img.onload = null\n }\n }, [definition.atlasUrl, props.visual])\n\n // Frame loop: advance the current track and write background-position.\n // Offsets must be in SCALED coordinates (background-position applies to the\n // scaled background image), so the current sprite scale rides a ref that\n // the loop reads every tick. Under prefers-reduced-motion the sprite holds\n // its track's first frame instead of animating (presentation-only; the\n // animation state machine is untouched).\n const spriteScale = display.size / cell.height\n const phase = snapshot?.phase ?? 'idle'\n const animation = snapshot?.animation ?? 'idle'\n const scaleRef = useRef(spriteScale)\n scaleRef.current = spriteScale\n useEffect(() => {\n if (props.visual !== undefined) return\n const reduceMotion = typeof window !== 'undefined'\n && window.matchMedia?.('(prefers-reduced-motion: reduce)')?.matches === true\n const sequence = animation === animationForPhase(phase) ? sequences?.[phase] : undefined\n const leadAnimation = sequence?.[0] ?? animation\n const row = rowOfTrack(leadAnimation)\n const track = trimTrack(tracks[leadAnimation], rows[row] ?? tracks[leadAnimation].frames.length)\n // Paint one static sprite frame up front either way, so the pet is never\n // blank while the loop heat-up runs.\n const leadCol = track.frames[0]!\n const lead = framePosition(cell, row, leadCol, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = lead.x + 'px ' + lead.y + 'px'\n }\n if (reduceMotion) return\n let raf = 0\n let last = performance.now()\n let sequenceElapsed = 0\n const tick = (ts: number): void => {\n const delta = ts - last\n last = ts\n if (sequence !== undefined) {\n sequenceElapsed += delta\n const current = sequenceFrameAt(sequence, tracks, sequenceElapsed)\n const currentRow = rowOfTrack(current.animation)\n const currentTrack = trimTrack(\n tracks[current.animation],\n rows[currentRow] ?? tracks[current.animation].frames.length,\n )\n const col = currentTrack.frames[current.frameIndex]!\n const pos = framePosition(cell, currentRow, col, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = pos.x + 'px ' + pos.y + 'px'\n }\n raf = requestAnimationFrame(tick)\n return\n }\n // row/track come from the effect scope: they were computed once above\n // and this effect re-runs when animation/tracks/rows change, so the\n // per-frame recompute (trimTrack slices fresh arrays) is pure waste.\n const st = frameRef.current\n if (st.track !== animation) {\n st.track = animation\n st.index = 0\n st.elapsed = 0\n }\n st.elapsed += delta\n const maxIndex = track.frames.length - 1\n while (st.elapsed >= (track.durations[st.index] ?? 0) && st.index < maxIndex) {\n st.elapsed -= track.durations[st.index] ?? 0\n st.index += 1\n }\n if (st.elapsed >= (track.durations[st.index] ?? 0)) {\n if (track.loop) {\n st.elapsed = 0\n st.index = 0\n } else {\n st.index = maxIndex // hold the final frame; the host switches tracks\n }\n }\n const col = track.frames[st.index]!\n const pos = framePosition(cell, row, col, scaleRef.current)\n if (spriteRef.current !== null) {\n spriteRef.current.style.backgroundPosition = pos.x + 'px ' + pos.y + 'px'\n }\n raf = requestAnimationFrame(tick)\n }\n raf = requestAnimationFrame(tick)\n return () => cancelAnimationFrame(raf)\n }, [animation, phase, cell, columns, rows, tracks, sequences, props.visual])\n\n // Auto-clear the feedback bubble after its CSS animation. The callback\n // rides a ref so re-renders never reset the timer: the 2s poll rebuilds\n // `props` every tick, and depending on it would starve the timeout.\n const feedbackDoneRef = useRef(props.onFeedbackDone)\n feedbackDoneRef.current = props.onFeedbackDone\n useEffect(() => {\n if (feedback === null) return\n const timer = window.setTimeout(() => feedbackDoneRef.current(), 2600)\n return () => window.clearTimeout(timer)\n }, [feedback])\n\n // Dragging: pointer events on the sprite; position is right/bottom based.\n // `draggedRef` records whether the pointer actually moved, so the browser's\n // trailing click (fired after pointerup) does not pet the sprite.\n const draggedRef = useRef(false)\n const clearHideTimer = (): void => {\n if (hideTimerRef.current !== null) {\n window.clearTimeout(hideTimerRef.current)\n hideTimerRef.current = null\n }\n }\n\n // Clear any pending auto-hide timer on unmount: a stray callback after\n // teardown reads window through react-dom and failed CI runs with\n // \"window is not defined\" (slow-runner timing, PetSprite.test.tsx).\n useEffect(() => () => clearHideTimer(), [])\n\n const onPointerDown = (e: ReactPointerEvent<HTMLDivElement>): void => {\n e.preventDefault()\n ;(e.target as HTMLElement).setPointerCapture?.(e.pointerId)\n const current = dragPos ?? { right: display.right, bottom: display.bottom }\n dragRef.current = { startX: e.clientX, startY: e.clientY, ...current }\n draggedRef.current = false\n setHovered(false)\n }\n const onPointerMove = (e: ReactPointerEvent<HTMLDivElement>): void => {\n const drag = dragRef.current\n if (drag === null) return\n const dx = e.clientX - drag.startX\n const dy = e.clientY - drag.startY\n if (Math.abs(dx) > 4 || Math.abs(dy) > 4) draggedRef.current = true\n const right = clampOffset(drag.right - dx, window.innerWidth - 40)\n const bottom = clampOffset(drag.bottom - dy, window.innerHeight - 40)\n setDragPos({ right, bottom })\n }\n const onPointerUp = (): void => {\n if (dragRef.current === null) return\n dragRef.current = null\n if (dragPos !== null) props.onDragEnd(dragPos.right, dragPos.bottom)\n }\n\n const pos = dragPos ?? { right: display.right, bottom: display.bottom }\n const spriteWidth = Math.round(cell.width * spriteScale)\n const spriteHeight = Math.round(cell.height * spriteScale)\n\n // Concurrent sessions share one bubble slot: only the display session\n // speaks by default, and the rest hide behind a '+N' badge until the stack\n // is hovered/pinned open. The legacy single 'bubble' is the fallback when\n // the host serves no per-session list. The hover panel normally sits below\n // the sprite, so the bubbles stay visible and clickable — no region swap.\n const sessionBubbles = snapshot?.sessions ?? []\n const stackOpen = stackPeek || stackPinned\n const collapsed = !stackOpen && sessionBubbles.length > 1\n const visibleSessions = collapsed ? sessionBubbles.slice(0, 1) : sessionBubbles\n const statusBubble = feedback === null && sessionBubbles.length === 0\n ? snapshot?.bubble\n : undefined\n // The display session's inner whisper (碎碎念) — short inner-voice copy\n // woken by the model's output. Instead of a second bubble of its own, a\n // fresh whisper takes over the display session's bubble (the stack top, or\n // the single status bubble) and re-tints it, so the pet never wears two\n // voices at once. Interaction feedback takes over the whole bubble area\n // while it plays, so whispers yield to it like status copy.\n const whisper = feedback === null ? snapshot?.whisper : undefined\n const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== undefined || whisper !== undefined\n const displayName = snapshot?.name ?? definition.displayName\n // The host-served status decoration (M5, #567); absent = text-only bubbles.\n const decoration = snapshot?.decoration\n\n // A settled session list can no longer stay pinned open.\n useEffect(() => {\n if (sessionBubbles.length <= 1) setStackPinned(false)\n }, [sessionBubbles.length])\n\n useLayoutEffect(() => {\n if (!hovered) {\n setPanelAbove(false)\n setPanelLift(0)\n return\n }\n const updatePanelPlacement = (): void => {\n const sprite = spriteRef.current\n const panel = panelRef.current\n if (sprite === null || panel === null) return\n const availableBelow = window.innerHeight - sprite.getBoundingClientRect().bottom\n const above = availableBelow < panel.getBoundingClientRect().height + 8\n setPanelAbove(above)\n // The fallback above-placement shares the sprite's top edge with the\n // bubble(s); lift the panel by the bubble area's height so the two\n // never overlap (8px base gap + 6px clearance above the top bubble).\n const bubbleHeight = above ? bubbleRef.current?.getBoundingClientRect().height ?? 0 : 0\n setPanelLift(bubbleHeight > 0 ? Math.ceil(bubbleHeight) + 14 : 0)\n }\n updatePanelPlacement()\n window.addEventListener('resize', updatePanelPlacement)\n return () => window.removeEventListener('resize', updatePanelPlacement)\n }, [hovered, renaming, pos.right, pos.bottom, display.size, bubblePresent, sessionBubbles.length, stackOpen, feedback])\n\n const float = (\n <div\n ref={floatRef}\n className={styles.float}\n style={{ right: pos.right, bottom: pos.bottom, zIndex: 2147483000 }}\n onPointerEnter={() => {\n clearHideTimer()\n setHovered(true)\n }}\n onPointerLeave={(e) => {\n // The panel renders OUTSIDE the container's box (absolute, below\n // the sprite), so moving onto it fires pointerleave on the container.\n // Treat a target still inside the container's DOM (the overflowed\n // panel) as \"still hovering\"; otherwise give the pointer a short\n // grace period to reach the panel across the gap below the sprite.\n // The bridge ('.panel::after') keeps the pointer inside the hit\n // area, and the grace period covers a slow mouse crossing the\n // remaining sliver.\n const next = e.relatedTarget\n if (next instanceof Node && floatRef.current?.contains(next)) return\n // Never auto-hide while the rename box is open: moving the pointer\n // onto an IME candidate window (an OS-level window outside the\n // webview) fires pointerleave, and unmounting the input mid-IME-\n // composition crashes some input methods / the renderer (#303).\n if (renaming) return\n clearHideTimer()\n hideTimerRef.current = window.setTimeout(() => setHovered(false), 300)\n }}\n >\n <div\n ref={spriteRef}\n className={styles.sprite}\n style={{\n width: spriteWidth,\n height: spriteHeight,\n ...(props.visual === undefined\n ? {\n backgroundImage: imageReady ? 'url(' + definition.atlasUrl + ')' : undefined,\n backgroundSize: (cell.width * columns * spriteScale) + 'px ' + (cell.height * (definition.atlasRows ?? rows.length) * spriteScale) + 'px',\n backgroundRepeat: 'no-repeat',\n backgroundPosition: '0 0',\n }\n : {}),\n cursor: dragRef.current === null ? 'grab' : 'grabbing',\n }}\n onPointerDown={onPointerDown}\n onPointerMove={onPointerMove}\n onPointerUp={onPointerUp}\n onClick={() => {\n // A pointer sequence that moved (dragged) still fires a trailing\n // click; skip the pet when that happened.\n if (draggedRef.current) return\n props.onPet()\n }}\n role=\"button\"\n aria-label={definition.displayName}\n >\n {props.visual}\n </div>\n {feedback !== null && (\n <div key={feedback.at} ref={bubbleRef} className={clsx(styles.bubble, feedback.kind === 'feed' ? styles.bubbleFeed : styles.bubblePet)}>\n {feedback.text}\n </div>\n )}\n {feedback === null && (sessionBubbles.length > 0 || statusBubble !== undefined || whisper !== undefined) && (\n <div\n ref={bubbleRef}\n className={styles.bubbleStack}\n onPointerEnter={() => setStackPeek(true)}\n onPointerLeave={() => setStackPeek(false)}\n >\n {visibleSessions.map((session, index) => {\n // The whisper rides the display session's bubble — the stack's\n // primary entry (DOM-first, rendered bottom-most by the reversed\n // column so it stays glued to the sprite when extras open above).\n // The key swap restarts the entrance animation so the mood change\n // reads as the bubble re-speaking.\n const speaksWhisper = index === 0 && whisper !== undefined\n const bubble = (\n <button\n key={speaksWhisper ? 'whisper:' + whisper : session.sessionId}\n type=\"button\"\n className={clsx(\n styles.bubble,\n styles.bubbleStatus,\n styles.bubbleClickable,\n speaksWhisper && styles.bubbleWhisper,\n )}\n title={props.t('pet.openSessionHint')}\n onClick={() => { props.onOpenSession(session.sessionId) }}\n >\n {index === 0 && !speaksWhisper && decoration !== undefined && (\n <StatusOrnament decoration={decoration} phase={phase} />\n )}\n {speaksWhisper ? whisper : session.bubble}\n </button>\n )\n // The primary bubble carries the '+N' badge while other sessions\n // hide behind it; the badge toggles the pinned (touch) expansion.\n if (index !== 0 || sessionBubbles.length <= 1) return bubble\n return (\n <span key=\"primary\" className={styles.bubbleAnchor}>\n {bubble}\n <button\n type=\"button\"\n className={styles.bubbleMore}\n title={stackOpen\n ? props.t('pet.collapseSessions')\n : props.t('pet.moreSessions', { n: sessionBubbles.length - 1 })}\n aria-label={stackOpen\n ? props.t('pet.collapseSessions')\n : props.t('pet.moreSessions', { n: sessionBubbles.length - 1 })}\n aria-expanded={stackOpen}\n onClick={(e) => {\n e.stopPropagation()\n setStackPinned(open => !open)\n }}\n >\n {stackOpen ? '×' : '+' + String(sessionBubbles.length - 1)}\n </button>\n </span>\n )\n })}\n {sessionBubbles.length === 0 && (statusBubble !== undefined || whisper !== undefined) && (\n // The key swap (status copy <-> whisper) restarts the entrance\n // animation on every mood change.\n <div\n key={whisper === undefined ? 'status' : 'whisper:' + whisper}\n className={clsx(styles.bubble, styles.bubbleStatus, whisper !== undefined && styles.bubbleWhisper)}\n role=\"status\"\n aria-live=\"polite\"\n >\n {whisper === undefined && decoration !== undefined && (\n <StatusOrnament decoration={decoration} phase={phase} />\n )}\n {whisper ?? statusBubble}\n </div>\n )}\n </div>\n )}\n {hovered && dragRef.current === null && (\n <div\n ref={panelRef}\n className={clsx(styles.panel, panelAbove && styles.panelAbove)}\n data-placement={panelAbove ? 'above' : 'below'}\n style={panelAbove && panelLift > 0\n ? ({ marginBottom: panelLift } as CSSProperties)\n : undefined}\n onPointerEnter={() => {\n // Reaching the panel (or its bridge) must cancel any hide timer\n // the container's pointerleave may have armed while the pointer\n // crossed the sliver between the sprite and the panel.\n clearHideTimer()\n }}\n >\n {renaming ? (\n <div className={styles.renameRow}>\n <input\n className={styles.nameInput}\n value={nameDraft}\n maxLength={20}\n placeholder={props.t('pet.namePlaceholder')}\n autoFocus\n onChange={(e) => setNameDraft(e.target.value)}\n onCompositionStart={() => { composingRef.current = true }}\n onCompositionEnd={() => { composingRef.current = false }}\n onKeyDown={(e) => {\n // While an IME composition is active (e.g. selecting a\n // Chinese candidate), Enter/Escape keydowns belong to the\n // input method: ignore them so candidate selection can\n // neither submit the draft nor close the rename box. The\n // explicit ref and the 'Process' key cover IMEs that mark\n // composition keydowns with isComposing === false (#303).\n if (composingRef.current || e.nativeEvent.isComposing || e.key === 'Process') return\n if (e.key === 'Enter') {\n const trimmed = nameDraft.trim()\n if (trimmed !== '') {\n props.onRename(trimmed)\n setRenaming(false)\n }\n } else if (e.key === 'Escape') {\n setRenaming(false)\n }\n }}\n />\n <button\n type=\"button\"\n className={styles.action}\n onClick={() => {\n const trimmed = nameDraft.trim()\n if (trimmed !== '') {\n props.onRename(trimmed)\n setRenaming(false)\n }\n }}\n >\n {panelLabel('confirm', props.t('pet.confirm'))}\n </button>\n </div>\n ) : (\n <>\n <div className={styles.rankRow}>\n <span className={styles.nameCell}>{displayName}</span>\n <span className={styles.statRank}>{panelStat('rank', 'pet.rank', { rank: snapshot?.affinity.rank ?? '?' })}</span>\n </div>\n <div className={styles.rankRow}>\n <span className={styles.statTreats}>{panelStat('treats', 'pet.treats', { n: snapshot?.treats.stocked ?? 0 })}</span>\n <span className={styles.statPoints}>{panelStat('points', 'pet.points', { points: snapshot?.affinity.points ?? 0 })}</span>\n </div>\n <div className={styles.actions}>\n {panelShows('feed') && (\n <button type=\"button\" className={styles.action} onClick={props.onFeed}>\n {panelLabel('feed', props.t('pet.feed'))}\n </button>\n )}\n {panelShows('rename') && (\n <button\n type=\"button\"\n className={styles.action}\n onClick={() => {\n // Cancel any pending hide so the rename box cannot\n // unmount right as the user starts typing (#303).\n clearHideTimer()\n setNameDraft(displayName)\n setRenaming(true)\n }}\n >\n {panelLabel('rename', props.t('pet.rename'))}\n </button>\n )}\n {panelShows('hide') && (\n <button type=\"button\" className={styles.action} onClick={props.onHide}>\n {panelLabel('hide', props.t('pet.hide'))}\n </button>\n )}\n </div>\n </>\n )}\n </div>\n )}\n </div>\n )\n\n return createPortal(float, document.body)\n}\n","/**\n * Renderer registry — dispatches a manifest's renderer kind to its\n * implementation (pet-center M2 P4, issue #623). Unknown kinds never blank\n * the pet: a fallback card names the problem and reports the kinds this\n * build actually supports.\n * @module @linxin666/dsh-pet/client/renderers/registry\n */\n\nimport type { PetRenderer, PetRendererContext, PetRendererHandle } from '../../contracts/renderer.ts'\n\n/** Renderer dispatch table. */\nexport class RendererRegistry {\n private readonly renderers = new Map<string, PetRenderer>()\n\n /** Register one renderer implementation (id wins on re-register). */\n register(renderer: PetRenderer): void {\n this.renderers.set(renderer.id, renderer)\n }\n\n /** Whether a renderer kind is available in this build. */\n has(id: string): boolean {\n return this.renderers.has(id)\n }\n\n /** The registered renderer kinds (for diagnostics). */\n kinds(): string[] {\n return [...this.renderers.keys()].sort()\n }\n\n /** Remove every registration (tests; the client index registers once). */\n clear(): void {\n this.renderers.clear()\n }\n\n /**\n * Mount a renderer for one activation. An unknown kind renders a clear\n * diagnostic card into the container instead of failing silently.\n */\n mount(kind: string, ctx: PetRendererContext, config: unknown): PetRendererHandle {\n const renderer = this.renderers.get(kind)\n if (renderer === undefined) {\n const note = document.createElement('div')\n note.dataset.dshPetRendererFallback = kind\n note.textContent = 'Pet renderer \"' + kind + '\" is not available in this build (supported: ' + this.kinds().join(', ') + ').'\n ctx.container.appendChild(note)\n ctx.onCleanup(() => note.remove())\n return { dispose: () => note.remove() }\n }\n return renderer.mount(ctx, renderer.validateConfig(config))\n }\n}\n\n/**\n * The plugin-wide renderer registry. The client entry registers the\n * built-in renderers at apply time; the renderer switch and the live2d\n * bridge dispatch through this instance.\n */\nexport const defaultPetRendererRegistry = new RendererRegistry()\n","/**\n * Phase stream — bridges the polled host snapshots onto the renderer\n * contract's { get, subscribe } shape (pet-center M2 P4, issue #623). The\n * existing poll loop pushes each snapshot's ActivityPhase; subscribers are\n * dispatched on CHANGE only (phase transitions are sparse — done/failed hold\n * a timed window before falling back to idle — and renderers like Live2D pay\n * per transition, not per tick).\n * @module @linxin666/dsh-pet/client/phase-stream\n */\n\nimport type { ActivityPhase } from '../state.ts'\n\n/** The renderer-facing phase stream. */\nexport interface PhaseStream {\n /** The latest pushed phase. */\n get(): ActivityPhase\n /** Subscribe to phase changes; returns the unsubscribe. */\n subscribe(listener: (phase: ActivityPhase) => void): () => void\n /** Feed a fresh snapshot phase; no-op when unchanged. */\n push(phase: ActivityPhase): void\n}\n\n/** Create the stream (one per pet entry lifetime, owned by the plugin body). */\nexport function createPhaseStream(initial: ActivityPhase = 'idle'): PhaseStream {\n let current = initial\n const listeners = new Set<(phase: ActivityPhase) => void>()\n return {\n get: () => current,\n subscribe(listener) {\n listeners.add(listener)\n return () => { listeners.delete(listener) }\n },\n push(phase) {\n if (phase === current) return\n current = phase\n for (const listener of [...listeners]) listener(phase)\n },\n }\n}\n","/**\n * Live2D visual mount (pet-center M3) — the React bridge between the pet\n * center chrome and the imperative live2d renderer. The bridge owns the\n * contract context (asset base, phase stream, interaction write-back,\n * activation cleanups), feeds the polled phase into the stream, forwards\n * sub-4px taps as hit-test coordinates, and renders the localized error\n * card when the renderer reports a fatal boot failure.\n * @module @linxin666/dsh-pet/client/renderers/live2d/Live2dVisualMount\n */\n\nimport { useEffect, useRef, useState, type ReactElement } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDefinition } from '../../../registry.ts'\nimport type { ActivityPhase } from '../../../state.ts'\nimport { createPhaseStream, type PhaseStream } from '../../phase-stream.ts'\nimport type { PetRendererContext } from '../../../contracts/renderer.ts'\nimport { defaultPetRendererRegistry } from '../registry.ts'\nimport type { Live2dErrorCode, Live2dRendererHandle } from '../live2d.ts'\nimport type { NS } from '../../locales.ts'\n\n/** Mount the live2d renderer as the sprite's visual (inside the chrome). */\nexport function Live2dVisualMount(props: {\n definition: PetDefinition\n phase: ActivityPhase\n onPet: () => void\n t: PropsLocale<typeof NS>['t']\n}): ReactElement {\n const containerRef = useRef<HTMLDivElement | null>(null)\n const streamRef = useRef<PhaseStream | null>(null)\n const handleRef = useRef<Live2dRendererHandle | null>(null)\n const downRef = useRef<{ x: number; y: number } | null>(null)\n const [error, setError] = useState<Live2dErrorCode | null>(null)\n\n // One activation per pet definition: build the contract context and mount.\n useEffect(() => {\n setError(null)\n const container = containerRef.current\n const live2d = props.definition.live2d\n if (container === null || live2d === undefined) return undefined\n streamRef.current ??= createPhaseStream(props.phase)\n const cleanups: (() => void)[] = []\n const ctx: PetRendererContext = {\n petId: props.definition.id,\n assetBase: '/pet/' + encodeURIComponent(props.definition.id),\n container,\n phase: streamRef.current,\n interact: props.onPet,\n onCleanup: (fn) => { cleanups.push(fn) },\n }\n let handle: Live2dRendererHandle\n try {\n handle = defaultPetRendererRegistry.mount('live2d', ctx, live2d) as Live2dRendererHandle\n } catch {\n setError('load-failed')\n return () => { for (const fn of cleanups.splice(0)) fn() }\n }\n handleRef.current = handle\n handle.onError?.(setError)\n return () => {\n handleRef.current = null\n for (const fn of cleanups.splice(0)) fn()\n handle.dispose()\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps -- one activation per pet identity\n }, [props.definition])\n\n // Feed the polled phase into the activation's stream (change-only).\n useEffect(() => {\n streamRef.current?.push(props.phase)\n }, [props.phase])\n\n return (\n <div\n ref={containerRef}\n data-dsh-pet-live2d={props.definition.id}\n style={{ width: '100%', height: '100%' }}\n onPointerDown={(e) => { downRef.current = { x: e.clientX, y: e.clientY } }}\n onPointerUp={(e) => {\n const down = downRef.current\n downRef.current = null\n if (down === null) return\n // A moved pointer is a drag (the chrome owns it), not a tap.\n if (Math.abs(e.clientX - down.x) > 4 || Math.abs(e.clientY - down.y) > 4) return\n const rect = e.currentTarget.getBoundingClientRect()\n handleRef.current?.tap(e.clientX - rect.left, e.clientY - rect.top)\n }}\n >\n {error !== null && (\n <span data-dsh-pet-live2d-error={error}>\n {error === 'core-missing'\n ? props.t('pet.live2d.core-missing')\n : error === 'vendor-missing'\n ? props.t('pet.live2d.vendor-missing')\n : props.t('pet.live2d.load-failed')}\n </span>\n )}\n </div>\n )\n}\n","/**\n * Renderer switch — the client dispatch seam of the pet center (issue #623,\n * milestone M2 P5 / M3). The pet's manifest picks the renderer: sprite2d\n * hands straight through to the sprite; live2d injects its visual INTO the\n * sprite chrome (the dock, bubbles and panel belong to the pet center, not\n * the renderer); a renderer this build cannot serve renders a clear\n * diagnostic card instead of blanking.\n * @module @linxin666/dsh-pet/client/renderers/PetRendererSwitch\n */\n\nimport { cloneElement, isValidElement, type ReactElement, type ReactNode } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDefinition } from '../../registry.ts'\nimport type { ActivityPhase } from '../../state.ts'\nimport type { PetSpriteProps } from '../PetSprite.tsx'\nimport { defaultPetRendererRegistry } from './registry.ts'\nimport { Live2dVisualMount } from './live2d/Live2dVisualMount.tsx'\nimport type { NS } from '../locales.ts'\n\n/** Dispatch one pet definition to its renderer; unknown kinds get a card. */\nexport function PetRendererSwitch(props: {\n definition: PetDefinition\n /** Current activity phase (fed to renderer visuals). */\n phase: ActivityPhase\n /** The chrome's pet interaction (affinity write-back owner). */\n onPet: () => void\n t: PropsLocale<typeof NS>['t']\n children?: ReactNode\n}): ReactElement {\n const renderer = props.definition.renderer ?? 'sprite2d'\n if (renderer === 'sprite2d') return <>{props.children}</>\n if (renderer === 'live2d' && defaultPetRendererRegistry.has('live2d') && isValidElement<PetSpriteProps>(props.children)) {\n const visual = (\n <Live2dVisualMount\n definition={props.definition}\n phase={props.phase}\n onPet={props.onPet}\n t={props.t}\n />\n )\n return cloneElement(props.children, { visual })\n }\n return (\n <span data-dsh-pet-renderer-fallback={renderer}>\n {props.t('pet.renderer.unavailable', { renderer })}\n </span>\n )\n}\n","/**\n * Global floating pet entry. The pet is host-global (its state, display and\n * interactions live on '/api/pet/*' endpoints with no session dimension), so\n * it must not ride a session-scoped slot — on the new-conversation screen no\n * session exists to scope a slot by, and the pet would vanish (issue #48).\n * The client half therefore mounts this entry straight onto 'document.body'\n * (see index.ts): while visible it renders the floating PetSprite (a\n * portal), while hidden it renders a fixed-position summon button. Which\n * sprite renders is decided by the host snapshot's pet id resolved against\n * the registry list — no per-pet component exists.\n * @module @linxin666/dsh-pet/client/PetDockEntry\n */\n\nimport { useEffect, useSyncExternalStore, type ReactElement } from 'react'\nimport type { PropsLocale } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetStoreInstance } from './pet-store.ts'\nimport { PetSprite } from './PetSprite.tsx'\nimport { PetRendererSwitch } from './renderers/PetRendererSwitch.tsx'\nimport { NS } from './locales.ts'\nimport styles from './pet.module.css'\n\n/** Injected actions handed to the dock entry component. */\nexport interface PetInjected {\n /** The app-wide pet store instance (snapshot + registry list + feedback). */\n store: PetStoreInstance\n /** Ensure the first snapshot (and registry list) is fetched (called on mount). */\n ensure: () => void\n /** Pet the sprite (click). */\n pet: () => void\n /** Feed the sprite. */\n feed: () => void\n /** Hide the sprite. */\n hide: () => void\n /** Summon the hidden sprite back. */\n summon: () => void\n /** Persist a drag position. */\n dragEnd: (right: number, bottom: number) => void\n /** Rename the selected pet (persisted by the host). */\n rename: (name: string) => void\n /** Navigate the GUI to the session a bubble reports on. */\n openSession: (sessionId: string) => void\n /** Clear the reaction bubble. */\n feedbackDone: () => void\n}\n\n/** Composed props of the global pet entry (locale + injected; no slot runtime share). */\nexport type PetDockEntryProps =\n PetInjected\n & PropsLocale<typeof NS>\n\nconst DEFAULT_DISPLAY: PetDisplayConfig = { visible: true, size: 160, right: 24, bottom: 20 }\n\n/**\n * Dock entry: while the pet is visible, mount the floating PetSprite (it\n * portals itself onto document.body); while hidden, render the summon\n * button so the pet can always come back. The store is the plugin-owned\n * single instance — the slot system provides none because the pet is\n * host-global, not session-scoped.\n */\nexport function PetDockEntry(props: PetDockEntryProps): ReactElement {\n const { store, ensure } = props\n const ui = useSyncExternalStore(store.subscribe, store.getSnapshot)\n const snapshot = ui.snapshot\n const feedback = ui.feedback\n const definition = ui.pets.find(entry => entry.id === snapshot?.pet.id) ?? null\n const visible = snapshot?.display.visible ?? true\n\n useEffect(() => {\n ensure()\n }, [ensure])\n\n if (visible) {\n return (\n <span data-pet-dock data-testid=\"pet-dock\">\n {snapshot === null || definition === null\n ? null\n : (\n <PetRendererSwitch\n definition={definition}\n phase={snapshot?.phase ?? 'idle'}\n onPet={props.pet}\n t={props.t}\n >\n <PetSprite\n snapshot={snapshot}\n definition={definition}\n display={snapshot.display}\n feedback={feedback}\n onPet={props.pet}\n onFeed={props.feed}\n onHide={props.hide}\n onDragEnd={props.dragEnd}\n onRename={props.rename}\n onOpenSession={props.openSession}\n onFeedbackDone={props.feedbackDone}\n t={props.t}\n />\n </PetRendererSwitch>\n )}\n </span>\n )\n }\n const display = snapshot?.display ?? DEFAULT_DISPLAY\n return (\n <button\n type=\"button\"\n className={styles.summon}\n style={{\n position: 'fixed',\n right: display.right,\n bottom: display.bottom,\n zIndex: 2147483000,\n }}\n onClick={props.summon}\n data-testid=\"pet-summon\"\n data-dsh-part=\"summon-button\"\n >\n {props.t('pet.summon', { name: snapshot?.name ?? '' })}\n </button>\n )\n}\n","/**\n * Renderer contract — the seam between the pet center and its renderers\n * (issue #623, milestone M2 P4). Renderers never see the DSH session, the\n * registry, or the network: they receive exactly three capabilities — an\n * asset base URL, the ActivityPhase stream, and the interaction write-back —\n * inside a center-owned container. Every mount is a fresh activation whose\n * cleanups must be idempotent.\n *\n * This contract only serves real consumers: sprite2d (existing) and live2d\n * (M3). Speculative capabilities join only when a renderer actually needs\n * them.\n * @module @linxin666/dsh-pet/contracts/renderer\n */\n\nimport type { ActivityPhase } from '../state.ts'\n\n/** Contract version renderers declare against (independent of the manifest). */\nexport const PET_RENDERER_API_VERSION = 'x-org.linxin666.pet-center/v1alpha1'\n\n/** What the pet center hands a renderer on mount. */\nexport interface PetRendererContext {\n /** The selected pet's id. */\n readonly petId: string\n /** Same-origin URL prefix of this pet's assets ('/pet/<id>'). */\n readonly assetBase: string\n /** Center-owned mount root; renderers must not attach to document.body. */\n readonly container: HTMLElement\n /** The ActivityPhase stream (pet-center owned; renderers subscribe). */\n readonly phase: {\n get(): ActivityPhase\n subscribe(listener: (phase: ActivityPhase) => void): () => void\n }\n /** The single interaction write-back into the affinity economy. */\n readonly interact: (kind: 'tap') => void\n /** Register an activation-scoped cleanup; run on dispose, idempotently. */\n onCleanup(fn: () => void): void\n}\n\n/** A mounted renderer activation. */\nexport interface PetRendererHandle {\n /** Tear the activation down; may be called 0/1/N times. */\n dispose(): void\n}\n\n/**\n * One renderer implementation. validateConfig is fail-closed over the\n * renderer-specific manifest block (schema v2 'sprite2d'/'live2d' blocks).\n */\nexport interface PetRenderer<Config = unknown> {\n readonly id: string\n readonly apiVersion: string\n validateConfig(config: unknown): Config\n mount(ctx: PetRendererContext, config: Config): PetRendererHandle\n}\n","/**\n * Live2D runtime loading (pet-center M3) — the two scripts a live2d mount\n * needs, fetched lazily through the plugin's own runtime route: the\n * user-supplied Cubism Core (proprietary; the plugin never bundles or\n * downloads it — issue #623 M1 §0) and the plugin-shipped MIT vendor bundle\n * (pixi.js + untitled-pixi-live2d-engine). Each loads at most once per page;\n * concurrent mounts share the in-flight promise, and a failure is cached as\n * 'absent' so a broken install stops retrying the network every mount.\n *\n * The vendor surface below is the structural slice the renderer consumes;\n * the real objects come from 'window.__dshPetLive2d' (lib/live2d-vendor.js),\n * so this module never imports pixi — the client bundle stays lean.\n * @module @linxin666/dsh-pet/client/renderers/live2d/runtime\n */\n\n/** Runtime file URLs the host serves ('/api/pet/runtime/<name>', M3-2). */\nconst CORE_URL = '/api/pet/runtime/live2dcubismcore.min.js'\nconst VENDOR_URL = '/api/pet/runtime/live2d-vendor.js'\n\n/** The pixi Application slice the renderer uses. */\nexport interface Live2dVendorApp {\n canvas: HTMLCanvasElement\n stage: { addChild(child: unknown): unknown }\n renderer: {\n readonly width: number\n readonly height: number\n resize(width: number, height: number): void\n }\n init(options: Record<string, unknown>): Promise<void>\n destroy(rendererOptions?: boolean | { removeView?: boolean; releaseGlobalResources?: boolean }, options?: Record<string, unknown>): void\n}\n\n/** The Live2DModel slice the renderer uses. */\nexport interface Live2dVendorModel {\n automator: { autoUpdate: boolean }\n anchor: { set(x: number, y?: number): void }\n position: { set(x: number, y: number): void }\n scale: { set(x: number, y?: number): void }\n readonly width: number\n readonly height: number\n internalModel: {\n settings: {\n motions?: Record<string, unknown[]>\n hitAreas?: readonly { Name?: string }[]\n }\n }\n motion(group: string, index?: number): Promise<unknown>\n expression(name?: string): unknown\n hitTest(x: number, y: number): string[]\n on(event: string, fn: () => void): unknown\n destroy(options?: { children?: boolean; texture?: boolean; baseTexture?: boolean }): void\n}\n\n/** The vendor bundle global (window.__dshPetLive2d). */\nexport interface Live2dVendor {\n Application: new () => Live2dVendorApp\n extensions: { add(...items: unknown[]): void }\n Live2DPlugin: unknown\n configureCubismSDK(options: Record<string, unknown>): void\n Live2DModel: { from(source: string, options?: Record<string, unknown>): Promise<Live2dVendorModel> }\n}\n\ndeclare global {\n interface Window {\n Live2DCubismCore?: unknown\n __dshPetLive2d?: Live2dVendor\n }\n}\n\n/** Injects one classic script tag; resolves on load, rejects on error. */\ntype ScriptInjector = (src: string) => Promise<void>\n\nconst defaultInjector: ScriptInjector = (src) => new Promise<void>((resolve, reject) => {\n const tag = document.createElement('script')\n tag.src = src\n tag.onload = () => resolve()\n tag.onerror = () => reject(new Error('script failed to load: ' + src))\n document.head.appendChild(tag)\n})\n\n/** Test seam: swap the network for a stub injector. */\nexport interface Live2dRuntimeProbe {\n inject?: ScriptInjector\n}\n\nlet corePromise: Promise<boolean> | undefined\nlet vendorPromise: Promise<Live2dVendor | undefined> | undefined\n\n/**\n * Ensure the Cubism Core global exists, injecting the runtime-route script\n * once when absent. Resolves false when the user has not installed the core\n * (a normal state — the renderer turns it into install guidance).\n */\nexport function ensureCubismCore(probe: Live2dRuntimeProbe = {}): Promise<boolean> {\n if (typeof window !== 'undefined' && window.Live2DCubismCore !== undefined) return Promise.resolve(true)\n if (probe.inject !== undefined) {\n return probe.inject(CORE_URL)\n .then(() => typeof window !== 'undefined' && window.Live2DCubismCore !== undefined)\n .catch(() => false)\n }\n corePromise ??= defaultInjector(CORE_URL)\n .then(() => typeof window !== 'undefined' && window.Live2DCubismCore !== undefined)\n .catch(() => false)\n return corePromise\n}\n\n/** Ensure the plugin vendor bundle global exists (same caching discipline). */\nexport function ensureLive2dVendor(probe: Live2dRuntimeProbe = {}): Promise<Live2dVendor | undefined> {\n if (typeof window !== 'undefined' && window.__dshPetLive2d !== undefined) return Promise.resolve(window.__dshPetLive2d)\n if (probe.inject !== undefined) {\n return probe.inject(VENDOR_URL)\n .then(() => typeof window !== 'undefined' ? window.__dshPetLive2d : undefined)\n .catch(() => undefined)\n }\n vendorPromise ??= defaultInjector(VENDOR_URL)\n .then(() => typeof window !== 'undefined' ? window.__dshPetLive2d : undefined)\n .catch(() => undefined)\n return vendorPromise\n}\n\n/** Reset the cached script promises (tests). */\nexport function resetLive2dRuntime(): void {\n corePromise = undefined\n vendorPromise = undefined\n}\n","/**\n * Live2D renderer (pet-center M3, issue #623) — mounts a Cubism model into\n * the center-owned container through the lazy vendor stack. The mount call\n * itself is synchronous per the renderer contract: the boot (core script →\n * vendor script → pixi → model) continues asynchronously and reports fatal\n * failures through the handle's error sink, so the React bridge can render\n * localized guidance. Disposing mid-boot is race-safe.\n *\n * Interaction model: the center chrome owns the affinity economy (its click\n * handler fires the pet interaction exactly like sprite2d); this renderer's\n * 'tap' affordance only drives the model's hit-area motion feedback. The\n * contract's interact write-back stays available for future standalone\n * mounts and is intentionally not invoked here.\n *\n * Motion mapping: manifests map ActivityPhases to motion GROUP names; every\n * unmapped phase (and any mapped-but-absent group) falls back to the idle\n * group — official sample models only ship Idle/TapBody, so the fallback is\n * mandatory. Groups with multiple motions pick a random entry, and a tap\n * that hits a declared hit area plays the conventional 'TapBody' group,\n * returning to the phase's group when the tap motion finishes.\n * @module @linxin666/dsh-pet/client/renderers/live2d\n */\n\nimport type { ActivityPhase } from '../../state.ts'\nimport {\n PET_RENDERER_API_VERSION,\n type PetRenderer,\n type PetRendererContext,\n type PetRendererHandle,\n} from '../../contracts/renderer.ts'\nimport {\n ensureCubismCore,\n ensureLive2dVendor,\n type Live2dVendor,\n type Live2dVendorApp,\n type Live2dVendorModel,\n} from './live2d/runtime.ts'\n\n/** Renderer config: the client-visible live2d block (fail-closed validated). */\nexport interface PetLive2dConfig {\n modelUrl: string\n scale?: number\n translate?: { x?: number; y?: number }\n motions: Partial<Record<ActivityPhase, string>> & { idle: string }\n expressions?: Partial<Record<ActivityPhase, string>>\n hitAreas?: string[]\n}\n\n/** Fatal mount failure codes the bridge localizes. */\nexport type Live2dErrorCode = 'core-missing' | 'vendor-missing' | 'load-failed'\n\n/** The live2d activation handle: contract dispose plus tap + error sink. */\nexport interface Live2dRendererHandle extends PetRendererHandle {\n /** Forward a chrome tap in container coordinates; plays the hit motion. */\n tap(x: number, y: number): void\n /** Subscribe to fatal mount errors (at most one fires per activation). */\n onError(listener: (code: Live2dErrorCode) => void): void\n}\n\n/** The de-facto tap-motion group of Cubism sample models. */\nconst TAP_GROUP = 'TapBody'\n\n/**\n * Keep one screen-appropriate atlas LOD instead of asking Pixi for the\n * engine's default full mip chain. A user model can legitimately carry an\n * 8192px texture while the pet itself is only a few hundred pixels tall;\n * `single-auto` preserves the source for larger renders and generates one\n * downsampled atlas only when the effective on-screen scale warrants it.\n */\nconst TEXTURE_OPTIONS = { lod: 'single-auto' } as const\n/** Recursively release the activation without invalidating shared texture caches. */\nconst DESTROY_OPTIONS = { children: true } as const\n/** Remove only this activation's canvas; `true` would release Pixi globals. */\nconst RENDERER_DESTROY_OPTIONS = { removeView: true } as const\n\ninterface Live2dModelSize {\n width: number\n height: number\n}\n\n/** Ignore hidden/zero boxes and keep Pixi dimensions stable and integral. */\nfunction normalizeRendererSize(width: number, height: number): Live2dModelSize | undefined {\n if (!Number.isFinite(width) || !Number.isFinite(height) || width <= 0 || height <= 0) return undefined\n return {\n width: Math.max(1, Math.round(width)),\n height: Math.max(1, Math.round(height)),\n }\n}\n\n/** Fit the model from its unscaled dimensions into the current Pixi screen. */\nfunction layoutModel(\n app: Live2dVendorApp,\n model: Live2dVendorModel,\n sourceSize: Live2dModelSize,\n config: PetLive2dConfig,\n): void {\n const fit = Math.min(\n app.renderer.width / sourceSize.width,\n app.renderer.height / sourceSize.height,\n ) * 0.92\n model.scale.set(fit * (config.scale ?? 1))\n model.anchor.set(0.5)\n model.position.set(\n app.renderer.width / 2 + (config.translate?.x ?? 0),\n app.renderer.height / 2 + (config.translate?.y ?? 0),\n )\n}\n\nlet vendorConfigured = false\n\n/** Configure pixi extensions + the Cubism SDK once per page. */\nfunction configureOnce(vendor: Live2dVendor): void {\n if (vendorConfigured) return\n vendorConfigured = true\n vendor.extensions.add(vendor.Live2DPlugin)\n vendor.configureCubismSDK({ memorySizeMB: 32 })\n}\n\n/** Reset module state (tests). */\nexport function resetLive2dRenderer(): void {\n vendorConfigured = false\n}\n\n/** Fail-closed config validation (contract: unknown manifest block in). */\nfunction validateLive2dConfig(config: unknown): PetLive2dConfig {\n if (typeof config !== 'object' || config === null) throw new Error('live2d config is not an object')\n const source = config as Record<string, unknown>\n if (typeof source.modelUrl !== 'string' || source.modelUrl === '') throw new Error('live2d config modelUrl is required')\n const motions = source.motions\n if (typeof motions !== 'object' || motions === null || typeof (motions as Record<string, unknown>).idle !== 'string') {\n throw new Error('live2d config motions.idle is required')\n }\n return config as PetLive2dConfig\n}\n\n/** The live2d renderer implementation. */\nexport const live2dRenderer: PetRenderer<PetLive2dConfig> = {\n id: 'live2d',\n apiVersion: PET_RENDERER_API_VERSION,\n validateConfig: validateLive2dConfig,\n mount(ctx: PetRendererContext, config: PetLive2dConfig): Live2dRendererHandle {\n let disposed = false\n let app: Live2dVendorApp | undefined\n let model: Live2dVendorModel | undefined\n let modelAttached = false\n let modelSourceSize: Live2dModelSize | undefined\n let resizeObserver: ResizeObserver | undefined\n let resizeTracking = false\n let errorListener: ((code: Live2dErrorCode) => void) | undefined\n let unsubscribe: (() => void) | undefined\n /** The motion group the current phase maps to (resume target after taps). */\n let phaseGroup: string = config.motions.idle\n let tapPlaying = false\n\n const stopResizeTracking = (): void => {\n resizeTracking = false\n resizeObserver?.disconnect()\n resizeObserver = undefined\n }\n\n const resizeRenderer = (pixiApp: Live2dVendorApp, width: number, height: number): void => {\n const next = normalizeRendererSize(width, height)\n if (disposed || !resizeTracking || next === undefined) return\n if (pixiApp.renderer.width === next.width && pixiApp.renderer.height === next.height) return\n pixiApp.renderer.resize(next.width, next.height)\n if (model !== undefined && modelSourceSize !== undefined) {\n layoutModel(pixiApp, model, modelSourceSize, config)\n }\n }\n\n const trackContainerSize = (pixiApp: Live2dVendorApp): void => {\n if (typeof ResizeObserver === 'undefined') return\n resizeTracking = true\n resizeObserver = new ResizeObserver((entries) => {\n const entry = entries.find(candidate => candidate.target === ctx.container)\n if (entry === undefined) return\n resizeRenderer(pixiApp, entry.contentRect.width, entry.contentRect.height)\n })\n resizeObserver.observe(ctx.container)\n // Catch a synchronous layout change between init() and observe().\n resizeRenderer(pixiApp, ctx.container.clientWidth, ctx.container.clientHeight)\n }\n\n /** Release every resource currently owned by this activation exactly once. */\n const destroyResources = (): void => {\n stopResizeTracking()\n unsubscribe?.()\n unsubscribe = undefined\n const currentApp = app\n const currentModel = model\n const modelOwnedByApp = currentApp !== undefined && modelAttached\n app = undefined\n model = undefined\n modelSourceSize = undefined\n modelAttached = false\n try {\n if (currentModel !== undefined && !modelOwnedByApp) currentModel.destroy(DESTROY_OPTIONS)\n } finally {\n currentApp?.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS)\n }\n }\n\n const playGroup = (group: string): void => {\n if (model === undefined) return\n const groups = model.internalModel.settings.motions ?? {}\n const count = Array.isArray(groups[group]) ? groups[group]!.length : 0\n if (count === 0) {\n // A mapped-but-absent group falls back to idle (never blank motion).\n if (group !== config.motions.idle) playGroup(config.motions.idle)\n return\n }\n const index = count > 1 ? Math.floor(Math.random() * count) : 0\n void model.motion(group, index)\n }\n\n const applyPhase = (phase: ActivityPhase): void => {\n phaseGroup = config.motions[phase] ?? config.motions.idle\n playGroup(phaseGroup)\n const expression = config.expressions?.[phase]\n if (expression !== undefined && model !== undefined) void model.expression(expression)\n }\n\n const boot = async (): Promise<void> => {\n if (!await ensureCubismCore()) {\n if (!disposed) errorListener?.('core-missing')\n return\n }\n const vendor = await ensureLive2dVendor()\n if (vendor === undefined) {\n if (!disposed) errorListener?.('vendor-missing')\n return\n }\n configureOnce(vendor)\n const pixiApp = new vendor.Application()\n const initialSize = normalizeRendererSize(ctx.container.clientWidth, ctx.container.clientHeight) ?? {\n width: 160,\n height: 174,\n }\n try {\n await pixiApp.init({\n width: initialSize.width,\n height: initialSize.height,\n backgroundAlpha: 0,\n antialias: true,\n autoDensity: true,\n preference: 'webgl',\n })\n } catch (error) {\n // init() can fail after allocating a partial renderer; cleanup is\n // best-effort because Pixi may not consider that partial app ready.\n try { pixiApp.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS) } catch {}\n throw error\n }\n if (disposed) {\n pixiApp.destroy(RENDERER_DESTROY_OPTIONS, DESTROY_OPTIONS)\n return\n }\n app = pixiApp\n pixiApp.canvas.style.display = 'block'\n pixiApp.canvas.style.width = '100%'\n pixiApp.canvas.style.height = '100%'\n ctx.container.appendChild(pixiApp.canvas)\n // Keep a model that rejects during setup off Ticker.shared; from()\n // does not expose that partial instance to callers for disposal.\n trackContainerSize(pixiApp)\n const loaded = await vendor.Live2DModel.from(config.modelUrl, {\n autoUpdate: false,\n autoHitTest: false,\n autoFocus: false,\n textureOptions: TEXTURE_OPTIONS,\n })\n model = loaded\n if (disposed) {\n destroyResources()\n return\n }\n modelSourceSize = {\n width: Math.max(1, loaded.width),\n height: Math.max(1, loaded.height),\n }\n // Auto-fit the model into the container; the manifest scale multiplies\n // the fit and translate offsets from the center anchor.\n layoutModel(pixiApp, loaded, modelSourceSize, config)\n pixiApp.stage.addChild(loaded)\n modelAttached = true\n loaded.automator.autoUpdate = true\n // Resume the phase group once a tap motion finishes playing.\n loaded.on('motionFinish', () => {\n if (tapPlaying) {\n tapPlaying = false\n playGroup(phaseGroup)\n }\n })\n applyPhase(ctx.phase.get())\n unsubscribe = ctx.phase.subscribe(applyPhase)\n }\n\n void boot().catch(() => {\n try {\n destroyResources()\n } finally {\n if (!disposed) errorListener?.('load-failed')\n }\n })\n\n return {\n dispose() {\n if (disposed) return\n disposed = true\n destroyResources()\n },\n tap(x: number, y: number) {\n const current = model\n if (disposed || current === undefined) return\n const hits = current.hitTest(x, y)\n const allowed = config.hitAreas\n const hit = allowed === undefined ? hits.length > 0 : hits.some(name => allowed.includes(name))\n if (!hit) return\n const groups = current.internalModel.settings.motions ?? {}\n const group = groups[TAP_GROUP]\n if (!Array.isArray(group) || group.length === 0) return\n tapPlaying = true\n const index = group.length > 1 ? Math.floor(Math.random() * group.length) : 0\n void current.motion(TAP_GROUP, index)\n },\n onError(listener: (code: Live2dErrorCode) => void) {\n errorListener = listener\n },\n }\n },\n}\n","/**\n * Cross-bundle-instance teardown slot for the page-global pet root\n * (issue #785).\n *\n * A client bundle swap (HMR rebuilt frame, plugin update, duplicate\n * injection) runs a new apply body while the previous instance's fiber\n * may still be draining. Module state does not survive the swap, so a\n * closure guard only sees one apply body and the previous instance's\n * container keeps sitting on document.body: the page shows two pets\n * until a full refresh. The slot rides globalThis (which does survive)\n * so a re-apply can find the previous instance and unmount its React\n * root cleanly before mounting its own; the previous fiber's later\n * disposal stays a no-op through the idempotent teardowns.\n */\n\nconst SLOT = Symbol.for('dsh-pet.client-ui-teardown')\n\ninterface TeardownSlot {\n [SLOT]?: (() => void) | undefined\n}\n\n/**\n * Claim the page-global pet UI slot with the current instance's teardown\n * (React root unmount + container removal + poll stop).\n * @param teardown - what a later instance runs to take the slot over.\n * @returns a disposer that clears the slot when the current instance's\n * UI is torn down (settings toggle, takeover, or fiber disposal).\n */\nexport function registerPetUiTeardown(teardown: () => void): () => void {\n const slot = globalThis as TeardownSlot\n slot[SLOT] = teardown\n return () => {\n if (slot[SLOT] === teardown) slot[SLOT] = undefined\n }\n}\n\n/**\n * Run the previous instance's teardown if one is registered, so the\n * re-applying instance becomes the sole owner of the page-global pet\n * root. No-op when the previous fiber already tore down cleanly.\n */\nexport function takeoverPetUiTeardown(): void {\n const slot = globalThis as TeardownSlot\n const teardown = slot[SLOT]\n slot[SLOT] = undefined\n teardown?.()\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/settings/PluginSettingsCard.tsx. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Family-shared chrome for plugin settings cards: a disclosure header naming\n * the plugin and what its settings govern, the controls inside, and the save\n * that writes them. Renders nothing while the namespace is unavailable — a\n * deployment that does not compose the owning plugin should show no trace of\n * it. Inlined into each consumer's client bundle; mirrors the official\n * ui-plugin-config PluginCard in a self-contained slice.\n */\n\nimport { useCallback, useEffect, useLayoutEffect, useRef, useState, type KeyboardEvent, type ReactNode } from 'react'\nimport type { CardShell } from './settings-form.ts'\nimport css from './settings-card.module.css'\n\n/** Copy keys the card chrome itself reads; every consumer locale carries this shared vocabulary. */\nexport const CARD_COPY_KEYS = [\n 'settings.collapse',\n 'settings.expand',\n 'settings.notExposed',\n 'settings.unsaved',\n 'settings.readOnly',\n 'settings.saveFailed',\n 'settings.discard',\n 'settings.save',\n 'settings.saving',\n] as const\n\n/** Copy key the card chrome itself reads. */\nexport type CardCopyKey = (typeof CARD_COPY_KEYS)[number]\n\n/** Key domain for the plugin's own copy (inferred per consumer). */\nexport type SettingsCardKey<TKey extends string = string> = TKey | CardCopyKey\n\n/** Card chrome shared by every plugin settings card. */\nexport interface PluginSettingsCardProps<TKey extends string = string> {\n /** Locale reader for this card's copy. */\n t: (key: SettingsCardKey<TKey>, params?: Record<string, string | number>) => string\n /** Locale key of the plugin's name. */\n titleKey: TKey\n /** Locale key of the line describing what this plugin's settings govern. */\n descriptionKey: TKey\n /** The card's form state: availability, writability, and what a save would do. */\n state: CardShell\n /** Write every staged edit. */\n onSave: () => void\n /** Drop every staged edit. */\n onDiscard: () => void\n /**\n * Render the controls expanded on arrival (still collapsible). Defaults to\n * true: promoted first-level sections show their settings immediately.\n */\n defaultOpen?: boolean\n /**\n * Render without the collapse affordance: a static header and an always\n * visible body. Used by first-level settings sections whose nav entry\n * already provides the selection.\n */\n alwaysOpen?: boolean\n /**\n * Hide the save/discard footer: cards whose body applies its own changes\n * immediately (an embedded external settings section) have no staged\n * edits, so the footer would sit there permanently disabled.\n */\n hideFooter?: boolean\n /** The plugin's controls. */\n children: ReactNode\n}\n\n/**\n * Render one plugin settings card.\n * @param props - the plugin's copy keys, its form state, and its controls.\n * @returns the card, or nothing while the namespace is still loading.\n */\nexport function PluginSettingsCard<TKey extends string = string>(props: PluginSettingsCardProps<TKey>) {\n const [open, setOpen] = useState(props.defaultOpen ?? true)\n const { state, alwaysOpen } = props\n if (!state.available) return null\n const title = props.t(props.titleKey)\n const description = props.t(props.descriptionKey)\n const blocked = !state.dirty || state.invalid || state.saving\n const expanded = alwaysOpen === true || open\n const cardClass = expanded ? `${css.cardOpen} ${css.card}` : css.card\n // With alwaysOpen the nav entry already provides the selection, so the\n // header is a static title row instead of a disclosure button.\n const header = alwaysOpen === true\n ? (\n <div className={css.headerStatic}>\n <span className={css.headText}>\n <span className={css.name} title={title}>{title}</span>\n <span className={css.description} title={description}>{description}</span>\n </span>\n {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}\n </div>\n )\n : (\n <button\n type=\"button\"\n className={css.header}\n aria-expanded={open}\n aria-label={`${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`}\n onClick={() => { setOpen(!open) }}\n >\n <span className={css.headText}>\n <span className={css.name} title={title}>{title}</span>\n <span className={css.description} title={description}>{description}</span>\n </span>\n {state.dirty ? <span className={css.pending} title={props.t('settings.unsaved')}>{props.t('settings.unsaved')}</span> : null}\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={open ? `${css.chevron} ${css.chevronOpen}` : css.chevron}\n >\n <path\n d=\"M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n )\n // The namespace exists but the Host does not serve it to this client (the\n // official settings allowlist omits third-party namespaces): show a card\n // that explains the gap instead of vanishing, so a missing card never\n // reads as a missing plugin.\n if (!state.exposed) {\n return (\n <li className={cardClass}>\n {header}\n {expanded\n ? (\n <div className={css.body}>\n <p className={css.notExposed} role=\"status\">{props.t('settings.notExposed')}</p>\n </div>\n )\n : null}\n </li>\n )\n }\n return (\n <li className={cardClass}>\n {header}\n {expanded\n ? (\n <div className={css.body}>\n {!state.writable ? <p className={css.readOnly} role=\"status\">{props.t('settings.readOnly')}</p> : null}\n {props.children}\n {props.hideFooter === true\n ? null\n : (\n <div className={css.footer}>\n {state.failed\n ? (\n <p className={css.failed} role=\"status\">\n {props.t('settings.saveFailed')}{state.failedReason ? ' - ' + state.failedReason : ''}\n </p>\n )\n : null}\n <button\n type=\"button\"\n className={css.discard}\n disabled={!state.dirty || state.saving}\n onClick={props.onDiscard}\n >\n {props.t('settings.discard')}\n </button>\n <button\n type=\"button\"\n className={css.save}\n disabled={blocked}\n onClick={props.onSave}\n >\n {props.t(!state.saving ? 'settings.save' : 'settings.saving')}\n </button>\n </div>\n )}\n </div>\n )\n : null}\n </li>\n )\n}\n\n/** Props every field control needs regardless of its value type. */\nexport interface FieldProps {\n /** Stable id associating the label with its control. */\n id: string\n /** Visible label. */\n label: string\n /** One-line explanation rendered under the control. */\n hint: string\n /** Draft text this control renders. */\n text: string\n /** True when saving would leave a user-layer entry for this field. */\n overridden: boolean\n /** True when the draft is not a value this field accepts. */\n invalid: boolean\n /** Copy for the overridden badge. */\n overriddenLabel: string\n /** Copy for the reset control. */\n resetLabel: string\n /** Copy shown in place of the hint while the draft is invalid. */\n invalidLabel: string\n /** Disables every control (read-only document, or an unavailable namespace). */\n disabled: boolean\n /** Stage draft text. */\n onEdit: (text: string) => void\n /** Stage a clear so the field re-inherits the composition layer. */\n onReset: () => void\n}\n\n/** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */\nexport function ValueField(props: FieldProps & {\n /** Hints a numeric keypad without narrowing what the control accepts. */\n numeric?: boolean\n /** Placeholder shown while the draft is empty. */\n placeholder?: string\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <input\n id={props.id}\n className={props.invalid ? css.inputInvalid : css.input}\n type=\"text\"\n {...props.numeric === true ? { inputMode: 'numeric' as const } : {}}\n {...props.invalid ? { 'aria-invalid': true } : {}}\n value={props.text}\n placeholder={props.placeholder ?? ''}\n disabled={props.disabled}\n onChange={(event) => { props.onEdit(event.target.value) }}\n />\n <p className={props.invalid ? css.invalid : css.hint}>\n {props.invalid ? props.invalidLabel : props.hint}\n </p>\n </div>\n )\n}\n\nconst NON_SKIN_BODY_MARKERS = new Set(['dshSkinCenter', 'dshSidebarCollapsed'])\n// 检测使用使用皮肤,用了皮肤退回原生select样式,防止样式冲突。默认外观下使用优化后的select样式。\nfunction isSkinActive(): boolean {\n const datasetList = Object.keys(document.body.dataset)\n const isActive = datasetList.some(key => key.startsWith('dsh') && !NON_SKIN_BODY_MARKERS.has(key))\n return isActive\n}\n\ninterface SelectOption {\n value: string\n label: string\n}\n\nconst SELECT_CLOSE_MS = 100\n\n/**\n * The shared dual-mode select control. While an appearance skin is active it\n * renders the legacy native `<select>` untouched, so element-level skin\n * selectors keep working; under the default appearance it renders a\n * self-drawn `role=\"listbox\"` popup whose open/close is transition-animated.\n * Staged cards reach it through BooleanField/ChoiceField; immediate-apply\n * editors (the side-card prefs) bind it directly through onEdit.\n * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。\n */\nexport function SelectField(props: {\n id: string\n options: ReadonlyArray<SelectOption>\n value: string\n disabled: boolean\n invalid: boolean\n onEdit: (text: string) => void\n}) {\n const { id, options, value } = props\n const [open, setOpen] = useState(false)\n const [closing, setClosing] = useState(false)\n const [phase, setPhase] = useState<'initial' | 'open'>('initial')\n const [activeIndex, setActiveIndex] = useState(0)\n const closeTimer = useRef<ReturnType<typeof setTimeout> | undefined>(undefined)\n const wrapRef = useRef<HTMLDivElement | null>(null)\n const popupRef = useRef<HTMLDivElement | null>(null)\n\n const currentIndex = () => {\n const index = options.findIndex(option => option.value === value)\n return index >= 0 ? index : 0\n }\n\n const close = useCallback(() => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n setClosing(true)\n closeTimer.current = setTimeout(() => {\n setClosing(false)\n setOpen(false)\n }, SELECT_CLOSE_MS)\n }, [])\n\n const openPopup = () => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n setActiveIndex(currentIndex())\n setPhase('initial')\n setClosing(false)\n setOpen(true)\n }\n\n const commit = (index: number) => {\n const option = options[index]\n if (option) props.onEdit(option.value)\n close()\n }\n\n const onTriggerClick = () => {\n if (props.disabled) return\n if (open && !closing) close()\n else openPopup()\n }\n\n const onKeyDown = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (props.disabled) return\n const count = options.length\n switch (event.key) {\n case 'ArrowDown':\n case 'ArrowUp':\n case 'Enter':\n case ' ':\n event.preventDefault()\n if (!open) {\n openPopup()\n } else if (!closing) {\n if (event.key === 'ArrowDown') setActiveIndex(index => (index + 1) % count)\n else if (event.key === 'ArrowUp') setActiveIndex(index => (index - 1 + count) % count)\n else commit(activeIndex)\n }\n break\n case 'Escape':\n if (open) {\n event.preventDefault()\n event.stopPropagation()\n close()\n }\n break\n case 'Tab':\n if (open) close()\n break\n }\n }\n\n useEffect(() => () => {\n if (closeTimer.current !== undefined) clearTimeout(closeTimer.current)\n }, [])\n useLayoutEffect(() => {\n if (open && !closing && phase === 'initial') {\n void popupRef.current?.offsetHeight\n setPhase('open')\n }\n }, [open, closing, phase])\n\n useEffect(() => {\n if (!open) return\n const onPointerDown = (event: PointerEvent) => {\n const target = event.target\n if (target instanceof Node && !wrapRef.current?.contains(target)) close()\n }\n document.addEventListener('pointerdown', onPointerDown)\n return () => document.removeEventListener('pointerdown', onPointerDown)\n }, [open, close])\n\n useEffect(() => {\n if (props.disabled && open) close()\n }, [props.disabled, open, close])\n\n // 使用了皮肤则退回原生select样式防止样式冲突。\n if (isSkinActive()) {\n return (\n <select\n id={id}\n className={css.select}\n value={value}\n disabled={props.disabled}\n onChange={(event) => { props.onEdit(event.target.value) }}\n >\n {options.map(option => (\n <option key={option.value} value={option.value}>{option.label}</option>\n ))}\n </select>\n )\n }\n\n const label = options.find(option => option.value === value)?.label ?? ''\n const popupClass = closing\n ? `${css.selectPopup} ${css.selectPopupClose}`\n : phase === 'open'\n ? `${css.selectPopup} ${css.selectPopupOpen}`\n : css.selectPopup\n return (\n <div className={css.selectWrap} ref={wrapRef}>\n <button\n type=\"button\"\n id={id}\n className={`${css.select} ${css.selectButton}`}\n disabled={props.disabled}\n aria-haspopup=\"listbox\"\n aria-expanded={open}\n aria-activedescendant={open ? `${id}-o${activeIndex}` : undefined}\n aria-invalid={props.invalid || undefined}\n onClick={onTriggerClick}\n onKeyDown={onKeyDown}\n >\n <span className={css.selectLabel}>{label}</span>\n <svg\n width=\"14\"\n height=\"14\"\n viewBox=\"0 0 14 14\"\n fill=\"none\"\n xmlns=\"http://www.w3.org/2000/svg\"\n className={open ? `${css.selectChevron} ${css.selectChevronOpen}` : css.selectChevron}\n aria-hidden=\"true\"\n >\n <path\n d=\"M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z\"\n fill=\"currentColor\"\n />\n </svg>\n </button>\n {open\n ? (\n <div className={popupClass} role=\"listbox\" ref={popupRef}>\n {options.map((option, index) => (\n <div\n key={option.value}\n id={`${id}-o${index}`}\n role=\"option\"\n aria-selected={option.value === value}\n className={`${css.selectOption}${option.value === value ? ` ${css.selectOptionSelected}` : ''}${index === activeIndex && !closing ? ` ${css.selectOptionActive}` : ''}`}\n onClick={() => { commit(index) }}\n >\n {option.label}\n </div>\n ))}\n </div>\n )\n : null}\n </div>\n )\n}\n\n/** A staged boolean field: 继承 / 开 / 关. */\nexport function BooleanField(props: FieldProps & {\n /** Copy for the inherit option. */\n inheritLabel: string\n /** Copy for the on option. */\n onLabel: string\n /** Copy for the off option. */\n offLabel: string\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <SelectField\n id={props.id}\n options={[\n { value: '', label: props.inheritLabel },\n { value: 'true', label: props.onLabel },\n { value: 'false', label: props.offLabel },\n ]}\n value={props.text}\n disabled={props.disabled}\n invalid={props.invalid}\n onEdit={props.onEdit}\n />\n <p className={css.hint}>{props.hint}</p>\n </div>\n )\n}\n\n/** A staged enumerated field rendered as a select. */\nexport function ChoiceField(props: FieldProps & {\n /** Copy for the inherit option (draft text is the empty string). */\n inheritLabel: string\n /** Choices rendered in order; `value` is the draft/stored text. */\n choices: ReadonlyArray<{ value: string; label: string }>\n}) {\n return (\n <div className={css.field}>\n <div className={css.head}>\n <label className={css.label} htmlFor={props.id}>{props.label}</label>\n {props.overridden\n ? (\n <span className={css.badges}>\n <span className={css.badge}>{props.overriddenLabel}</span>\n <button\n type=\"button\"\n className={css.reset}\n disabled={props.disabled}\n onClick={props.onReset}\n >\n {props.resetLabel}\n </button>\n </span>\n )\n : null}\n </div>\n <SelectField\n id={props.id}\n options={[{ value: '', label: props.inheritLabel }, ...props.choices]}\n value={props.text}\n disabled={props.disabled}\n invalid={props.invalid}\n onEdit={props.onEdit}\n />\n <p className={props.invalid ? css.invalid : css.hint}>\n {props.invalid ? props.invalidLabel : props.hint}\n </p>\n </div>\n )\n}\n","// Generated by scripts/sync-shared.mjs from shared/client/settings/settings-form.ts. Do not edit this copy; edit the shared source and run \"node scripts/sync-shared.mjs\".\n/**\n * Staged form model behind the plugin settings card. A card stages what the\n * user types and writes it only when they save — the settings write is a\n * durable, revision-fenced document mutation, so staging keeps what is on\n * screen exactly what a save would store. Family-shared slice inlined into\n * each plugin's client bundle; mirrors the official ui-plugin-config\n * card-store pattern.\n */\n\nimport type { SettingsScope, SettingsScopeSnapshot, SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\nimport { createSnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\n\n/** The write one field's staged text performs when the card is saved. */\nexport type FieldWrite =\n | { kind: 'set'; value: unknown }\n | { kind: 'clear' }\n\n/** How one field converts between its stored value and its draft text. */\nexport interface FieldSpec {\n /** Field name inside the namespace section. */\n field: string\n /**\n * Whether the Host treats this field as a secret and redacts its value from\n * the read-back (role('secret') in the section schema). Redacted secrets are\n * never compared against the draft on save; the field lands when the scope\n * reports the write succeeded (its secret-set marker under the bridge), so\n * a successful secret save is not misreported as failed.\n */\n secret?: boolean\n /** Render a stored value as draft text; the empty string when the section carries none. */\n format: (value: unknown) => string\n /**\n * The write this draft text stages, or undefined when the text is not a\n * value this field accepts — which blocks the save rather than discarding it.\n */\n parse: (text: string) => FieldWrite | undefined\n}\n\n/** One field as the card renders it. */\nexport interface FieldState {\n /** Draft text the control renders. */\n text: string\n /** Whether saving would leave a user-layer entry for this field. */\n overridden: boolean\n /** Whether the draft is not a value this field accepts, which blocks saving. */\n invalid: boolean\n}\n\n/** Form state every plugin settings card shares. */\nexport interface CardShell {\n /** False while the namespace is still loading; the card renders nothing. */\n available: boolean\n /**\n * Whether the namespace is actually served to this client. False when the\n * Host deployment does not expose it (e.g. the official apiproxy settings\n * allowlist omits third-party namespaces): the card renders an explanation\n * instead of its form, so a missing namespace never looks like a missing\n * plugin.\n */\n exposed: boolean\n /** Whether the Host document accepts writes. */\n writable: boolean\n /** Whether the form holds edits that a save would write. */\n dirty: boolean\n /** Whether any staged draft is invalid, which blocks the save. */\n invalid: boolean\n /** Whether a save is crossing the wire. */\n saving: boolean\n /** Whether the last save did not land as staged; cleared by the next edit or save. */\n failed: boolean\n /**\n * The rejection code/message the Host returned for the last failed save,\n * surfaced next to the generic failure text. Undefined while no save has\n * failed (or the failure carried no server reason).\n */\n failedReason?: string\n}\n\n/** The write actions the card's slot entry injects. */\nexport interface CardActions {\n /** Stage draft text for one field. */\n edit: (field: string, text: string) => void\n /** Stage a clear, so saving lets the field re-inherit the composition layer. */\n resetField: (field: string) => void\n /** Write every staged edit, then re-seed from what the Host accepted. */\n save: () => void\n /** Drop every staged edit. */\n discard: () => void\n}\n\n/** One field's staged edit. */\ninterface StagedEdit {\n /** Draft text the control renders. */\n text: string\n /** True when this edit clears the field whatever text it shows. */\n clear: boolean\n}\n\n/** One staged edit resolved into the write a save performs. */\ninterface PlannedWrite {\n /** Field this entry writes. */\n field: string\n /** The durable write this entry performs, described for a batched scope. */\n op: BatchedWrite\n /** Perform the write and report whether the Host holds the staged value afterwards. */\n run: (() => Promise<boolean>) | undefined\n}\n\n/** One durable write a batched settings scope performs. */\nexport interface BatchedWrite {\n /** Field this entry writes. */\n field: string\n /** set stores a value; unset drops the leaf. */\n op: 'set' | 'unset'\n /** Value for op set (absent for unset). */\n value?: unknown\n}\n\n/** Per-field outcome of one batched scope write. */\nexport interface BatchedFieldResult {\n /** Field this entry writes. */\n field: string\n /** Whether the Host accepted this field's write (per the read-back view). */\n landed: boolean\n}\n\n/**\n * Result of a batched scope write. The bridge scope posts every planned write\n * in one /mutate so the Host validate hook judges baseURL+model together; a\n * batched refusal fails the whole save rather than per-field.\n */\nexport interface BatchResult {\n /** Whether the whole mutate was accepted. */\n ok: boolean\n /** Per-field success, in the request order (always present when ok). */\n fields: BatchedFieldResult[]\n /** Host rejection code (mutate refused). */\n code?: string\n /** Host rejection message (mutate refused). */\n message?: string\n}\n\n/** The optional batch surface the bridge scope adds over the SettingsScope contract. */\ninterface BatchedSettingsScope {\n /** Write every operation in one scope mutation, reporting per-field success. */\n mutate: (writes: BatchedWrite[]) => Promise<BatchResult>\n}\n\n/** Constraints a numeric field's accepted drafts must satisfy, mirroring the host schema. */\nexport interface NumberConstraints {\n /** The accepted value must be a whole number. */\n integer?: boolean\n /** The accepted value must be at least this. */\n min?: number\n}\n\n/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */\nexport function numberField(field: string, constraints: NumberConstraints = {}): FieldSpec {\n const { integer = false, min } = constraints\n return {\n field,\n format: value => typeof value === 'number' ? String(value) : '',\n parse: (text) => {\n const trimmed = text.trim()\n if (trimmed === '') return { kind: 'clear' }\n const parsed = Number(trimmed)\n if (!Number.isFinite(parsed)) return undefined\n if (integer && !Number.isInteger(parsed)) return undefined\n if (min !== undefined && parsed < min) return undefined\n return { kind: 'set', value: parsed }\n },\n }\n}\n\n/** A free-text field. An empty draft clears the field. */\nexport function textField(field: string): FieldSpec {\n return {\n field,\n format: value => typeof value === 'string' ? value : '',\n parse: (text) => {\n const trimmed = text.trim()\n return trimmed === '' ? { kind: 'clear' } : { kind: 'set', value: trimmed }\n },\n }\n}\n\n/**\n * A free-text field the Host treats as a secret and redacts from the read-back\n * (role('secret') in the section schema). The card still edits it like text,\n * but a save never compares the redacted value back and relies on the scope\n * reporting the write landed.\n */\nexport function secretField(field: string): FieldSpec {\n return { ...textField(field), secret: true }\n}\n\n/** A boolean field, edited through true/false draft text. */\nexport function booleanField(field: string): FieldSpec {\n return {\n field,\n format: value => typeof value === 'boolean' ? String(value) : '',\n parse: (text) => {\n const trimmed = text.trim()\n if (trimmed === '') return { kind: 'clear' }\n if (trimmed === 'true') return { kind: 'set', value: true }\n if (trimmed === 'false') return { kind: 'set', value: false }\n return undefined\n },\n }\n}\n\n/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */\nexport function choiceField(field: string, choices: readonly string[]): FieldSpec {\n return {\n field,\n format: value => typeof value === 'string' && choices.includes(value) ? value : '',\n parse: (text) => {\n if (text === '') return { kind: 'clear' }\n return choices.includes(text) ? { kind: 'set', value: text } : undefined\n },\n }\n}\n\n/**\n * Stages one card's edits over one settings namespace and writes them on save.\n *\n * The Host is the only authority on whether a value was accepted — its\n * validators own the constraints no schema can express — so the outcome is\n * read back from the section rather than predicted here. A save that did not\n * land keeps its drafts, so the user can correct them instead of retyping.\n */\nexport class CardForm<T> {\n private readonly specs: Map<string, FieldSpec>\n private readonly staged = new Map<string, StagedEdit>()\n private readonly listeners = new Set<() => void>()\n /** The scope subscription installed in the constructor; released by dispose(). */\n private readonly disposeScope: () => void\n private disposed = false\n private saving = false\n private failed = false\n private failedReason: string | undefined\n\n /** @param scope - the bound settings scope for this card's namespace. */\n constructor(\n private readonly scope: SettingsScope<T>,\n specs: FieldSpec[],\n ) {\n this.specs = new Map(specs.map(spec => [spec.field, spec]))\n this.disposeScope = scope.subscribe(() => { this.publish() })\n }\n\n /**\n * Release the scope subscription and every bound store listener. The card\n * must call this on teardown; later calls are no-ops.\n */\n dispose(): void {\n if (this.disposed) return\n this.disposed = true\n this.disposeScope()\n this.listeners.clear()\n }\n\n /** Publish a projection of this form, rebuilt whenever the scope or a draft changes. */\n bind<S>(project: () => S): SnapshotStore<S> {\n const store = createSnapshotStore(project())\n this.listeners.add(() => { store.set(project()) })\n return store\n }\n\n /** Read the card-level state: what the Host serves, and what a save would do. */\n shell(): CardShell {\n const snapshot = this.scope.getSnapshot()\n const plan = this.plan()\n return {\n available: snapshot.status !== 'loading',\n exposed: snapshot.status === 'ready',\n writable: snapshot.writable,\n dirty: plan.length > 0,\n invalid: plan.some(item => item.run === undefined),\n saving: this.saving,\n failed: this.failed,\n ...this.failedReason === undefined ? {} : { failedReason: this.failedReason },\n }\n }\n\n /** Read one field's state from the effective section and its staged draft. */\n field(field: string): FieldState {\n const spec = this.specOf(field)\n const staged = this.staged.get(field)\n if (staged === undefined) {\n return { text: spec.format(this.sectionValue(field)), overridden: this.stored(field), invalid: false }\n }\n const write = staged.clear ? { kind: 'clear' as const } : spec.parse(staged.text)\n return {\n text: staged.text,\n overridden: write?.kind === 'set',\n invalid: write === undefined,\n }\n }\n\n /** The actions the card's slot registration injects. */\n actions(): CardActions {\n return {\n edit: (field, text) => { this.stage(field, { text, clear: false }) },\n resetField: (field) => {\n this.stage(field, { text: this.specOf(field).format(this.baseValue(field)), clear: true })\n },\n save: () => { void this.save() },\n discard: () => {\n if (this.staged.size === 0 && !this.failed) return\n this.staged.clear()\n this.failed = false\n this.failedReason = undefined\n this.publish()\n },\n }\n }\n\n /**\n * Write every staged edit, then re-seed from what the Host accepted.\n *\n * When the scope carries the optional batch surface (the dsh-web-ui\n * bridge scope), every planned write rides one mutation so cross-field\n * validate hooks (baseURL+model) judge the batch as a unit instead of\n * deadlocking on per-field writes. Otherwise the per-field loop runs.\n * A field lands only when the Host reports it held the staged value; a\n * landed field's draft is dropped, a failed one stays staged for the user.\n * @returns settlement after every write and the read-back.\n */\n async save(): Promise<void> {\n const plan = this.plan()\n const valid = plan.filter(item => item.run !== undefined)\n if (plan.length === 0 || this.saving || valid.length !== plan.length) return\n const plannedWrites = valid.map(item => item.op)\n // Snapshot the staged entries this save writes, so an edit staged while it\n // is in flight (which replaces the same key) survives: only delete the key\n // when the entry is still the one this save started from.\n const pending = new Map<string, StagedEdit | undefined>()\n for (const item of plan) pending.set(item.field, this.staged.get(item.field))\n this.saving = true\n this.failed = false\n this.failedReason = undefined\n this.publish()\n const landed = new Set<string>()\n const batch = this.batchedScope()\n if (batch !== undefined) {\n const result = await batch.mutate(plannedWrites)\n if (result.ok) {\n for (const field of result.fields) {\n if (field.landed) landed.add(field.field)\n }\n } else {\n this.failedReason = result.message\n }\n } else {\n for (const item of valid) {\n if (await item.run!()) landed.add(item.field)\n }\n }\n for (const [field, before] of pending) {\n if (landed.has(field) && this.staged.get(field) === before) this.staged.delete(field)\n }\n this.saving = false\n this.failed = landed.size !== pending.size\n this.publish()\n }\n\n /** The scope's batch surface when it supports one; undefined conservatively otherwise. */\n private batchedScope(): BatchedSettingsScope | undefined {\n const candidate = this.scope as unknown as BatchedSettingsScope | undefined\n return typeof candidate?.mutate === 'function' ? candidate : undefined\n }\n\n /**\n * Every staged edit a save would write. An entry whose draft is not a value\n * its field accepts carries no write: the form is still dirty, and the save\n * refuses rather than dropping the edit. A staged edit that matches the\n * effective section is not a write at all.\n * @returns the planned writes, in the order the fields were staged.\n */\n private plan(): PlannedWrite[] {\n const plan: PlannedWrite[] = []\n for (const [field, staged] of this.staged) {\n const spec = this.specOf(field)\n if (staged.clear) {\n if (this.stored(field)) plan.push({ field, op: { field, op: 'unset' }, run: () => this.clear(field) })\n continue\n }\n if (staged.text === spec.format(this.sectionValue(field))) continue\n const write = spec.parse(staged.text)\n if (write === undefined) plan.push({ field, op: { field, op: 'unset' }, run: undefined })\n else if (write.kind === 'clear') plan.push({ field, op: { field, op: 'unset' }, run: () => this.clear(field) })\n else plan.push({ field, op: { field, op: 'set', value: write.value }, run: () => this.store(field, write.value) })\n }\n return plan\n }\n\n private async clear(field: string): Promise<boolean> {\n await this.scope.unset(field)\n return !this.stored(field)\n }\n\n private async store(field: string, value: unknown): Promise<boolean> {\n await this.scope.set(field, value)\n // A redacted secret never appears in the user layer read-back; judging it\n // by value would misreport a successful secret save as failed. The bridge\n // reports secret writes through its secret-set markers (batch path); on\n // the per-field path the scope resolved, so the write is landed.\n if (this.specOf(field).secret) return true\n return this.userLayer()?.[field] === value\n }\n\n private stage(field: string, edit: StagedEdit): void {\n this.staged.set(field, edit)\n this.failed = false\n this.failedReason = undefined\n this.publish()\n }\n\n private specOf(field: string): FieldSpec {\n const spec = this.specs.get(field)\n // Every call site names a field this card declared; a missing one is a\n // wiring mistake that must not degrade into a silently inert control.\n if (spec === undefined) throw new Error(`settings card has no field ${field}`)\n return spec\n }\n\n private snapshotOf(): SettingsScopeSnapshot<T> {\n return this.scope.getSnapshot()\n }\n\n private sectionValue(field: string): unknown {\n return (this.snapshotOf().value as Record<string, unknown> | undefined)?.[field]\n }\n\n private baseValue(field: string): unknown {\n return (this.snapshotOf().base as Record<string, unknown> | undefined)?.[field]\n }\n\n private userLayer(): Record<string, unknown> | undefined {\n return this.snapshotOf().user as Record<string, unknown> | undefined\n }\n\n private stored(field: string): boolean {\n const user = this.userLayer()\n return user !== undefined && Object.hasOwn(user, field)\n }\n\n private publish(): void {\n for (const listener of this.listeners) listener()\n }\n}\n","/**\n * The pet settings card: pet selection plus display layout, bound to the\n * 'pet' settings namespace the host plugin registers. Rendered as an\n * always-open first-level settings page; the section wrapper below mounts it\n * as the content of the top-level 'settings.section' nav entry. The petId\n * choices come from the registry endpoint ('/api/pet/pets') — the same list\n * the sprite renders from — so the card carries no per-pet knowledge.\n */\n\nimport type { ReactNode } from 'react'\nimport type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots'\nimport type { SettingsScope, SnapshotStore } from '@deepseek-ai/dsh-client-runtime/client'\n// Type-only: pulls the settings-surface SlotMap merge (the 'settings.section' entry).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport { PluginSettingsCard, ValueField, BooleanField, ChoiceField } from './PluginSettingsCard.tsx'\nimport { CardForm, booleanField, choiceField, numberField, type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts'\nimport sectionCss from './settings-section.module.css'\n\n/** The pet's settings fields this card edits (the namespace's full schema). */\nexport interface PetSettings {\n /** Master switch for the plugin. */\n enabled?: boolean\n /** Master switch. */\n visible?: boolean\n /** Scale of the rendered pet in px (sprite cell height). */\n size?: number\n /** Horizontal inset from the viewport right edge, px. */\n right?: number\n /** Vertical inset from the viewport bottom edge, px. */\n bottom?: number\n /** Selected pet id (a registry entry). */\n petId?: string\n /** Status-decoration master switch (pet-center M5, #567). */\n decorationEnabled?: boolean\n}\n\n/** What the pet settings card renders. */\nexport interface PetSettingsCardState extends CardShell {\n /** Plugin master switch. */\n enabled: CardFieldState\n /** Master switch. */\n visible: CardFieldState\n /** Pet scale. */\n size: CardFieldState\n /** Right inset. */\n right: CardFieldState\n /** Bottom inset. */\n bottom: CardFieldState\n /** Selected pet. */\n petId: CardFieldState\n /** Status-decoration master switch. */\n decorationEnabled: CardFieldState\n /** Pet choices (registry ids + display names), loaded from the host. */\n petChoices: readonly { value: string; label: string }[]\n /** Registry diagnostics (v1 migration hints, invalid entries), host-served. */\n petDiagnostics: readonly PetDiagnosticView[]\n}\n\n/** The registration-side face the card's slot entry injects. */\nexport interface PetSettingsCardFace extends CardActions {\n hooks: {\n /** Card snapshot bound by the renderer as usePetSettingsCard. */\n petSettingsCard: SnapshotStore<PetSettingsCardState>\n }\n}\n\n/** One registry choice as served by '/api/pet/pets'. */\ninterface PetChoice {\n id: string\n displayName: string\n}\n\n/** One registry diagnostic as served by '/api/pet/diagnostics' (#623). */\nexport interface PetDiagnosticView {\n level: 'error' | 'warning'\n message: string\n}\n\n/** Fetch the registry list (the same data the sprite renders from). */\nasync function fetchPetChoices(): Promise<PetChoice[]> {\n const response = await fetch('/api/pet/pets')\n if (!response.ok) throw new Error('pet pets failed: ' + response.status)\n return (await response.json()) as PetChoice[]\n}\n\n/** Fetch the registry diagnostics (v1 migration hints, invalid entries). */\nasync function fetchPetDiagnostics(): Promise<PetDiagnosticView[]> {\n const response = await fetch('/api/pet/diagnostics')\n if (!response.ok) throw new Error('pet diagnostics failed: ' + response.status)\n const body = (await response.json()) as { diagnostics?: PetDiagnosticView[] }\n return body.diagnostics ?? []\n}\n\n/** Bridges the 'pet' scope onto the card's staged form. */\nexport class PetSettingsCardController {\n private readonly form: CardForm<PetSettings>\n private readonly store: SnapshotStore<PetSettingsCardState>\n // The choice list rides a mutable array shared with the choiceField spec,\n // so loading the registry re-validates and re-formats the petId field\n // without rebuilding the form.\n private readonly petChoices: string[] = []\n private readonly petLabels = new Map<string, string>()\n private diagnostics: PetDiagnosticView[] = []\n private loaded = false\n private attempts = 0\n\n /** @param scope - the bound settings scope for the 'pet' namespace. */\n constructor(scope: SettingsScope<PetSettings>) {\n this.form = new CardForm(scope, [\n booleanField('enabled'),\n booleanField('decorationEnabled'),\n booleanField('visible'),\n numberField('size'),\n numberField('right'),\n numberField('bottom'),\n choiceField('petId', this.petChoices),\n ])\n this.store = this.form.bind(() => this.projection())\n // Client plugins are applied synchronously during shell startup. Defer\n // the first registry request until that pass completes so transport\n // plugins (notably remote-web-ui on a paired non-loopback origin) can\n // install their fetch channel before /api/pet/pets is issued.\n window.setTimeout(() => {\n void this.loadPets()\n void this.loadDiagnostics()\n }, 0)\n }\n\n /** Fetch registry diagnostics once (soft-fail: an empty list on error). */\n private async loadDiagnostics(): Promise<void> {\n try {\n this.diagnostics = await fetchPetDiagnostics()\n this.store.set(this.projection())\n } catch {\n this.diagnostics = []\n }\n }\n\n /** Resolve the registry choices once (retried a few times on failure). */\n private async loadPets(): Promise<void> {\n if (this.loaded) return\n try {\n const list = await fetchPetChoices()\n this.petChoices.splice(0, this.petChoices.length, ...list.map(choice => choice.id))\n for (const choice of list) this.petLabels.set(choice.id, choice.displayName)\n this.loaded = true\n this.store.set(this.projection())\n } catch {\n this.attempts += 1\n if (this.attempts < 3) {\n window.setTimeout(() => { void this.loadPets() }, 3000)\n }\n }\n }\n\n private projection(): PetSettingsCardState {\n return {\n ...this.form.shell(),\n enabled: this.form.field('enabled'),\n decorationEnabled: this.form.field('decorationEnabled'),\n visible: this.form.field('visible'),\n size: this.form.field('size'),\n right: this.form.field('right'),\n bottom: this.form.field('bottom'),\n petId: this.form.field('petId'),\n petChoices: this.petChoices.map(id => ({ value: id, label: this.petLabels.get(id) ?? id })),\n petDiagnostics: this.diagnostics,\n }\n }\n\n /**\n * Build the face the card's slot registration injects.\n * @returns the card's snapshot and its form actions.\n */\n inject(): PetSettingsCardFace {\n return { hooks: { petSettingsCard: this.store }, ...this.form.actions() }\n }\n\n /**\n * Release the card's scope subscription and bound stores; the slot\n * disposer calls this on teardown.\n */\n dispose(): void {\n this.form.dispose()\n }\n}\n\n/** Props the renderer binds for the pet settings card. */\nexport type PetSettingsCardProps =\n PropsLocale<'pet'>\n & InjectFace<PetSettingsCardFace>\n\n/**\n * Render the pet settings card.\n * @param props - locale copy, the card snapshot, and its form actions.\n * @returns the card.\n */\nexport function PetSettingsCard(props: PetSettingsCardProps) {\n const { t } = props\n const state = props.usePetSettingsCard(snapshot => snapshot)\n const disabled = !state.writable\n const fieldProps = {\n overriddenLabel: t('settings.overridden'),\n resetLabel: t('settings.reset'),\n invalidLabel: t('settings.invalidNumber'),\n disabled,\n }\n return (\n <PluginSettingsCard\n t={t}\n titleKey=\"settings.title\"\n descriptionKey=\"settings.description\"\n state={state}\n onSave={props.save}\n onDiscard={props.discard}\n alwaysOpen\n >\n <BooleanField\n id=\"settings-pet-enabled\"\n label={t('settings.enabled')}\n hint={t('settings.enabledHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.enabled}\n onEdit={(text) => { props.edit('enabled', text) }}\n onReset={() => { props.resetField('enabled') }}\n />\n <BooleanField\n id=\"settings-pet-decoration\"\n label={t('settings.decoration')}\n hint={t('settings.decorationHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.decorationEnabled}\n onEdit={(text) => { props.edit('decorationEnabled', text) }}\n onReset={() => { props.resetField('decorationEnabled') }}\n />\n <ChoiceField\n id=\"settings-pet-pet\"\n label={t('settings.pet')}\n hint={t('settings.petHint')}\n inheritLabel={t('settings.inherit')}\n {...fieldProps}\n {...state.petId}\n choices={state.petChoices}\n onEdit={(text) => { props.edit('petId', text) }}\n onReset={() => { props.resetField('petId') }}\n />\n {state.petDiagnostics.length === 0 ? null : (\n <li className={sectionCss.diagnostics} data-dsh-part=\"diagnostics\">\n <span className={sectionCss.diagnosticsTitle}>{t('settings.diagnosticsTitle')}</span>\n <ul>\n {state.petDiagnostics.map((diagnostic, index) => (\n <li key={index} data-level={diagnostic.level}>{diagnostic.message}</li>\n ))}\n </ul>\n </li>\n )}\n <BooleanField\n id=\"settings-pet-visible\"\n label={t('settings.visible')}\n hint={t('settings.visibleHint')}\n inheritLabel={t('settings.inherit')}\n onLabel={t('settings.on')}\n offLabel={t('settings.off')}\n {...fieldProps}\n {...state.visible}\n onEdit={(text) => { props.edit('visible', text) }}\n onReset={() => { props.resetField('visible') }}\n />\n <ValueField\n id=\"settings-pet-size\"\n label={t('settings.size')}\n hint={t('settings.sizeHint')}\n numeric\n {...fieldProps}\n {...state.size}\n onEdit={(text) => { props.edit('size', text) }}\n onReset={() => { props.resetField('size') }}\n />\n <ValueField\n id=\"settings-pet-right\"\n label={t('settings.right')}\n hint={t('settings.rightHint')}\n numeric\n {...fieldProps}\n {...state.right}\n onEdit={(text) => { props.edit('right', text) }}\n onReset={() => { props.resetField('right') }}\n />\n <ValueField\n id=\"settings-pet-bottom\"\n label={t('settings.bottom')}\n hint={t('settings.bottomHint')}\n numeric\n {...fieldProps}\n {...state.bottom}\n onEdit={(text) => { props.edit('bottom', text) }}\n onReset={() => { props.resetField('bottom') }}\n />\n </PluginSettingsCard>\n )\n}\n\n/** Props the settings section binds for the pet card page. */\nexport type PetSettingsSectionProps =\n PropsRuntime<'settings.section'>\n & PropsLocale<'pet'>\n & InjectFace<PetSettingsCardFace>\n\n/** Render the pet settings card as a first-level settings page. */\nexport function PetSettingsSection(props: PetSettingsSectionProps): ReactNode {\n const { t, usePetSettingsCard, save, discard, edit, resetField } = props\n return (\n <ul className={sectionCss.sectionList}>\n <PetSettingsCard t={t} usePetSettingsCard={usePetSettingsCard} save={save} discard={discard} edit={edit} resetField={resetField} />\n </ul>\n )\n}\n","/**\n * dsh-pet locale dictionaries (zh/en).\n * @module @linxin666/dsh-pet/client/locales\n */\n\n/** Dictionary namespace this package registers. */\nexport const NS = 'pet'\n\n/** Chinese copy. */\nexport const zh = {\n 'pet.feed': '喂食',\n 'pet.hide': '隐藏',\n 'pet.rename': '改名',\n 'pet.confirm': '确定',\n 'pet.namePlaceholder': '输入新名字',\n 'pet.summon': '召唤{name}',\n 'pet.rank': '亲密度 {rank}',\n 'pet.points': '{points} 点',\n 'pet.treats': '小鱼干 ×{n}',\n 'pet.state.loading': '宠物正在赶来…',\n 'pet.state.error': '宠物迷路了(连接失败)',\n 'pet.renderer.unavailable': '这只宠物需要的渲染器({renderer})在当前版本不可用。',\n 'pet.live2d.core-missing': 'Live2D 核心未安装:请把官方 live2dcubismcore.min.js 放入 $DSH_HOME/pets/.runtime/ 后刷新(步骤见宠物插件 README)。',\n 'pet.live2d.vendor-missing': 'Live2D 组件缺失,请升级宠物插件。',\n 'pet.live2d.load-failed': 'Live2D 模型加载失败,请检查该宠物目录的完整性。',\n 'pet.openSessionHint': '点击跳转到对应会话',\n 'pet.moreSessions': '展开其余 {n} 个会话的气泡',\n 'pet.collapseSessions': '收起会话气泡',\n // 一级设置页(settings.section 席位)。\n 'settings.title': '宠物',\n 'settings.diagnosticsTitle': '宠物目录诊断',\n 'settings.description': '选择宠物并调整它的显示布局。',\n 'settings.pet': '宠物',\n 'settings.petHint': '选择显示哪只宠物;每只宠物独立命名,可在宠物悬浮面板改名。',\n 'settings.enabled': '启用宠物',\n 'settings.enabledHint': '关闭后隐藏宠物并停止轮询,可在设置里重新启用。',\n 'settings.decoration': '状态装饰',\n 'settings.decorationHint': '在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。',\n 'settings.visible': '显示宠物',\n 'settings.visibleHint': '关闭后宠物隐藏,可从聊天输入区重新召唤。',\n 'settings.size': '大小(px)',\n 'settings.sizeHint': '精灵单元高度,范围 32–512。',\n 'settings.right': '距右侧(px)',\n 'settings.rightHint': '距视口右边缘的水平内缩距离。',\n 'settings.bottom': '距底部(px)',\n 'settings.bottomHint': '距视口底边的垂直内缩距离。',\n 'settings.inherit': '继承',\n 'settings.on': '开',\n 'settings.off': '关',\n 'settings.overridden': '已覆盖',\n 'settings.reset': '恢复默认',\n 'settings.notExposed': '当前 DSH 版本未向设置页暴露本插件的配置命名空间,表单不可用。可编辑 ~/.dsh/settings.yaml 直接配置,或为 dsh-host-apiproxy 的 WEB_SETTINGS_NAMESPACES 白名单补充本命名空间后重启。',\n 'settings.readOnly': '当前部署的设置只读。',\n 'settings.expand': '展开设置',\n 'settings.collapse': '收起设置',\n 'settings.save': '保存',\n 'settings.saving': '保存中…',\n 'settings.discard': '放弃',\n 'settings.unsaved': '未保存',\n 'settings.saveFailed': '部署未接受这些值,已保留供你修改。',\n 'settings.invalidNumber': '请输入数字,留空则使用默认值。',\n} as const\n\n/** English copy. */\nexport const en = {\n 'pet.feed': 'Feed',\n 'pet.hide': 'Hide',\n 'pet.rename': 'Rename',\n 'pet.confirm': 'OK',\n 'pet.namePlaceholder': 'Enter a new name',\n 'pet.summon': 'Summon {name}',\n 'pet.rank': 'Affinity {rank}',\n 'pet.points': '{points} pts',\n 'pet.treats': 'Treats ×{n}',\n 'pet.state.loading': 'The pet is on its way…',\n 'pet.state.error': 'The pet is lost (connection failed)',\n 'pet.renderer.unavailable': 'This pet needs a renderer ({renderer}) that is not available in this build.',\n 'pet.live2d.core-missing': 'Live2D Cubism Core is not installed: place the official live2dcubismcore.min.js under $DSH_HOME/pets/.runtime/ and refresh (see the pet plugin README).',\n 'pet.live2d.vendor-missing': 'The Live2D component is missing; please update the pet plugin.',\n 'pet.live2d.load-failed': 'The Live2D model failed to load; check the pet directory is complete.',\n 'pet.openSessionHint': 'Click to jump to this session',\n 'pet.moreSessions': 'Expand {n} more session bubbles',\n 'pet.collapseSessions': 'Collapse session bubbles',\n // First-level settings section (the `settings.section` seat).\n 'settings.title': 'Pet',\n 'settings.diagnosticsTitle': 'Pet directory diagnostics',\n 'settings.description': 'Pick a pet and tune its display layout.',\n 'settings.pet': 'Pet',\n 'settings.petHint': 'Choose which pet shows. Names are stored per pet; rename from the pet hover panel.',\n 'settings.enabled': 'Enable the pet',\n 'settings.enabledHint': 'When off, the pet hides and polling stops; re-enable it here.',\n 'settings.decoration': 'Status decoration',\n 'settings.decorationHint': 'Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.',\n 'settings.visible': 'Show the pet',\n 'settings.visibleHint': 'When off, the pet hides; summon it again from the input row.',\n 'settings.size': 'Size (px)',\n 'settings.sizeHint': 'Sprite cell height, 32\\u2013512.',\n 'settings.right': 'Right inset (px)',\n 'settings.rightHint': 'Horizontal inset from the viewport right edge.',\n 'settings.bottom': 'Bottom inset (px)',\n 'settings.bottomHint': 'Vertical inset from the viewport bottom edge.',\n 'settings.inherit': 'Inherit',\n 'settings.on': 'On',\n 'settings.off': 'Off',\n 'settings.overridden': 'Overridden',\n 'settings.reset': 'Reset to default',\n 'settings.notExposed': 'This DSH version does not expose this plugin\\'s settings namespace to the configuration page, so the form is unavailable. Edit ~/.dsh/settings.yaml directly, or add the namespace to dsh-host-apiproxy\\'s WEB_SETTINGS_NAMESPACES allowlist and restart.',\n 'settings.readOnly': 'This deployment stores settings read-only.',\n 'settings.expand': 'Show settings',\n 'settings.collapse': 'Hide settings',\n 'settings.save': 'Save',\n 'settings.saving': 'Saving\\u2026',\n 'settings.discard': 'Discard',\n 'settings.unsaved': 'Unsaved',\n 'settings.saveFailed': 'The deployment did not accept these values; they were left for you to correct.',\n 'settings.invalidNumber': 'Enter a number, or leave blank to use the default.',\n} as const\n\n/** Key union for this namespace. */\nexport type PetKey = keyof typeof zh\n\n/** The settings-card slice of the pet dictionary. */\nexport type SettingsCardKey = PetKey\n\n/**\n * Active dictionary, picked by the document language at call time. The pet\n * mounts as a global floating surface (not a session-scoped slot), so it has\n * no framework locale seat and resolves its copy the same tiny way the\n * task-board's DOM-injected surface does.\n */\nexport function dictionary(): Record<PetKey, string> {\n const lang = typeof document !== 'undefined' ? document.documentElement.lang : 'zh'\n return lang.toLowerCase().startsWith('en') ? en : zh\n}\n\n/**\n * Translate a key with optional `{name}` template params. Mirrors the slot\n * `Translate` contract `(key, params?) => string` so it can be handed to the\n * same components that used to receive the framework-injected `t` seat. The\n * key is typed loosely (`string`) so the function is assignable to the slot's\n * `TranslateNS<'pet'>` (whose key domain also spans the shared common\n * vocabulary); a missing key degrades to the key itself rather than throwing.\n */\nexport function t(key: string, params?: Record<string, unknown>): string {\n let text: string = (dictionary() as Record<string, string>)[key] ?? key\n if (params !== undefined) {\n for (const [name, value] of Object.entries(params)) {\n text = text.replaceAll(`{${name}}`, String(value))\n }\n }\n return text\n}\n\ndeclare module '@deepseek-ai/dsh-client-ui-slots' {\n interface LocaleNamespaceMap {\n /** dsh-pet UI copy. */\n pet: PetKey\n }\n}\n","/**\n * dsh-pet browser half — mounts the selected pet as a global floating\n * surface and drives it from the host's same-origin '/api/pet/*' JSON\n * endpoints: fetch the registry list once, poll the host snapshot (~2 s),\n * forward interactions, persist drag positions. The pet is host-global (no\n * session dimension), so it mounts directly onto 'document.body' via a\n * single React root rather than a session-scoped slot — on the\n * new-conversation screen no session exists, and a dock-mounted pet would\n * vanish there (issue #48). When the pet is hidden the entry becomes a\n * fixed-position summon button.\n * @module @linxin666/dsh-pet/client\n */\n\nimport type { ClientContext, ISessions, SessionId, SettingsScope, SettingsScopeSpec } from '@deepseek-ai/dsh-client-runtime/client'\n// Type-only: pulls the locale plugin's Context merge (ctx.locale).\nimport type {} from '@deepseek-ai/dsh-client-locale/client'\n// Type-only: pulls the settings-surface Context merge (ctx.settingsScope).\nimport type {} from '@deepseek-ai/dsh-client-ui-settings/client'\nimport type {} from '@deepseek-ai/dsh-client-ui-slots'\nimport type {} from '@deepseek-ai/dsh-client-ui-conversation/client'\nimport type { PetDisplayConfig } from '../persist.ts'\nimport type { PetInteractResult, PetStateView } from '../service.ts'\nimport type { PetInteraction } from '../affinity.ts'\nimport type { PetDefinition } from '../registry.ts'\nimport { createElement } from 'react'\nimport { createRoot } from 'react-dom/client'\nimport { createPetStore, type PetStoreInstance } from './pet-store.ts'\nimport { PetDockEntry, type PetInjected } from './PetDockEntry.tsx'\nimport { defaultPetRendererRegistry } from './renderers/registry.ts'\nimport { live2dRenderer } from './renderers/live2d.ts'\nimport { registerPetUiTeardown, takeoverPetUiTeardown } from './ui-teardown.ts'\nimport { PetSettingsSection, PetSettingsCardController, type PetSettings } from './PetSettingsCard.tsx'\nimport { NS, en, zh, t } from './locales.ts'\n\n/** The host pet API as the browser sees it (same-origin JSON endpoints). */\ninterface PetHttpApi {\n state(): Promise<PetStateView>\n pets(): Promise<PetDefinition[]>\n interact(kind: PetInteraction): Promise<PetInteractResult>\n setVisible(visible: boolean): Promise<{ ok: true; display: PetDisplayConfig }>\n setConfig(patch: Partial<PetDisplayConfig>): Promise<{ ok: true; display: PetDisplayConfig }>\n setName(name: string): Promise<{ ok: true; name: string } | { ok: false; error: string }>\n setPet(petId: string): Promise<{ ok: true; petId: string } | { ok: false; error: string }>\n}\n\n/** Same-origin JSON fetch helper (GET without body, POST with JSON body). */\nasync function petFetch<T>(path: string, body?: unknown): Promise<T> {\n const response = await fetch(path, body === undefined\n ? {}\n : {\n method: 'POST',\n headers: { 'content-type': 'application/json' },\n body: JSON.stringify(body),\n })\n if (!response.ok) {\n throw new Error('pet ' + path + ' failed: ' + response.status)\n }\n return (await response.json()) as T\n}\n\n/** The live host API instance (always defined; failures surface per call). */\nconst petApi: PetHttpApi = {\n state: () => petFetch('/api/pet/state'),\n pets: () => petFetch('/api/pet/pets'),\n interact: (kind) => petFetch('/api/pet/interact', { kind }),\n setVisible: (visible) => petFetch('/api/pet/set-visible', { visible }),\n setConfig: (patch) => petFetch('/api/pet/set-config', patch),\n setName: (name) => petFetch('/api/pet/set-name', { name }),\n setPet: (petId) => petFetch('/api/pet/set-pet', { petId }),\n}\n\n/** Poll interval for the host snapshot. */\nconst POLL_MS = 2000\n\n/** Settings namespace the pet settings card edits (the Host plugin registers it). */\nconst PET_SETTINGS_NS = 'pet'\n\n/** Required services (sessions powers bubble-to-session navigation). */\nexport const inject = ['slots', 'locale', 'connection', 'settingsScope', 'remote', 'sessions']\n\n/** Re-exported for consumers that type against the injected face. */\nexport type { PetInjected, PetDockEntryProps } from './PetDockEntry.tsx'\nexport type { PetSpriteProps } from './PetSprite.tsx'\nexport type { PetUiState, PetFeedback } from './pet-store.ts'\nexport type { PetSettingsCardFace, PetSettingsCardState } from './PetSettingsCard.tsx'\nexport type { PetSettingsSectionProps } from './PetSettingsCard.tsx'\nexport type { PetDefinition } from '../registry.ts'\n\ndeclare module '@deepseek-ai/cordis' {\n interface Context {\n /**\n * Optional rc.6 compatibility binder provided by dsh-web-ui-settings;\n * absent when that group plugin is not installed, so callers fall back to\n * the official settings scope.\n */\n webUiSettings?: { bind<S>(spec: SettingsScopeSpec<S>): SettingsScope<S> }\n }\n}\n\n/**\n * Client plugin body: register dictionaries, mount the global pet entry and\n * poll loop while the plugin is enabled, and seat the settings card as a\n * first-level settings section.\n * @param ctx - client root context.\n */\nexport function apply(ctx: ClientContext): void {\n ctx.effect(() => ctx.locale.register(NS, { zh, en }), 'pet: dictionaries')\n\n // Built-in renderers dispatch through the plugin-wide registry (pet-center\n // M3). Registration is idempotent (id wins), so re-applies stay clean.\n defaultPetRendererRegistry.register(live2dRenderer)\n\n const binder = ctx.get('webUiSettings') ?? ctx.settingsScope\n const settingsScope = binder.bind<PetSettings>({ namespace: PET_SETTINGS_NS })\n const enabled = (): boolean => {\n const snapshot = settingsScope.getSnapshot()\n return snapshot.status === 'ready'\n ? snapshot.value?.enabled ?? true\n : snapshot.status === 'unavailable'\n }\n\n // First-level settings section: one staged form over the 'pet' settings\n // namespace, registered as a top-level settings page. The controller loads\n // the petId choices from the registry endpoint itself.\n const petSettings = new PetSettingsCardController(settingsScope)\n ctx.slots.inject('settings.section', () => {\n const unregister = ctx.slots.register({\n name: 'settings.section',\n id: 'pet',\n order: 130,\n label: () => ctx.locale.bind('pet')('settings.title'),\n locale: 'pet',\n inject: () => petSettings.inject(),\n }, PetSettingsSection)\n return () => {\n petSettings.dispose()\n unregister()\n }\n })\n\n // The global pet entry, its store, and the poll loop live while the plugin\n // is enabled; toggling the setting off hides the pet and stops polling.\n // 'uiDead' marks a terminal teardown (takeover by a later bundle instance\n // or fiber disposal): a taken-over or disposed instance must never remount\n // from a late settings callback (issue #785).\n let disposeUi: (() => void) | undefined\n let clearUiTeardown: (() => void) | undefined\n let uiDead = false\n const killUi = (): void => {\n if (uiDead) return\n uiDead = true\n clearUiTeardown?.()\n clearUiTeardown = undefined\n disposeUi?.()\n disposeUi = undefined\n }\n const syncUi = (): void => {\n if (!uiDead && enabled() && disposeUi === undefined) {\n // ONE store instance for the whole app, owned by this apply body. The\n // pet is host-global (state/display/interactions are /api/pet/*\n // endpoints with no session dimension), so the slot system's per-session\n // store scoping would only reset the pet on session switches and leave\n // it stateless on the new-conversation screen (no session to scope by).\n const petStore: PetStoreInstance = createPetStore().create()\n const setSnapshot = petStore.actions.setSnapshot\n const setPets = petStore.actions.setPets\n const setState = petStore.actions.setState\n const setFeedback = petStore.actions.setFeedback\n\n // The registry list is fetched lazily with retries baked into the poll\n // cycle: until it lands, the dock entry renders nothing and every 2s\n // tick tries again. After it lands, one list feeds both the sprite and\n // the settings card's choices.\n let petsLoaded = false\n // Latest-wins guard: the 2s tick, visibility recovery, and\n // interaction-triggered refreshes can overlap; only the newest\n // response may publish, so a slow older one can never roll the\n // snapshot back.\n let stateSeq = 0\n const pollNow = (): void => {\n if (!petsLoaded) {\n petApi.pets().then((list) => {\n petsLoaded = true\n setPets(list)\n }, () => {\n // Retry on the next poll tick.\n })\n }\n const seq = stateSeq + 1\n stateSeq = seq\n petApi.state().then((snapshot) => {\n if (seq !== stateSeq) return\n setSnapshot(snapshot)\n }, () => {\n if (seq !== stateSeq) return\n setState('error', 'pet.state transport error')\n })\n }\n\n const disposePoll = ctx.effect(() => {\n // Poll only while the tab is visible: the host snapshot does not\n // change while the page is hidden, so a background interval would\n // only burn RPCs (browser throttling is an unreliable backstop).\n // Coming back to the tab refreshes the pet immediately instead of\n // waiting out the next 2 s cycle.\n let timer: number | undefined\n const stop = (): void => {\n if (timer !== undefined) {\n window.clearInterval(timer)\n timer = undefined\n }\n }\n const start = (): void => {\n if (timer === undefined && document.visibilityState === 'visible') {\n timer = window.setInterval(pollNow, POLL_MS)\n }\n }\n const onVisibility = (): void => {\n if (document.visibilityState === 'visible') {\n pollNow()\n start()\n } else {\n stop()\n }\n }\n start()\n document.addEventListener('visibilitychange', onVisibility)\n return () => {\n stop()\n document.removeEventListener('visibilitychange', onVisibility)\n }\n }, 'pet: poll')\n\n // Clicking a session bubble jumps the GUI to that session. A bubble\n // can outlive its disposed session by one poll tick, and the sessions\n // service fails loud on unknown ids, so consult the live list first.\n // The pet's type program also loads the host-side dsh-session package\n // through the service types, whose Context merge declares a different\n // 'sessions' face; pin the browser runtime's outward face here.\n const sessions = ctx.sessions as unknown as ISessions\n const openSession = (sessionId: string): void => {\n const list = sessions.list.getSnapshot()\n if (list.byId[sessionId as SessionId] === undefined) return\n sessions.open(sessionId as SessionId)\n }\n\n const injected = (): PetInjected => ({\n store: petStore,\n ensure: pollNow,\n openSession,\n pet: () => {\n petApi.interact('pet').then((result) => {\n setFeedback({\n text: result.reaction,\n kind: 'pet',\n at: Date.now(),\n })\n }, () => {\n // Ignore transport errors on interactions; the next poll resyncs.\n })\n },\n feed: () => {\n petApi.interact('feed').then((result) => {\n setFeedback({\n text: result.reaction,\n kind: 'feed',\n at: Date.now(),\n })\n }, () => {\n // Ignore transport errors on interactions; the next poll resyncs.\n })\n },\n hide: () => {\n petApi.setVisible(false).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n summon: () => {\n petApi.setVisible(true).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n dragEnd: (right, bottom) => {\n petApi.setConfig({ right, bottom }).then(() => {\n pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n rename: (name) => {\n petApi.setName(name).then((result) => {\n if (result.ok) pollNow()\n }, () => {\n // Ignore; next poll resyncs.\n })\n },\n feedbackDone: () => {\n setFeedback(null)\n },\n })\n\n // The pet is host-global (its state/display/interactions have no session\n // dimension), and the official rc.6 shell declares no root-scoped slot\n // for a global floating surface — the dock is session-scoped, so a pet\n // mounted there would vanish on the new-conversation screen (issue #48).\n // The entry therefore mounts straight onto document.body via a single\n // React root for the page lifetime: PetSprite portals itself to body\n // when visible, and the hidden-state summon button is fixed-positioned.\n //\n // Cross-instance single-mount guard (issue #785): take over the\n // page-global slot first — the previous bundle instance's fiber may\n // still be draining during a client reload, so unmount its React root\n // and remove its container — then sweep containers left behind by\n // instances that predate the teardown registry, so this mount is the\n // page's only [data-dsh-pet-root].\n takeoverPetUiTeardown()\n for (const stale of Array.from(document.querySelectorAll('div[data-dsh-pet-root]'))) {\n stale.remove()\n }\n const container = document.createElement('div')\n container.dataset.dshPetRoot = ''\n container.dataset.dshPlugin = 'pet'\n document.body.appendChild(container)\n const petRoot = createRoot(container)\n petRoot.render(createElement(PetDockEntry, { ...injected(), t }))\n\n let uiGone = false\n disposeUi = () => {\n if (uiGone) return\n uiGone = true\n clearUiTeardown?.()\n clearUiTeardown = undefined\n petRoot.unmount()\n container.remove()\n disposePoll()\n disposeUi = undefined\n }\n // The slot teardown is the takeover hook a later apply body runs; it\n // marks this instance terminal so a late settings callback from the\n // still-draining instance cannot remount a second pet.\n clearUiTeardown = registerPetUiTeardown(() => {\n uiDead = true\n disposeUi?.()\n })\n } else if (!uiDead && !enabled() && disposeUi !== undefined) {\n disposeUi()\n disposeUi = undefined\n }\n }\n // The settings subscription and the pet UI lifetime follow the fiber\n // (issue #785): disposal drops the subscription and tears the UI down\n // (terminal), so a hot-reloaded or re-injected bundle never leaves the\n // previous React root, container, or poll loop behind on document.body.\n const unsubscribeSettings = settingsScope.subscribe(syncUi)\n ctx.effect(\n () => () => {\n unsubscribeSettings()\n killUi()\n },\n 'pet: client lifecycle',\n )\n syncUi()\n}\n"],"x_google_ignoreList":[1],"mappings":";;;;;;;;;;;;;;;;;;;;EAmDA,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