@linxin666/dsh-pet 0.4.3 → 0.4.5

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/lib/index.js CHANGED
@@ -4638,6 +4638,15 @@ var PetService = class extends Service {
4638
4638
  * the same turn again after the pet is disabled and re-enabled.
4639
4639
  */
4640
4640
  officialEventSessions = /* @__PURE__ */ new WeakSet();
4641
+ /**
4642
+ * Resolve the settings namespace this plugin's own config is served as, when
4643
+ * the caller can read it off the composition. A plugin's settings ARE its own
4644
+ * config, so the namespace is the row's id — and an aggregate bundle renames
4645
+ * child rows (`pet` becomes `web-ui-pet`), which is why it cannot be assumed
4646
+ * to be {@link PET_SETTINGS_NAMESPACE}. `apply` sets this; absent means the
4647
+ * plugin runs outside a Loader and the package's own id stands.
4648
+ */
4649
+ settingsNamespaceProvider = void 0;
4641
4650
  constructor(ctx, config = {}) {
4642
4651
  super(ctx, "pet");
4643
4652
  this.persistDir = config.persistDir ?? petHomeDir();
@@ -5182,7 +5191,7 @@ var PetService = class extends Service {
5182
5191
  this.ledger.setRemarks(selected.remarks);
5183
5192
  } else if (section.petId !== void 0) this.syncSettingsFromPet();
5184
5193
  const next = { ...this.ledger.snapshot.display };
5185
- next.visible = section.visible && (section.enabled ?? true);
5194
+ next.visible = section.visible;
5186
5195
  next.size = Math.round(Math.min(DISPLAY_SIZE_MAX, Math.max(32, section.size)));
5187
5196
  next.right = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.right)));
5188
5197
  next.bottom = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.bottom)));
@@ -5194,8 +5203,9 @@ var PetService = class extends Service {
5194
5203
  syncSettingsFromPet() {
5195
5204
  const settings = this.ctx.get("settings", false);
5196
5205
  if (settings === void 0) return;
5206
+ const ns = this.settingsNamespaceProvider?.() ?? "pet";
5197
5207
  const snapshot = this.ledger.snapshot;
5198
- settings.update("pet", {
5208
+ settings.update(ns, {
5199
5209
  visible: snapshot.display.visible,
5200
5210
  size: snapshot.display.size,
5201
5211
  right: snapshot.display.right,
@@ -5253,7 +5263,10 @@ var PetService = class extends Service {
5253
5263
  ...decoration === void 0 ? {} : { decoration },
5254
5264
  ...announcement === void 0 ? {} : { announcement },
5255
5265
  affinity: this.ledger.affinityView(Date.now()),
5256
- display: { ...this.ledger.snapshot.display },
5266
+ display: {
5267
+ ...this.ledger.snapshot.display,
5268
+ visible: this.isEnabled() && this.ledger.snapshot.display.visible
5269
+ },
5257
5270
  pet: {
5258
5271
  id: entry.id,
5259
5272
  displayName: entry.displayName,
@@ -6171,27 +6184,92 @@ function readLive(field, fallback) {
6171
6184
  return typeof ref.get === "function" ? ref.get() ?? fallback : field;
6172
6185
  }
6173
6186
  /**
6187
+ * Resolve one display field of the section. The precedence is deliberate:
6188
+ *
6189
+ * 1. an explicit profile value (`committed`) — the user's own choice, and the
6190
+ * only signal that carries a value equal to the schema default on purpose;
6191
+ * 2. a live value the row committed at runtime, i.e. one that differs from the
6192
+ * schema default, which is all an untouched field ever resolves to;
6193
+ * 3. what the pet's own `pet.json` already holds (`persisted`), so a field the
6194
+ * profile never touched keeps the position the user dragged instead of
6195
+ * snapping back to the schema default on the next mount.
6196
+ *
6197
+ * Step 3 is what makes a drag survive a restart. The display fields carry
6198
+ * schema defaults (`right: 24`, `bottom: 20` — the bottom-right corner), and a
6199
+ * config that never set them reads back exactly like one that set them to the
6200
+ * defaults, so without `persisted` the startup section resets the layout every
6201
+ * time the profile commits none — which is what an aggregate install does.
6202
+ * @param key - the display field to resolve.
6203
+ * @param live - the row config's own field, absent when the entry declares none.
6204
+ * @param persisted - the display the pet already shows (its own `pet.json`).
6205
+ * @param committed - the profile layer's explicit display values, when known.
6206
+ * @returns the value the pet runs with.
6207
+ */
6208
+ function displayField(key, live, persisted, committed) {
6209
+ const explicit = committed[key];
6210
+ if (explicit !== void 0) return explicit;
6211
+ const value = readLive(live, PET_FORM_DEFAULTS[key]);
6212
+ if (value !== PET_FORM_DEFAULTS[key]) return value;
6213
+ const kept = persisted[key];
6214
+ return kept === void 0 ? value : kept;
6215
+ }
6216
+ /**
6174
6217
  * The settings section the pet runs with: the effective values of the row's
6175
6218
  * own config. `fallbackPetId` covers a mount whose config names no pet at all
6176
6219
  * (a direct mount outside a Loader) — under a Loader the schema default is
6177
6220
  * always present, so the persisted selection stands whenever the config
6178
- * carries it.
6221
+ * carries it. `persisted` and `committed` give the display fields the same
6222
+ * treatment; see {@link displayField}.
6179
6223
  * @param config - the effective config of the pet row.
6180
6224
  * @param fallbackPetId - pet id to use when the config names none.
6225
+ * @param persisted - the display the pet already shows (its own `pet.json`).
6226
+ * @param committed - the profile layer's explicit display values, when known.
6181
6227
  * @returns the resolved settings section.
6182
6228
  */
6183
- function petSettingsSection(config, fallbackPetId) {
6229
+ function petSettingsSection(config, fallbackPetId, persisted = {}, committed = {}) {
6230
+ const enabled = readLive(config.enabled, PET_FORM_DEFAULTS.enabled);
6184
6231
  return {
6185
- visible: readLive(config.visible, PET_FORM_DEFAULTS.visible),
6186
- size: readLive(config.size, PET_FORM_DEFAULTS.size),
6187
- right: readLive(config.right, PET_FORM_DEFAULTS.right),
6188
- bottom: readLive(config.bottom, PET_FORM_DEFAULTS.bottom),
6189
- bubbleScale: readLive(config.bubbleScale, PET_FORM_DEFAULTS.bubbleScale),
6232
+ visible: displayField("visible", config.visible, persisted, committed),
6233
+ size: displayField("size", config.size, persisted, committed),
6234
+ right: displayField("right", config.right, persisted, committed),
6235
+ bottom: displayField("bottom", config.bottom, persisted, committed),
6236
+ bubbleScale: displayField("bubbleScale", config.bubbleScale, persisted, committed),
6190
6237
  petId: readLive(config.petId, fallbackPetId),
6191
- enabled: readLive(config.enabled, PET_FORM_DEFAULTS.enabled),
6238
+ enabled,
6192
6239
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled)
6193
6240
  };
6194
6241
  }
6242
+ /** The settings row ids a pet install is served under, most specific first. */
6243
+ const PET_SETTINGS_ROW_IDS = [
6244
+ "web-ui-pet",
6245
+ "ui-pet",
6246
+ "pet"
6247
+ ];
6248
+ /**
6249
+ * The settings row serving this plugin's own config, or undefined when the
6250
+ * settings service is not mounted (a direct mount) or serves no row for the pet.
6251
+ *
6252
+ * Every settings write has to address this row's id, and that id is not the
6253
+ * package's plugin name: an aggregate bundle renames child rows (`pet` becomes
6254
+ * `web-ui-pet`). The browser half resolves the same id through its own
6255
+ * `servedEntryId`, so both halves write to one namespace.
6256
+ * @param ctx - the plugin's context.
6257
+ * @returns the serving row, when there is one.
6258
+ */
6259
+ function servedRow(ctx) {
6260
+ try {
6261
+ const settings = ctx.get("settings", false);
6262
+ if (settings === void 0) return void 0;
6263
+ const rows = settings.describe();
6264
+ for (const id of PET_SETTINGS_ROW_IDS) {
6265
+ const row = rows.find((candidate) => candidate.ns === id);
6266
+ if (row !== void 0) return row;
6267
+ }
6268
+ return;
6269
+ } catch {
6270
+ return;
6271
+ }
6272
+ }
6195
6273
  /** Register the pet service and its API + asset routes on the context. */
6196
6274
  const apply = mountOnce("@linxin666/dsh-pet", applyImpl);
6197
6275
  function applyImpl(ctx, config = {}) {
@@ -6205,7 +6283,8 @@ function applyImpl(ctx, config = {}) {
6205
6283
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled),
6206
6284
  registry
6207
6285
  });
6208
- const current = () => petSettingsSection(config, service.selectedPetId());
6286
+ service.settingsNamespaceProvider = () => servedRow(ctx)?.ns;
6287
+ const current = () => petSettingsSection(config, service.selectedPetId(), service.display(), servedRow(ctx)?.user);
6209
6288
  const routes = makePetRoutes({
6210
6289
  service,
6211
6290
  ctx
@@ -38,5 +38,7 @@ declare module '@deepseek-ai/cordis' {
38
38
  };
39
39
  }
40
40
  }
41
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
42
+ export declare const BINDER_RETRY_MS = 250;
41
43
  export declare function apply(ctx: ClientContext): void;
42
44
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,4CAA4C,CAAA;AAqFzF,wEAAwE;AACxE,eAAO,MAAM,MAAM,UAAwF,CAAA;AAE3G,qEAAqE;AACrE,YAAY,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAA;AACxE,YAAY,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AACrD,YAAY,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC7D,YAAY,EAAE,mBAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AACtF,YAAY,EAAE,uBAAuB,EAAE,MAAM,uBAAuB,CAAA;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAEnD,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,OAAO;QACf;;;;WAIG;QACH,aAAa,CAAC,EAAE;YACd,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE;gBAAE,SAAS,EAAE,MAAM,CAAC;gBAAC,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,CAAC,GAAG,SAAS,CAAA;aAAE,GAAG,UAAU,CAAC,CAAC,CAAC,CAAA;SAClG,CAAA;KACF;CACF;AA0DD,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAoU9C"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAGnE,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,4CAA4C,CAAA;AAqFhG,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;AAmNlC,wBAAgB,KAAK,CAAC,GAAG,EAAE,aAAa,GAAG,IAAI,CAuU9C"}
@@ -62,38 +62,199 @@ const PET_SETTINGS_NS = 'pet';
62
62
  /** Required services (sessions powers bubble-to-session navigation). */
63
63
  export const inject = ['slots', 'locale', 'connection', 'configForms', 'remote', 'sessions', 'uiWorkspace'];
64
64
  /**
65
- * The configuration form the settings card stages and saves through: the
66
- * family binder when dsh-web-settings is mounted, otherwise the shared form of
67
- * this plugin's own profile entry.
68
- *
69
- * The two are not interchangeable by name. A plugin's settings ARE its own
70
- * config on 0.1.7, so the form belongs to the profile entry that carries the
71
- * plugin — and only the family binder knows which entry that is, because the
72
- * family bundle renames child rows ('pet' becomes 'web-ui-pet' there) while a
73
- * standalone install keeps the package's own id.
74
- * @param ctx - client root context.
75
- * @returns the form for the pet's settings page.
65
+ * The profile entry ids a pet install is served under, most specific first. The
66
+ * family bundle renames child rows, so a standalone install and an aggregate
67
+ * one answer to different ids for the same 'pet' namespace.
76
68
  */
77
69
  const AGGREGATE_ENTRY_ID = 'web-ui-pet';
78
70
  const PET_ENTRY_IDS = [AGGREGATE_ENTRY_ID, 'ui-pet', PET_SETTINGS_NS];
79
- function servedEntryId(forms) {
80
- let served;
81
- try {
82
- served = forms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
71
+ /** How long the deferred form keeps retrying before it settles on the fallback. */
72
+ export const BINDER_RETRY_MS = 250;
73
+ const BINDER_ATTEMPTS = 24;
74
+ /** The snapshot an unresolved (or resolvable-but-unbound) form publishes. */
75
+ function pendingSnapshot(status) {
76
+ return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false, mode: 'host' };
77
+ }
78
+ /**
79
+ * A ConfigForm that late-binds to the family settings binder.
80
+ *
81
+ * The binder service (dsh-web-settings) is not guaranteed to be published by the
82
+ * time this plugin's apply() runs: the aggregate bundle mounts its inlined
83
+ * children — including the binder — inside an async mount that awaits the
84
+ * active-rows fetch, while standalone loader entries like this one apply
85
+ * synchronously in that window. A single early probe then permanently falls
86
+ * back to `configForms.get('pet')`, which is never a served row id under the
87
+ * aggregate (the row is `web-ui-pet`), so the settings card renders "not
88
+ * exposed" forever even though the Host serves the namespace.
89
+ *
90
+ * This form resolves through the binder as soon as the service appears and
91
+ * delegates the whole ConfigForm surface to it, re-publishing to its own
92
+ * subscribers on every swap. Until a form is resolved it publishes a loading
93
+ * (then unavailable) snapshot so the card shows a transient state, never a
94
+ * false "not exposed". If the binder never appears it retries for a bounded
95
+ * window, then permanently binds the non-bridge fallback by SERVED entry id.
96
+ */
97
+ class DeferredSettingsForm {
98
+ ctx;
99
+ current;
100
+ listeners = new Set();
101
+ unsubscribeCurrent;
102
+ retryTimer;
103
+ attempts = 0;
104
+ disposed = false;
105
+ fallback;
106
+ fallbackUnsubscribe;
107
+ constructor(ctx) {
108
+ this.ctx = ctx;
109
+ this.fallback = ctx.configForms.get(this.resolveFallbackEntryId());
110
+ // 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 once.
112
+ if (!this.resolve() && !this.fallbackSettled())
113
+ this.scheduleRetry();
114
+ else if (this.current === undefined)
115
+ this.adoptFallback();
83
116
  }
84
- catch {
85
- served = undefined;
117
+ /**
118
+ * True while the shared mirror reports the pet namespace unavailable — the
119
+ * only state in which waiting can still help. A fallback that is ready (or
120
+ * merely loading, which the mirror fills in on its own) is adopted at once.
121
+ */
122
+ fallbackSettled() {
123
+ try {
124
+ return this.fallback.getSnapshot().status !== 'unavailable';
125
+ }
126
+ catch {
127
+ return false;
128
+ }
86
129
  }
87
- if (!served || served.length === 0)
130
+ /**
131
+ * Bind the fallback to a SERVED row id when the mirror can name one; a mirror
132
+ * that cannot is left to report its own unavailable state.
133
+ */
134
+ resolveFallbackEntryId() {
135
+ try {
136
+ const served = this.ctx.configForms.describe().getSnapshot().view?.namespaces.map(view => view.ns);
137
+ if (served && served.length > 0) {
138
+ const hit = PET_ENTRY_IDS.find(id => served.includes(id));
139
+ if (hit !== undefined)
140
+ return hit;
141
+ }
142
+ }
143
+ catch {
144
+ // fall through to the family namespace; the form reports unavailable.
145
+ }
88
146
  return PET_SETTINGS_NS;
89
- return PET_ENTRY_IDS.find(id => served.includes(id)) ?? PET_SETTINGS_NS;
90
- }
91
- function petSettingsForm(ctx) {
92
- const binder = ctx.get('webUiSettings');
93
- if (binder !== undefined && typeof binder.bind === 'function') {
94
- return binder.bind({ namespace: PET_SETTINGS_NS });
95
147
  }
96
- return ctx.configForms.get(servedEntryId(ctx.configForms));
148
+ /**
149
+ * Adopt the family binder the moment it is published.
150
+ * @returns true when a binder was bound, false when none is available yet.
151
+ */
152
+ resolve() {
153
+ if (this.disposed)
154
+ return false;
155
+ let binder;
156
+ try {
157
+ binder = this.ctx.get('webUiSettings');
158
+ }
159
+ catch {
160
+ binder = undefined;
161
+ }
162
+ if (binder === undefined || typeof binder.bind !== 'function')
163
+ return false;
164
+ let bound;
165
+ try {
166
+ bound = binder
167
+ .bind({ namespace: PET_SETTINGS_NS });
168
+ }
169
+ catch {
170
+ return false;
171
+ }
172
+ this.current = bound;
173
+ // Mirror the bound form's changes to our own subscribers; a later re-resolve
174
+ // swaps this subscription to the new form.
175
+ this.unsubscribeCurrent?.();
176
+ this.unsubscribeCurrent = bound.subscribe(() => this.publish());
177
+ this.publish();
178
+ return true;
179
+ }
180
+ /**
181
+ * Adopt the shared per-entry form. It is used immediately unless it reports
182
+ * the namespace unavailable, in which case the binder may still be on its way
183
+ * and the retry window takes over (see scheduleRetry).
184
+ */
185
+ adoptFallback() {
186
+ this.current = this.fallback;
187
+ this.fallbackUnsubscribe ??= this.fallback.subscribe(() => this.publish());
188
+ this.unsubscribeCurrent = this.fallbackUnsubscribe;
189
+ this.publish();
190
+ }
191
+ /** Retry the binder lookup a few times across the aggregate's async mount. */
192
+ scheduleRetry() {
193
+ if (this.disposed)
194
+ return;
195
+ if (this.attempts >= BINDER_ATTEMPTS) {
196
+ this.adoptFallback();
197
+ return;
198
+ }
199
+ this.attempts += 1;
200
+ this.retryTimer = window.setTimeout(() => {
201
+ this.retryTimer = undefined;
202
+ if (this.disposed)
203
+ return;
204
+ if (this.resolve())
205
+ return;
206
+ // The binder still absent: keep waiting only while the shared form cannot
207
+ // answer for itself, otherwise a standalone install stalls for the window.
208
+ if (this.fallbackSettled()) {
209
+ this.attempts = BINDER_ATTEMPTS;
210
+ this.adoptFallback();
211
+ return;
212
+ }
213
+ this.scheduleRetry();
214
+ }, BINDER_RETRY_MS);
215
+ }
216
+ publish() {
217
+ for (const listener of this.listeners)
218
+ listener();
219
+ }
220
+ /** The resolved form, or a placeholder snapshot when still pending. */
221
+ snapshot() {
222
+ return this.current?.getSnapshot() ?? pendingSnapshot(this.attempts >= BINDER_ATTEMPTS ? 'unavailable' : 'loading');
223
+ }
224
+ getSnapshot() {
225
+ return this.snapshot();
226
+ }
227
+ subscribe(listener) {
228
+ this.listeners.add(listener);
229
+ return () => { this.listeners.delete(listener); };
230
+ }
231
+ mutate(ops, expectedRevision) {
232
+ return this.current?.mutate(ops, expectedRevision) ?? Promise.resolve(false);
233
+ }
234
+ set(field, value) {
235
+ return this.current?.set(field, value) ?? Promise.resolve(false);
236
+ }
237
+ unset(field) {
238
+ return this.current?.unset(field) ?? Promise.resolve(false);
239
+ }
240
+ /** Release the retry timer and mirror subscription; not part of ConfigForm. */
241
+ dispose() {
242
+ if (this.disposed)
243
+ return;
244
+ this.disposed = true;
245
+ if (this.retryTimer !== undefined) {
246
+ window.clearTimeout(this.retryTimer);
247
+ this.retryTimer = undefined;
248
+ }
249
+ this.unsubscribeCurrent?.();
250
+ this.unsubscribeCurrent = undefined;
251
+ this.current = undefined;
252
+ this.listeners.clear();
253
+ // The shared per-entry form carries no disposer of its own (ConfigForm is a
254
+ // pure read/write surface); only this form's own subscriptions are released.
255
+ this.fallbackUnsubscribe?.();
256
+ this.fallbackUnsubscribe = undefined;
257
+ }
97
258
  }
98
259
  /**
99
260
  * Client plugin body: register dictionaries, mount the global pet entry and
@@ -129,7 +290,7 @@ export function apply(ctx) {
129
290
  // M3). Registration is idempotent (id wins), so re-applies stay clean.
130
291
  defaultPetRendererRegistry.register(live2dRenderer);
131
292
  defaultPetRendererRegistry.register(frames2dRenderer);
132
- const settingsForm = petSettingsForm(ctx);
293
+ const settingsForm = new DeferredSettingsForm(ctx);
133
294
  const enabled = () => {
134
295
  const snapshot = settingsForm.getSnapshot();
135
296
  return snapshot.status === 'ready'
@@ -430,6 +591,9 @@ export function apply(ctx) {
430
591
  const unsubscribeSettings = settingsForm.subscribe(syncUi);
431
592
  ctx.effect(() => () => {
432
593
  unsubscribeSettings();
594
+ // Release the deferred form's retry timer and its mirror subscription so a
595
+ // disposed fiber can never bind or publish after teardown.
596
+ settingsForm.dispose();
433
597
  killUi();
434
598
  }, 'pet: client lifecycle');
435
599
  syncUi();
@@ -13,6 +13,7 @@
13
13
  import { Context, type Volatile } from '@deepseek-ai/cordis';
14
14
  import z from '@deepseek-ai/schemastery';
15
15
  import { type PetConfig, type PetSettingsSection } from './service.ts';
16
+ import { type PetDisplayConfig } from './persist.ts';
16
17
  export { PetService, MAX_SESSION_BUBBLES } from './service.ts';
17
18
  export type { PetConfig, PetInteractResult, PetSettingsSection, PetSessionView, PetStateView, } from './service.ts';
18
19
  export { AFFINITY_MAX, AFFINITY_RANKS, applyInteraction, applyTurnReward, emptyAffinity, rankOf, } from './affinity.ts';
@@ -112,12 +113,15 @@ export declare const Config: z<Schemastery.ObjectS<NoInfer<{
112
113
  * own config. `fallbackPetId` covers a mount whose config names no pet at all
113
114
  * (a direct mount outside a Loader) — under a Loader the schema default is
114
115
  * always present, so the persisted selection stands whenever the config
115
- * carries it.
116
+ * carries it. `persisted` and `committed` give the display fields the same
117
+ * treatment; see {@link displayField}.
116
118
  * @param config - the effective config of the pet row.
117
119
  * @param fallbackPetId - pet id to use when the config names none.
120
+ * @param persisted - the display the pet already shows (its own `pet.json`).
121
+ * @param committed - the profile layer's explicit display values, when known.
118
122
  * @returns the resolved settings section.
119
123
  */
120
- export declare function petSettingsSection(config: PetFormConfig, fallbackPetId: string): PetSettingsSection;
124
+ export declare function petSettingsSection(config: PetFormConfig, fallbackPetId: string, persisted?: Partial<PetDisplayConfig>, committed?: Partial<PetDisplayConfig>): PetSettingsSection;
121
125
  /** Register the pet service and its API + asset routes on the context. */
122
126
  export declare const apply: typeof applyImpl;
123
127
  /** Plugin config: the tuning block a profile may declare plus the pet's settings fields. */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,qBAAqB,CAAA;AAI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BAAmB,CAAC,GAAG,aAAa,CAAA;AAE9F,iBAAS,SAAS,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,eAAoB,GAAG,IAAI,CA8EnE;AAED,OAAO,QAAQ,qBAAqB,CAAC;IACnC,UAAU,MAAM;QACd;;;;WAIG;QACH,wBAAwB,CAAC,KAAK,EAAE,SAAS,CAAC,SAAS,MAAM,EAAE,CAAC,EAAE,GAAG,IAAI,CAAA;KACtE;CACF"}
@@ -11,7 +11,7 @@
11
11
  * @module @linxin666/dsh-pet
12
12
  */
13
13
  import z from '@deepseek-ai/schemastery';
14
- import { PetService } from "./service.js";
14
+ import { PET_SETTINGS_NAMESPACE, PetService } from "./service.js";
15
15
  import { makePetRoutes } from "./routes.js";
16
16
  import { loadPetRegistry, petPackageRoot } from "./registry.js";
17
17
  import { BUBBLE_SCALE_MAX, BUBBLE_SCALE_MIN, DEFAULT_PET_ID, DISPLAY_INSET_MAX, DISPLAY_SIZE_MAX, DISPLAY_SIZE_MIN } from "./persist.js";
@@ -82,28 +82,109 @@ function readLive(field, fallback) {
82
82
  const ref = field;
83
83
  return typeof ref.get === 'function' ? ref.get() ?? fallback : field;
84
84
  }
85
+ /**
86
+ * Resolve one display field of the section. The precedence is deliberate:
87
+ *
88
+ * 1. an explicit profile value (`committed`) — the user's own choice, and the
89
+ * only signal that carries a value equal to the schema default on purpose;
90
+ * 2. a live value the row committed at runtime, i.e. one that differs from the
91
+ * schema default, which is all an untouched field ever resolves to;
92
+ * 3. what the pet's own `pet.json` already holds (`persisted`), so a field the
93
+ * profile never touched keeps the position the user dragged instead of
94
+ * snapping back to the schema default on the next mount.
95
+ *
96
+ * Step 3 is what makes a drag survive a restart. The display fields carry
97
+ * schema defaults (`right: 24`, `bottom: 20` — the bottom-right corner), and a
98
+ * config that never set them reads back exactly like one that set them to the
99
+ * defaults, so without `persisted` the startup section resets the layout every
100
+ * time the profile commits none — which is what an aggregate install does.
101
+ * @param key - the display field to resolve.
102
+ * @param live - the row config's own field, absent when the entry declares none.
103
+ * @param persisted - the display the pet already shows (its own `pet.json`).
104
+ * @param committed - the profile layer's explicit display values, when known.
105
+ * @returns the value the pet runs with.
106
+ */
107
+ function displayField(key, live, persisted, committed) {
108
+ const explicit = committed[key];
109
+ if (explicit !== undefined)
110
+ return explicit;
111
+ const value = readLive(live, PET_FORM_DEFAULTS[key]);
112
+ if (value !== PET_FORM_DEFAULTS[key])
113
+ return value;
114
+ const kept = persisted[key];
115
+ return kept === undefined ? value : kept;
116
+ }
85
117
  /**
86
118
  * The settings section the pet runs with: the effective values of the row's
87
119
  * own config. `fallbackPetId` covers a mount whose config names no pet at all
88
120
  * (a direct mount outside a Loader) — under a Loader the schema default is
89
121
  * always present, so the persisted selection stands whenever the config
90
- * carries it.
122
+ * carries it. `persisted` and `committed` give the display fields the same
123
+ * treatment; see {@link displayField}.
91
124
  * @param config - the effective config of the pet row.
92
125
  * @param fallbackPetId - pet id to use when the config names none.
126
+ * @param persisted - the display the pet already shows (its own `pet.json`).
127
+ * @param committed - the profile layer's explicit display values, when known.
93
128
  * @returns the resolved settings section.
94
129
  */
95
- export function petSettingsSection(config, fallbackPetId) {
130
+ export function petSettingsSection(config, fallbackPetId, persisted = {}, committed = {}) {
131
+ // `visible` and `enabled` answer two DIFFERENT questions and are kept
132
+ // apart on purpose (#1762):
133
+ //
134
+ // - `visible` is the pet's own hide/show intent, persisted in its pet.json
135
+ // and written by the sprite's hide/summon control and by the aggregate
136
+ // shell's fallback switch.
137
+ // - `enabled` is the plugin master switch, which hides the pet whatever that
138
+ // own intent says.
139
+ //
140
+ // The effective "is it on screen" state is the conjunction, and it belongs at
141
+ // the single point that PRODUCES the view (see PetService.state), never here
142
+ // and never written back to pet.json. Folding it into this field is what made
143
+ // the master switch one-way: switching it off stored the derived `false` as
144
+ // the user's own intent, so switching it on again (or restarting) read that
145
+ // stored `false` back and the pet never returned.
146
+ const enabled = readLive(config.enabled, PET_FORM_DEFAULTS.enabled);
96
147
  return {
97
- visible: readLive(config.visible, PET_FORM_DEFAULTS.visible),
98
- size: readLive(config.size, PET_FORM_DEFAULTS.size),
99
- right: readLive(config.right, PET_FORM_DEFAULTS.right),
100
- bottom: readLive(config.bottom, PET_FORM_DEFAULTS.bottom),
101
- bubbleScale: readLive(config.bubbleScale, PET_FORM_DEFAULTS.bubbleScale),
148
+ visible: displayField('visible', config.visible, persisted, committed),
149
+ size: displayField('size', config.size, persisted, committed),
150
+ right: displayField('right', config.right, persisted, committed),
151
+ bottom: displayField('bottom', config.bottom, persisted, committed),
152
+ bubbleScale: displayField('bubbleScale', config.bubbleScale, persisted, committed),
102
153
  petId: readLive(config.petId, fallbackPetId),
103
- enabled: readLive(config.enabled, PET_FORM_DEFAULTS.enabled),
154
+ enabled,
104
155
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled),
105
156
  };
106
157
  }
158
+ /** The settings row ids a pet install is served under, most specific first. */
159
+ const PET_SETTINGS_ROW_IDS = ['web-ui-pet', 'ui-pet', PET_SETTINGS_NAMESPACE];
160
+ /**
161
+ * The settings row serving this plugin's own config, or undefined when the
162
+ * settings service is not mounted (a direct mount) or serves no row for the pet.
163
+ *
164
+ * Every settings write has to address this row's id, and that id is not the
165
+ * package's plugin name: an aggregate bundle renames child rows (`pet` becomes
166
+ * `web-ui-pet`). The browser half resolves the same id through its own
167
+ * `servedEntryId`, so both halves write to one namespace.
168
+ * @param ctx - the plugin's context.
169
+ * @returns the serving row, when there is one.
170
+ */
171
+ function servedRow(ctx) {
172
+ try {
173
+ const settings = ctx.get('settings', false);
174
+ if (settings === undefined)
175
+ return undefined;
176
+ const rows = settings.describe();
177
+ for (const id of PET_SETTINGS_ROW_IDS) {
178
+ const row = rows.find(candidate => candidate.ns === id);
179
+ if (row !== undefined)
180
+ return row;
181
+ }
182
+ return undefined;
183
+ }
184
+ catch {
185
+ return undefined;
186
+ }
187
+ }
107
188
  /** Register the pet service and its API + asset routes on the context. */
108
189
  export const apply = mountOnce('@linxin666/dsh-pet', applyImpl);
109
190
  function applyImpl(ctx, config = {}) {
@@ -118,12 +199,19 @@ function applyImpl(ctx, config = {}) {
118
199
  decorationEnabled: readLive(config.decorationEnabled, PET_FORM_DEFAULTS.decorationEnabled),
119
200
  registry,
120
201
  });
202
+ // The mirror back into the settings document (see syncSettingsFromPet) has to
203
+ // address the row that serves this plugin's config, which an aggregate bundle
204
+ // renames; the id is resolved lazily, once the composition serves it.
205
+ service.settingsNamespaceProvider = () => servedRow(ctx)?.ns;
121
206
  // The effective settings ARE this row's own config: the Host serves one form
122
207
  // per profile entry from `Config` above, and every edit is committed into the
123
208
  // running config, so the plugin re-reads the section here instead of holding
124
209
  // a separate settings document (0.1.6 registered one through
125
- // settings.installSection/register and re-resolved it on every change).
126
- const current = () => petSettingsSection(config, service.selectedPetId());
210
+ // settings.installSection/register and re-resolved it on every change). The
211
+ // display fields additionally read the persisted layout and the profile layer,
212
+ // so a mount with a config that never set them cannot reset a dragged
213
+ // position to the schema defaults (see displayField).
214
+ const current = () => petSettingsSection(config, service.selectedPetId(), service.display(), servedRow(ctx)?.user);
127
215
  // The browser half talks to the pet through same-origin JSON endpoints and
128
216
  // loads each pet's atlas from the registry's own media route (RPC domains
129
217
  // are platform-registered, so the pet serves its own API — the same
@@ -222,6 +222,15 @@ export declare class PetService extends Service {
222
222
  * the same turn again after the pet is disabled and re-enabled.
223
223
  */
224
224
  private readonly officialEventSessions;
225
+ /**
226
+ * Resolve the settings namespace this plugin's own config is served as, when
227
+ * the caller can read it off the composition. A plugin's settings ARE its own
228
+ * config, so the namespace is the row's id — and an aggregate bundle renames
229
+ * child rows (`pet` becomes `web-ui-pet`), which is why it cannot be assumed
230
+ * to be {@link PET_SETTINGS_NAMESPACE}. `apply` sets this; absent means the
231
+ * plugin runs outside a Loader and the package's own id stands.
232
+ */
233
+ settingsNamespaceProvider: (() => string | undefined) | undefined;
225
234
  constructor(ctx: Context, config?: PetConfig);
226
235
  /**
227
236
  * The draw-time voice-pool provider handed to every projection runtime.