@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/README.i18n.yaml +2 -2
- package/README.md +18 -4
- package/README.zh.md +18 -4
- package/lib/client.js +176 -16
- package/lib/client.js.map +1 -1
- package/lib/index.js +91 -12
- package/lib/types/client/index.d.ts +2 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +190 -26
- package/lib/types/index.d.ts +6 -2
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +99 -11
- package/lib/types/service.d.ts +9 -0
- package/lib/types/service.d.ts.map +1 -1
- package/lib/types/service.js +23 -3
- package/package.json +1 -1
- package/src/client/index.test.tsx +81 -3
- package/src/client/index.ts +194 -27
- package/src/index.test.ts +39 -0
- package/src/index.ts +122 -12
- package/src/registry.test.ts +11 -1
- package/src/service.ts +23 -3
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/service.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAGtD,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,eAAe,CAAA;AACpF,OAAO,EAAwC,KAAK,eAAe,EAAE,MAAM,eAAe,CAAA;AAC1F,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAS9C,OAAO,EAAgC,KAAK,uBAAuB,EAAE,MAAM,aAAa,CAAA;AACxF,OAAO,EAWL,KAAK,gBAAgB,EACtB,MAAM,cAAc,CAAA;AACrB,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC3B,MAAM,eAAe,CAAA;AAGtB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,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A;KAAE,GAAG;QAAE,EAAE,EAAE,KAAK,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAS/F;;;;;OAKG;IACH,oBAAoB,CAAC,OAAO,EAAE,kBAAkB,GAAG,IAAI;IA2BvD,oFAAoF;IACpF,OAAO,CAAC,mBAAmB;IAgB3B,qFAAqF;IACrF,OAAO,CAAC,UAAU;IAIlB,8EAA8E;IAC9E,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,IAAI;IAsFZ,OAAO,CAAC,KAAK;CAOd"}
|
package/lib/types/service.js
CHANGED
|
@@ -66,6 +66,15 @@ export class PetService extends Service {
|
|
|
66
66
|
* the same turn again after the pet is disabled and re-enabled.
|
|
67
67
|
*/
|
|
68
68
|
officialEventSessions = new WeakSet();
|
|
69
|
+
/**
|
|
70
|
+
* Resolve the settings namespace this plugin's own config is served as, when
|
|
71
|
+
* the caller can read it off the composition. A plugin's settings ARE its own
|
|
72
|
+
* config, so the namespace is the row's id — and an aggregate bundle renames
|
|
73
|
+
* child rows (`pet` becomes `web-ui-pet`), which is why it cannot be assumed
|
|
74
|
+
* to be {@link PET_SETTINGS_NAMESPACE}. `apply` sets this; absent means the
|
|
75
|
+
* plugin runs outside a Loader and the package's own id stands.
|
|
76
|
+
*/
|
|
77
|
+
settingsNamespaceProvider = undefined;
|
|
69
78
|
constructor(ctx, config = {}) {
|
|
70
79
|
super(ctx, 'pet');
|
|
71
80
|
this.persistDir = config.persistDir ?? petHomeDir();
|
|
@@ -596,7 +605,13 @@ export class PetService extends Service {
|
|
|
596
605
|
this.syncSettingsFromPet();
|
|
597
606
|
}
|
|
598
607
|
const next = { ...this.ledger.snapshot.display };
|
|
599
|
-
|
|
608
|
+
// The pet's own hide/show intent, stored verbatim. The master switch is
|
|
609
|
+
// applied when the state view is produced (see the state view below), not
|
|
610
|
+
// here: writing the conjunction into pet.json turned `enabled: false` into
|
|
611
|
+
// a persisted "the user hid the pet" and the switch could never be undone -
|
|
612
|
+
// re-enabling it (or restarting) read that stored `false` straight back
|
|
613
|
+
// (#1762).
|
|
614
|
+
next.visible = section.visible;
|
|
600
615
|
next.size = Math.round(Math.min(DISPLAY_SIZE_MAX, Math.max(DISPLAY_SIZE_MIN, section.size)));
|
|
601
616
|
next.right = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.right)));
|
|
602
617
|
next.bottom = Math.round(Math.min(DISPLAY_INSET_MAX, Math.max(0, section.bottom)));
|
|
@@ -609,8 +624,9 @@ export class PetService extends Service {
|
|
|
609
624
|
const settings = this.ctx.get('settings', false);
|
|
610
625
|
if (settings === undefined)
|
|
611
626
|
return;
|
|
627
|
+
const ns = this.settingsNamespaceProvider?.() ?? PET_SETTINGS_NAMESPACE;
|
|
612
628
|
const snapshot = this.ledger.snapshot;
|
|
613
|
-
void settings.update(
|
|
629
|
+
void settings.update(ns, {
|
|
614
630
|
visible: snapshot.display.visible,
|
|
615
631
|
size: snapshot.display.size,
|
|
616
632
|
right: snapshot.display.right,
|
|
@@ -700,7 +716,11 @@ export class PetService extends Service {
|
|
|
700
716
|
...(decoration === undefined ? {} : { decoration }),
|
|
701
717
|
...(announcement === undefined ? {} : { announcement }),
|
|
702
718
|
affinity: this.ledger.affinityView(Date.now()),
|
|
703
|
-
|
|
719
|
+
// The one place the two visibility answers are combined: the pet's own
|
|
720
|
+
// hide/show intent AND the plugin master switch. Producing the effective
|
|
721
|
+
// value here - rather than storing it - keeps the switch reversible and
|
|
722
|
+
// keeps pet.json describing only what the user chose (#1762).
|
|
723
|
+
display: { ...this.ledger.snapshot.display, visible: this.isEnabled() && this.ledger.snapshot.display.visible },
|
|
704
724
|
pet: {
|
|
705
725
|
id: entry.id,
|
|
706
726
|
displayName: entry.displayName,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@linxin666/dsh-pet",
|
|
3
3
|
"description": "Multi-pet companion plugin for the dsh web GUI: a registry-driven floating pet that reacts to model activity, with per-pet naming, petting/feeding interactions and an affinity score",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.5",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
7
7
|
},
|
|
@@ -49,7 +49,7 @@ vi.mock('@deepseek-ai/dsh-client-store', () => ({
|
|
|
49
49
|
},
|
|
50
50
|
}))
|
|
51
51
|
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
52
|
-
import { apply } from './index.ts'
|
|
52
|
+
import { apply, BINDER_RETRY_MS } from './index.ts'
|
|
53
53
|
|
|
54
54
|
beforeAll(() => {
|
|
55
55
|
document.documentElement.lang = 'zh'
|
|
@@ -65,6 +65,8 @@ interface FakeClientLifecycle {
|
|
|
65
65
|
setEnabled(enabled: boolean): void
|
|
66
66
|
/** Namespaces the family settings binder was asked for (empty without one). */
|
|
67
67
|
boundNamespaces(): string[]
|
|
68
|
+
/** Publish the family settings binder, as the aggregate's async mount does. */
|
|
69
|
+
publishFamilyBinder(enabled: boolean): void
|
|
68
70
|
}
|
|
69
71
|
|
|
70
72
|
const activeLifecycles: FakeClientLifecycle[] = []
|
|
@@ -79,6 +81,12 @@ interface FakeContextOptions {
|
|
|
79
81
|
familyBinder?: boolean
|
|
80
82
|
/** Initial value of the settings section the bound form answers with. */
|
|
81
83
|
enabled?: boolean
|
|
84
|
+
/**
|
|
85
|
+
* What the shared per-entry form answers before any family binder exists.
|
|
86
|
+
* The aggregate renames the pet row to 'web-ui-pet', so the family alias
|
|
87
|
+
* 'pet' is never a served key there and the fallback reports unavailable.
|
|
88
|
+
*/
|
|
89
|
+
fallbackStatus?: 'ready' | 'unavailable'
|
|
82
90
|
}
|
|
83
91
|
|
|
84
92
|
function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
|
|
@@ -87,6 +95,39 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
|
|
|
87
95
|
const sessionListeners = new Set<() => void>()
|
|
88
96
|
const boundNamespaces: string[] = []
|
|
89
97
|
let settingsValue: { enabled?: boolean } | undefined = options.enabled === undefined ? undefined : { enabled: options.enabled }
|
|
98
|
+
// The family binder is published later in the aggregate race; the shared form
|
|
99
|
+
// answers 'unavailable' until then, exactly as the wrongly-keyed fallback does.
|
|
100
|
+
let binderPublished = options.familyBinder === true
|
|
101
|
+
const fallbackStatus = options.fallbackStatus ?? 'ready'
|
|
102
|
+
// The shared per-entry form a standalone install answers with: the plugin's
|
|
103
|
+
// own row id IS served, so it carries the same values as the bound scope. A
|
|
104
|
+
// test that sets fallbackStatus to 'unavailable' models the aggregate, where
|
|
105
|
+
// the family alias is never a served key and the form can only report that.
|
|
106
|
+
const fallbackScope = {
|
|
107
|
+
getSnapshot: () => (fallbackStatus === 'ready'
|
|
108
|
+
? {
|
|
109
|
+
status: 'ready',
|
|
110
|
+
writable: true,
|
|
111
|
+
value: settingsValue,
|
|
112
|
+
base: undefined,
|
|
113
|
+
user: {},
|
|
114
|
+
revision: 1,
|
|
115
|
+
mode: 'host',
|
|
116
|
+
}
|
|
117
|
+
: {
|
|
118
|
+
status: 'unavailable',
|
|
119
|
+
writable: false,
|
|
120
|
+
value: undefined,
|
|
121
|
+
base: undefined,
|
|
122
|
+
user: {},
|
|
123
|
+
revision: undefined,
|
|
124
|
+
mode: 'host',
|
|
125
|
+
}),
|
|
126
|
+
subscribe: (listener: () => void) => {
|
|
127
|
+
settingsListeners.add(listener)
|
|
128
|
+
return () => { settingsListeners.delete(listener) }
|
|
129
|
+
},
|
|
130
|
+
}
|
|
90
131
|
const scope = {
|
|
91
132
|
getSnapshot: () => ({
|
|
92
133
|
status: 'ready',
|
|
@@ -119,8 +160,15 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
|
|
|
119
160
|
locale: { register: () => () => {} },
|
|
120
161
|
// The family binder is optional (dsh-web-settings may be absent); both
|
|
121
162
|
// answers are the shared per-entry form of this plugin's own profile entry.
|
|
122
|
-
get: (name: string) => name === 'webUiSettings' &&
|
|
123
|
-
configForms: {
|
|
163
|
+
get: (name: string) => name === 'webUiSettings' && binderPublished ? familyBinder : undefined,
|
|
164
|
+
configForms: {
|
|
165
|
+
get: () => fallbackScope,
|
|
166
|
+
// The aggregate's mirror names the renamed row; the family alias never
|
|
167
|
+
// appears there, so the fallback lookup cannot resolve it.
|
|
168
|
+
describe: () => ({
|
|
169
|
+
getSnapshot: () => ({ view: { namespaces: [{ ns: 'web-ui-pet' }] } }),
|
|
170
|
+
}),
|
|
171
|
+
},
|
|
124
172
|
slots: {
|
|
125
173
|
// Cordis runs the factory when the slot mounts and its returned
|
|
126
174
|
// disposer when the fiber disposes; mirror that so slot content
|
|
@@ -158,6 +206,10 @@ function fakeContext(options: FakeContextOptions = {}): FakeClientLifecycle {
|
|
|
158
206
|
sessionsListenerCount: () => sessionListeners.size,
|
|
159
207
|
setEnabled: (enabled: boolean) => { settingsValue = { enabled } },
|
|
160
208
|
boundNamespaces: () => boundNamespaces,
|
|
209
|
+
publishFamilyBinder: (enabled: boolean) => {
|
|
210
|
+
binderPublished = true
|
|
211
|
+
settingsValue = { enabled }
|
|
212
|
+
},
|
|
161
213
|
}
|
|
162
214
|
activeLifecycles.push(lifecycle)
|
|
163
215
|
return lifecycle
|
|
@@ -256,6 +308,32 @@ describe('pet client apply', () => {
|
|
|
256
308
|
expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(1)
|
|
257
309
|
})
|
|
258
310
|
|
|
311
|
+
it('binds the family binder published AFTER apply, instead of keeping the dead fallback', () => {
|
|
312
|
+
// Given a page where the aggregate mounts its inlined children behind an
|
|
313
|
+
// async fetch: at apply() time the family settings binder does not exist
|
|
314
|
+
// yet, and the shared mirror cannot resolve the 'pet' alias (the aggregate
|
|
315
|
+
// serves the renamed 'web-ui-pet' row), so a single early probe falls back
|
|
316
|
+
// to a permanently unavailable form.
|
|
317
|
+
vi.useFakeTimers()
|
|
318
|
+
const lifecycle = fakeContext({ fallbackStatus: 'unavailable' })
|
|
319
|
+
|
|
320
|
+
// When the pet client plugin applies inside that window
|
|
321
|
+
apply(lifecycle.ctx)
|
|
322
|
+
|
|
323
|
+
// Then no binder was bound yet and the pet surface is not yet up
|
|
324
|
+
expect(lifecycle.boundNamespaces()).toEqual([])
|
|
325
|
+
expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(0)
|
|
326
|
+
|
|
327
|
+
// And when the aggregate finally publishes the binder, the settings form
|
|
328
|
+
// rebinds to the real namespace and the pet surface comes up.
|
|
329
|
+
lifecycle.publishFamilyBinder(true)
|
|
330
|
+
vi.advanceTimersByTime(BINDER_RETRY_MS)
|
|
331
|
+
|
|
332
|
+
expect(lifecycle.boundNamespaces()).toEqual(['pet'])
|
|
333
|
+
expect(document.body.querySelectorAll('[data-dsh-pet-root]')).toHaveLength(1)
|
|
334
|
+
vi.useRealTimers()
|
|
335
|
+
})
|
|
336
|
+
|
|
259
337
|
it('user gets the pet settings form through the family binder when the group plugin is mounted', () => {
|
|
260
338
|
// Given a client context that provides the dsh-web-settings family binder
|
|
261
339
|
// and answers 'disabled' through the form that binder returns
|
package/src/client/index.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import type { Context as ClientContext } from '@deepseek-ai/cordis'
|
|
17
17
|
import type { ISessions } from '@deepseek-ai/dsh-api-session-controller/client'
|
|
18
18
|
import type { SessionId } from '@deepseek-ai/dsh-api-remotes/client'
|
|
19
|
-
import type { ConfigForm,
|
|
19
|
+
import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
|
|
20
20
|
// Type-only: pulls the locale plugin's Context merge (ctx.locale).
|
|
21
21
|
import type {} from '@deepseek-ai/dsh-client-locale/client'
|
|
22
22
|
// Type-only: pulls the shared configuration forms Context merge (ctx.configForms).
|
|
@@ -126,38 +126,202 @@ declare module '@deepseek-ai/cordis' {
|
|
|
126
126
|
}
|
|
127
127
|
|
|
128
128
|
/**
|
|
129
|
-
* The
|
|
130
|
-
* family
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
* The two are not interchangeable by name. A plugin's settings ARE its own
|
|
134
|
-
* config on 0.1.7, so the form belongs to the profile entry that carries the
|
|
135
|
-
* plugin — and only the family binder knows which entry that is, because the
|
|
136
|
-
* family bundle renames child rows ('pet' becomes 'web-ui-pet' there) while a
|
|
137
|
-
* standalone install keeps the package's own id.
|
|
138
|
-
* @param ctx - client root context.
|
|
139
|
-
* @returns the form for the pet's settings page.
|
|
129
|
+
* The profile entry ids a pet install is served under, most specific first. The
|
|
130
|
+
* family bundle renames child rows, so a standalone install and an aggregate
|
|
131
|
+
* one answer to different ids for the same 'pet' namespace.
|
|
140
132
|
*/
|
|
141
133
|
const AGGREGATE_ENTRY_ID = 'web-ui-pet'
|
|
142
134
|
const PET_ENTRY_IDS: readonly string[] = [AGGREGATE_ENTRY_ID, 'ui-pet', PET_SETTINGS_NS]
|
|
143
135
|
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
if (!served || served.length === 0) return PET_SETTINGS_NS
|
|
152
|
-
return PET_ENTRY_IDS.find(id => served.includes(id)) ?? PET_SETTINGS_NS
|
|
136
|
+
/** How long the deferred form keeps retrying before it settles on the fallback. */
|
|
137
|
+
export const BINDER_RETRY_MS = 250
|
|
138
|
+
const BINDER_ATTEMPTS = 24
|
|
139
|
+
|
|
140
|
+
/** The snapshot an unresolved (or resolvable-but-unbound) form publishes. */
|
|
141
|
+
function pendingSnapshot<T>(status: 'loading' | 'unavailable'): ConfigFormSnapshot<T> {
|
|
142
|
+
return { status, value: undefined, base: undefined, user: undefined, revision: undefined, writable: false, mode: 'host' }
|
|
153
143
|
}
|
|
154
144
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
145
|
+
/**
|
|
146
|
+
* A ConfigForm that late-binds to the family settings binder.
|
|
147
|
+
*
|
|
148
|
+
* The binder service (dsh-web-settings) is not guaranteed to be published by the
|
|
149
|
+
* time this plugin's apply() runs: the aggregate bundle mounts its inlined
|
|
150
|
+
* children — including the binder — inside an async mount that awaits the
|
|
151
|
+
* active-rows fetch, while standalone loader entries like this one apply
|
|
152
|
+
* synchronously in that window. A single early probe then permanently falls
|
|
153
|
+
* back to `configForms.get('pet')`, which is never a served row id under the
|
|
154
|
+
* aggregate (the row is `web-ui-pet`), so the settings card renders "not
|
|
155
|
+
* exposed" forever even though the Host serves the namespace.
|
|
156
|
+
*
|
|
157
|
+
* This form resolves through the binder as soon as the service appears and
|
|
158
|
+
* delegates the whole ConfigForm surface to it, re-publishing to its own
|
|
159
|
+
* subscribers on every swap. Until a form is resolved it publishes a loading
|
|
160
|
+
* (then unavailable) snapshot so the card shows a transient state, never a
|
|
161
|
+
* false "not exposed". If the binder never appears it retries for a bounded
|
|
162
|
+
* window, then permanently binds the non-bridge fallback by SERVED entry id.
|
|
163
|
+
*/
|
|
164
|
+
class DeferredSettingsForm implements ConfigForm<PetSettings> {
|
|
165
|
+
private ctx: ClientContext
|
|
166
|
+
private current: ConfigForm<PetSettings> | undefined
|
|
167
|
+
private readonly listeners = new Set<() => void>()
|
|
168
|
+
private unsubscribeCurrent: (() => void) | undefined
|
|
169
|
+
private retryTimer: number | undefined
|
|
170
|
+
private attempts = 0
|
|
171
|
+
private disposed = false
|
|
172
|
+
private readonly fallback: ConfigForm<PetSettings>
|
|
173
|
+
private fallbackUnsubscribe: (() => void) | undefined
|
|
174
|
+
|
|
175
|
+
constructor(ctx: ClientContext) {
|
|
176
|
+
this.ctx = ctx
|
|
177
|
+
this.fallback = ctx.configForms.get<PetSettings>(this.resolveFallbackEntryId())
|
|
178
|
+
// No binder yet: the aggregate publishes it after an async mount, so keep
|
|
179
|
+
// probing. A shared form that can answer for itself is adopted at once.
|
|
180
|
+
if (!this.resolve() && !this.fallbackSettled()) this.scheduleRetry()
|
|
181
|
+
else if (this.current === undefined) this.adoptFallback()
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* True while the shared mirror reports the pet namespace unavailable — the
|
|
186
|
+
* only state in which waiting can still help. A fallback that is ready (or
|
|
187
|
+
* merely loading, which the mirror fills in on its own) is adopted at once.
|
|
188
|
+
*/
|
|
189
|
+
private fallbackSettled(): boolean {
|
|
190
|
+
try {
|
|
191
|
+
return this.fallback.getSnapshot().status !== 'unavailable'
|
|
192
|
+
} catch {
|
|
193
|
+
return false
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* Bind the fallback to a SERVED row id when the mirror can name one; a mirror
|
|
199
|
+
* that cannot is left to report its own unavailable state.
|
|
200
|
+
*/
|
|
201
|
+
private resolveFallbackEntryId(): string {
|
|
202
|
+
try {
|
|
203
|
+
const served = this.ctx.configForms.describe().getSnapshot().view?.namespaces.map(view => view.ns)
|
|
204
|
+
if (served && served.length > 0) {
|
|
205
|
+
const hit = PET_ENTRY_IDS.find(id => served.includes(id))
|
|
206
|
+
if (hit !== undefined) return hit
|
|
207
|
+
}
|
|
208
|
+
} catch {
|
|
209
|
+
// fall through to the family namespace; the form reports unavailable.
|
|
210
|
+
}
|
|
211
|
+
return PET_SETTINGS_NS
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* Adopt the family binder the moment it is published.
|
|
216
|
+
* @returns true when a binder was bound, false when none is available yet.
|
|
217
|
+
*/
|
|
218
|
+
private resolve(): boolean {
|
|
219
|
+
if (this.disposed) return false
|
|
220
|
+
let binder: { bind?: unknown } | undefined
|
|
221
|
+
try {
|
|
222
|
+
binder = this.ctx.get('webUiSettings') as { bind?: unknown } | undefined
|
|
223
|
+
} catch {
|
|
224
|
+
binder = undefined
|
|
225
|
+
}
|
|
226
|
+
if (binder === undefined || typeof binder.bind !== 'function') return false
|
|
227
|
+
let bound: ConfigForm<PetSettings>
|
|
228
|
+
try {
|
|
229
|
+
bound = (binder as { bind: <T>(spec: { namespace: string }) => ConfigForm<T> })
|
|
230
|
+
.bind<PetSettings>({ namespace: PET_SETTINGS_NS })
|
|
231
|
+
} catch {
|
|
232
|
+
return false
|
|
233
|
+
}
|
|
234
|
+
this.current = bound
|
|
235
|
+
// Mirror the bound form's changes to our own subscribers; a later re-resolve
|
|
236
|
+
// swaps this subscription to the new form.
|
|
237
|
+
this.unsubscribeCurrent?.()
|
|
238
|
+
this.unsubscribeCurrent = bound.subscribe(() => this.publish())
|
|
239
|
+
this.publish()
|
|
240
|
+
return true
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Adopt the shared per-entry form. It is used immediately unless it reports
|
|
245
|
+
* the namespace unavailable, in which case the binder may still be on its way
|
|
246
|
+
* and the retry window takes over (see scheduleRetry).
|
|
247
|
+
*/
|
|
248
|
+
private adoptFallback(): void {
|
|
249
|
+
this.current = this.fallback
|
|
250
|
+
this.fallbackUnsubscribe ??= this.fallback.subscribe(() => this.publish())
|
|
251
|
+
this.unsubscribeCurrent = this.fallbackUnsubscribe
|
|
252
|
+
this.publish()
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/** Retry the binder lookup a few times across the aggregate's async mount. */
|
|
256
|
+
private scheduleRetry(): void {
|
|
257
|
+
if (this.disposed) return
|
|
258
|
+
if (this.attempts >= BINDER_ATTEMPTS) {
|
|
259
|
+
this.adoptFallback()
|
|
260
|
+
return
|
|
261
|
+
}
|
|
262
|
+
this.attempts += 1
|
|
263
|
+
this.retryTimer = window.setTimeout(() => {
|
|
264
|
+
this.retryTimer = undefined
|
|
265
|
+
if (this.disposed) return
|
|
266
|
+
if (this.resolve()) return
|
|
267
|
+
// The binder still absent: keep waiting only while the shared form cannot
|
|
268
|
+
// answer for itself, otherwise a standalone install stalls for the window.
|
|
269
|
+
if (this.fallbackSettled()) {
|
|
270
|
+
this.attempts = BINDER_ATTEMPTS
|
|
271
|
+
this.adoptFallback()
|
|
272
|
+
return
|
|
273
|
+
}
|
|
274
|
+
this.scheduleRetry()
|
|
275
|
+
}, BINDER_RETRY_MS)
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
private publish(): void {
|
|
279
|
+
for (const listener of this.listeners) listener()
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
/** The resolved form, or a placeholder snapshot when still pending. */
|
|
283
|
+
private snapshot(): ConfigFormSnapshot<PetSettings> {
|
|
284
|
+
return this.current?.getSnapshot() ?? pendingSnapshot<PetSettings>(this.attempts >= BINDER_ATTEMPTS ? 'unavailable' : 'loading')
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
getSnapshot(): ConfigFormSnapshot<PetSettings> {
|
|
288
|
+
return this.snapshot()
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
subscribe(listener: () => void): () => void {
|
|
292
|
+
this.listeners.add(listener)
|
|
293
|
+
return () => { this.listeners.delete(listener) }
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
mutate(ops: Parameters<ConfigForm<PetSettings>['mutate']>[0], expectedRevision?: number): Promise<boolean> {
|
|
297
|
+
return this.current?.mutate(ops, expectedRevision) ?? Promise.resolve(false)
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
set(field: string, value: unknown): Promise<boolean> {
|
|
301
|
+
return this.current?.set(field, value) ?? Promise.resolve(false)
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
unset(field: string): Promise<boolean> {
|
|
305
|
+
return this.current?.unset(field) ?? Promise.resolve(false)
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/** Release the retry timer and mirror subscription; not part of ConfigForm. */
|
|
309
|
+
dispose(): void {
|
|
310
|
+
if (this.disposed) return
|
|
311
|
+
this.disposed = true
|
|
312
|
+
if (this.retryTimer !== undefined) {
|
|
313
|
+
window.clearTimeout(this.retryTimer)
|
|
314
|
+
this.retryTimer = undefined
|
|
315
|
+
}
|
|
316
|
+
this.unsubscribeCurrent?.()
|
|
317
|
+
this.unsubscribeCurrent = undefined
|
|
318
|
+
this.current = undefined
|
|
319
|
+
this.listeners.clear()
|
|
320
|
+
// The shared per-entry form carries no disposer of its own (ConfigForm is a
|
|
321
|
+
// pure read/write surface); only this form's own subscriptions are released.
|
|
322
|
+
this.fallbackUnsubscribe?.()
|
|
323
|
+
this.fallbackUnsubscribe = undefined
|
|
159
324
|
}
|
|
160
|
-
return ctx.configForms.get<PetSettings>(servedEntryId(ctx.configForms))
|
|
161
325
|
}
|
|
162
326
|
|
|
163
327
|
/**
|
|
@@ -199,7 +363,7 @@ export function apply(ctx: ClientContext): void {
|
|
|
199
363
|
defaultPetRendererRegistry.register(live2dRenderer)
|
|
200
364
|
defaultPetRendererRegistry.register(frames2dRenderer)
|
|
201
365
|
|
|
202
|
-
const settingsForm =
|
|
366
|
+
const settingsForm = new DeferredSettingsForm(ctx)
|
|
203
367
|
const enabled = (): boolean => {
|
|
204
368
|
const snapshot = settingsForm.getSnapshot()
|
|
205
369
|
return snapshot.status === 'ready'
|
|
@@ -500,6 +664,9 @@ export function apply(ctx: ClientContext): void {
|
|
|
500
664
|
ctx.effect(
|
|
501
665
|
() => () => {
|
|
502
666
|
unsubscribeSettings()
|
|
667
|
+
// Release the deferred form's retry timer and its mirror subscription so a
|
|
668
|
+
// disposed fiber can never bind or publish after teardown.
|
|
669
|
+
settingsForm.dispose()
|
|
503
670
|
killUi()
|
|
504
671
|
},
|
|
505
672
|
'pet: client lifecycle',
|
package/src/index.test.ts
CHANGED
|
@@ -117,3 +117,42 @@ describe('petSettingsSection', () => {
|
|
|
117
117
|
expect(section.petId).toBe('doro')
|
|
118
118
|
})
|
|
119
119
|
})
|
|
120
|
+
|
|
121
|
+
describe('petSettingsSection display persistence', () => {
|
|
122
|
+
/** The layout a user dragged the pet to, as its own pet.json holds it. */
|
|
123
|
+
const dragged = { visible: true, size: 160, right: 1428, bottom: 167, bubbleScale: 1 }
|
|
124
|
+
|
|
125
|
+
it('user keeps the dragged position when the profile never committed one', () => {
|
|
126
|
+
// Given a pet.json holding the layout the pet was dragged to
|
|
127
|
+
// And a row config that never set the display fields, so they read back as
|
|
128
|
+
// the schema defaults (the bottom-right corner)
|
|
129
|
+
// When the plugin starts and resolves its active settings
|
|
130
|
+
const section = petSettingsSection(Config({}), 'ouo-neko', dragged)
|
|
131
|
+
// Then the dragged layout stands instead of snapping back to those defaults
|
|
132
|
+
expect(section).toMatchObject({ right: 1428, bottom: 167 })
|
|
133
|
+
})
|
|
134
|
+
|
|
135
|
+
it('user commits a display field and the profile value outranks the persisted one', () => {
|
|
136
|
+
// Given a dragged layout and a profile layer that committed a right inset
|
|
137
|
+
const section = petSettingsSection(Config({}), 'ouo-neko', dragged, { right: 48 })
|
|
138
|
+
// Then the explicit choice wins and the untouched field keeps the dragged one
|
|
139
|
+
expect(section).toMatchObject({ right: 48, bottom: 167 })
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
it('user commits the schema default and the choice is not mistaken for unset', () => {
|
|
143
|
+
// Given a dragged layout and a profile layer that committed the default inset
|
|
144
|
+
const section = petSettingsSection(Config({}), 'ouo-neko', dragged, { right: 24 })
|
|
145
|
+
// Then the explicit (default-valued) choice stands over the persisted one
|
|
146
|
+
expect(section.right).toBe(24)
|
|
147
|
+
})
|
|
148
|
+
|
|
149
|
+
it('user commits a layout at runtime and the result outranks the persisted one', () => {
|
|
150
|
+
// Given a live reference the Host committed into the running config
|
|
151
|
+
const resolved = Config({})
|
|
152
|
+
commitLive(resolved.right, 500)
|
|
153
|
+
// When the plugin resolves the section against an older persisted layout
|
|
154
|
+
const section = petSettingsSection(resolved, 'ouo-neko', dragged)
|
|
155
|
+
// Then the live commit wins and the persisted value fills the other fields
|
|
156
|
+
expect(section).toMatchObject({ right: 500, bottom: 167 })
|
|
157
|
+
})
|
|
158
|
+
})
|