@linxin666/dsh-pet 0.4.10 → 0.4.11

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 (53) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +1 -1
  3. package/README.zh.md +4 -4
  4. package/lib/client.js +1092 -348
  5. package/lib/client.js.map +1 -1
  6. package/lib/types/client/PetPreview.d.ts +12 -0
  7. package/lib/types/client/PetPreview.d.ts.map +1 -0
  8. package/lib/types/client/PetPreview.js +32 -0
  9. package/lib/types/client/PetSettingsCard.d.ts +30 -2
  10. package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
  11. package/lib/types/client/PetSettingsCard.js +48 -8
  12. package/lib/types/client/PluginSettingsCard.d.ts +131 -17
  13. package/lib/types/client/PluginSettingsCard.d.ts.map +1 -1
  14. package/lib/types/client/PluginSettingsCard.js +158 -37
  15. package/lib/types/client/RangeBubble.d.ts +47 -0
  16. package/lib/types/client/RangeBubble.d.ts.map +1 -0
  17. package/lib/types/client/RangeBubble.js +107 -0
  18. package/lib/types/client/SegmentGroup.d.ts +29 -0
  19. package/lib/types/client/SegmentGroup.d.ts.map +1 -0
  20. package/lib/types/client/SegmentGroup.js +81 -0
  21. package/lib/types/client/index.d.ts.map +1 -1
  22. package/lib/types/client/index.js +9 -28
  23. package/lib/types/client/locales.d.ts +36 -44
  24. package/lib/types/client/locales.d.ts.map +1 -1
  25. package/lib/types/client/locales.js +36 -44
  26. package/lib/types/client/settings-form.d.ts +79 -41
  27. package/lib/types/client/settings-form.d.ts.map +1 -1
  28. package/lib/types/client/settings-form.js +96 -36
  29. package/lib/types/client/settings-registration.d.ts +15 -0
  30. package/lib/types/client/settings-registration.d.ts.map +1 -0
  31. package/lib/types/client/settings-registration.js +24 -0
  32. package/lib/types/client/web-extension-contract.d.ts +32 -0
  33. package/lib/types/client/web-extension-contract.d.ts.map +1 -0
  34. package/lib/types/client/web-extension-contract.js +6 -0
  35. package/lib/types/client/web-extension-page.d.ts +51 -0
  36. package/lib/types/client/web-extension-page.d.ts.map +1 -0
  37. package/lib/types/client/web-extension-page.js +122 -0
  38. package/package.json +1 -1
  39. package/src/client/PetPreview.tsx +51 -0
  40. package/src/client/PetSettingsCard.test.tsx +28 -22
  41. package/src/client/PetSettingsCard.tsx +201 -110
  42. package/src/client/PluginSettingsCard.tsx +369 -108
  43. package/src/client/RangeBubble.tsx +163 -0
  44. package/src/client/SegmentGroup.tsx +92 -0
  45. package/src/client/index.ts +9 -27
  46. package/src/client/locales.ts +36 -44
  47. package/src/client/settings-card.module.css +493 -91
  48. package/src/client/settings-form.ts +116 -49
  49. package/src/client/settings-registration.test.ts +79 -0
  50. package/src/client/settings-registration.ts +34 -0
  51. package/src/client/settings-section.module.css +182 -0
  52. package/src/client/web-extension-contract.ts +35 -0
  53. package/src/client/web-extension-page.ts +150 -0
@@ -0,0 +1,12 @@
1
+ /** Lightweight, static pet thumbnails built from the registry's existing assets. */
2
+ import type { PetDefinition } from '../registry.ts';
3
+ /** Registry data needed by a thumbnail; older hosts may serve only id/name. */
4
+ export type PetPreviewDefinition = Pick<PetDefinition, 'id' | 'displayName'> & Partial<Pick<PetDefinition, 'renderer' | 'cell' | 'columns' | 'atlasRows' | 'atlasUrl' | 'frames2d'>>;
5
+ /**
6
+ * Render the atlas's first sprite cell or a frames2d idle frame. Live2d and
7
+ * incomplete legacy responses degrade to a text mark instead of a broken image.
8
+ */
9
+ export declare function PetPreview(props: {
10
+ pet: PetPreviewDefinition;
11
+ }): import("react").JSX.Element;
12
+ //# sourceMappingURL=PetPreview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PetPreview.d.ts","sourceRoot":"","sources":["../../../src/client/PetPreview.tsx"],"names":[],"mappings":"AAAA,oFAAoF;AAEpF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAGnD,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,IAAI,GAAG,aAAa,CAAC,GACxE,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC,CAAC,CAAA;AAKzG;;;GAGG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE;IAAE,GAAG,EAAE,oBAAoB,CAAA;CAAE,+BAkC9D"}
@@ -0,0 +1,32 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import sectionCss from './settings-section.module.css';
3
+ const PREVIEW_LIMIT = 72;
4
+ const DEFAULT_CELL = { width: 192, height: 208 };
5
+ /**
6
+ * Render the atlas's first sprite cell or a frames2d idle frame. Live2d and
7
+ * incomplete legacy responses degrade to a text mark instead of a broken image.
8
+ */
9
+ export function PetPreview(props) {
10
+ const { pet } = props;
11
+ const renderer = pet.renderer ?? 'sprite2d';
12
+ if (renderer === 'sprite2d' && pet.atlasUrl !== undefined) {
13
+ const cell = pet.cell ?? DEFAULT_CELL;
14
+ const scale = Math.min(PREVIEW_LIMIT / cell.width, PREVIEW_LIMIT / cell.height);
15
+ const width = Math.max(1, Math.round(cell.width * scale));
16
+ const height = Math.max(1, Math.round(cell.height * scale));
17
+ const columns = pet.columns ?? 8;
18
+ const rows = pet.atlasRows ?? 9;
19
+ return (_jsx("span", { className: sectionCss.previewFrame, "aria-hidden": "true", children: _jsx("span", { className: sectionCss.previewAtlas, style: {
20
+ width,
21
+ height,
22
+ backgroundImage: `url("${pet.atlasUrl}")`,
23
+ backgroundSize: `${columns * width}px ${rows * height}px`,
24
+ } }) }));
25
+ }
26
+ const frame = renderer === 'frames2d'
27
+ ? pet.frames2d?.tracks.idle?.frames[0] ?? pet.atlasUrl
28
+ : undefined;
29
+ return (_jsx("span", { className: sectionCss.previewFrame, "aria-hidden": "true", children: frame === undefined
30
+ ? _jsx("span", { className: sectionCss.previewFallback, children: pet.displayName.slice(0, 1) })
31
+ : _jsx("img", { className: sectionCss.previewImage, src: frame, alt: "", draggable: false }) }));
32
+ }
@@ -12,6 +12,7 @@ import type { ReactNode } from 'react';
12
12
  import type { InjectFace, PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
13
13
  import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
14
14
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
15
+ import { type PetPreviewDefinition } from './PetPreview.tsx';
15
16
  import { type CardActions, type CardShell, type FieldState as CardFieldState } from './settings-form.ts';
16
17
  /** The pet's settings fields this card edits (the namespace's full schema). */
17
18
  export interface PetSettings {
@@ -61,6 +62,8 @@ export interface PetSettingsCardState extends CardShell {
61
62
  value: string;
62
63
  label: string;
63
64
  }[];
65
+ /** The same registry entries with the visual data their thumbnails need. */
66
+ petPreviews: readonly PetPreviewDefinition[];
64
67
  }
65
68
  /** The registration-side face the card's slot entry injects. */
66
69
  export interface PetSettingsCardFace extends CardActions {
@@ -69,17 +72,41 @@ export interface PetSettingsCardFace extends CardActions {
69
72
  petSettingsCard: SnapshotStore<PetSettingsCardState>;
70
73
  };
71
74
  }
75
+ /**
76
+ * The spans the coarse sliders cover, spelled as literals for the same reason.
77
+ * Size and bubble scale are the schema's own bounds (src/persist.ts); the
78
+ * insets reach the schema's far end only by typing, so their slider covers the
79
+ * distances a window can show.
80
+ */
81
+ export declare const SIZE_RANGE: {
82
+ min: number;
83
+ max: number;
84
+ step: number;
85
+ };
86
+ export declare const INSET_RANGE: {
87
+ min: number;
88
+ max: number;
89
+ step: number;
90
+ };
91
+ export declare const BUBBLE_SCALE_RANGE: {
92
+ min: number;
93
+ max: number;
94
+ step: number;
95
+ };
72
96
  /** Bridges the 'pet' scope onto the card's staged form. */
73
97
  export declare class PetSettingsCardController {
74
98
  private readonly form;
75
99
  private readonly store;
76
100
  private readonly petChoices;
77
101
  private readonly petLabels;
102
+ private petPreviews;
78
103
  private selectedPetId;
79
104
  private selectedVisible;
80
105
  private stagedPetId;
81
106
  private stagedVisible;
82
107
  private savingPet;
108
+ /** A fallback pick made while a write was in flight. */
109
+ private fallbackQueued;
83
110
  private petSaveFailed;
84
111
  private loaded;
85
112
  private attempts;
@@ -102,7 +129,8 @@ export declare class PetSettingsCardController {
102
129
  * Persist the staged selection and visibility through the pet API — the only
103
130
  * writer available when the aggregate shell serves this card, since there is
104
131
  * no Host settings form to mutate — then confirm the read-back before the
105
- * drafts are cleared.
132
+ * drafts are cleared. A refused write puts both picks back to what the pet
133
+ * persisted. A pick made while a write is in flight runs once it settles.
106
134
  */
107
135
  private saveFallback;
108
136
  private projection;
@@ -126,7 +154,7 @@ export type PetSettingsCardProps = PropsLocale<'pet'> & InjectFace<PetSettingsCa
126
154
  */
127
155
  export declare function PetSettingsCard(props: PetSettingsCardProps): import("react").JSX.Element;
128
156
  /** Props the settings section binds for the pet card page. */
129
- export type PetSettingsSectionProps = PropsRuntime<'settings.section'> & PropsLocale<'pet'> & InjectFace<PetSettingsCardFace>;
157
+ export type PetSettingsSectionProps = (PropsRuntime<'settings.section'> | PropsRuntime<'web-ui.extension'>) & PropsLocale<'pet'> & InjectFace<PetSettingsCardFace>;
130
158
  /** Render the pet settings card as a first-level settings page. */
131
159
  export declare function PetSettingsSection(props: PetSettingsSectionProps): ReactNode;
132
160
  //# sourceMappingURL=PetSettingsCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PetSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/client/PetSettingsCard.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAC7F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4CAA4C,CAAA;AAC5E,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAIlE,OAAO,EAAoD,KAAK,WAAW,EAAE,KA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./PluginSettingsCard.js";
2
+ import { PluginSettingsCard, ValueField, BooleanField, ChoiceField, ToggleSwitch } from "./PluginSettingsCard.js";
3
+ import { PetPreview } from "./PetPreview.js";
3
4
  import { CardForm, booleanField, choiceField, numberField } from "./settings-form.js";
4
5
  import sectionCss from './settings-section.module.css';
5
6
  /**
@@ -8,6 +9,15 @@ import sectionCss from './settings-section.module.css';
8
9
  * host module for a value, so the accepted set is spelled here as literals.
9
10
  */
10
11
  const STATUS_BUBBLE_CHOICES = ['auto', 'off'];
12
+ /**
13
+ * The spans the coarse sliders cover, spelled as literals for the same reason.
14
+ * Size and bubble scale are the schema's own bounds (src/persist.ts); the
15
+ * insets reach the schema's far end only by typing, so their slider covers the
16
+ * distances a window can show.
17
+ */
18
+ export const SIZE_RANGE = { min: 32, max: 1024, step: 1 };
19
+ export const INSET_RANGE = { min: 0, max: 1000, step: 1 };
20
+ export const BUBBLE_SCALE_RANGE = { min: 0.5, max: 2, step: 0.05 };
11
21
  /** Fetch the registry list (the same data the sprite renders from). */
12
22
  async function fetchPetChoices() {
13
23
  const response = await fetch('/api/pet/pets');
@@ -35,11 +45,14 @@ export class PetSettingsCardController {
35
45
  // without rebuilding the form.
36
46
  petChoices = [];
37
47
  petLabels = new Map();
48
+ petPreviews = [];
38
49
  selectedPetId;
39
50
  selectedVisible;
40
51
  stagedPetId;
41
52
  stagedVisible;
42
53
  savingPet = false;
54
+ /** A fallback pick made while a write was in flight. */
55
+ fallbackQueued = false;
43
56
  petSaveFailed = false;
44
57
  loaded = false;
45
58
  attempts = 0;
@@ -85,6 +98,7 @@ export class PetSettingsCardController {
85
98
  if (this.disposed)
86
99
  return;
87
100
  this.petChoices.splice(0, this.petChoices.length, ...list.map(choice => choice.id));
101
+ this.petPreviews = list;
88
102
  for (const choice of list)
89
103
  this.petLabels.set(choice.id, choice.displayName);
90
104
  this.loaded = true;
@@ -135,13 +149,16 @@ export class PetSettingsCardController {
135
149
  * Persist the staged selection and visibility through the pet API — the only
136
150
  * writer available when the aggregate shell serves this card, since there is
137
151
  * no Host settings form to mutate — then confirm the read-back before the
138
- * drafts are cleared.
152
+ * drafts are cleared. A refused write puts both picks back to what the pet
153
+ * persisted. A pick made while a write is in flight runs once it settles.
139
154
  */
140
155
  async saveFallback() {
141
156
  const petId = this.stagedPetId;
142
157
  const visible = this.stagedVisible;
143
- if (this.savingPet)
158
+ if (this.savingPet) {
159
+ this.fallbackQueued = true;
144
160
  return;
161
+ }
145
162
  if (petId === undefined && visible === undefined)
146
163
  return;
147
164
  if (petId !== undefined && !this.petChoices.includes(petId))
@@ -184,12 +201,20 @@ export class PetSettingsCardController {
184
201
  }
185
202
  catch {
186
203
  this.petSaveFailed = true;
204
+ if (this.stagedPetId === petId)
205
+ this.stagedPetId = undefined;
206
+ if (this.stagedVisible === visible)
207
+ this.stagedVisible = undefined;
187
208
  }
188
209
  finally {
189
210
  this.savingPet = false;
190
211
  if (!this.disposed)
191
212
  this.store.set(this.projection());
192
213
  }
214
+ if (this.fallbackQueued && !this.disposed) {
215
+ this.fallbackQueued = false;
216
+ await this.saveFallback();
217
+ }
193
218
  }
194
219
  projection() {
195
220
  const fallback = this.fallback();
@@ -222,6 +247,7 @@ export class PetSettingsCardController {
222
247
  ? { ...configuredPet, text: this.selectedPetId }
223
248
  : configuredPet,
224
249
  petChoices: this.petChoices.map(id => ({ value: id, label: this.petLabels.get(id) ?? id })),
250
+ petPreviews: this.petPreviews,
225
251
  };
226
252
  }
227
253
  /**
@@ -232,6 +258,8 @@ export class PetSettingsCardController {
232
258
  const actions = this.form.actions();
233
259
  return {
234
260
  hooks: { petSettingsCard: this.store },
261
+ // The fallback's two fields are both picks, so each is written through
262
+ // the pet API the moment it is made, as the form writes its own picks.
235
263
  edit: (field, value) => {
236
264
  if (!this.fallback())
237
265
  return actions.edit(field, value);
@@ -243,6 +271,7 @@ export class PetSettingsCardController {
243
271
  return;
244
272
  this.petSaveFailed = false;
245
273
  this.store.set(this.projection());
274
+ void this.saveFallback();
246
275
  },
247
276
  resetField: (field) => {
248
277
  if (!this.fallback())
@@ -299,14 +328,25 @@ export function PetSettingsCard(props) {
299
328
  resetLabel: t('settings.reset'),
300
329
  invalidLabel: t('settings.invalidNumber'),
301
330
  disabled,
331
+ presentation: 'segment',
302
332
  };
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'); } })] }));
333
+ // The master switch sits in the header, as the Workshop and Usage pages
334
+ // carry theirs; the fallback has no Host form to write it through.
335
+ const enabledSwitch = state.petSelectionFallback
336
+ ? undefined
337
+ : (_jsx(ToggleSwitch, { labelledBy: "settings-pet-title", checked: state.enabled.text !== 'false', disabled: disabled, onChange: (next) => { props.edit('enabled', String(next)); } }));
338
+ return (_jsx(PluginSettingsCard, { t: t, titleKey: "settings.title", titleId: "settings-pet-title", descriptionKey: "settings.description", descriptionNode: state.petSelectionFallback ? t('settings.petHint') : undefined, headerAction: enabledSwitch, state: state, onSave: props.save, onDiscard: props.discard, alwaysOpen: true, children: _jsxs("div", { className: sectionCss.settingsLayout, children: [_jsxs("section", { className: sectionCss.selectionGroup, children: [_jsxs("div", { className: sectionCss.groupHeader, children: [_jsx("h3", { className: sectionCss.groupTitle, id: "settings-pet-selection-title", children: t('settings.pet') }), state.petId.overridden
339
+ ? (_jsx("button", { type: "button", className: sectionCss.textAction, disabled: disabled, onClick: () => { props.resetField('petId'); }, children: t('settings.reset') }))
340
+ : null] }), _jsx("div", { id: "settings-pet-pet", className: sectionCss.petGrid, role: "group", "aria-labelledby": "settings-pet-selection-title", children: state.petPreviews.map(pet => {
341
+ const selected = state.petId.text === pet.id;
342
+ return (_jsxs("button", { type: "button", className: selected ? `${sectionCss.petChoice} ${sectionCss.petChoiceSelected}` : sectionCss.petChoice, "aria-pressed": selected, title: pet.displayName, disabled: disabled, onClick: () => { props.edit('petId', pet.id); }, children: [_jsx(PetPreview, { pet: pet }), _jsx("span", { className: sectionCss.petChoiceLabel, children: pet.displayName })] }, pet.id));
343
+ }) }), _jsx("p", { className: state.petId.invalid ? sectionCss.invalid : sectionCss.groupHint, children: state.petId.invalid ? t('settings.invalidNumber') : t('settings.petHint') })] }), _jsxs("div", { className: sectionCss.settingsColumn, children: [_jsxs("section", { className: sectionCss.settingsGroup, children: [_jsx("div", { className: sectionCss.groupHeader, children: _jsx("h3", { className: sectionCss.groupTitle, id: "settings-pet-display-title", children: t('settings.displayGroup') }) }), _jsxs("div", { className: sectionCss.fields, children: [_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, range: SIZE_RANGE, ...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, range: INSET_RANGE, ...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, range: INSET_RANGE, ...fieldProps, ...state.bottom, onEdit: (text) => { props.edit('bottom', text); }, onReset: () => { props.resetField('bottom'); } })] })] }), state.petSelectionFallback ? null : (_jsxs("section", { className: sectionCss.settingsGroup, children: [_jsx("div", { className: sectionCss.groupHeader, children: _jsx("h3", { className: sectionCss.groupTitle, id: "settings-pet-behavior-title", children: t('settings.bubbleGroup') }) }), _jsxs("div", { className: sectionCss.fields, children: [_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-status-bubbles", label: t('settings.statusBubbles'), hint: t('settings.statusBubblesHint'), inheritLabel: t('settings.inherit'), ...fieldProps, ...state.statusBubbles, choices: [
344
+ { value: STATUS_BUBBLE_CHOICES[0], label: t('settings.on') },
345
+ { value: STATUS_BUBBLE_CHOICES[1], label: t('settings.off') },
346
+ ], onEdit: (text) => { props.edit('statusBubbles', text); }, onReset: () => { props.resetField('statusBubbles'); } }), _jsx(ValueField, { id: "settings-pet-bubble-scale", label: t('settings.bubbleScale'), hint: t('settings.bubbleScaleHint'), numeric: true, range: BUBBLE_SCALE_RANGE, ...fieldProps, ...state.bubbleScale, onEdit: (text) => { props.edit('bubbleScale', text); }, onReset: () => { props.resetField('bubbleScale'); } })] })] }))] })] }) }));
307
347
  }
308
348
  /** Render the pet settings card as a first-level settings page. */
309
349
  export function PetSettingsSection(props) {
310
350
  const { t, usePetSettingsCard, save, discard, edit, resetField } = props;
311
- return (_jsx("ul", { className: sectionCss.sectionList, children: _jsx(PetSettingsCard, { t: t, usePetSettingsCard: usePetSettingsCard, save: save, discard: discard, edit: edit, resetField: resetField }) }));
351
+ return (_jsx("ul", { className: sectionCss.sectionList, "data-dsh-plugin": "pet", "data-dsh-part": "panel", children: _jsx(PetSettingsCard, { t: t, usePetSettingsCard: usePetSettingsCard, save: save, discard: discard, edit: edit, resetField: resetField }) }));
312
352
  }
@@ -1,15 +1,21 @@
1
1
  /**
2
2
  * Family-shared chrome for plugin settings cards: a disclosure header naming
3
- * the plugin and what its settings govern, the controls inside, and the save
4
- * that writes them. Renders nothing while the namespace is unavailable — a
3
+ * the plugin and what its settings govern, the controls inside, and the line
4
+ * that reports a refused write. A pick is written the moment it is made and a
5
+ * typed value after a pause, so the card has no save button and nothing waits
6
+ * on the reader. Renders nothing while the namespace is unavailable — a
5
7
  * deployment that does not compose the owning plugin should show no trace of
6
8
  * it. Inlined into each consumer's client bundle; mirrors the official
7
9
  * ui-plugin-config PluginCard in a self-contained slice.
10
+ *
11
+ * Every field inside the body is one settings row: the label and its hint on
12
+ * the left, the control on the right, a hairline between two rows; a narrow
13
+ * card stacks the control under the text (settings-card.module.css).
8
14
  */
9
15
  import { type ReactNode } from 'react';
10
16
  import type { CardShell } from './settings-form.ts';
11
17
  /** Copy keys the card chrome itself reads; every consumer locale carries this shared vocabulary. */
12
- export declare const CARD_COPY_KEYS: readonly ["settings.collapse", "settings.expand", "settings.notExposed", "settings.unsaved", "settings.readOnly", "settings.saveFailed", "settings.discard", "settings.save", "settings.saving"];
18
+ export declare const CARD_COPY_KEYS: readonly ["settings.collapse", "settings.expand", "settings.notExposed", "settings.readOnly", "settings.saveFailed"];
13
19
  /** Copy key the card chrome itself reads. */
14
20
  export type CardCopyKey = (typeof CARD_COPY_KEYS)[number];
15
21
  /** Key domain for the plugin's own copy (inferred per consumer). */
@@ -24,12 +30,40 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
24
30
  descriptionKey: TKey;
25
31
  /** Optional rich header description rendered instead of the plain t(descriptionKey) text (the plain text stays as the tooltip). */
26
32
  descriptionNode?: ReactNode;
27
- /** The card's form state: availability, writability, and what a save would do. */
33
+ /**
34
+ * Locale key of the full sentence behind a shortened description: when
35
+ * present, the header's native `title` takes this text while the visible
36
+ * line keeps `descriptionKey`/`descriptionNode`, so a compact card can
37
+ * compress the sentence without keeping a second visible copy of it.
38
+ * Defaults to the description key.
39
+ */
40
+ descriptionTitleKey?: TKey;
41
+ /**
42
+ * Optional leading mark identifying the plugin. A card without one keeps the
43
+ * plain official header shape, so the chrome stays a readable sibling of the
44
+ * built-in PluginCard wherever a family plugin lands in the official bundle
45
+ * seat.
46
+ */
47
+ icon?: ReactNode;
48
+ /** The card's form state: availability, writability, and how the last write went. */
28
49
  state: CardShell;
29
- /** Write every staged edit. */
50
+ /** Write every pending draft now: a text field's Enter or blur. */
30
51
  onSave: () => void;
31
- /** Drop every staged edit. */
52
+ /** Drop every pending draft: a text field's Escape. */
32
53
  onDiscard: () => void;
54
+ /**
55
+ * Id applied to the card's title element, so a header control (an immediate
56
+ * toggle in `headerAction`) can name itself through `aria-labelledby`
57
+ * instead of repeating the title as a string.
58
+ */
59
+ titleId?: string;
60
+ /**
61
+ * Render the header only, with no body region. A card whose whole setting is
62
+ * the header control (a switch whose explanation is the description) has no
63
+ * controls to lay out below it, and an empty body would draw a divider line
64
+ * with nothing under it.
65
+ */
66
+ headerOnly?: boolean;
33
67
  /**
34
68
  * Render the controls expanded on arrival (still collapsible). Defaults to
35
69
  * true: promoted first-level sections show their settings immediately.
@@ -42,15 +76,29 @@ export interface PluginSettingsCardProps<TKey extends string = string> {
42
76
  */
43
77
  alwaysOpen?: boolean;
44
78
  /**
45
- * Hide the save/discard footer: cards whose body applies its own changes
46
- * immediately (an embedded external settings section) have no staged
47
- * edits, so the footer would sit there permanently disabled.
79
+ * Hide the line under the body that reports a refused write: a card whose
80
+ * body applies its own changes (an embedded external settings section)
81
+ * reports its own failures.
48
82
  */
49
83
  hideFooter?: boolean;
84
+ /**
85
+ * Optional control rendered at the header's trailing edge, before the
86
+ * chevron. A card whose setting is one immediate flip (it
87
+ * applies outside the card's form) puts its ToggleSwitch here, so the control
88
+ * is reachable without opening the card and matches a plugin card's shape.
89
+ */
90
+ headerAction?: ReactNode;
50
91
  /** Render children even when the settings namespace is not exposed by the host. */
51
92
  renderChildrenWhenNotExposed?: boolean;
52
93
  /** Hide the 'not exposed' warning banner when the settings namespace is not exposed. */
53
94
  hideNotExposedNotice?: boolean;
95
+ /**
96
+ * Compact chrome for a topic card rendered inside another card's body: a
97
+ * smaller title, a tighter header and body inset, and a one-line description
98
+ * whose full text stays on the header's own title. Defaults to the
99
+ * first-level chrome, which is unchanged.
100
+ */
101
+ density?: 'nested';
54
102
  /** The plugin's controls. */
55
103
  children: ReactNode;
56
104
  }
@@ -68,9 +116,15 @@ export interface FieldProps {
68
116
  label: string;
69
117
  /** One-line explanation rendered under the control. */
70
118
  hint: string;
119
+ /**
120
+ * Full sentence behind the visible hint, exposed as the paragraph's native
121
+ * `title` so a card can shorten the line without losing the text. Omitted:
122
+ * the paragraph carries no title attribute at all.
123
+ */
124
+ hintTitle?: string;
71
125
  /** Draft text this control renders. */
72
126
  text: string;
73
- /** True when saving would leave a user-layer entry for this field. */
127
+ /** True when the field holds a user-layer entry over the inherited value. */
74
128
  overridden: boolean;
75
129
  /** True when the draft is not a value this field accepts. */
76
130
  invalid: boolean;
@@ -82,17 +136,29 @@ export interface FieldProps {
82
136
  invalidLabel: string;
83
137
  /** Disables every control (read-only document, or an unavailable namespace). */
84
138
  disabled: boolean;
85
- /** Stage draft text. */
139
+ /** Take new draft text; the card writes it as the field's entry rule says. */
86
140
  onEdit: (text: string) => void;
87
- /** Stage a clear so the field re-inherits the composition layer. */
141
+ /** Clear the field at once so it re-inherits the composition layer. */
88
142
  onReset: () => void;
89
143
  }
90
- /** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */
144
+ /**
145
+ * A typed value field. Its draft is written after a pause in typing, at once on
146
+ * Enter or when focus leaves, and Escape puts the stored value back. `numeric`
147
+ * only hints the keypad: which drafts a field accepts is decided by its spec.
148
+ * A field given a `range` also offers the coarse slider bubble: dragging fills
149
+ * the draft live and releasing writes it.
150
+ */
91
151
  export declare function ValueField(props: FieldProps & {
92
152
  /** Hints a numeric keypad without narrowing what the control accepts. */
93
153
  numeric?: boolean;
94
154
  /** Placeholder shown while the draft is empty. */
95
155
  placeholder?: string;
156
+ /** Bounds of a numeric field, for the coarse slider; the spec still judges every draft. */
157
+ range?: {
158
+ min: number;
159
+ max: number;
160
+ step: number;
161
+ };
96
162
  }): import("react").JSX.Element;
97
163
  interface SelectOption {
98
164
  value: string;
@@ -103,8 +169,8 @@ interface SelectOption {
103
169
  * renders the legacy native `<select>` untouched, so element-level skin
104
170
  * selectors keep working; under the default appearance it renders a
105
171
  * self-drawn `role="listbox"` popup whose open/close is transition-animated.
106
- * Staged cards reach it through BooleanField/ChoiceField; immediate-apply
107
- * editors (the side-card prefs) bind it directly through onEdit.
172
+ * Cards reach it through BooleanField/ChoiceField; editors outside a card
173
+ * (the side-card prefs) bind it directly through onEdit.
108
174
  * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
109
175
  */
110
176
  export declare function SelectField(props: {
@@ -115,7 +181,25 @@ export declare function SelectField(props: {
115
181
  invalid: boolean;
116
182
  onEdit: (text: string) => void;
117
183
  }): import("react").JSX.Element;
118
- /** A staged boolean field: 继承 / 开 / 关. */
184
+ /**
185
+ * A visible segmented group for a small set of mutually exclusive values.
186
+ * Every option stays on screen, so inherit/on/off and short enum fields take
187
+ * one click without opening a popup. The pressed option carries the group's
188
+ * sliding highlight and `aria-pressed`; the group takes the field label as its
189
+ * accessible name.
190
+ */
191
+ export declare function SegmentField(props: {
192
+ id: string;
193
+ label: string;
194
+ options: ReadonlyArray<SelectOption>;
195
+ value: string;
196
+ disabled: boolean;
197
+ invalid: boolean;
198
+ onEdit: (text: string) => void;
199
+ }): import("react").JSX.Element;
200
+ /** How a small single-choice field presents its options. */
201
+ export type FieldPresentation = 'select' | 'segment';
202
+ /** A boolean field: 继承 / 开 / 关. */
119
203
  export declare function BooleanField(props: FieldProps & {
120
204
  /** Copy for the inherit option. */
121
205
  inheritLabel: string;
@@ -123,8 +207,10 @@ export declare function BooleanField(props: FieldProps & {
123
207
  onLabel: string;
124
208
  /** Copy for the off option. */
125
209
  offLabel: string;
210
+ /** Defaults to the visible segments: the three answers always fit on one row. */
211
+ presentation?: FieldPresentation;
126
212
  }): import("react").JSX.Element;
127
- /** A staged enumerated field rendered as a select. */
213
+ /** An enumerated field, selecting or segmenting its small choice set. */
128
214
  export declare function ChoiceField(props: FieldProps & {
129
215
  /** Copy for the inherit option (draft text is the empty string). */
130
216
  inheritLabel: string;
@@ -133,6 +219,34 @@ export declare function ChoiceField(props: FieldProps & {
133
219
  value: string;
134
220
  label: string;
135
221
  }>;
222
+ /**
223
+ * Visible segmented options for a short fixed set; defaults to the compact
224
+ * select, which also suits a list whose length follows the deployment.
225
+ */
226
+ presentation?: FieldPresentation;
227
+ }): import("react").JSX.Element;
228
+ /**
229
+ * A boolean toggle drawn as a switch track, for a setting that is only on or
230
+ * off and applies on flip. It is a real button with
231
+ * `role="switch"` and `aria-checked`, so keyboard and assistive activation
232
+ * arrive as a click and the state is announced instead of inferred from a
233
+ * checkbox tick.
234
+ *
235
+ * The thumb bounces across only once the reader has pressed this switch: the
236
+ * press writes the mark that arms the bounce, so a page opening, a TAB
237
+ * switching back or a value arriving from elsewhere draws every thumb at rest.
238
+ */
239
+ export declare function ToggleSwitch(props: {
240
+ /** Id of the element naming the switch (the card's title). */
241
+ labelledBy?: string;
242
+ /** Accessible name when no element labels it. */
243
+ ariaLabel?: string;
244
+ /** Current state. */
245
+ checked: boolean;
246
+ /** Disables the switch while a write is in flight or the Host refuses writes. */
247
+ disabled?: boolean;
248
+ /** Called with the requested next state. */
249
+ onChange: (next: boolean) => void;
136
250
  }): import("react").JSX.Element;
137
251
  export {};
138
252
  //# sourceMappingURL=PluginSettingsCard.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PluginSettingsCard.d.ts","sourceRoot":"","sources":["../../../src/client/PluginSettingsCard.tsx"],"names":[],"mappings":"AACA;;;;;;;GAOG;AAEH,OAAO,EAAiF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AACrH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAA;AAGnD,oGAAoG;AACpG,eAAO,MAAM,cAAc,kMAUjB,CAAA;AAEV,6CAA6C;AAC7C,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA;AAEzD,oEAAoE;AACpE,MAAM,MAAM,eAAe,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM,IAAI,IAAI,GAAG,WAAW,CAAA;AAE9E,wDAAwD;AACxD,MAAM,WAAW,uBAAuB,CAAC,IAAI,SAAS,MAAM,GAAG,MAAM;IACnE,0CAA0C;IAC1C,CAAC,EAAE,CAAC,GAAG,EAAE,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KAAK,MAAM,CAAA;IACnF,uCAAuC;IACvC,QAAQ,EAAE,IAAI,CAAA;IACd,4EAA4E;IAC5E,cAAc,EAAE,IAAI,CAAA;IACpB,mIAAmI;IACnI,eAAe,CAAC,EAAE,SAAS,CAAA;IAC3B,kFAAkF;IAClF,KAAK,EAAE,SAAS,CAAA;IAChB,+BAA+B;IAC/B,MAAM,EAAE,MAAM,IAAI,CAAA;IAClB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,IAAI,CAAA;IACrB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB;;;;OAIG;IACH,UAAU,CAAC,EAAE,OAAO,CAA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