@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
@@ -1,27 +1,38 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
- // Generated by scripts/sync-shared.mjs from shared/client/settings/PluginSettingsCard.tsx. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
2
  /**
4
3
  * Family-shared chrome for plugin settings cards: a disclosure header naming
5
- * the plugin and what its settings govern, the controls inside, and the save
6
- * that writes them. Renders nothing while the namespace is unavailable — a
4
+ * the plugin and what its settings govern, the controls inside, and the line
5
+ * that reports a refused write. A pick is written the moment it is made and a
6
+ * typed value after a pause, so the card has no save button and nothing waits
7
+ * on the reader. Renders nothing while the namespace is unavailable — a
7
8
  * deployment that does not compose the owning plugin should show no trace of
8
9
  * it. Inlined into each consumer's client bundle; mirrors the official
9
10
  * ui-plugin-config PluginCard in a self-contained slice.
11
+ *
12
+ * Every field inside the body is one settings row: the label and its hint on
13
+ * the left, the control on the right, a hairline between two rows; a narrow
14
+ * card stacks the control under the text (settings-card.module.css).
10
15
  */
11
- import { useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';
16
+ import { createContext, useCallback, useContext, useEffect, useLayoutEffect, useRef, useState } from 'react';
17
+ import { RangeBubble } from "./RangeBubble.js";
18
+ import { SegmentGroup } from "./SegmentGroup.js";
12
19
  import css from './settings-card.module.css';
13
20
  /** Copy keys the card chrome itself reads; every consumer locale carries this shared vocabulary. */
14
21
  export const CARD_COPY_KEYS = [
15
22
  'settings.collapse',
16
23
  'settings.expand',
17
24
  'settings.notExposed',
18
- 'settings.unsaved',
19
25
  'settings.readOnly',
20
26
  'settings.saveFailed',
21
- 'settings.discard',
22
- 'settings.save',
23
- 'settings.saving',
24
27
  ];
28
+ /**
29
+ * What a text field inside a card reaches without its plugin wiring it: write
30
+ * the pending draft now (Enter, leaving the field) or put it back (Escape).
31
+ * Picks need neither; they are written the moment they are made.
32
+ */
33
+ const CardApply = createContext(null);
34
+ /** Length of the body's disclosure motion; it matches `--settings-card-motion` on the card root. */
35
+ const BODY_MOTION_MS = 180;
25
36
  /**
26
37
  * Render one plugin settings card.
27
38
  * @param props - the plugin's copy keys, its form state, and its controls.
@@ -30,41 +41,102 @@ export const CARD_COPY_KEYS = [
30
41
  export function PluginSettingsCard(props) {
31
42
  const [open, setOpen] = useState(props.defaultOpen ?? true);
32
43
  const { state, alwaysOpen } = props;
44
+ const expanded = alwaysOpen === true || open;
45
+ const [bodyPhase, setBodyPhase] = useState(expanded ? 'shown' : 'hidden');
46
+ const bodyRef = useRef(null);
47
+ // Enter and leave run the same pair: a body that should open is mounted
48
+ // closed for one frame so its transition has a state to leave, and a closing
49
+ // one stays mounted until its leg has run.
50
+ useLayoutEffect(() => {
51
+ if (expanded) {
52
+ if (bodyPhase === 'hidden')
53
+ setBodyPhase('collapsed');
54
+ else if (bodyPhase === 'collapsed') {
55
+ const node = bodyRef.current;
56
+ if (node !== null)
57
+ void node.offsetHeight;
58
+ setBodyPhase('entering');
59
+ }
60
+ else if (bodyPhase === 'closing')
61
+ setBodyPhase('entering');
62
+ return;
63
+ }
64
+ if (bodyPhase === 'collapsed')
65
+ setBodyPhase('hidden');
66
+ else if (bodyPhase === 'entering' || bodyPhase === 'shown')
67
+ setBodyPhase('closing');
68
+ }, [expanded, bodyPhase]);
69
+ useEffect(() => {
70
+ if (bodyPhase !== 'entering' && bodyPhase !== 'closing')
71
+ return;
72
+ const timer = setTimeout(() => {
73
+ setBodyPhase(bodyPhase === 'entering' ? 'shown' : 'hidden');
74
+ }, BODY_MOTION_MS);
75
+ return () => { clearTimeout(timer); };
76
+ }, [bodyPhase]);
33
77
  if (!state.available)
34
78
  return null;
35
79
  const title = props.t(props.titleKey);
36
80
  const description = props.t(props.descriptionKey);
37
- const blocked = !state.dirty || state.invalid || state.saving;
38
- const expanded = alwaysOpen === true || open;
39
- const cardClass = expanded ? `${css.cardOpen} ${css.card}` : css.card;
81
+ const descriptionTitle = props.descriptionTitleKey === undefined ? description : props.t(props.descriptionTitleKey);
82
+ const baseClass = expanded ? `${css.cardOpen} ${css.card}` : css.card;
83
+ const cardClass = props.density === 'nested' ? `${baseClass} ${css.cardNested}` : baseClass;
84
+ /** The body region both legs share; a hidden phase renders nothing at all. */
85
+ const bodyRegion = (content) => bodyPhase === 'hidden'
86
+ ? null
87
+ : (_jsx("div", { className: css.disclosure, "data-state": bodyPhase, ref: bodyRef, children: _jsx("div", { className: css.body, children: content }) }));
40
88
  // With alwaysOpen the nav entry already provides the selection, so the
41
89
  // header is a static title row instead of a disclosure button.
42
90
  const header = alwaysOpen === true
43
- ? (_jsxs("div", { className: css.headerStatic, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: props.descriptionNode ?? description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null] }))
44
- : (_jsxs("button", { type: "button", className: css.header, "aria-expanded": open, "aria-label": `${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`, onClick: () => { setOpen(!open); }, children: [_jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, title: title, children: title }), _jsx("span", { className: css.description, title: description, children: props.descriptionNode ?? description })] }), state.dirty ? _jsx("span", { className: css.pending, title: props.t('settings.unsaved'), children: props.t('settings.unsaved') }) : null, _jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: open ? `${css.chevron} ${css.chevronOpen}` : css.chevron, children: _jsx("path", { d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z", fill: "currentColor" }) })] }));
91
+ ? (_jsxs("div", { className: css.headerStatic, children: [props.icon !== undefined ? _jsx("span", { className: css.mark, "aria-hidden": "true", children: props.icon }) : null, _jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, id: props.titleId, title: title, children: title }), _jsx("span", { className: css.description, title: descriptionTitle, children: props.descriptionNode ?? description })] }), props.headerAction !== undefined ? _jsx("span", { className: css.headerAction, children: props.headerAction }) : null] }))
92
+ : (_jsxs("button", { type: "button", className: css.header, "aria-expanded": open, "aria-label": `${props.t(open ? 'settings.collapse' : 'settings.expand')}: ${title}`, onClick: () => { setOpen(!open); }, children: [props.icon !== undefined ? _jsx("span", { className: css.mark, "aria-hidden": "true", children: props.icon }) : null, _jsxs("span", { className: css.headText, children: [_jsx("span", { className: css.name, id: props.titleId, title: title, children: title }), _jsx("span", { className: css.description, title: descriptionTitle, children: props.descriptionNode ?? description })] }), props.headerAction !== undefined ? _jsx("span", { className: css.headerAction, children: props.headerAction }) : null, _jsx("svg", { width: "14", height: "14", viewBox: "0 0 14 14", fill: "none", xmlns: "http://www.w3.org/2000/svg", className: open ? `${css.chevron} ${css.chevronOpen}` : css.chevron, children: _jsx("path", { d: "M11.8486 5.5L11.4238 5.92383L8.69727 8.65137C8.44157 8.90706 8.21562 9.13382 8.01172 9.29785C7.79912 9.46883 7.55595 9.61756 7.25 9.66602C7.08435 9.69222 6.91565 9.69222 6.75 9.66602C6.44405 9.61756 6.20088 9.46883 5.98828 9.29785C5.78438 9.13382 5.55843 8.90706 5.30273 8.65137L2.57617 5.92383L2.15137 5.5L3 4.65137L3.42383 5.07617L6.15137 7.80273C6.42595 8.07732 6.59876 8.24849 6.74023 8.3623C6.87291 8.46904 6.92272 8.47813 6.9375 8.48047C6.97895 8.48703 7.02105 8.48703 7.0625 8.48047C7.07728 8.47813 7.12709 8.46904 7.25977 8.3623C7.40124 8.24849 7.57405 8.07732 7.84863 7.80273L10.5762 5.07617L11 4.65137L11.8486 5.5Z", fill: "currentColor" }) })] }));
45
93
  // The namespace exists but the Host does not serve it to this client (the
46
94
  // official settings allowlist omits third-party namespaces): show a card
47
95
  // that explains the gap instead of vanishing, so a missing card never
48
96
  // reads as a missing plugin.
49
97
  if (!state.exposed && props.renderChildrenWhenNotExposed !== true) {
50
98
  const showNotice = props.hideNotExposedNotice !== true;
51
- return (_jsxs("li", { className: cardClass, children: [header, expanded
52
- ? (_jsx("div", { className: css.body, children: showNotice ? _jsx("p", { className: css.notExposed, role: "status", children: props.t('settings.notExposed') }) : null }))
53
- : null] }));
99
+ return (_jsxs("li", { className: cardClass, children: [header, bodyRegion(showNotice ? _jsx("p", { className: css.notExposed, role: "status", children: props.t('settings.notExposed') }) : null)] }));
54
100
  }
55
- return (_jsxs("li", { className: cardClass, children: [header, expanded
56
- ? (_jsxs("div", { className: css.body, children: [!state.writable ? _jsx("p", { className: css.readOnly, role: "status", children: props.t('settings.readOnly') }) : null, props.children, props.hideFooter === true
57
- ? null
58
- : (_jsxs("div", { className: css.footer, children: [state.failed
59
- ? (_jsxs("p", { className: css.failed, role: "status", children: [props.t('settings.saveFailed'), state.failedReason ? ' - ' + state.failedReason : ''] }))
60
- : null, _jsx("button", { type: "button", className: css.discard, disabled: !state.dirty || state.saving, onClick: props.onDiscard, children: props.t('settings.discard') }), _jsx("button", { type: "button", className: css.save, disabled: blocked, onClick: props.onSave, children: props.t(!state.saving ? 'settings.save' : 'settings.saving') })] }))] }))
101
+ // A header-only card has no body region at all: the divider would otherwise
102
+ // sit above an empty box.
103
+ const bodyVisible = props.headerOnly !== true;
104
+ return (_jsxs("li", { className: cardClass, children: [header, bodyVisible
105
+ ? bodyRegion(_jsxs(_Fragment, { children: [!state.writable ? _jsx("p", { className: css.readOnly, role: "status", children: props.t('settings.readOnly') }) : null, _jsx(CardApply.Provider, { value: { commit: props.onSave, revert: props.onDiscard }, children: props.children }), props.hideFooter !== true && state.failed
106
+ ? (_jsxs("p", { className: css.failed, role: "status", children: [props.t('settings.saveFailed'), state.failedReason ? ' - ' + state.failedReason : ''] }))
107
+ : null] }))
61
108
  : null] }));
62
109
  }
63
- /** A staged value field. `numeric` only hints the keypad: which drafts a field accepts is decided by its spec. */
110
+ /**
111
+ * A typed value field. Its draft is written after a pause in typing, at once on
112
+ * Enter or when focus leaves, and Escape puts the stored value back. `numeric`
113
+ * only hints the keypad: which drafts a field accepts is decided by its spec.
114
+ * A field given a `range` also offers the coarse slider bubble: dragging fills
115
+ * the draft live and releasing writes it.
116
+ */
64
117
  export function ValueField(props) {
118
+ const apply = useContext(CardApply);
119
+ const onKeyDown = (event) => {
120
+ if (apply === null || (event.key !== 'Enter' && event.key !== 'Escape'))
121
+ return;
122
+ event.preventDefault();
123
+ if (event.key === 'Enter')
124
+ apply.commit();
125
+ else
126
+ apply.revert();
127
+ event.currentTarget.blur();
128
+ };
129
+ const input = (_jsx("input", { id: props.id, className: props.invalid ? css.inputInvalid : css.input, type: "text", ...props.numeric === true ? { inputMode: 'numeric' } : {}, ...props.invalid ? { 'aria-invalid': true } : {}, value: props.text, placeholder: props.placeholder ?? '', disabled: props.disabled, onChange: (event) => { props.onEdit(event.target.value); }, onKeyDown: onKeyDown, onBlur: () => { apply?.commit(); } }));
130
+ const { range } = props;
131
+ const typed = Number(props.text);
65
132
  return (_jsxs("div", { className: css.field, children: [_jsxs("div", { className: css.head, children: [_jsx("label", { className: css.label, htmlFor: props.id, children: props.label }), props.overridden
66
133
  ? (_jsxs("span", { className: css.badges, children: [_jsx("span", { className: css.badge, children: props.overriddenLabel }), _jsx("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })] }))
67
- : null] }), _jsx("input", { id: props.id, className: props.invalid ? css.inputInvalid : css.input, type: "text", ...props.numeric === true ? { inputMode: 'numeric' } : {}, ...props.invalid ? { 'aria-invalid': true } : {}, value: props.text, placeholder: props.placeholder ?? '', disabled: props.disabled, onChange: (event) => { props.onEdit(event.target.value); } }), _jsx("p", { className: props.invalid ? css.invalid : css.hint, children: props.invalid ? props.invalidLabel : props.hint })] }));
134
+ : null] }), range === undefined
135
+ ? input
136
+ : (_jsx(RangeBubble, { min: range.min, max: range.max, step: range.step, value: props.text.trim() === '' || Number.isNaN(typed) ? range.min : typed, label: `${props.label} ${range.min}–${range.max}`, disabled: props.disabled, onInput: (value) => { props.onEdit(String(value)); }, onCommit: (value) => {
137
+ props.onEdit(String(value));
138
+ apply?.commit();
139
+ }, children: input })), _jsx("p", { className: props.invalid ? css.invalid : css.hint, title: props.hintTitle, children: props.invalid ? props.invalidLabel : props.hint })] }));
68
140
  }
69
141
  const NON_SKIN_BODY_MARKERS = new Set(['dshSkinCenter', 'dshSidebarCollapsed']);
70
142
  // 检测使用使用皮肤,用了皮肤退回原生select样式,防止样式冲突。默认外观下使用优化后的select样式。
@@ -79,8 +151,8 @@ const SELECT_CLOSE_MS = 100;
79
151
  * renders the legacy native `<select>` untouched, so element-level skin
80
152
  * selectors keep working; under the default appearance it renders a
81
153
  * self-drawn `role="listbox"` popup whose open/close is transition-animated.
82
- * Staged cards reach it through BooleanField/ChoiceField; immediate-apply
83
- * editors (the side-card prefs) bind it directly through onEdit.
154
+ * Cards reach it through BooleanField/ChoiceField; editors outside a card
155
+ * (the side-card prefs) bind it directly through onEdit.
84
156
  * 双模式下拉框:皮肤激活时用原生 select,默认外观用自绘动画弹层。
85
157
  */
86
158
  export function SelectField(props) {
@@ -201,19 +273,68 @@ export function SelectField(props) {
201
273
  ? (_jsx("div", { className: popupClass, role: "listbox", ref: popupRef, children: options.map((option, index) => (_jsx("div", { id: `${id}-o${index}`, role: "option", "aria-selected": option.value === value, className: `${css.selectOption}${option.value === value ? ` ${css.selectOptionSelected}` : ''}${index === activeIndex && !closing ? ` ${css.selectOptionActive}` : ''}`, onClick: () => { commit(index); }, children: option.label }, option.value))) }))
202
274
  : null] }));
203
275
  }
204
- /** A staged boolean field: 继承 / 开 / 关. */
276
+ /**
277
+ * A visible segmented group for a small set of mutually exclusive values.
278
+ * Every option stays on screen, so inherit/on/off and short enum fields take
279
+ * one click without opening a popup. The pressed option carries the group's
280
+ * sliding highlight and `aria-pressed`; the group takes the field label as its
281
+ * accessible name.
282
+ */
283
+ export function SegmentField(props) {
284
+ return (_jsx(SegmentGroup, { id: props.id, role: "group", "aria-label": props.label, "aria-invalid": props.invalid || undefined, children: props.options.map((option, index) => {
285
+ const active = option.value === props.value;
286
+ return (_jsx("button", { type: "button", className: css.segment, "aria-pressed": active, disabled: props.disabled, "data-active": active ? '' : undefined, "data-segment-index": index, onClick: () => {
287
+ if (!active)
288
+ props.onEdit(option.value);
289
+ }, children: option.label }, option.value));
290
+ }) }));
291
+ }
292
+ /** A boolean field: 继承 / 开 / 关. */
205
293
  export function BooleanField(props) {
206
- return (_jsxs("div", { className: css.field, children: [_jsxs("div", { className: css.head, children: [_jsx("label", { className: css.label, htmlFor: props.id, children: props.label }), props.overridden
294
+ const segmented = props.presentation !== 'select';
295
+ return (_jsxs("div", { className: css.field, children: [_jsxs("div", { className: css.head, children: [segmented
296
+ ? _jsx("span", { className: css.label, children: props.label })
297
+ : _jsx("label", { className: css.label, htmlFor: props.id, children: props.label }), props.overridden
207
298
  ? (_jsxs("span", { className: css.badges, children: [_jsx("span", { className: css.badge, children: props.overriddenLabel }), _jsx("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })] }))
208
- : null] }), _jsx(SelectField, { id: props.id, options: [
209
- { value: '', label: props.inheritLabel },
210
- { value: 'true', label: props.onLabel },
211
- { value: 'false', label: props.offLabel },
212
- ], value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit }), _jsx("p", { className: css.hint, children: props.hint })] }));
299
+ : null] }), segmented
300
+ ? (_jsx(SegmentField, { id: props.id, label: props.label, options: [
301
+ { value: '', label: props.inheritLabel },
302
+ { value: 'true', label: props.onLabel },
303
+ { value: 'false', label: props.offLabel },
304
+ ], value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit }))
305
+ : (_jsx(SelectField, { id: props.id, options: [
306
+ { value: '', label: props.inheritLabel },
307
+ { value: 'true', label: props.onLabel },
308
+ { value: 'false', label: props.offLabel },
309
+ ], value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit })), _jsx("p", { className: css.hint, title: props.hintTitle, children: props.hint })] }));
213
310
  }
214
- /** A staged enumerated field rendered as a select. */
311
+ /** An enumerated field, selecting or segmenting its small choice set. */
215
312
  export function ChoiceField(props) {
216
- return (_jsxs("div", { className: css.field, children: [_jsxs("div", { className: css.head, children: [_jsx("label", { className: css.label, htmlFor: props.id, children: props.label }), props.overridden
313
+ const segmented = props.presentation === 'segment';
314
+ const options = [{ value: '', label: props.inheritLabel }, ...props.choices];
315
+ return (_jsxs("div", { className: css.field, children: [_jsxs("div", { className: css.head, children: [segmented
316
+ ? _jsx("span", { className: css.label, children: props.label })
317
+ : _jsx("label", { className: css.label, htmlFor: props.id, children: props.label }), props.overridden
217
318
  ? (_jsxs("span", { className: css.badges, children: [_jsx("span", { className: css.badge, children: props.overriddenLabel }), _jsx("button", { type: "button", className: css.reset, disabled: props.disabled, onClick: props.onReset, children: props.resetLabel })] }))
218
- : null] }), _jsx(SelectField, { id: props.id, options: [{ value: '', label: props.inheritLabel }, ...props.choices], value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit }), _jsx("p", { className: props.invalid ? css.invalid : css.hint, children: props.invalid ? props.invalidLabel : props.hint })] }));
319
+ : null] }), segmented
320
+ ? (_jsx(SegmentField, { id: props.id, label: props.label, options: options, value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit }))
321
+ : (_jsx(SelectField, { id: props.id, options: options, value: props.text, disabled: props.disabled, invalid: props.invalid, onEdit: props.onEdit })), _jsx("p", { className: props.invalid ? css.invalid : css.hint, title: props.hintTitle, children: props.invalid ? props.invalidLabel : props.hint })] }));
322
+ }
323
+ /**
324
+ * A boolean toggle drawn as a switch track, for a setting that is only on or
325
+ * off and applies on flip. It is a real button with
326
+ * `role="switch"` and `aria-checked`, so keyboard and assistive activation
327
+ * arrive as a click and the state is announced instead of inferred from a
328
+ * checkbox tick.
329
+ *
330
+ * The thumb bounces across only once the reader has pressed this switch: the
331
+ * press writes the mark that arms the bounce, so a page opening, a TAB
332
+ * switching back or a value arriving from elsewhere draws every thumb at rest.
333
+ */
334
+ export function ToggleSwitch(props) {
335
+ const [moved, setMoved] = useState(false);
336
+ return (_jsx("button", { type: "button", className: css.toggle, role: "switch", "aria-checked": props.checked, "aria-labelledby": props.labelledBy, "aria-label": props.labelledBy === undefined ? props.ariaLabel : undefined, disabled: props.disabled, "data-moved": moved ? '' : undefined, onClick: () => {
337
+ setMoved(true);
338
+ props.onChange(!props.checked);
339
+ }, children: _jsx("span", { className: css.toggleTrack, children: _jsx("span", { className: css.toggleThumb }) }) }));
219
340
  }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Coarse adjustment for a bounded number: resting the pointer on the control
3
+ * (or moving focus into it) raises a small bubble holding a slider across the
4
+ * field's whole range, so a large change is one drag instead of many presses
5
+ * or a retyped value. The control itself stays the precise entry.
6
+ *
7
+ * The bubble belongs to the anchor's subtree, so moving from the control onto
8
+ * the bubble never counts as leaving. It opens after a short rest and closes a
9
+ * moment after the pointer and focus have both gone, so crossing the control
10
+ * on the way elsewhere does not flash it. While a drag is in progress the
11
+ * bubble stays put even if the pointer strays off it.
12
+ *
13
+ * Dragging reports each value through `onInput`, so the field shows it live;
14
+ * releasing the thumb, or a key press on it, reports `onCommit` once. The
15
+ * bubble opens on the side of the control that has room inside the nearest
16
+ * scrolling ancestor, so a row near the top of a settings page does not hang
17
+ * its bubble under the page edge.
18
+ */
19
+ import { type ReactNode } from 'react';
20
+ /** Props of {@link RangeBubble}. */
21
+ export interface RangeBubbleProps {
22
+ /** Lowest value the slider reaches. */
23
+ min: number;
24
+ /** Highest value the slider reaches. */
25
+ max: number;
26
+ /** Slider granularity. */
27
+ step: number;
28
+ /** Current value; a value outside the range parks the thumb at the nearer end. */
29
+ value: number;
30
+ /** Accessible name of the slider. */
31
+ label: string;
32
+ /** Disables the bubble along with the control. */
33
+ disabled?: boolean;
34
+ /** Each value while the thumb moves. */
35
+ onInput: (value: number) => void;
36
+ /** The value the thumb was released on, once per drag or key press. */
37
+ onCommit: (value: number) => void;
38
+ /** The precise control the bubble hangs off. */
39
+ children: ReactNode;
40
+ }
41
+ /**
42
+ * Render the control with its coarse-adjustment bubble.
43
+ * @param props - the range, the value and the two report callbacks.
44
+ * @returns the anchor holding the control and the bubble.
45
+ */
46
+ export declare function RangeBubble(props: RangeBubbleProps): ReactNode;
47
+ //# sourceMappingURL=RangeBubble.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RangeBubble.d.ts","sourceRoot":"","sources":["../../../src/client/RangeBubble.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAyF,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAU7H,oCAAoC;AACpC,MAAM,WAAW,gBAAgB;IAC/B,uCAAuC;IACvC,GAAG,EAAE,MAAM,CAAA;IACX,wCAAwC;IACxC,GAAG,EAAE,MAAM,CAAA;IACX,0BAA0B;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,kFAAkF;IAClF,KAAK,EAAE,MAAM,CAAA;IACb,qCAAqC;IACrC,KAAK,EAAE,MAAM,CAAA;IACb,kDAAkD;IAClD,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,wCAAwC;IACxC,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IAChC,uEAAuE;IACvE,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAA;IACjC,gDAAgD;IAChD,QAAQ,EAAE,SAAS,CAAA;CACpB;AAWD;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,gBAAgB,GAAG,SAAS,CAiG9D"}
@@ -0,0 +1,107 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Coarse adjustment for a bounded number: resting the pointer on the control
4
+ * (or moving focus into it) raises a small bubble holding a slider across the
5
+ * field's whole range, so a large change is one drag instead of many presses
6
+ * or a retyped value. The control itself stays the precise entry.
7
+ *
8
+ * The bubble belongs to the anchor's subtree, so moving from the control onto
9
+ * the bubble never counts as leaving. It opens after a short rest and closes a
10
+ * moment after the pointer and focus have both gone, so crossing the control
11
+ * on the way elsewhere does not flash it. While a drag is in progress the
12
+ * bubble stays put even if the pointer strays off it.
13
+ *
14
+ * Dragging reports each value through `onInput`, so the field shows it live;
15
+ * releasing the thumb, or a key press on it, reports `onCommit` once. The
16
+ * bubble opens on the side of the control that has room inside the nearest
17
+ * scrolling ancestor, so a row near the top of a settings page does not hang
18
+ * its bubble under the page edge.
19
+ */
20
+ import { useEffect, useRef, useState } from 'react';
21
+ import css from './settings-card.module.css';
22
+ /** Rest on the control before the bubble opens. */
23
+ const OPEN_DELAY_MS = 220;
24
+ /** Grace after pointer and focus have left before the bubble closes. */
25
+ const CLOSE_DELAY_MS = 200;
26
+ /** Room the bubble needs between the control and the scroller's edge. */
27
+ const BUBBLE_ROOM_PX = 64;
28
+ /** The nearest ancestor that scrolls vertically, or the viewport's root. */
29
+ function scroller(node) {
30
+ for (let parent = node.parentElement; parent !== null; parent = parent.parentElement) {
31
+ const overflow = getComputedStyle(parent).overflowY;
32
+ if (overflow === 'auto' || overflow === 'scroll')
33
+ return parent;
34
+ }
35
+ return node.ownerDocument.documentElement;
36
+ }
37
+ /**
38
+ * Render the control with its coarse-adjustment bubble.
39
+ * @param props - the range, the value and the two report callbacks.
40
+ * @returns the anchor holding the control and the bubble.
41
+ */
42
+ export function RangeBubble(props) {
43
+ const { min, max, step, disabled = false } = props;
44
+ const [open, setOpen] = useState(false);
45
+ const [side, setSide] = useState('above');
46
+ const [live, setLive] = useState(null);
47
+ const anchorRef = useRef(null);
48
+ const timer = useRef(undefined);
49
+ const hovered = useRef(false);
50
+ const focused = useRef(false);
51
+ const dragging = useRef(false);
52
+ useEffect(() => () => { clearTimeout(timer.current); }, []);
53
+ useEffect(() => {
54
+ if (disabled) {
55
+ clearTimeout(timer.current);
56
+ setOpen(false);
57
+ }
58
+ }, [disabled]);
59
+ const show = () => {
60
+ const anchor = anchorRef.current;
61
+ if (anchor !== null) {
62
+ const room = anchor.getBoundingClientRect().top - scroller(anchor).getBoundingClientRect().top;
63
+ setSide(room >= BUBBLE_ROOM_PX ? 'above' : 'below');
64
+ }
65
+ setOpen(true);
66
+ };
67
+ const schedule = () => {
68
+ clearTimeout(timer.current);
69
+ if (disabled)
70
+ return;
71
+ if (hovered.current || focused.current || dragging.current) {
72
+ if (!open)
73
+ timer.current = setTimeout(show, focused.current ? 0 : OPEN_DELAY_MS);
74
+ return;
75
+ }
76
+ timer.current = setTimeout(() => { setOpen(false); }, CLOSE_DELAY_MS);
77
+ };
78
+ const commit = (value) => {
79
+ dragging.current = false;
80
+ setLive(null);
81
+ props.onCommit(value);
82
+ schedule();
83
+ };
84
+ const onChange = (event) => {
85
+ const value = Number(event.target.value);
86
+ setLive(value);
87
+ props.onInput(value);
88
+ };
89
+ const onKeyUp = (event) => {
90
+ if (live !== null)
91
+ commit(live);
92
+ if (event.key === 'Escape') {
93
+ clearTimeout(timer.current);
94
+ setOpen(false);
95
+ }
96
+ };
97
+ const shown = live ?? Math.min(max, Math.max(min, props.value));
98
+ return (_jsxs("div", { ref: anchorRef, className: css.rangeAnchor, onPointerEnter: () => { hovered.current = true; schedule(); }, onPointerLeave: () => { hovered.current = false; schedule(); }, onFocus: () => { focused.current = true; schedule(); }, onBlur: (event) => {
99
+ if (event.currentTarget.contains(event.relatedTarget))
100
+ return;
101
+ focused.current = false;
102
+ if (live !== null)
103
+ commit(live);
104
+ else
105
+ schedule();
106
+ }, children: [props.children, _jsxs("div", { className: css.rangeBubble, "data-open": open ? '' : undefined, "data-side": side, children: [_jsx("input", { type: "range", className: css.rangeSlider, min: min, max: max, step: step, value: shown, "aria-label": props.label, tabIndex: open ? 0 : -1, disabled: disabled, style: { '--range-fill': `${((shown - min) / (max - min)) * 100}%` }, onPointerDown: () => { dragging.current = true; }, onPointerUp: (event) => { commit(Number(event.currentTarget.value)); }, onPointerCancel: (event) => { commit(Number(event.currentTarget.value)); }, onChange: onChange, onKeyUp: onKeyUp }), _jsxs("span", { className: css.rangeEnds, "aria-hidden": "true", children: [_jsx("span", { children: min }), _jsx("span", { children: max })] })] })] }));
107
+ }
@@ -0,0 +1,29 @@
1
+ /**
2
+ * The family's segmented control: a quiet track whose options share one
3
+ * highlight that slides to the pressed option, instead of each option fading
4
+ * its own background out and the next one in. The settings fields' small
5
+ * choices and the Web Extensions TAB strip both render through it, so the two
6
+ * read as one control.
7
+ *
8
+ * The caller builds the option buttons and marks the pressed one with
9
+ * `data-active`; the group measures that button after every render and writes
10
+ * its box as four custom properties, and the stylesheet draws the highlight
11
+ * there (`.segmentGroup[data-pill]::before`). Attribute and first placement
12
+ * land in the same task, so the highlight appears in place and only later
13
+ * changes slide. A ResizeObserver re-measures when the group or an option
14
+ * changes size: a longer locale, a font arriving, a container growing, a
15
+ * strip wrapping onto a second line.
16
+ */
17
+ import { type HTMLAttributes, type ReactNode } from 'react';
18
+ /** Props of {@link SegmentGroup}: the track's own attributes and the option buttons. */
19
+ export interface SegmentGroupProps extends HTMLAttributes<HTMLDivElement> {
20
+ /** The option buttons; the pressed one carries `data-active`. */
21
+ children: ReactNode;
22
+ }
23
+ /**
24
+ * Render a segmented track around the caller's option buttons.
25
+ * @param props - the track's attributes (role, accessible name, key handler) and its options.
26
+ * @returns the track.
27
+ */
28
+ export declare function SegmentGroup(props: SegmentGroupProps): ReactNode;
29
+ //# sourceMappingURL=SegmentGroup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SegmentGroup.d.ts","sourceRoot":"","sources":["../../../src/client/SegmentGroup.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,EAAqC,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,OAAO,CAAA;AAS9F,wFAAwF;AACxF,MAAM,WAAW,iBAAkB,SAAQ,cAAc,CAAC,cAAc,CAAC;IACvE,iEAAiE;IACjE,QAAQ,EAAE,SAAS,CAAA;CACpB;AA+BD;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAyBhE"}
@@ -0,0 +1,81 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * The family's segmented control: a quiet track whose options share one
4
+ * highlight that slides to the pressed option, instead of each option fading
5
+ * its own background out and the next one in. The settings fields' small
6
+ * choices and the Web Extensions TAB strip both render through it, so the two
7
+ * read as one control.
8
+ *
9
+ * The caller builds the option buttons and marks the pressed one with
10
+ * `data-active`; the group measures that button after every render and writes
11
+ * its box as four custom properties, and the stylesheet draws the highlight
12
+ * there (`.segmentGroup[data-pill]::before`). Attribute and first placement
13
+ * land in the same task, so the highlight appears in place and only later
14
+ * changes slide. A ResizeObserver re-measures when the group or an option
15
+ * changes size: a longer locale, a font arriving, a container growing, a
16
+ * strip wrapping onto a second line.
17
+ */
18
+ import { Children, useLayoutEffect, useRef } from 'react';
19
+ import css from './settings-card.module.css';
20
+ /** The attribute marking a group whose highlight has been placed. */
21
+ const PILL_ATTR = 'data-pill';
22
+ /** The pressed option, relative to the group. */
23
+ const ACTIVE_SELECTOR = ':scope > [data-active]';
24
+ const PILL_PROPERTIES = ['--segment-pill-x', '--segment-pill-y', '--segment-pill-w', '--segment-pill-h'];
25
+ /**
26
+ * Write the highlight's box from the pressed option's box, or take the
27
+ * highlight off when nothing is pressed or the group has no layout yet.
28
+ * The two boxes are read in viewport pixels and turned back into the group's
29
+ * own CSS pixels, so a dialog that opens through a scale transform still
30
+ * lands the highlight on its option.
31
+ */
32
+ function placePill(group) {
33
+ const item = group.querySelector(ACTIVE_SELECTOR);
34
+ const box = group.getBoundingClientRect();
35
+ if (item === null || group.offsetWidth === 0 || box.width === 0) {
36
+ group.removeAttribute(PILL_ATTR);
37
+ for (const property of PILL_PROPERTIES)
38
+ group.style.removeProperty(property);
39
+ return;
40
+ }
41
+ const scale = box.width / group.offsetWidth;
42
+ const itemBox = item.getBoundingClientRect();
43
+ const values = [
44
+ (itemBox.left - box.left) / scale - group.clientLeft,
45
+ (itemBox.top - box.top) / scale - group.clientTop,
46
+ itemBox.width / scale,
47
+ itemBox.height / scale,
48
+ ];
49
+ values.forEach((value, index) => {
50
+ group.style.setProperty(PILL_PROPERTIES[index], `${Math.round(value * 100) / 100}px`);
51
+ });
52
+ if (!group.hasAttribute(PILL_ATTR))
53
+ group.setAttribute(PILL_ATTR, '');
54
+ }
55
+ /**
56
+ * Render a segmented track around the caller's option buttons.
57
+ * @param props - the track's attributes (role, accessible name, key handler) and its options.
58
+ * @returns the track.
59
+ */
60
+ export function SegmentGroup(props) {
61
+ const { children, className, ...rest } = props;
62
+ const group = useRef(null);
63
+ const count = Children.count(children);
64
+ // Placed before the frame is painted, after every render: a press moves the
65
+ // pressed mark and the highlight follows it in the same frame.
66
+ useLayoutEffect(() => {
67
+ if (group.current !== null)
68
+ placePill(group.current);
69
+ });
70
+ useLayoutEffect(() => {
71
+ const element = group.current;
72
+ if (element === null || typeof ResizeObserver === 'undefined')
73
+ return undefined;
74
+ const observer = new ResizeObserver(() => { placePill(element); });
75
+ observer.observe(element);
76
+ for (const item of Array.from(element.children))
77
+ observer.observe(item);
78
+ return () => { observer.disconnect(); };
79
+ }, [count]);
80
+ return (_jsx("div", { ...rest, ref: group, className: className === undefined ? css.segmentGroup : `${css.segmentGroup} ${className}`, children: children }));
81
+ }
@@ -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;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,CA2W9C"}
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;AAwFhG,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,CAwV9C"}
@@ -21,7 +21,8 @@ import { defaultPetRendererRegistry } from "./renderers/registry.js";
21
21
  import { live2dRenderer } from "./renderers/live2d.js";
22
22
  import { frames2dRenderer } from "./renderers/frames2d.js";
23
23
  import { registerPetUiTeardown, takeoverPetUiTeardown } from "./ui-teardown.js";
24
- import { PetSettingsSection, PetSettingsCardController } from "./PetSettingsCard.js";
24
+ import { PetSettingsCardController } from "./PetSettingsCard.js";
25
+ import { installPetSettingsRegistration } from "./settings-registration.js";
25
26
  import { NS, en, zh } from "./locales.js";
26
27
  import { mainViewSessionId } from "./main-session.js";
27
28
  import { reportDailyHeartbeat } from "./telemetry.js";
@@ -306,34 +307,14 @@ export function apply(ctx) {
306
307
  ? snapshot.value?.enabled ?? true
307
308
  : snapshot.status === 'unavailable';
308
309
  };
309
- // First-level settings section: one staged form over the 'pet' profile
310
- // entry's configuration, registered as a top-level settings page. The
311
- // controller loads the petId choices from the registry endpoint itself — the
312
- // registry lists the available pets (built-in assets plus user dirs), so the
313
- // section only ever shows installed pets. Installing new pets happens in the
314
- // Workshop store.
310
+ // One staged form follows the pet page between Web Extensions and the
311
+ // standalone first-level section. Seat migration does not reset drafts.
315
312
  const petSettings = new PetSettingsCardController(settingsForm);
316
- // The section entry owns the controller: unregistering it (fiber disposal,
317
- // hot reload) releases the form subscription through petSettings.dispose.
318
- ctx.slots.inject('settings.section', () => {
319
- try {
320
- const unregister = ctx.slots.register({
321
- name: 'settings.section',
322
- id: 'pet',
323
- order: 130,
324
- label: () => ctx.locale.bind('pet')('settings.title'),
325
- locale: 'pet',
326
- inject: () => petSettings.inject(),
327
- }, PetSettingsSection);
328
- return () => {
329
- unregister();
330
- petSettings.dispose();
331
- };
332
- }
333
- catch {
334
- return () => { };
335
- }
336
- });
313
+ const disposeSettingsRegistration = installPetSettingsRegistration(ctx, petSettings);
314
+ ctx.effect(() => () => {
315
+ disposeSettingsRegistration();
316
+ petSettings.dispose();
317
+ }, 'pet: settings page');
337
318
  // The global pet entry, its store, and the poll loop live while the plugin
338
319
  // is enabled; toggling the setting off hides the pet and stops polling.
339
320
  // 'uiDead' marks a terminal teardown (takeover by a later bundle instance