@linxin666/dsh-pet 0.4.9 → 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,18 +1,18 @@
1
- // Generated by scripts/sync-shared.mjs from shared/client/settings/settings-form.ts. Do not edit this copy; edit the shared source and run "node scripts/sync-shared.mjs".
2
1
  /**
3
- * Staged form model behind the plugin settings card. A card stages what the
4
- * user types and writes it only when they save — the settings write is a
5
- * durable, revision-fenced document mutation, so staging keeps what is on
6
- * screen exactly what a save would store. Family-shared slice inlined into
7
- * each plugin's client bundle; mirrors the official ui-plugin-config
8
- * card-store pattern.
2
+ * Form model behind the plugin settings card. Every control applies itself:
3
+ * a pick (a segment, a select option, a reset) writes the moment it is made,
4
+ * and typed text writes once typing pauses or the reader leaves the field.
5
+ * Between the edit and the write the edit is held here as a draft, so what is
6
+ * on screen is exactly what the write will store; a write the Host refuses
7
+ * puts a pick back to the stored value and keeps typed text for correcting.
8
+ * Family-shared slice inlined into each plugin's client bundle.
9
9
  */
10
10
 
11
11
  import type { ConfigForm, ConfigFormSnapshot } from '@deepseek-ai/dsh-client-ui-settings/client'
12
12
  import type { SnapshotStore } from '@deepseek-ai/dsh-client-store'
13
13
  import { createSnapshotStore } from '@deepseek-ai/dsh-client-store'
14
14
 
15
- /** The write one field's staged text performs when the card is saved. */
15
+ /** The write one field's draft text performs when it is applied. */
16
16
  export type FieldWrite =
17
17
  | { kind: 'set'; value: unknown }
18
18
  | { kind: 'clear' }
@@ -21,6 +21,12 @@ export type FieldWrite =
21
21
  export interface FieldSpec {
22
22
  /** Field name inside the namespace section. */
23
23
  field: string
24
+ /**
25
+ * How the reader enters a value, which decides when it is written: a `pick`
26
+ * is a whole value at once and applies immediately; `type` is text arriving
27
+ * a keystroke at a time and applies once typing pauses or the field is left.
28
+ */
29
+ entry: 'pick' | 'type'
24
30
  /**
25
31
  * Whether the Host treats this field as a secret and redacts its value from
26
32
  * the read-back (role('secret') in the section schema). Redacted secrets are
@@ -34,8 +40,9 @@ export interface FieldSpec {
34
40
  /** Render a stored value as draft text; the empty string when the section carries none. */
35
41
  format: (value: unknown) => string
36
42
  /**
37
- * The write this draft text stages, or undefined when the text is not a
38
- * value this field accepts — which blocks the save rather than discarding it.
43
+ * The write this draft text performs, or undefined when the text is not a
44
+ * value this field accepts — which holds the draft unwritten rather than
45
+ * discarding it.
39
46
  */
40
47
  parse: (text: string) => FieldWrite | undefined
41
48
  }
@@ -44,9 +51,9 @@ export interface FieldSpec {
44
51
  export interface FieldState {
45
52
  /** Draft text the control renders. */
46
53
  text: string
47
- /** Whether saving would leave a user-layer entry for this field. */
54
+ /** Whether the field leaves (or will leave) a user-layer entry. */
48
55
  overridden: boolean
49
- /** Whether the draft is not a value this field accepts, which blocks saving. */
56
+ /** Whether the draft is not a value this field accepts, which holds it unwritten. */
50
57
  invalid: boolean
51
58
  }
52
59
 
@@ -64,13 +71,13 @@ export interface CardShell {
64
71
  exposed: boolean
65
72
  /** Whether the Host document accepts writes. */
66
73
  writable: boolean
67
- /** Whether the form holds edits that a save would write. */
74
+ /** Whether the form holds drafts not yet written (typed text waiting for its pause). */
68
75
  dirty: boolean
69
- /** Whether any staged draft is invalid, which blocks the save. */
76
+ /** Whether any draft is invalid, which holds it unwritten. */
70
77
  invalid: boolean
71
- /** Whether a save is crossing the wire. */
78
+ /** Whether a write is crossing the wire. */
72
79
  saving: boolean
73
- /** Whether the last save did not land as staged; cleared by the next edit or save. */
80
+ /** Whether the last write did not land; cleared by the next edit or write. */
74
81
  failed: boolean
75
82
  /**
76
83
  * The rejection code/message the Host returned for the last failed save,
@@ -82,16 +89,19 @@ export interface CardShell {
82
89
 
83
90
  /** The write actions the card's slot entry injects. */
84
91
  export interface CardActions {
85
- /** Stage draft text for one field. */
92
+ /** Take draft text for one field; a pick writes at once, typed text after a pause. */
86
93
  edit: (field: string, text: string) => void
87
- /** Stage a clear, so saving lets the field re-inherit the composition layer. */
94
+ /** Clear one field at once, so it re-inherits the composition layer. */
88
95
  resetField: (field: string) => void
89
- /** Write every staged edit, then re-seed from what the Host accepted. */
96
+ /** Write every pending draft now (a text field's Enter or blur), then re-seed from what the Host accepted. */
90
97
  save: () => void
91
- /** Drop every staged edit. */
98
+ /** Drop every pending draft, putting each control back to the stored value (a text field's Escape). */
92
99
  discard: () => void
93
100
  }
94
101
 
102
+ /** How long typed text rests before it is written. */
103
+ export const TYPE_PAUSE_MS = 600
104
+
95
105
  /** One field's staged edit. */
96
106
  interface StagedEdit {
97
107
  /** Draft text the control renders. */
@@ -132,11 +142,12 @@ export interface NumberConstraints {
132
142
  min?: number
133
143
  }
134
144
 
135
- /** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints blocks the save. */
145
+ /** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
136
146
  export function numberField(field: string, constraints: NumberConstraints = {}): FieldSpec {
137
147
  const { integer = false, min } = constraints
138
148
  return {
139
149
  field,
150
+ entry: 'type',
140
151
  format: value => typeof value === 'number' ? String(value) : '',
141
152
  parse: (text) => {
142
153
  const trimmed = text.trim()
@@ -150,10 +161,14 @@ export function numberField(field: string, constraints: NumberConstraints = {}):
150
161
  }
151
162
  }
152
163
 
153
- /** A free-text field. An empty draft clears the field. */
154
- export function textField(field: string): FieldSpec {
164
+ /**
165
+ * A free-text field. An empty draft clears the field. `entry` is `pick` when
166
+ * the text arrives whole from a picker (a preset or a reasoning level).
167
+ */
168
+ export function textField(field: string, entry: FieldSpec['entry'] = 'type'): FieldSpec {
155
169
  return {
156
170
  field,
171
+ entry,
157
172
  format: value => typeof value === 'string' ? value : '',
158
173
  parse: (text) => {
159
174
  const trimmed = text.trim()
@@ -176,6 +191,7 @@ export function secretField(field: string): FieldSpec {
176
191
  export function booleanField(field: string): FieldSpec {
177
192
  return {
178
193
  field,
194
+ entry: 'pick',
179
195
  format: value => typeof value === 'boolean' ? String(value) : '',
180
196
  parse: (text) => {
181
197
  const trimmed = text.trim()
@@ -191,6 +207,7 @@ export function booleanField(field: string): FieldSpec {
191
207
  export function choiceField(field: string, choices: readonly string[]): FieldSpec {
192
208
  return {
193
209
  field,
210
+ entry: 'pick',
194
211
  format: value => typeof value === 'string' && choices.includes(value) ? value : '',
195
212
  parse: (text) => {
196
213
  if (text === '') return { kind: 'clear' }
@@ -200,12 +217,14 @@ export function choiceField(field: string, choices: readonly string[]): FieldSpe
200
217
  }
201
218
 
202
219
  /**
203
- * Stages one card's edits over one settings namespace and writes them on save.
220
+ * Applies one card's edits to one settings namespace as the reader makes them.
204
221
  *
205
222
  * The Host is the only authority on whether a value was accepted — its
206
223
  * validators own the constraints no schema can express — so the outcome is
207
- * read back from the section rather than predicted here. A save that did not
208
- * land keeps its drafts, so the user can correct them instead of retyping.
224
+ * read back from the section rather than predicted here. A write that did not
225
+ * land puts each pick back to the stored value, the way a switch that could not
226
+ * flip springs back, and keeps typed text so the reader can correct it instead
227
+ * of retyping.
209
228
  */
210
229
  export class CardForm<T> {
211
230
  private readonly specs: Map<string, FieldSpec>
@@ -214,7 +233,11 @@ export class CardForm<T> {
214
233
  /** The form subscription installed in the constructor; released by dispose(). */
215
234
  private readonly disposeForm: () => void
216
235
  private disposed = false
236
+ /** The pending write of typed text, waiting for typing to pause. */
237
+ private typePause: ReturnType<typeof setTimeout> | undefined
217
238
  private saving = false
239
+ /** A save asked for while one was in flight; it runs once the first settles (#1754). */
240
+ private saveQueued = false
218
241
  private failed = false
219
242
  private failedReason: string | undefined
220
243
 
@@ -234,6 +257,7 @@ export class CardForm<T> {
234
257
  dispose(): void {
235
258
  if (this.disposed) return
236
259
  this.disposed = true
260
+ clearTimeout(this.typePause)
237
261
  this.disposeForm()
238
262
  this.listeners.clear()
239
263
  }
@@ -245,7 +269,7 @@ export class CardForm<T> {
245
269
  return store
246
270
  }
247
271
 
248
- /** Read the card-level state: what the Host serves, and what a save would do. */
272
+ /** Read the card-level state: what the Host serves, and what is still waiting to be written. */
249
273
  shell(): CardShell {
250
274
  const snapshot = this.scope.getSnapshot()
251
275
  const plan = this.plan()
@@ -283,8 +307,9 @@ export class CardForm<T> {
283
307
  resetField: (field) => {
284
308
  this.stage(field, { text: this.specOf(field).format(this.baseValue(field)), clear: true })
285
309
  },
286
- save: () => { void this.save() },
310
+ save: () => { this.applyNow() },
287
311
  discard: () => {
312
+ clearTimeout(this.typePause)
288
313
  if (this.staged.size === 0 && !this.failed) return
289
314
  this.staged.clear()
290
315
  this.failed = false
@@ -295,30 +320,53 @@ export class CardForm<T> {
295
320
  }
296
321
 
297
322
  /**
298
- * Write every staged edit in one atomic form mutation, then re-seed from
299
- * what the Host accepted.
323
+ * Run one write, and re-run it once if another was asked for while this one
324
+ * was still in flight.
325
+ *
326
+ * A write is a Host round trip that also drives the profile reconcile, and
327
+ * the Host runs it inside one exclusive transaction. Answering an edit that
328
+ * arrives mid-flight by returning immediately dropped it with no explanation
329
+ * (#1754). Serializing instead means an edit made while another write is
330
+ * still settling is written against the settled state.
331
+ * @returns settlement after the mutation and the read-back.
332
+ */
333
+ async requestSave(): Promise<void> {
334
+ if (this.saving) {
335
+ this.saveQueued = true
336
+ return
337
+ }
338
+ await this.save()
339
+ if (!this.saveQueued) return
340
+ this.saveQueued = false
341
+ await this.requestSave()
342
+ }
343
+
344
+ /**
345
+ * Write every valid draft in one atomic form mutation, then re-seed from
346
+ * what the Host accepted. A draft the field does not accept stays on screen,
347
+ * unwritten, without holding the others back.
300
348
  *
301
- * The whole batch rides one mutate, so cross-field validate hooks
302
- * (baseURL+model) judge it as a unit: the Host either applies every write
303
- * or refuses the batch. The form contract answers a refusal or a skipped
304
- * write with `false` (it recovers with a fresh Host view instead of
305
- * throwing), so the outcome is judged twice: the answer itself, and then the
306
- * settled snapshot read back one planned write at a time. One missed write
307
- * fails the whole save. A transport that rejects instead (the dsh-web bridge
308
- * controller on a dead connection) reports through the same failure path
309
- * with its rejection message. A save that did not land keeps its drafts, so
310
- * the user can correct them instead of retyping.
349
+ * The batch rides one mutate, so cross-field validate hooks (baseURL+model)
350
+ * judge it as a unit: the Host either applies every write or refuses the
351
+ * batch. The form contract answers a refusal or a skipped write with `false`
352
+ * (it recovers with a fresh Host view instead of throwing), so the outcome is
353
+ * judged twice: the answer itself, and then the settled snapshot read back
354
+ * one planned write at a time. One missed write fails the whole batch. A
355
+ * transport that rejects instead (the dsh-web bridge controller on a dead
356
+ * connection) reports through the same failure path with its rejection
357
+ * message. A batch that did not land puts its picks and clears back to the
358
+ * stored value and keeps its typed text, so the reader can correct it.
311
359
  * @returns settlement after the mutation and the read-back.
312
360
  */
313
361
  async save(): Promise<void> {
314
362
  const plan = this.plan()
315
363
  const valid = plan.filter((item): item is PlannedWrite & { judge: () => boolean } => item.judge !== undefined)
316
- if (plan.length === 0 || this.saving || valid.length !== plan.length) return
317
- // Snapshot the staged entries this save writes, so an edit staged while it
318
- // is in flight (which replaces the same key) survives: only delete the key
319
- // when the entry is still the one this save started from.
364
+ if (valid.length === 0 || this.saving) return
365
+ // Snapshot the staged entries this write carries, so an edit staged while
366
+ // it is in flight (which replaces the same key) survives: only settle the
367
+ // key when the entry is still the one this write started from.
320
368
  const pending = new Map<string, StagedEdit | undefined>()
321
- for (const item of plan) pending.set(item.field, this.staged.get(item.field))
369
+ for (const item of valid) pending.set(item.field, this.staged.get(item.field))
322
370
  this.saving = true
323
371
  this.failed = false
324
372
  this.failedReason = undefined
@@ -343,7 +391,8 @@ export class CardForm<T> {
343
391
  // whole save and keeps the drafts.
344
392
  const landed = accepted && failedReason === undefined && valid.every(item => item.judge())
345
393
  for (const [field, before] of pending) {
346
- if (landed && this.staged.get(field) === before) this.staged.delete(field)
394
+ if (this.staged.get(field) !== before) continue
395
+ if (landed || before === undefined || before.clear || this.specOf(field).entry === 'pick') this.staged.delete(field)
347
396
  }
348
397
  this.saving = false
349
398
  this.failed = !landed
@@ -355,9 +404,9 @@ export class CardForm<T> {
355
404
  }
356
405
 
357
406
  /**
358
- * Every staged edit a save would write. An entry whose draft is not a value
359
- * its field accepts carries no write: the form is still dirty, and the save
360
- * refuses rather than dropping the edit. A staged edit that matches the
407
+ * Every staged edit a write would carry. An entry whose draft is not a value
408
+ * its field accepts carries no write: the form is still dirty, and the draft
409
+ * stays on screen rather than being dropped. A staged edit that matches the
361
410
  * effective section is not a write at all.
362
411
  * @returns the planned writes, in the order the fields were staged.
363
412
  */
@@ -400,11 +449,29 @@ export class CardForm<T> {
400
449
  return !this.stored(field)
401
450
  }
402
451
 
452
+ /**
453
+ * Take one edit and schedule its write: a pick or a clear is written now,
454
+ * typed text once typing has rested for TYPE_PAUSE_MS.
455
+ */
403
456
  private stage(field: string, edit: StagedEdit): void {
404
457
  this.staged.set(field, edit)
405
458
  this.failed = false
406
459
  this.failedReason = undefined
407
460
  this.publish()
461
+ if (edit.clear || this.specOf(field).entry === 'pick') {
462
+ this.applyNow()
463
+ return
464
+ }
465
+ clearTimeout(this.typePause)
466
+ this.typePause = setTimeout(() => { this.applyNow() }, TYPE_PAUSE_MS)
467
+ }
468
+
469
+ /** Write every pending draft now, taking the place of a waiting pause. */
470
+ private applyNow(): void {
471
+ clearTimeout(this.typePause)
472
+ this.typePause = undefined
473
+ if (this.disposed) return
474
+ void this.requestSave()
408
475
  }
409
476
 
410
477
  private specOf(field: string): FieldSpec {
@@ -0,0 +1,79 @@
1
+ import { describe, expect, it } from 'vitest'
2
+ import { installPetSettingsRegistration } from './settings-registration.ts'
3
+
4
+ function makeCtx() {
5
+ let service: object | undefined
6
+ let changed: (() => void) | undefined
7
+ const registered: Array<{ options: Record<string, unknown> }> = []
8
+ const ctx = {
9
+ get: (name: string) => name === 'webUiExtensions' ? service : undefined,
10
+ on: (event: string, listener: () => void) => {
11
+ if (event === 'slots/changed') changed = listener
12
+ return () => { changed = undefined }
13
+ },
14
+ slots: {
15
+ register: (options: Record<string, unknown>) => {
16
+ const entry = { options }
17
+ registered.push(entry)
18
+ changed?.()
19
+ return () => {
20
+ const index = registered.indexOf(entry)
21
+ if (index >= 0) registered.splice(index, 1)
22
+ changed?.()
23
+ }
24
+ },
25
+ entries: (slot: string) => registered.filter(entry => entry.options.name === slot),
26
+ },
27
+ }
28
+ const pushPage = (page: Record<string, unknown>) => {
29
+ const entry = {
30
+ options: {
31
+ name: 'web-ui.extension',
32
+ key: page.key,
33
+ locale: page.locale,
34
+ inject: page.inject,
35
+ children: page.children,
36
+ },
37
+ }
38
+ registered.push(entry)
39
+ changed?.()
40
+ return () => {
41
+ const index = registered.indexOf(entry)
42
+ if (index >= 0) registered.splice(index, 1)
43
+ changed?.()
44
+ }
45
+ }
46
+ return {
47
+ ctx,
48
+ registered,
49
+ setService(value: object | undefined) {
50
+ service = value === undefined ? undefined : { ...value, registerPage: pushPage }
51
+ changed?.()
52
+ },
53
+ }
54
+ }
55
+
56
+ const controller = { inject: () => ({ hooks: {} }) } as never
57
+
58
+ describe('pet settings registration', () => {
59
+ it('moves one entry between the standalone section and Web Extensions', () => {
60
+ const { ctx, registered, setService } = makeCtx()
61
+ const dispose = installPetSettingsRegistration(ctx as never, controller)
62
+ expect(registered.map(entry => entry.options)).toEqual([
63
+ expect.objectContaining({ name: 'settings.section', id: 'pet', order: 130 }),
64
+ ])
65
+
66
+ setService({ sectionId: 'web-ui-plugins', label: () => 'Web Extensions', open: () => true })
67
+ expect(registered).toHaveLength(1)
68
+ expect(registered[0]?.options).toMatchObject({ name: 'web-ui.extension', key: 'pet' })
69
+ expect(registered[0]?.options).not.toHaveProperty('id')
70
+ expect(registered[0]?.options).not.toHaveProperty('order')
71
+ expect(registered[0]?.options).not.toHaveProperty('label')
72
+
73
+ setService(undefined)
74
+ expect(registered).toHaveLength(1)
75
+ expect(registered[0]?.options).toMatchObject({ name: 'settings.section', id: 'pet' })
76
+ dispose()
77
+ expect(registered).toHaveLength(0)
78
+ })
79
+ })
@@ -0,0 +1,34 @@
1
+ /**
2
+ * The pet settings page's contribution: the Web Extensions parent mounts it
3
+ * through its page service, while a standalone install keeps the original
4
+ * first-level settings section.
5
+ */
6
+
7
+ import type { Context as ClientContext } from '@deepseek-ai/cordis'
8
+ // Type-only: the renderer owns ctx.slots and the locale plugin owns ctx.locale.
9
+ import type {} from '@deepseek-ai/dsh-client-ui-renderer/client'
10
+ import type {} from '@deepseek-ai/dsh-client-locale/client'
11
+ import type {} from './web-extension-contract.ts'
12
+ import { PetSettingsSection, type PetSettingsCardController } from './PetSettingsCard.tsx'
13
+ import { NS } from './locales.ts'
14
+ import { installWebExtensionPage } from './web-extension-page.ts'
15
+
16
+ /**
17
+ * Register exactly one reachable pet entry and follow the parent across late
18
+ * loading or teardown. The controller belongs to apply(), not a registration,
19
+ * so moving seats never resets staged edits or subscriptions.
20
+ * @returns the page contribution's disposer.
21
+ */
22
+ export function installPetSettingsRegistration(
23
+ ctx: ClientContext,
24
+ controller: PetSettingsCardController,
25
+ ): () => void {
26
+ return installWebExtensionPage(ctx, {
27
+ key: 'pet',
28
+ order: 130,
29
+ locale: NS,
30
+ label: () => ctx.locale.bind(NS)('settings.title'),
31
+ inject: () => controller.inject(),
32
+ component: PetSettingsSection,
33
+ })
34
+ }
@@ -1,5 +1,187 @@
1
1
  .sectionList {
2
+ container-type: inline-size;
2
3
  list-style: none;
3
4
  margin: 0;
4
5
  padding: 0;
5
6
  }
7
+
8
+ .settingsLayout {
9
+ display: grid;
10
+ grid-template-columns: minmax(220px, 0.85fr) minmax(280px, 1.15fr);
11
+ gap: 16px;
12
+ align-items: start;
13
+ }
14
+
15
+ .settingsColumn {
16
+ display: flex;
17
+ flex-direction: column;
18
+ gap: 16px;
19
+ min-width: 0;
20
+ }
21
+
22
+ .selectionGroup,
23
+ .settingsGroup {
24
+ min-width: 0;
25
+ padding: 16px;
26
+ border: 1px solid color-mix(in srgb, currentColor 13%, transparent);
27
+ border-radius: 12px;
28
+ background: color-mix(in srgb, currentColor 3%, transparent);
29
+ }
30
+
31
+ .groupHeader {
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: space-between;
35
+ gap: 12px;
36
+ min-height: 24px;
37
+ margin-bottom: 14px;
38
+ }
39
+
40
+ .groupTitle {
41
+ margin: 0;
42
+ color: inherit;
43
+ font-size: 14px;
44
+ font-weight: 400;
45
+ line-height: 22px;
46
+ }
47
+
48
+ .textAction {
49
+ appearance: none;
50
+ padding: 2px 0;
51
+ border: 0;
52
+ background: transparent;
53
+ color: inherit;
54
+ font: inherit;
55
+ font-size: 12px;
56
+ cursor: pointer;
57
+ opacity: 0.7;
58
+ }
59
+
60
+ .textAction:hover:not(:disabled) {
61
+ opacity: 1;
62
+ }
63
+
64
+ .petGrid {
65
+ display: grid;
66
+ grid-template-columns: repeat(2, minmax(0, 1fr));
67
+ gap: 8px;
68
+ }
69
+
70
+ .petChoice {
71
+ appearance: none;
72
+ display: flex;
73
+ flex-direction: column;
74
+ align-items: center;
75
+ justify-content: center;
76
+ gap: 7px;
77
+ min-width: 0;
78
+ min-height: 112px;
79
+ padding: 9px 7px;
80
+ border: 1px solid color-mix(in srgb, currentColor 12%, transparent);
81
+ border-radius: 10px;
82
+ background: color-mix(in srgb, currentColor 3%, transparent);
83
+ color: inherit;
84
+ font: inherit;
85
+ cursor: pointer;
86
+ transition: border-color 120ms ease, background-color 120ms ease;
87
+ }
88
+
89
+ .petChoice:hover:not(:disabled) {
90
+ border-color: color-mix(in srgb, currentColor 30%, transparent);
91
+ background: color-mix(in srgb, currentColor 6%, transparent);
92
+ }
93
+
94
+ .petChoiceSelected {
95
+ border-color: color-mix(in srgb, currentColor 52%, transparent);
96
+ background: color-mix(in srgb, currentColor 8%, transparent);
97
+ }
98
+
99
+ .petChoice:focus-visible,
100
+ .textAction:focus-visible {
101
+ outline: 2px solid color-mix(in srgb, currentColor 55%, transparent);
102
+ outline-offset: 2px;
103
+ }
104
+
105
+ .petChoice:disabled,
106
+ .textAction:disabled {
107
+ cursor: default;
108
+ opacity: 0.5;
109
+ }
110
+
111
+ .petChoiceLabel {
112
+ max-width: 100%;
113
+ overflow: hidden;
114
+ font-size: 12px;
115
+ line-height: 16px;
116
+ text-align: center;
117
+ text-overflow: ellipsis;
118
+ white-space: nowrap;
119
+ }
120
+
121
+ .previewFrame {
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: center;
125
+ width: 76px;
126
+ height: 76px;
127
+ overflow: hidden;
128
+ border-radius: 9px;
129
+ background: color-mix(in srgb, currentColor 5%, transparent);
130
+ }
131
+
132
+ .previewAtlas {
133
+ display: block;
134
+ flex: none;
135
+ background-position: 0 0;
136
+ background-repeat: no-repeat;
137
+ }
138
+
139
+ .previewImage {
140
+ display: block;
141
+ width: 100%;
142
+ height: 100%;
143
+ object-fit: contain;
144
+ }
145
+
146
+ .previewFallback {
147
+ font-size: 25px;
148
+ font-weight: 600;
149
+ opacity: 0.65;
150
+ }
151
+
152
+ .groupHint,
153
+ .invalid {
154
+ margin: 4px 0 0;
155
+ font-size: 12px;
156
+ line-height: 18px;
157
+ }
158
+
159
+ .groupHint {
160
+ color: var(--dsw-alias-label-secondary);
161
+ }
162
+
163
+ .invalid {
164
+ color: var(--dsw-alias-text-danger, #d55454);
165
+ }
166
+
167
+ .fields {
168
+ display: flex;
169
+ flex-direction: column;
170
+ gap: 12px;
171
+ }
172
+
173
+ @container (max-width: 640px) {
174
+ .settingsLayout {
175
+ grid-template-columns: minmax(0, 1fr);
176
+ }
177
+
178
+ .petGrid {
179
+ grid-template-columns: repeat(3, minmax(0, 1fr));
180
+ }
181
+ }
182
+
183
+ @container (max-width: 420px) {
184
+ .petGrid {
185
+ grid-template-columns: repeat(2, minmax(0, 1fr));
186
+ }
187
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * The Web Extensions host contract consumed by the pet settings page. This
3
+ * package declares the collaboration types locally and never value-imports
4
+ * the host plugin, so a standalone pet install keeps working without it.
5
+ */
6
+
7
+ import type { SettingsSectionOwnerProps } from '@deepseek-ai/dsh-client-ui-settings/client'
8
+
9
+ /** Optional navigator published by the Web Extensions parent section. */
10
+ export interface WebUiExtensionService {
11
+ /** The parent keeps the established first-level section id for deep links. */
12
+ readonly sectionId: 'web-ui-plugins'
13
+ /** Localized parent-section label used by the host's deep-link fallback. */
14
+ label(): string
15
+ /** Open one extension tab by its keyed entry id. */
16
+ open(id: string): boolean
17
+ }
18
+
19
+ declare module '@deepseek-ai/cordis' {
20
+ interface Context {
21
+ /** Presence marks the Web Extensions parent as available. */
22
+ webUiExtensions?: WebUiExtensionService
23
+ }
24
+ }
25
+
26
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
27
+ interface SlotMap {
28
+ /** One keyed, root-scoped page inside the Web Extensions parent section. */
29
+ 'web-ui.extension': {
30
+ kind: 'keyed'
31
+ scope: 'root'
32
+ owner: SettingsSectionOwnerProps
33
+ }
34
+ }
35
+ }