@linxin666/dsh-pet 0.4.4 → 0.4.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +46 -6
  3. package/README.zh.md +46 -6
  4. package/lib/client.js +244 -47
  5. package/lib/client.js.map +1 -1
  6. package/lib/index.js +287 -28
  7. package/lib/types/announce.d.ts +16 -0
  8. package/lib/types/announce.d.ts.map +1 -1
  9. package/lib/types/announce.js +16 -0
  10. package/lib/types/client/PetDockEntry.d.ts +6 -0
  11. package/lib/types/client/PetDockEntry.d.ts.map +1 -1
  12. package/lib/types/client/PetDockEntry.js +1 -1
  13. package/lib/types/client/PetSettingsCard.d.ts +4 -0
  14. package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
  15. package/lib/types/client/PetSettingsCard.js +16 -1
  16. package/lib/types/client/PetSprite.d.ts +7 -0
  17. package/lib/types/client/PetSprite.d.ts.map +1 -1
  18. package/lib/types/client/PetSprite.js +23 -13
  19. package/lib/types/client/index.d.ts +2 -0
  20. package/lib/types/client/index.d.ts.map +1 -1
  21. package/lib/types/client/index.js +224 -28
  22. package/lib/types/client/locales.d.ts +4 -0
  23. package/lib/types/client/locales.d.ts.map +1 -1
  24. package/lib/types/client/locales.js +4 -0
  25. package/lib/types/index.d.ts +14 -3
  26. package/lib/types/index.d.ts.map +1 -1
  27. package/lib/types/index.js +32 -3
  28. package/lib/types/panel-actions.d.ts +96 -0
  29. package/lib/types/panel-actions.d.ts.map +1 -0
  30. package/lib/types/panel-actions.js +134 -0
  31. package/lib/types/routes.d.ts.map +1 -1
  32. package/lib/types/routes.js +10 -0
  33. package/lib/types/service.d.ts +137 -9
  34. package/lib/types/service.d.ts.map +1 -1
  35. package/lib/types/service.js +163 -21
  36. package/package.json +1 -1
  37. package/src/announce.ts +17 -0
  38. package/src/client/PetDockEntry.test.tsx +1 -0
  39. package/src/client/PetDockEntry.tsx +7 -0
  40. package/src/client/PetSettingsCard.test.tsx +88 -0
  41. package/src/client/PetSettingsCard.tsx +31 -0
  42. package/src/client/PetSprite.test.tsx +197 -0
  43. package/src/client/PetSprite.tsx +56 -12
  44. package/src/client/index.test.tsx +152 -4
  45. package/src/client/index.ts +228 -29
  46. package/src/client/locales.ts +4 -0
  47. package/src/index.test.ts +22 -0
  48. package/src/index.ts +45 -3
  49. package/src/panel-actions.test.ts +130 -0
  50. package/src/panel-actions.ts +182 -0
  51. package/src/registry.test.ts +11 -1
  52. package/src/routes.ts +9 -0
  53. package/src/service.test.ts +128 -0
  54. package/src/service.ts +218 -24
@@ -2,6 +2,12 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { PluginSettingsCard, ValueField, BooleanField, ChoiceField } from "./PluginSettingsCard.js";
3
3
  import { CardForm, booleanField, choiceField, numberField } from "./settings-form.js";
4
4
  import sectionCss from './settings-section.module.css';
5
+ /**
6
+ * The bubble modes this card can write, in render order. Mirrors the host
7
+ * schema's union (see PetStatusBubbleMode); the browser half never imports the
8
+ * host module for a value, so the accepted set is spelled here as literals.
9
+ */
10
+ const STATUS_BUBBLE_CHOICES = ['auto', 'off'];
5
11
  /** Fetch the registry list (the same data the sprite renders from). */
6
12
  async function fetchPetChoices() {
7
13
  const response = await fetch('/api/pet/pets');
@@ -45,6 +51,11 @@ export class PetSettingsCardController {
45
51
  this.form = new CardForm(scope, [
46
52
  booleanField('enabled'),
47
53
  booleanField('decorationEnabled'),
54
+ // The bubble switch is a two-value mode, not a boolean: 'off' is the
55
+ // opt-out, and a future mode (say, one that keeps only the current
56
+ // session's bubble) has to be able to join the same field without
57
+ // breaking every settings document already written.
58
+ choiceField('statusBubbles', STATUS_BUBBLE_CHOICES),
48
59
  booleanField('visible'),
49
60
  numberField('size'),
50
61
  numberField('right'),
@@ -199,6 +210,7 @@ export class PetSettingsCardController {
199
210
  petSelectionFallback: fallback,
200
211
  enabled: this.form.field('enabled'),
201
212
  decorationEnabled: this.form.field('decorationEnabled'),
213
+ statusBubbles: this.form.field('statusBubbles'),
202
214
  visible: fallback ? this.fallbackVisible() : this.form.field('visible'),
203
215
  size: this.form.field('size'),
204
216
  right: this.form.field('right'),
@@ -288,7 +300,10 @@ export function PetSettingsCard(props) {
288
300
  invalidLabel: t('settings.invalidNumber'),
289
301
  disabled,
290
302
  };
291
- return (_jsxs(PluginSettingsCard, { t: t, titleKey: "settings.title", descriptionKey: "settings.description", descriptionNode: state.petSelectionFallback ? t('settings.petHint') : undefined, state: state, onSave: props.save, onDiscard: props.discard, alwaysOpen: true, children: [state.petSelectionFallback ? null : _jsx(BooleanField, { id: "settings-pet-enabled", label: t('settings.enabled'), hint: t('settings.enabledHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.enabled, onEdit: (text) => { props.edit('enabled', text); }, onReset: () => { props.resetField('enabled'); } }), state.petSelectionFallback ? null : _jsx(BooleanField, { id: "settings-pet-decoration", label: t('settings.decoration'), hint: t('settings.decorationHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.decorationEnabled, onEdit: (text) => { props.edit('decorationEnabled', text); }, onReset: () => { props.resetField('decorationEnabled'); } }), _jsx(ChoiceField, { id: "settings-pet-pet", label: t('settings.pet'), hint: t('settings.petHint'), inheritLabel: t('settings.inherit'), ...fieldProps, ...state.petId, choices: state.petChoices, onEdit: (text) => { props.edit('petId', text); }, onReset: () => { props.resetField('petId'); } }), _jsx(BooleanField, { id: "settings-pet-visible", label: t('settings.visible'), hint: t('settings.visibleHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.visible, onEdit: (text) => { props.edit('visible', text); }, onReset: () => { props.resetField('visible'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-size", label: t('settings.size'), hint: t('settings.sizeHint'), numeric: true, ...fieldProps, ...state.size, onEdit: (text) => { props.edit('size', text); }, onReset: () => { props.resetField('size'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-right", label: t('settings.right'), hint: t('settings.rightHint'), numeric: true, ...fieldProps, ...state.right, onEdit: (text) => { props.edit('right', text); }, onReset: () => { props.resetField('right'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-bottom", label: t('settings.bottom'), hint: t('settings.bottomHint'), numeric: true, ...fieldProps, ...state.bottom, onEdit: (text) => { props.edit('bottom', text); }, onReset: () => { props.resetField('bottom'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-bubble-scale", label: t('settings.bubbleScale'), hint: t('settings.bubbleScaleHint'), numeric: true, ...fieldProps, ...state.bubbleScale, onEdit: (text) => { props.edit('bubbleScale', text); }, onReset: () => { props.resetField('bubbleScale'); } })] }));
303
+ return (_jsxs(PluginSettingsCard, { t: t, titleKey: "settings.title", descriptionKey: "settings.description", descriptionNode: state.petSelectionFallback ? t('settings.petHint') : undefined, state: state, onSave: props.save, onDiscard: props.discard, alwaysOpen: true, children: [state.petSelectionFallback ? null : _jsx(BooleanField, { id: "settings-pet-enabled", label: t('settings.enabled'), hint: t('settings.enabledHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.enabled, onEdit: (text) => { props.edit('enabled', text); }, onReset: () => { props.resetField('enabled'); } }), state.petSelectionFallback ? null : _jsx(BooleanField, { id: "settings-pet-decoration", label: t('settings.decoration'), hint: t('settings.decorationHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.decorationEnabled, onEdit: (text) => { props.edit('decorationEnabled', text); }, onReset: () => { props.resetField('decorationEnabled'); } }), state.petSelectionFallback ? null : _jsx(ChoiceField, { id: "settings-pet-status-bubbles", label: t('settings.statusBubbles'), hint: t('settings.statusBubblesHint'), inheritLabel: t('settings.inherit'), ...fieldProps, ...state.statusBubbles, choices: [
304
+ { value: STATUS_BUBBLE_CHOICES[0], label: t('settings.on') },
305
+ { value: STATUS_BUBBLE_CHOICES[1], label: t('settings.off') },
306
+ ], onEdit: (text) => { props.edit('statusBubbles', text); }, onReset: () => { props.resetField('statusBubbles'); } }), _jsx(ChoiceField, { id: "settings-pet-pet", label: t('settings.pet'), hint: t('settings.petHint'), inheritLabel: t('settings.inherit'), ...fieldProps, ...state.petId, choices: state.petChoices, onEdit: (text) => { props.edit('petId', text); }, onReset: () => { props.resetField('petId'); } }), _jsx(BooleanField, { id: "settings-pet-visible", label: t('settings.visible'), hint: t('settings.visibleHint'), inheritLabel: t('settings.inherit'), onLabel: t('settings.on'), offLabel: t('settings.off'), ...fieldProps, ...state.visible, onEdit: (text) => { props.edit('visible', text); }, onReset: () => { props.resetField('visible'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-size", label: t('settings.size'), hint: t('settings.sizeHint'), numeric: true, ...fieldProps, ...state.size, onEdit: (text) => { props.edit('size', text); }, onReset: () => { props.resetField('size'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-right", label: t('settings.right'), hint: t('settings.rightHint'), numeric: true, ...fieldProps, ...state.right, onEdit: (text) => { props.edit('right', text); }, onReset: () => { props.resetField('right'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-bottom", label: t('settings.bottom'), hint: t('settings.bottomHint'), numeric: true, ...fieldProps, ...state.bottom, onEdit: (text) => { props.edit('bottom', text); }, onReset: () => { props.resetField('bottom'); } }), state.petSelectionFallback ? null : _jsx(ValueField, { id: "settings-pet-bubble-scale", label: t('settings.bubbleScale'), hint: t('settings.bubbleScaleHint'), numeric: true, ...fieldProps, ...state.bubbleScale, onEdit: (text) => { props.edit('bubbleScale', text); }, onReset: () => { props.resetField('bubbleScale'); } })] }));
292
307
  }
293
308
  /** Render the pet settings card as a first-level settings page. */
294
309
  export function PetSettingsSection(props) {
@@ -38,6 +38,13 @@ export interface PetSpriteProps {
38
38
  onDraggingChange?: (dragging: boolean) => void;
39
39
  /** Rename the selected pet (persisted by the host). */
40
40
  onRename: (name: string) => void;
41
+ /**
42
+ * Report a click on one plugin-registered action (issue #6). The buttons
43
+ * themselves come from the state snapshot's `panelActions` slice, so the
44
+ * panel renders exactly the registrations the host serves and adds nothing
45
+ * of its own.
46
+ */
47
+ onPanelAction: (id: string) => void;
41
48
  /** Navigate to the session one status bubble reports on. */
42
49
  onOpenSession: (sessionId: string) => void;
43
50
  /** Clear the reaction bubble (after its CSS animation). */
@@ -1 +1 @@
1
- {"version":3,"file":"PetSprite.d.ts","sourceRoot":"","sources":["../../../src/client/PetSprite.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAkE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAA;AAGnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AACnE,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,eAAe,CAAA;AACrE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAA;AAEjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAGpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAIjD,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAGjC,wEAAwE;AACxE,MAAM,WAAW,cAAc;IAC7B,gDAAgD;IAChD,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAA;IAC7B,8EAA8E;IAC9E,UAAU,EAAE,aAAa,CAAA;IACzB,qDAAqD;IACrD,OAAO,EAAE,gBAAgB,CAAA;IACzB,sCAAsC;IACtC,QAAQ,EAAE,WAAW,GAAG,IAAI,CAAA;IAC5B,8BAA8B;IAC9B,KAAK,EAAE,MAAM,IAAI,CAAA;IACjB,sCAAsC;IACtC,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,MAAM,IAAI,CAAA;IAC1B;;;;OAIG;IACH,MAAM,CAAC,EAAE,SAAS,CAAA;IAClB;;;;OAIG;IACH,GAAG,CAAC,EAAE,SAAS,CAAA;IACf;;;;OAIG;IACH,aAAa,CAAC,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9D;;;;;OAKG;IACH,cAAc,CAAC,EAAE,MAAM,IAAI,CAAA;IAC3B,qEAAqE;IACrE,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB;;;OAGG;IACH,GAAG,CAAC,EAAE,WAAW,CAAA;IACjB;;;;;;OAMG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,+CAA+C;IAC/C,CAAC,EAAE,WAAW,CAAC,OAAO,EAAE,CAAC,CAAA;CAC1B;AAkJD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,GAAG,WAAW,CA8tB5D"}
@@ -507,20 +507,30 @@ export function PetSprite(props) {
507
507
  // is hovered/pinned open. The legacy single 'bubble' is the fallback when
508
508
  // the host serves no per-session list. The hover panel normally sits below
509
509
  // the sprite, so the bubbles stay visible and clickable — no region swap.
510
- const sessionBubbles = snapshot?.sessions ?? [];
510
+ // Whether the pet renders its OWN session/status bubbles (issue #6). Only
511
+ // these are gated: the interaction feedback bubble and a sibling plugin's
512
+ // announcement bubble are separate surfaces and keep rendering, so a plugin
513
+ // that drives its own bubble can switch the built-in ones off. A host that
514
+ // predates the field serves no mode at all, which reads as 'auto' — the
515
+ // behavior that shipped before the switch existed.
516
+ const statusBubblesOn = (snapshot?.statusBubbles ?? 'auto') !== 'off';
517
+ const sessionBubbles = statusBubblesOn ? (snapshot?.sessions ?? []) : [];
511
518
  const stackOpen = stackPeek || stackPinned;
512
519
  const collapsed = !stackOpen && sessionBubbles.length > 1;
513
520
  const visibleSessions = collapsed ? sessionBubbles.slice(0, 1) : sessionBubbles;
514
- const statusBubble = feedback === null && sessionBubbles.length === 0
521
+ const statusBubble = statusBubblesOn && feedback === null && sessionBubbles.length === 0
515
522
  ? snapshot?.bubble
516
523
  : undefined;
517
- // The freshest plugin-authored announcement (dsh-usage linkage): a
518
- // dedicated, specially styled bubble above the session stack. The host
519
- // already TTL-filters; this client-side check covers the last poll tick.
520
- const announcement = snapshot?.announcement;
521
- const usageAnnouncement = feedback === null && announcement !== undefined && announcementFresh(announcement, Date.now())
522
- ? announcement
523
- : undefined;
524
+ // The plugin-authored announcements: one dedicated, specially styled bubble
525
+ // per publishing plugin above the session stack (issue #1812 — the contract
526
+ // used to hold a single slot, so a second publisher displaced the first).
527
+ // The host already TTL-filters; this client-side check covers the last poll
528
+ // tick. A host predating the array serves the singular field only, and a
529
+ // browser half predating it (this file, before the upgrade) renders the same
530
+ // one bubble, so neither side of a rolling upgrade loses a publisher.
531
+ const announced = snapshot?.announcements ?? (snapshot?.announcement !== undefined ? [snapshot.announcement] : []);
532
+ const now = Date.now();
533
+ const usageAnnouncements = feedback === null ? announced.filter(entry => announcementFresh(entry, now)) : [];
524
534
  // Each session's inner whisper (碎碎念) rides its own bubble — short
525
535
  // inner-voice copy woken by that session's activity, never the model's or
526
536
  // another session's. Instead of a second bubble of its own, a fresh
@@ -528,7 +538,7 @@ export function PetSprite(props) {
528
538
  // never wears two voices at once. Interaction feedback takes over the
529
539
  // whole bubble area while it plays, so whispers yield to it like status
530
540
  // copy.
531
- const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== undefined || usageAnnouncement !== undefined;
541
+ const bubblePresent = feedback !== null || sessionBubbles.length > 0 || statusBubble !== undefined || usageAnnouncements.length > 0;
532
542
  const displayName = snapshot?.name ?? definition.displayName;
533
543
  // The host-served status decoration (M5, #567); absent = text-only bubbles.
534
544
  const decoration = snapshot?.decoration;
@@ -615,7 +625,7 @@ export function PetSprite(props) {
615
625
  }
616
626
  }
617
627
  props.onPet();
618
- }, role: "button", "aria-label": definition.displayName, children: props.visual }) }), props.hud, feedback !== null && (_jsx("div", { ref: bubbleRef, className: clsx(styles.bubble, feedback.kind === 'feed' ? styles.bubbleFeed : styles.bubblePet), children: feedback.text }, feedback.at)), feedback === null && (sessionBubbles.length > 0 || statusBubble !== undefined || usageAnnouncement !== undefined) && (_jsxs("div", { ref: bubbleRef, className: styles.bubbleStack, onPointerEnter: () => setStackPeek(true), onPointerLeave: () => setStackPeek(false), children: [visibleSessions.map((session, index) => {
628
+ }, role: "button", "aria-label": definition.displayName, children: props.visual }) }), props.hud, feedback !== null && (_jsx("div", { ref: bubbleRef, className: clsx(styles.bubble, feedback.kind === 'feed' ? styles.bubbleFeed : styles.bubblePet), children: feedback.text }, feedback.at)), feedback === null && (sessionBubbles.length > 0 || statusBubble !== undefined || usageAnnouncements.length > 0) && (_jsxs("div", { ref: bubbleRef, className: styles.bubbleStack, onPointerEnter: () => setStackPeek(true), onPointerLeave: () => setStackPeek(false), children: [visibleSessions.map((session, index) => {
619
629
  // A session's whisper rides ITS OWN bubble (the stack lead when
620
630
  // the current session has one, any bubble when the stack is
621
631
  // expanded). The key swap restarts the entrance animation so the
@@ -634,7 +644,7 @@ export function PetSprite(props) {
634
644
  e.stopPropagation();
635
645
  setStackPinned(open => !open);
636
646
  }, children: stackOpen ? '×' : '+' + String(sessionBubbles.length - 1) })] }, "primary"));
637
- }), sessionBubbles.length === 0 && statusBubble !== undefined && (_jsxs("div", { className: clsx(styles.bubble, styles.bubbleStatus), role: "status", "aria-live": "polite", children: [decoration !== undefined && (_jsx(StatusOrnament, { decoration: decoration, phase: phase })), statusBubble] }, "status")), usageAnnouncement !== undefined && _jsx(UsageAnnouncementBubble, { announcement: usageAnnouncement })] })), hovered && dragRef.current === null && (_jsx("div", { ref: panelRef, className: clsx(styles.panel, panelAbove && styles.panelAbove), "data-placement": panelAbove ? 'above' : 'below', style: panelAbove && panelLift > 0
647
+ }), sessionBubbles.length === 0 && statusBubble !== undefined && (_jsxs("div", { className: clsx(styles.bubble, styles.bubbleStatus), role: "status", "aria-live": "polite", children: [decoration !== undefined && (_jsx(StatusOrnament, { decoration: decoration, phase: phase })), statusBubble] }, "status")), usageAnnouncements.map(entry => (_jsx(UsageAnnouncementBubble, { announcement: entry }, entry.source)))] })), hovered && dragRef.current === null && (_jsx("div", { ref: panelRef, className: clsx(styles.panel, panelAbove && styles.panelAbove), "data-placement": panelAbove ? 'above' : 'below', style: panelAbove && panelLift > 0
638
648
  ? { marginBottom: panelLift }
639
649
  : undefined, onPointerEnter: () => {
640
650
  // Reaching the panel (or its bridge) must cancel any hide timer
@@ -678,6 +688,6 @@ export function PetSprite(props) {
678
688
  clearHideTimer();
679
689
  setNameDraft(displayName);
680
690
  setRenaming(true);
681
- }, children: panelLabel('rename', props.t('pet.rename')) })), panelShows('hide') && (_jsx("button", { type: "button", className: styles.action, onClick: props.onHide, children: panelLabel('hide', props.t('pet.hide')) })), props.onGameplayMenu !== undefined && (_jsx("button", { type: "button", className: styles.action, onClick: props.onGameplayMenu, children: props.t('pet.gameplay.menu') }))] })] })) }))] }));
691
+ }, children: panelLabel('rename', props.t('pet.rename')) })), panelShows('hide') && (_jsx("button", { type: "button", className: styles.action, onClick: props.onHide, children: panelLabel('hide', props.t('pet.hide')) })), props.onGameplayMenu !== undefined && (_jsx("button", { type: "button", className: styles.action, onClick: props.onGameplayMenu, children: props.t('pet.gameplay.menu') })), (snapshot?.panelActions ?? []).map(action => (_jsx("button", { type: "button", className: styles.action, "data-dsh-pet-panel-action": action.id, ...(action.title === undefined ? {} : { title: action.title }), onClick: () => { props.onPanelAction(action.id); }, children: action.label }, action.id)))] })] })) }))] }));
682
692
  return createPortal(float, props.portalTarget ?? document.body);
683
693
  }
@@ -38,5 +38,7 @@ declare module '@deepseek-ai/cordis' {
38
38
  };
39
39
  }
40
40
  }
41
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
42
+ export declare const BINDER_RETRY_MS = 250;
41
43
  export declare function apply(ctx: ClientContext): void;
42
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,4CAA4C,CAAA;AAqFzF,wEAAwE;AACxE,eAAO,MAAM,MAAM,UAAwF,CAAA;AAE3G,qEAAqE;AACrE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf;;;;WAIG;QACH,aAAa,CAAC,EAAE;YACd,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA;aAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;SAClG,CAAA;KACF;CACF;AA0DD,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAoU9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,4CAA4C,CAAA;AAuFhG,wEAAwE;AACxE,eAAO,MAAM,MAAM,UAAwF,CAAA;AAE3G,qEAAqE;AACrE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf;;;;WAIG;QACH,aAAa,CAAC,EAAE;YACd,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA;aAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;SAClG,CAAA;KACF;CACF;AAUD,mFAAmF;AACnF,eAAO,MAAM,eAAe,MAAM,CAAA;AA2NlC,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CA6V9C"}
@@ -22,7 +22,7 @@ import { live2dRenderer } from "./renderers/live2d.js";
22
22
  import { frames2dRenderer } from "./renderers/frames2d.js";
23
23
  import { registerPetUiTeardown, takeoverPetUiTeardown } from "./ui-teardown.js";
24
24
  import { PetSettingsSection, PetSettingsCardController } from "./PetSettingsCard.js";
25
- import { NS, en, zh, t } from "./locales.js";
25
+ import { NS, en, zh } from "./locales.js";
26
26
  import { mainViewSessionId } from "./main-session.js";
27
27
  import { reportDailyHeartbeat } from "./telemetry.js";
28
28
  /** Same-origin JSON fetch helper (GET without body, POST with JSON body). */
@@ -49,6 +49,7 @@ const petApi = {
49
49
  setConfig: (patch) => petFetch('/api/pet/set-config', patch),
50
50
  setName: (name) => petFetch('/api/pet/set-name', { name }),
51
51
  setPet: (petId) => petFetch('/api/pet/set-pet', { petId }),
52
+ panelAction: (id) => petFetch('/api/pet/panel-action', { id }),
52
53
  setSkin: (skin) => petFetch('/api/pet/set-skin', skin === undefined ? {} : { skin }),
53
54
  gameplayTouch: (zone) => petFetch('/api/pet/gameplay/touch', zone === undefined ? {} : { zone }),
54
55
  gameplaySetMode: (mode) => petFetch('/api/pet/gameplay/mode', { mode }),
@@ -62,38 +63,207 @@ const PET_SETTINGS_NS = 'pet';
62
63
  /** Required services (sessions powers bubble-to-session navigation). */
63
64
  export const inject = ['slots', 'locale', 'connection', 'configForms', 'remote', 'sessions', 'uiWorkspace'];
64
65
  /**
65
- * The configuration form the settings card stages and saves through: the
66
- * family binder when dsh-web-settings is mounted, otherwise the shared form of
67
- * this plugin's own profile entry.
68
- *
69
- * The two are not interchangeable by name. A plugin's settings ARE its own
70
- * config on 0.1.7, so the form belongs to the profile entry that carries the
71
- * plugin — and only the family binder knows which entry that is, because the
72
- * family bundle renames child rows ('pet' becomes 'web-ui-pet' there) while a
73
- * standalone install keeps the package's own id.
74
- * @param ctx - client root context.
75
- * @returns the form for the pet's settings page.
66
+ * The profile entry ids a pet install is served under, most specific first. The
67
+ * family bundle renames child rows, so a standalone install and an aggregate
68
+ * one answer to different ids for the same 'pet' namespace.
76
69
  */
77
70
  const AGGREGATE_ENTRY_ID = 'web-ui-pet';
78
71
  const PET_ENTRY_IDS = [AGGREGATE_ENTRY_ID, 'ui-pet', PET_SETTINGS_NS];
79
- function servedEntryId(forms) {
80
- let served;
81
- try {
82
- served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
72
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
73
+ export const BINDER_RETRY_MS = 250;
74
+ const BINDER_ATTEMPTS = 24;
75
+ /** The snapshot an unresolved (or resolvable-but-unbound) form publishes. */
76
+ function pendingSnapshot(status) {
77
+ return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false, mode: 'host' };
78
+ }
79
+ /**
80
+ * A ConfigForm that late-binds to the family settings binder.
81
+ *
82
+ * The binder service (dsh-web-settings) is not guaranteed to be published by the
83
+ * time this plugin's apply() runs: the aggregate bundle mounts its inlined
84
+ * children — including the binder — inside an async mount that awaits the
85
+ * active-rows fetch, while standalone loader entries like this one apply
86
+ * synchronously in that window. A single early probe then permanently falls
87
+ * back to `configForms.get('pet')`, which is never a served row id under the
88
+ * aggregate (the row is `web-ui-pet`), so the settings card renders "not
89
+ * exposed" forever even though the Host serves the namespace.
90
+ *
91
+ * This form resolves through the binder as soon as the service appears and
92
+ * delegates the whole ConfigForm surface to it, re-publishing to its own
93
+ * subscribers on every swap. Until a form is resolved it publishes a loading
94
+ * (then unavailable) snapshot so the card shows a transient state, never a
95
+ * false "not exposed". If the binder never appears it retries for a bounded
96
+ * window, then permanently binds the non-bridge fallback by SERVED entry id.
97
+ */
98
+ class DeferredSettingsForm {
99
+ ctx;
100
+ current;
101
+ listeners = new Set();
102
+ unsubscribeCurrent;
103
+ retryTimer;
104
+ attempts = 0;
105
+ disposed = false;
106
+ fallback;
107
+ fallbackUnsubscribe;
108
+ constructor(ctx) {
109
+ this.ctx = ctx;
110
+ this.fallback = ctx.configForms.get(this.resolveFallbackEntryId());
111
+ // No binder yet: the aggregate publishes it after an async mount, so keep
112
+ // probing. A shared form that can already answer for itself is adopted at
113
+ // once; one still loading has simply not been filled in yet.
114
+ if (!this.resolve() && !this.fallbackSettled())
115
+ this.scheduleRetry();
116
+ else if (this.current === undefined)
117
+ this.adoptFallback();
83
118
  }
84
- catch {
85
- served = undefined;
119
+ /**
120
+ * True only once the shared mirror answers for the pet namespace itself.
121
+ *
122
+ * 'ready' is the only state that answers (#1813). A host-persisted row starts
123
+ * out as 'loading' — the mirror has published no view yet — and that is not
124
+ * an answer: adopting it on sight drops the retry window, and under the
125
+ * aggregate, which serves only the renamed 'web-ui-pet' row, the form then
126
+ * settles into 'unavailable' and the page stays "not exposed" for good. So
127
+ * 'loading' and 'unavailable' both keep the window open and let the binder be
128
+ * adopted the moment the aggregate publishes it.
129
+ */
130
+ fallbackSettled() {
131
+ try {
132
+ return this.fallback.getSnapshot().status === 'ready';
133
+ }
134
+ catch {
135
+ return false;
136
+ }
86
137
  }
87
- if (!served || served.length === 0)
138
+ /**
139
+ * Bind the fallback to a SERVED row id when the mirror can name one; a mirror
140
+ * that cannot is left to report its own unavailable state.
141
+ */
142
+ resolveFallbackEntryId() {
143
+ try {
144
+ const served = this.ctx.configForms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
145
+ if (served && served.length > 0) {
146
+ const hit = PET_ENTRY_IDS.find(id => served.includes(id));
147
+ if (hit !== undefined)
148
+ return hit;
149
+ }
150
+ }
151
+ catch {
152
+ // fall through to the family namespace; the form reports unavailable.
153
+ }
88
154
  return PET_SETTINGS_NS;
89
- return PET_ENTRY_IDS.find(id => served.includes(id)) ?? PET_SETTINGS_NS;
90
- }
91
- function petSettingsForm(ctx) {
92
- const binder = ctx.get('webUiSettings');
93
- if (binder !== undefined && typeof binder.bind === 'function') {
94
- return binder.bind({ namespace: PET_SETTINGS_NS });
95
155
  }
96
- return ctx.configForms.get(servedEntryId(ctx.configForms));
156
+ /**
157
+ * Adopt the family binder the moment it is published.
158
+ * @returns true when a binder was bound, false when none is available yet.
159
+ */
160
+ resolve() {
161
+ if (this.disposed)
162
+ return false;
163
+ let binder;
164
+ try {
165
+ binder = this.ctx.get('webUiSettings');
166
+ }
167
+ catch {
168
+ binder = undefined;
169
+ }
170
+ if (binder === undefined || typeof binder.bind !== 'function')
171
+ return false;
172
+ let bound;
173
+ try {
174
+ bound = binder
175
+ .bind({ namespace: PET_SETTINGS_NS });
176
+ }
177
+ catch {
178
+ return false;
179
+ }
180
+ this.current = bound;
181
+ // Mirror the bound form's changes to our own subscribers; a later re-resolve
182
+ // swaps this subscription to the new form.
183
+ this.unsubscribeCurrent?.();
184
+ this.unsubscribeCurrent = bound.subscribe(() => this.publish());
185
+ this.publish();
186
+ return true;
187
+ }
188
+ /**
189
+ * Adopt the shared per-entry form. It is used immediately unless it cannot
190
+ * answer yet (still loading, or reporting the namespace unavailable), in which
191
+ * case the binder may still be on its way and the retry window takes over
192
+ * (see scheduleRetry).
193
+ */
194
+ adoptFallback() {
195
+ this.current = this.fallback;
196
+ this.fallbackUnsubscribe ??= this.fallback.subscribe(() => this.publish());
197
+ this.unsubscribeCurrent = this.fallbackUnsubscribe;
198
+ this.publish();
199
+ }
200
+ /** Retry the binder lookup a few times across the aggregate's async mount. */
201
+ scheduleRetry() {
202
+ if (this.disposed)
203
+ return;
204
+ if (this.attempts >= BINDER_ATTEMPTS) {
205
+ this.adoptFallback();
206
+ return;
207
+ }
208
+ this.attempts += 1;
209
+ this.retryTimer = window.setTimeout(() => {
210
+ this.retryTimer = undefined;
211
+ if (this.disposed)
212
+ return;
213
+ if (this.resolve())
214
+ return;
215
+ // The binder still absent: keep waiting only while the shared form cannot
216
+ // answer for itself, otherwise a standalone install stalls for the window.
217
+ if (this.fallbackSettled()) {
218
+ this.attempts = BINDER_ATTEMPTS;
219
+ this.adoptFallback();
220
+ return;
221
+ }
222
+ this.scheduleRetry();
223
+ }, BINDER_RETRY_MS);
224
+ }
225
+ publish() {
226
+ for (const listener of this.listeners)
227
+ listener();
228
+ }
229
+ /** The resolved form, or a placeholder snapshot when still pending. */
230
+ snapshot() {
231
+ return this.current?.getSnapshot() ?? pendingSnapshot(this.attempts >= BINDER_ATTEMPTS ? 'unavailable' : 'loading');
232
+ }
233
+ getSnapshot() {
234
+ return this.snapshot();
235
+ }
236
+ subscribe(listener) {
237
+ this.listeners.add(listener);
238
+ return () => { this.listeners.delete(listener); };
239
+ }
240
+ mutate(ops, expectedRevision) {
241
+ return this.current?.mutate(ops, expectedRevision) ?? Promise.resolve(false);
242
+ }
243
+ set(field, value) {
244
+ return this.current?.set(field, value) ?? Promise.resolve(false);
245
+ }
246
+ unset(field) {
247
+ return this.current?.unset(field) ?? Promise.resolve(false);
248
+ }
249
+ /** Release the retry timer and mirror subscription; not part of ConfigForm. */
250
+ dispose() {
251
+ if (this.disposed)
252
+ return;
253
+ this.disposed = true;
254
+ if (this.retryTimer !== undefined) {
255
+ window.clearTimeout(this.retryTimer);
256
+ this.retryTimer = undefined;
257
+ }
258
+ this.unsubscribeCurrent?.();
259
+ this.unsubscribeCurrent = undefined;
260
+ this.current = undefined;
261
+ this.listeners.clear();
262
+ // The shared per-entry form carries no disposer of its own (ConfigForm is a
263
+ // pure read/write surface); only this form's own subscriptions are released.
264
+ this.fallbackUnsubscribe?.();
265
+ this.fallbackUnsubscribe = undefined;
266
+ }
97
267
  }
98
268
  /**
99
269
  * Client plugin body: register dictionaries, mount the global pet entry and
@@ -129,7 +299,7 @@ export function apply(ctx) {
129
299
  // M3). Registration is idempotent (id wins), so re-applies stay clean.
130
300
  defaultPetRendererRegistry.register(live2dRenderer);
131
301
  defaultPetRendererRegistry.register(frames2dRenderer);
132
- const settingsForm = petSettingsForm(ctx);
302
+ const settingsForm = new DeferredSettingsForm(ctx);
133
303
  const enabled = () => {
134
304
  const snapshot = settingsForm.getSnapshot();
135
305
  return snapshot.status === 'ready'
@@ -342,6 +512,20 @@ export function apply(ctx) {
342
512
  // Ignore; next poll resyncs.
343
513
  });
344
514
  },
515
+ // A panel action click (issue #6) travels back to the host, which
516
+ // dispatches it to the plugin that registered the action. The plugin's
517
+ // own callback does the work; the browser half only reports the id, and
518
+ // the next poll brings back whatever that callback changed. A click on
519
+ // an action the plugin already disposed answers { ok: false } — the
520
+ // button was one poll tick stale, which is not a pet failure.
521
+ panelAction: (id) => {
522
+ petApi.panelAction(id).then((result) => {
523
+ if (result.ok)
524
+ pollNow();
525
+ }, () => {
526
+ // Ignore; next poll resyncs.
527
+ });
528
+ },
345
529
  feedbackDone: () => {
346
530
  setFeedback(null);
347
531
  },
@@ -396,7 +580,16 @@ export function apply(ctx) {
396
580
  // root then owns the whole surface, so a root-keyed suppressor (the
397
581
  // portrait mobile layer, which hides [data-dsh-plugin="pet"]) really
398
582
  // hides the sprite instead of missing the portaled float.
399
- petRoot.render(createElement(PetDockEntry, { ...injected(), t, portalTarget: container }));
583
+ //
584
+ // The floating surface has no session-scoped locale seat, so it must be
585
+ // handed the framework one explicitly. Resolving its copy from the
586
+ // plugin's own zh/en dictionary keyed on <html lang> sent every
587
+ // registered language except English to Chinese: a ru/ja/de page showed a
588
+ // Chinese panel while the settings card beside it was translated. Binding
589
+ // the 'pet' namespace instead follows the active language, the English
590
+ // fallback, and every language pack that registers a dictionary for it
591
+ // (the settings section label already resolves through the same seat).
592
+ petRoot.render(createElement(PetDockEntry, { ...injected(), t: ctx.locale.bind(NS), portalTarget: container }));
400
593
  let uiGone = false;
401
594
  disposeUi = () => {
402
595
  if (uiGone)
@@ -430,6 +623,9 @@ export function apply(ctx) {
430
623
  const unsubscribeSettings = settingsForm.subscribe(syncUi);
431
624
  ctx.effect(() => () => {
432
625
  unsubscribeSettings();
626
+ // Release the deferred form's retry timer and its mirror subscription so a
627
+ // disposed fiber can never bind or publish after teardown.
628
+ settingsForm.dispose();
433
629
  killUi();
434
630
  }, 'pet: client lifecycle');
435
631
  syncUi();
@@ -60,6 +60,8 @@ export declare const zh: {
60
60
  readonly 'settings.enabledHint': "关闭后隐藏宠物并停止轮询,可在设置里重新启用。";
61
61
  readonly 'settings.decoration': "状态装饰";
62
62
  readonly 'settings.decorationHint': "在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。";
63
+ readonly 'settings.statusBubbles': "状态气泡";
64
+ readonly 'settings.statusBubblesHint': "宠物自带的会话/状态气泡(正在思考、正在使用 xxx)。关掉后只剩第三方插件通过公告契约推送的气泡与互动反馈气泡;默认开启。";
63
65
  readonly 'settings.visible': "显示宠物";
64
66
  readonly 'settings.visibleHint': "关闭后宠物隐藏,可从聊天输入区重新召唤。";
65
67
  readonly 'settings.size': "大小(px)";
@@ -142,6 +144,8 @@ export declare const en: {
142
144
  readonly 'settings.enabledHint': "When off, the pet hides and polling stops; re-enable it here.";
143
145
  readonly 'settings.decoration': "Status decoration";
144
146
  readonly 'settings.decorationHint': "Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.";
147
+ readonly 'settings.statusBubbles': "Status bubbles";
148
+ readonly 'settings.statusBubblesHint': "The pet's own session/status bubbles (thinking, using ...). Turning them off leaves only bubbles a third-party plugin pushes through the announcement contract, plus the interaction feedback bubble; on by default.";
145
149
  readonly 'settings.visible': "Show the pet";
146
150
  readonly 'settings.visibleHint': "When off, the pet hides; summon it again from the input row.";
147
151
  readonly 'settings.size': "Size (px)";
@@ -1 +1 @@
1
- {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,eAAO,MAAM,EAAE,QAAQ,CAAA;AAEvB,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFL,CAAA;AAEV,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkFL,CAAA;AAEV,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAA;AAEpC,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AAEpC;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAQvE;AAED,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,uBAAuB;QACvB,GAAG,EAAE,MAAM,CAAA;KACZ;CACF"}
1
+ {"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,eAAO,MAAM,EAAE,QAAQ,CAAA;AAEvB,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFL,CAAA;AAEV,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAoFL,CAAA;AAEV,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAA;AAEpC,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AAEpC;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAQvE;AAED,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,uBAAuB;QACvB,GAAG,EAAE,MAAM,CAAA;KACZ;CACF"}
@@ -62,6 +62,8 @@ export const zh = {
62
62
  'settings.enabledHint': '关闭后隐藏宠物并停止轮询,可在设置里重新启用。',
63
63
  'settings.decoration': '状态装饰',
64
64
  'settings.decorationHint': '在宠物状态气泡里显示喷水鲸鱼等状态装饰;关闭后气泡只剩文字。',
65
+ 'settings.statusBubbles': '状态气泡',
66
+ 'settings.statusBubblesHint': '宠物自带的会话/状态气泡(正在思考、正在使用 xxx)。关掉后只剩第三方插件通过公告契约推送的气泡与互动反馈气泡;默认开启。',
65
67
  'settings.visible': '显示宠物',
66
68
  'settings.visibleHint': '关闭后宠物隐藏,可从聊天输入区重新召唤。',
67
69
  'settings.size': '大小(px)',
@@ -146,6 +148,8 @@ export const en = {
146
148
  'settings.enabledHint': 'When off, the pet hides and polling stops; re-enable it here.',
147
149
  'settings.decoration': 'Status decoration',
148
150
  'settings.decorationHint': 'Show ornaments like the spouting whale inside the pet status bubbles; when off, bubbles stay text-only.',
151
+ 'settings.statusBubbles': 'Status bubbles',
152
+ 'settings.statusBubblesHint': 'The pet\'s own session/status bubbles (thinking, using ...). Turning them off leaves only bubbles a third-party plugin pushes through the announcement contract, plus the interaction feedback bubble; on by default.',
149
153
  'settings.visible': 'Show the pet',
150
154
  'settings.visibleHint': 'When off, the pet hides; summon it again from the input row.',
151
155
  'settings.size': 'Size (px)',
@@ -12,10 +12,12 @@
12
12
  */
13
13
  import { Context, type Volatile } from '@deepseek-ai/cordis';
14
14
  import z from '@deepseek-ai/schemastery';
15
- import { type PetConfig, type PetSettingsSection } from './service.ts';
15
+ import { type PetConfig, type PetSettingsSection, type PetStatusBubbleMode } from './service.ts';
16
16
  import { type PetDisplayConfig } from './persist.ts';
17
- export { PetService, MAX_SESSION_BUBBLES } from './service.ts';
18
- export type { PetConfig, PetInteractResult, PetSettingsSection, PetSessionView, PetStateView, } from './service.ts';
17
+ export { PetService, MAX_SESSION_BUBBLES, DEFAULT_STATUS_BUBBLE_MODE, STATUS_BUBBLE_MODES, statusBubbleMode } from './service.ts';
18
+ export type { PetConfig, PetInteractResult, PetSettingsSection, PetSessionView, PetStateView, PetStatusBubbleMode, } from './service.ts';
19
+ export { MAX_PANEL_ACTIONS, PanelActionRegistry, normalizePanelAction } from './panel-actions.ts';
20
+ export type { PetPanelActionContext, PetPanelActionHandler, PetPanelActionRegistration, PetPanelActionView, } from './panel-actions.ts';
19
21
  export { AFFINITY_MAX, AFFINITY_RANKS, applyInteraction, applyTurnReward, emptyAffinity, rankOf, } from './affinity.ts';
20
22
  export type { AffinityConfig, AffinityState, InteractionOutcome, PetInteraction, } from './affinity.ts';
21
23
  export { animationForPhase, PetStateMachine, rowOf, } from './state.ts';
@@ -47,6 +49,7 @@ export declare const PET_FORM_DEFAULTS: {
47
49
  readonly petId: "whale-girl";
48
50
  readonly enabled: true;
49
51
  readonly decorationEnabled: true;
52
+ readonly statusBubbles: PetStatusBubbleMode;
50
53
  };
51
54
  /**
52
55
  * One settings field as the config carries it. The Host commits an edit into
@@ -61,6 +64,12 @@ export interface PetFormConfig {
61
64
  enabled?: LiveField<boolean>;
62
65
  /** Status-decoration master switch (pet-center M5, #567); defaults to on. */
63
66
  decorationEnabled?: LiveField<boolean>;
67
+ /**
68
+ * Whether the pet renders its own session/status bubbles (issue #6);
69
+ * defaults to 'auto', which is exactly the behavior that shipped before
70
+ * the switch existed.
71
+ */
72
+ statusBubbles?: LiveField<PetStatusBubbleMode | undefined>;
64
73
  /** Master switch for the pet surface. */
65
74
  visible?: LiveField<boolean>;
66
75
  /** Scale of the rendered pet in px (sprite cell height). */
@@ -98,6 +107,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
98
107
  petId: z<string, string, "volatile">;
99
108
  enabled: z<boolean, boolean, "volatile-defined">;
100
109
  decorationEnabled: z<boolean, boolean, "volatile-defined">;
110
+ statusBubbles: z<"auto" | "off", "auto" | "off", "volatile-defined">;
101
111
  }>>, Schemastery.ObjectT<NoInfer<{
102
112
  visible: z<boolean, boolean, "volatile-defined">;
103
113
  size: z<number, number, "volatile-defined">;
@@ -107,6 +117,7 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
107
117
  petId: z<string, string, "volatile">;
108
118
  enabled: z<boolean, boolean, "volatile-defined">;
109
119
  decorationEnabled: z<boolean, boolean, "volatile-defined">;
120
+ statusBubbles: z<"auto" | "off", "auto" | "off", "volatile-defined">;
110
121
  }>>, "plain">;
111
122
  /**
112
123
  * The settings section the pet runs with: the effective values of the row's
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI5D,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAsC,KAAK,SAAS,EAAE,KAAK,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAG1G,OAAO,EAA6G,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAG/J,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAA;AAC9D,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EACd,YAAY,GACb,MAAM,cAAc,CAAA;AACrB,OAAO,EACL,YAAY,EACZ,cAAc,EACd,gBAAgB,EAChB,eAAe,EACf,aAAa,EACb,MAAM,GACP,MAAM,eAAe,CAAA;AACtB,YAAY,EACV,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,cAAc,GACf,MAAM,eAAe,CAAA;AACtB,OAAO,EACL,iBAAiB,EACjB,eAAe,EACf,KAAK,GACN,MAAM,YAAY,CAAA;AACnB,YAAY,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,aAAa,EACb,gBAAgB,GACjB,MAAM,YAAY,CAAA;AACnB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAA;AACpB,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC5E,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,mBAAmB,GACpB,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,UAAU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