@linxin666/dsh-pet 0.4.5 → 0.4.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.i18n.yaml +2 -2
- package/README.md +30 -3
- package/README.zh.md +30 -3
- package/lib/client.js +178 -62
- package/lib/client.js.map +1 -1
- package/lib/index.js +734 -26
- package/lib/live2d-vendor.js +129 -95
- package/lib/live2d-vendor.js.map +1 -1
- package/lib/types/announce.d.ts +16 -0
- package/lib/types/announce.d.ts.map +1 -1
- package/lib/types/announce.js +16 -0
- package/lib/types/client/PetDockEntry.d.ts +6 -0
- package/lib/types/client/PetDockEntry.d.ts.map +1 -1
- package/lib/types/client/PetDockEntry.js +1 -1
- package/lib/types/client/PetSettingsCard.d.ts +4 -0
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +16 -1
- package/lib/types/client/PetSprite.d.ts +7 -0
- package/lib/types/client/PetSprite.d.ts.map +1 -1
- package/lib/types/client/PetSprite.js +23 -13
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +43 -11
- package/lib/types/client/locales.d.ts +4 -0
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +4 -0
- package/lib/types/client/renderers/frames2d.d.ts +5 -3
- package/lib/types/client/renderers/frames2d.d.ts.map +1 -1
- package/lib/types/client/renderers/frames2d.js +139 -33
- package/lib/types/index.d.ts +14 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +15 -2
- package/lib/types/panel-actions.d.ts +96 -0
- package/lib/types/panel-actions.d.ts.map +1 -0
- package/lib/types/panel-actions.js +134 -0
- package/lib/types/routes.d.ts.map +1 -1
- package/lib/types/routes.js +10 -0
- package/lib/types/service.d.ts +137 -9
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +151 -19
- package/package.json +26 -30
- package/src/announce.ts +17 -0
- package/src/client/PetDockEntry.test.tsx +1 -0
- package/src/client/PetDockEntry.tsx +7 -0
- package/src/client/PetSettingsCard.test.tsx +88 -0
- package/src/client/PetSettingsCard.tsx +31 -0
- package/src/client/PetSprite.test.tsx +197 -0
- package/src/client/PetSprite.tsx +56 -12
- package/src/client/index.test.tsx +74 -4
- package/src/client/index.ts +43 -11
- package/src/client/locales.ts +4 -0
- package/src/client/renderers/frames2d.test.ts +103 -1
- package/src/client/renderers/frames2d.ts +143 -30
- package/src/index.test.ts +22 -0
- package/src/index.ts +28 -2
- package/src/panel-actions.test.ts +130 -0
- package/src/panel-actions.ts +182 -0
- package/src/registry.test.ts +3 -2
- package/src/routes.ts +9 -0
- package/src/service.test.ts +128 -0
- package/src/service.ts +206 -22
- package/lib/invariant.js +0 -34
- package/lib/state-NvDEoCln.js +0 -455
- package/lib/types/invariant.d.ts +0 -10
- package/lib/types/invariant.d.ts.map +0 -1
- package/lib/types/invariant.js +0 -27
- package/src/invariant.ts +0 -40
package/lib/types/announce.d.ts
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* validates it into a bounded payload, and the browser half renders it as a
|
|
5
5
|
* dedicated, specially styled bubble above the session bubble stack.
|
|
6
6
|
*
|
|
7
|
+
* One slot per publisher (issue #1812): `source` is the slot key, so two
|
|
8
|
+
* announcing plugins coexist instead of displacing each other, and each keeps
|
|
9
|
+
* its own TTL. The single-slot contract this replaced is kept on the wire as
|
|
10
|
+
* the freshest entry, so an older browser half keeps working unchanged.
|
|
11
|
+
*
|
|
7
12
|
* The validation lives in this pure module so the wire contract has exactly
|
|
8
13
|
* one home and stays testable without the cordis service.
|
|
9
14
|
* @module @linxin666/dsh-pet/announce
|
|
@@ -33,6 +38,17 @@ export interface PetAnnouncement {
|
|
|
33
38
|
}
|
|
34
39
|
/** Default freshness window. */
|
|
35
40
|
export declare const ANNOUNCE_DEFAULT_TTL_MS = 10000;
|
|
41
|
+
/**
|
|
42
|
+
* How many publishers can hold an announcement bubble at once (issue #1812).
|
|
43
|
+
*
|
|
44
|
+
* The contract has exactly one slot per `source` — that is the whole upgrade
|
|
45
|
+
* from the single-slot design — but the pet's bubble stack is a finite column,
|
|
46
|
+
* so the table is bounded rather than open. The bound is deliberately above the
|
|
47
|
+
* realistic publisher count (a quota bubble, a balance bubble, a notification):
|
|
48
|
+
* it exists so a misbehaving publisher that rotates `source` per bubble cannot
|
|
49
|
+
* grow the pet's stack without limit.
|
|
50
|
+
*/
|
|
51
|
+
export declare const MAX_ANNOUNCEMENTS = 4;
|
|
36
52
|
/**
|
|
37
53
|
* Hard TTL ceiling. A repeating announcer declares its poll cadence as
|
|
38
54
|
* the TTL, so an always-on bubble stays continuous across polls; the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../../src/announce.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"announce.d.ts","sourceRoot":"","sources":["../../src/announce.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,+CAA+C;AAC/C,MAAM,WAAW,eAAe;IAC9B,kEAAkE;IAClE,MAAM,EAAE,MAAM,CAAA;IACd,yFAAyF;IACzF,IAAI,EAAE,SAAS,GAAG,MAAM,GAAG,MAAM,CAAA;IACjC,qDAAqD;IACrD,KAAK,EAAE,MAAM,CAAA;IACb,yFAAyF;IACzF,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,oFAAoF;IACpF,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,qDAAqD;IACrD,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,KAAK,CAAA;IAC3B,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAA;IACb,yCAAyC;IACzC,EAAE,EAAE,MAAM,CAAA;CACX;AAED,gCAAgC;AAChC,eAAO,MAAM,uBAAuB,QAAS,CAAA;AAE7C;;;;;;;;;GASG;AACH,eAAO,MAAM,iBAAiB,IAAI,CAAA;AAElC;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,UAAY,CAAA;AAc5C;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,eAAe,GAAG,SAAS,CAgC1F;AAED,uDAAuD;AACvD,wBAAgB,iBAAiB,CAAC,YAAY,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAErF"}
|
package/lib/types/announce.js
CHANGED
|
@@ -4,12 +4,28 @@
|
|
|
4
4
|
* validates it into a bounded payload, and the browser half renders it as a
|
|
5
5
|
* dedicated, specially styled bubble above the session bubble stack.
|
|
6
6
|
*
|
|
7
|
+
* One slot per publisher (issue #1812): `source` is the slot key, so two
|
|
8
|
+
* announcing plugins coexist instead of displacing each other, and each keeps
|
|
9
|
+
* its own TTL. The single-slot contract this replaced is kept on the wire as
|
|
10
|
+
* the freshest entry, so an older browser half keeps working unchanged.
|
|
11
|
+
*
|
|
7
12
|
* The validation lives in this pure module so the wire contract has exactly
|
|
8
13
|
* one home and stays testable without the cordis service.
|
|
9
14
|
* @module @linxin666/dsh-pet/announce
|
|
10
15
|
*/
|
|
11
16
|
/** Default freshness window. */
|
|
12
17
|
export const ANNOUNCE_DEFAULT_TTL_MS = 10_000;
|
|
18
|
+
/**
|
|
19
|
+
* How many publishers can hold an announcement bubble at once (issue #1812).
|
|
20
|
+
*
|
|
21
|
+
* The contract has exactly one slot per `source` — that is the whole upgrade
|
|
22
|
+
* from the single-slot design — but the pet's bubble stack is a finite column,
|
|
23
|
+
* so the table is bounded rather than open. The bound is deliberately above the
|
|
24
|
+
* realistic publisher count (a quota bubble, a balance bubble, a notification):
|
|
25
|
+
* it exists so a misbehaving publisher that rotates `source` per bubble cannot
|
|
26
|
+
* grow the pet's stack without limit.
|
|
27
|
+
*/
|
|
28
|
+
export const MAX_ANNOUNCEMENTS = 4;
|
|
13
29
|
/**
|
|
14
30
|
* Hard TTL ceiling. A repeating announcer declares its poll cadence as
|
|
15
31
|
* the TTL, so an always-on bubble stays continuous across polls; the
|
|
@@ -34,6 +34,12 @@ export interface PetInjected {
|
|
|
34
34
|
dragEnd: (right: number, bottom: number) => void;
|
|
35
35
|
/** Rename the selected pet (persisted by the host). */
|
|
36
36
|
rename: (name: string) => void;
|
|
37
|
+
/**
|
|
38
|
+
* Report a click on one plugin-registered panel action (issue #6). The host
|
|
39
|
+
* dispatches it to the plugin that registered the action; the panel itself
|
|
40
|
+
* only renders the button the state snapshot served.
|
|
41
|
+
*/
|
|
42
|
+
panelAction: (id: string) => void;
|
|
37
43
|
/** Navigate the GUI to the session a bubble reports on. */
|
|
38
44
|
openSession: (sessionId: string) => void;
|
|
39
45
|
/** Clear the reaction bubble. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PetDockEntry.d.ts","sourceRoot":"","sources":["../../../src/client/PetDockEntry.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAA2C,KAAK,YAAY,EAAE,MAAM,OAAO,CAAA;AAClF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAA;AAItD,OAAO,EAAe,KAAK,WAAW,EAAoB,MAAM,oBAAoB,CAAA;AACpF,OAAO,EAAE,EAAE,EAAE,MAAM,cAAc,CAAA;AAGjC,2DAA2D;AAC3D,MAAM,WAAW,WAAW;IAC1B,6EAA6E;IAC7E,KAAK,EAAE,gBAAgB,CAAA;IACvB,kFAAkF;IAClF,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,8BAA8B;IAC9B,GAAG,EAAE,MAAM,IAAI,CAAA;IACf,uBAAuB;IACvB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,qC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ACvB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,uBAAuB;IACvB,IAAI,EAAE,MAAM,IAAI,CAAA;IAChB,qCAAqC;IACrC,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,+BAA+B;IAC/B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAChD,uDAAuD;IACvD,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAC9B;;;;OAIG;IACH,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,2DAA2D;IAC3D,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IACxC,iCAAiC;IACjC,YAAY,EAAE,MAAM,IAAI,CAAA;IACxB,uGAAuG;IACvG,QAAQ,EAAE,WAAW,CAAA;CACtB;AAED,yFAAyF;AACzF,MAAM,MAAM,iBAAiB,GAC3B,WAAW,GACT,WAAW,CAAC,OAAO,EAAE,CAAC,GACtB;IACA;;;;;OAKG;IACH,YAAY,CAAC,EAAE,OAAO,CAAA;CACvB,CAAA;AAIH;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,YAAY,CA2FnE"}
|
|
@@ -47,7 +47,7 @@ export function PetDockEntry(props) {
|
|
|
47
47
|
if (visible) {
|
|
48
48
|
return (_jsx("span", { "data-pet-dock": true, "data-testid": "pet-dock", children: snapshot === null || definition === null
|
|
49
49
|
? null
|
|
50
|
-
: (_jsx(PetRendererSwitch, { definition: definition, phase: snapshot?.phase ?? 'idle', onPet: props.pet, ...(aux === null ? {} : { drag: aux.drag, bus: aux.bus }), t: props.t, children: _jsx(PetSprite, { snapshot: snapshot, definition: definition, display: snapshot.display, feedback: feedback, onPet: props.pet, onFeed: props.feed, onHide: props.hide, onDragEnd: props.dragEnd, onRename: props.rename, onOpenSession: props.openSession, onFeedbackDone: props.feedbackDone, portalTarget: props.portalTarget, dragDisabled: snapshot.gameplay?.mode === 'work', ...(aux === null ? {} : { bus: aux.bus }), ...(gameplay === undefined || aux === null
|
|
50
|
+
: (_jsx(PetRendererSwitch, { definition: definition, phase: snapshot?.phase ?? 'idle', onPet: props.pet, ...(aux === null ? {} : { drag: aux.drag, bus: aux.bus }), t: props.t, children: _jsx(PetSprite, { snapshot: snapshot, definition: definition, display: snapshot.display, feedback: feedback, onPet: props.pet, onFeed: props.feed, onHide: props.hide, onDragEnd: props.dragEnd, onRename: props.rename, onPanelAction: props.panelAction, onOpenSession: props.openSession, onFeedbackDone: props.feedbackDone, portalTarget: props.portalTarget, dragDisabled: snapshot.gameplay?.mode === 'work', ...(aux === null ? {} : { bus: aux.bus }), ...(gameplay === undefined || aux === null
|
|
51
51
|
? {}
|
|
52
52
|
: {
|
|
53
53
|
onGameplayTap: (fx, fy) => aux.bus.tap?.(fx, fy),
|
|
@@ -31,6 +31,8 @@ export interface PetSettings {
|
|
|
31
31
|
petId?: string;
|
|
32
32
|
/** Status-decoration master switch (pet-center M5, #567). */
|
|
33
33
|
decorationEnabled?: boolean;
|
|
34
|
+
/** Whether the pet's own session/status bubbles render (issue #6). */
|
|
35
|
+
statusBubbles?: string;
|
|
34
36
|
}
|
|
35
37
|
/** What the pet settings card renders. */
|
|
36
38
|
export interface PetSettingsCardState extends CardShell {
|
|
@@ -52,6 +54,8 @@ export interface PetSettingsCardState extends CardShell {
|
|
|
52
54
|
petId: CardFieldState;
|
|
53
55
|
/** Status-decoration master switch. */
|
|
54
56
|
decorationEnabled: CardFieldState;
|
|
57
|
+
/** Whether the pet's own session/status bubbles render. */
|
|
58
|
+
statusBubbles: CardFieldState;
|
|
55
59
|
/** Pet choices (registry ids + display names), loaded from the host. */
|
|
56
60
|
petChoices: readonly {
|
|
57
61
|
value: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PetSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/client/PetSettingsCard.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B,GACjC,YAAY,CAAC,kBAAkB,CAAC,GAC9B,WAAW,CAAC,KAAK,CAAC,GAClB,UAAU,CAAC,mBAAmB,CAAC,CAAA;AAEnC,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,uBAAuB,GAAG,SAAS,CAO5E"}
|
|
@@ -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'); } }),
|
|
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,K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AAE,MAAM,IAAI,CAAA;IAClB,+BAA+B;IAC/B,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,KAAK,IAAI,CAAA;IAClD,6EAA6E;IAC7E,gBAAgB,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,KAAK,IAAI,CAAA;IAC9C,uDAAuD;IACvD,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC;;;;;OAKG;IACH,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAA;IACnC,4DAA4D;IAC5D,aAAa,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAA;IAC1C,2DAA2D;IAC3D,cAAc,EAAE,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
|
-
|
|
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
|
|
518
|
-
//
|
|
519
|
-
//
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
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 ||
|
|
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 ||
|
|
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")),
|
|
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
|
}
|
|
@@ -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,EAAsB,MAAM,4CAA4C,CAAA;
|
|
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
|
|
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 }),
|
|
@@ -73,7 +74,7 @@ export const BINDER_RETRY_MS = 250;
|
|
|
73
74
|
const BINDER_ATTEMPTS = 24;
|
|
74
75
|
/** The snapshot an unresolved (or resolvable-but-unbound) form publishes. */
|
|
75
76
|
function pendingSnapshot(status) {
|
|
76
|
-
return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false
|
|
77
|
+
return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false };
|
|
77
78
|
}
|
|
78
79
|
/**
|
|
79
80
|
* A ConfigForm that late-binds to the family settings binder.
|
|
@@ -108,20 +109,27 @@ class DeferredSettingsForm {
|
|
|
108
109
|
this.ctx = ctx;
|
|
109
110
|
this.fallback = ctx.configForms.get(this.resolveFallbackEntryId());
|
|
110
111
|
// No binder yet: the aggregate publishes it after an async mount, so keep
|
|
111
|
-
// probing. A shared form that can answer for itself is adopted at
|
|
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.
|
|
112
114
|
if (!this.resolve() && !this.fallbackSettled())
|
|
113
115
|
this.scheduleRetry();
|
|
114
116
|
else if (this.current === undefined)
|
|
115
117
|
this.adoptFallback();
|
|
116
118
|
}
|
|
117
119
|
/**
|
|
118
|
-
* True
|
|
119
|
-
*
|
|
120
|
-
*
|
|
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.
|
|
121
129
|
*/
|
|
122
130
|
fallbackSettled() {
|
|
123
131
|
try {
|
|
124
|
-
return this.fallback.getSnapshot().status
|
|
132
|
+
return this.fallback.getSnapshot().status === 'ready';
|
|
125
133
|
}
|
|
126
134
|
catch {
|
|
127
135
|
return false;
|
|
@@ -178,9 +186,10 @@ class DeferredSettingsForm {
|
|
|
178
186
|
return true;
|
|
179
187
|
}
|
|
180
188
|
/**
|
|
181
|
-
* Adopt the shared per-entry form. It is used immediately unless it
|
|
182
|
-
*
|
|
183
|
-
* and the retry window takes over
|
|
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).
|
|
184
193
|
*/
|
|
185
194
|
adoptFallback() {
|
|
186
195
|
this.current = this.fallback;
|
|
@@ -503,6 +512,20 @@ export function apply(ctx) {
|
|
|
503
512
|
// Ignore; next poll resyncs.
|
|
504
513
|
});
|
|
505
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
|
+
},
|
|
506
529
|
feedbackDone: () => {
|
|
507
530
|
setFeedback(null);
|
|
508
531
|
},
|
|
@@ -557,7 +580,16 @@ export function apply(ctx) {
|
|
|
557
580
|
// root then owns the whole surface, so a root-keyed suppressor (the
|
|
558
581
|
// portrait mobile layer, which hides [data-dsh-plugin="pet"]) really
|
|
559
582
|
// hides the sprite instead of missing the portaled float.
|
|
560
|
-
|
|
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 }));
|
|
561
593
|
let uiGone = false;
|
|
562
594
|
disposeUi = () => {
|
|
563
595
|
if (uiGone)
|
|
@@ -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
|
|
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)',
|
|
@@ -14,9 +14,11 @@
|
|
|
14
14
|
* - Canvas bitmap buffer (default where createImageBitmap/fetch/2D context
|
|
15
15
|
* exist): frames are decoded once into an ImageBitmap on demand, with a
|
|
16
16
|
* bounded look-ahead window over the playing track, and drawn onto one
|
|
17
|
-
* <canvas
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* <canvas>. Steady-state playback issues zero DOM mutations and re-decodes
|
|
18
|
+
* only what the retention budget evicted: decoded frames are held under
|
|
19
|
+
* MAX_RETAINED_BYTES, so a long-lived pet that plays every track of every
|
|
20
|
+
* skin cannot pin every bitmap for the life of the page (measured hotspot:
|
|
21
|
+
* swapping <img>.src per frame drove image decode + invalidation every tick).
|
|
20
22
|
* - Classic <img> fallback (jsdom/tests or missing APIs): identical to the
|
|
21
23
|
* historical behavior - cache-warm Image elements plus guarded src swaps,
|
|
22
24
|
* so environments without modern decoding keep working unchanged.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"frames2d.d.ts","sourceRoot":"","sources":["../../../../src/client/renderers/frames2d.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"frames2d.d.ts","sourceRoot":"","sources":["../../../../src/client/renderers/frames2d.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAA4B,KAAK,WAAW,EAA2B,KAAK,iBAAiB,EAAE,MAAM,6BAA6B,CAAA;AACzI,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,oEAAoE;AACpE,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,IAAI,EAAE,OAAO,CAAA;IACb,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB;AAED,8DAA8D;AAC9D,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAA;IAC3C,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC,GAAG;QAAE,IAAI,EAAE,MAAM,CAAA;KAAE,CAAA;IACjE,wEAAwE;IACxE,KAAK,CAAC,EAAE,kBAAkB,EAAE,CAAA;CAC7B;AAED,sEAAsE;AACtE,MAAM,W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