@linxin666/dsh-pet 0.3.5 → 0.3.9

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 (88) hide show
  1. package/README.i18n.yaml +2 -2
  2. package/README.md +4 -0
  3. package/README.zh.md +4 -0
  4. package/contracts/voice-pack-v1.schema.json +30 -0
  5. package/cordis.patch.yml +1 -1
  6. package/lib/client.js +330 -103
  7. package/lib/client.js.map +1 -1
  8. package/lib/index.js +145 -28
  9. package/lib/invariant.js +1 -1
  10. package/lib/live2d-vendor.js +106 -95
  11. package/lib/live2d-vendor.js.map +1 -1
  12. package/lib/{state-DrMX22GL.js → state-NvDEoCln.js} +5 -2
  13. package/lib/types/access.d.ts +5 -4
  14. package/lib/types/access.d.ts.map +1 -1
  15. package/lib/types/access.js +2 -12
  16. package/lib/types/affinity.d.ts +2 -0
  17. package/lib/types/affinity.d.ts.map +1 -1
  18. package/lib/types/affinity.js +12 -0
  19. package/lib/types/announce.d.ts +53 -0
  20. package/lib/types/announce.d.ts.map +1 -0
  21. package/lib/types/announce.js +80 -0
  22. package/lib/types/client/PetDockEntry.d.ts +14 -5
  23. package/lib/types/client/PetDockEntry.d.ts.map +1 -1
  24. package/lib/types/client/PetDockEntry.js +6 -5
  25. package/lib/types/client/PetSettingsCard.d.ts +2 -1
  26. package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
  27. package/lib/types/client/PetSprite.d.ts +8 -0
  28. package/lib/types/client/PetSprite.d.ts.map +1 -1
  29. package/lib/types/client/PetSprite.js +36 -5
  30. package/lib/types/client/index.d.ts +8 -5
  31. package/lib/types/client/index.d.ts.map +1 -1
  32. package/lib/types/client/index.js +11 -5
  33. package/lib/types/client/locales.d.ts +20 -2
  34. package/lib/types/client/locales.d.ts.map +1 -1
  35. package/lib/types/client/locales.js +20 -2
  36. package/lib/types/client/pet-store.d.ts +1 -1
  37. package/lib/types/client/pet-store.d.ts.map +1 -1
  38. package/lib/types/client/pet-store.js +1 -1
  39. package/lib/types/client/renderers/frames2d.d.ts +12 -0
  40. package/lib/types/client/renderers/frames2d.d.ts.map +1 -1
  41. package/lib/types/client/renderers/frames2d.js +143 -18
  42. package/lib/types/client/settings-form.d.ts +35 -43
  43. package/lib/types/client/settings-form.d.ts.map +1 -1
  44. package/lib/types/client/settings-form.js +60 -53
  45. package/lib/types/index.d.ts.map +1 -1
  46. package/lib/types/index.js +10 -9
  47. package/lib/types/ledger.d.ts +4 -2
  48. package/lib/types/ledger.d.ts.map +1 -1
  49. package/lib/types/ledger.js +4 -4
  50. package/lib/types/pair-access.d.ts +35 -0
  51. package/lib/types/pair-access.d.ts.map +1 -0
  52. package/lib/types/pair-access.js +19 -0
  53. package/lib/types/remarks.d.ts +1 -1
  54. package/lib/types/remarks.d.ts.map +1 -1
  55. package/lib/types/remarks.js +11 -2
  56. package/lib/types/service.d.ts +18 -0
  57. package/lib/types/service.d.ts.map +1 -1
  58. package/lib/types/service.js +26 -1
  59. package/lib/types/voice-pack.d.ts +5 -0
  60. package/lib/types/voice-pack.d.ts.map +1 -1
  61. package/lib/types/voice-pack.js +36 -2
  62. package/package.json +17 -13
  63. package/src/access.ts +7 -27
  64. package/src/affinity.ts +13 -0
  65. package/src/announce.ts +103 -0
  66. package/src/client/PetDockEntry.test.tsx +1 -1
  67. package/src/client/PetDockEntry.tsx +15 -4
  68. package/src/client/PetSettingsCard.tsx +2 -1
  69. package/src/client/PetSprite.test.tsx +36 -0
  70. package/src/client/PetSprite.tsx +75 -4
  71. package/src/client/gameplay-hud.test.tsx +1 -1
  72. package/src/client/index.test.tsx +2 -2
  73. package/src/client/index.ts +17 -6
  74. package/src/client/locales.ts +20 -2
  75. package/src/client/pet-store.ts +2 -2
  76. package/src/client/pet.module.css +104 -0
  77. package/src/client/renderers/frames2d.test.ts +101 -0
  78. package/src/client/renderers/frames2d.ts +138 -18
  79. package/src/client/settings-form.ts +78 -92
  80. package/src/dsh-home.ts +1 -1
  81. package/src/index.ts +17 -15
  82. package/src/ledger.ts +6 -4
  83. package/src/pair-access.ts +49 -0
  84. package/src/remarks.test.ts +10 -0
  85. package/src/remarks.ts +9 -2
  86. package/src/service.ts +32 -2
  87. package/src/voice-pack.test.ts +39 -0
  88. package/src/voice-pack.ts +37 -2
package/src/voice-pack.ts CHANGED
@@ -37,6 +37,7 @@ import {
37
37
  type WhisperCategory,
38
38
  type WhisperResult,
39
39
  } from './chatter.ts'
40
+ import { normalizePetRemarks, type PetRemarks } from './remarks.ts'
40
41
 
41
42
  /** Schema version this module normalizes (optional field; missing = 1). */
42
43
  export const VOICE_PACK_V1 = 1 as const
@@ -69,6 +70,10 @@ export interface VoicePack {
69
70
  overrides: VoicePackOverrides
70
71
  /** Hover-panel chrome, when the pack declares any. */
71
72
  panel?: PetPanelView
73
+ /** Pat/feed interaction remark pools (issue #1226). */
74
+ remarks?: PetRemarks
75
+ /** Affinity rank name overrides (issue #1226). */
76
+ ranks?: Record<string, string>
72
77
  }
73
78
 
74
79
  /** Hard caps shared by every pool slot (mirrors the remarks discipline). */
@@ -265,7 +270,7 @@ export function normalizePanel(
265
270
  }
266
271
 
267
272
  /** Voice-pack top-level fields ('$schema' mirrors the schema twin; drift-locked in tests). */
268
- export const VOICE_PACK_KEYS = new Set(['$schema', 'voicePackVersion', 'status', 'tools', 'toolRemaining', 'whispers', 'panel'])
273
+ export const VOICE_PACK_KEYS = new Set(['$schema', 'voicePackVersion', 'status', 'tools', 'toolRemaining', 'whispers', 'panel', 'remarks', 'ranks'])
269
274
 
270
275
  /** Allowed whisper-section fields (drift-locked in tests). */
271
276
  export const WHISPER_KEYS = new Set(['categories', 'results'])
@@ -356,16 +361,36 @@ export function normalizeVoicePack(
356
361
  }
357
362
  }
358
363
  const panel = raw.panel === undefined ? undefined : normalizePanel(raw.panel, onWarning)
364
+ const remarks = raw.remarks === undefined ? undefined : normalizePetRemarks(raw.remarks, onWarning)
365
+ const ranksRaw = raw.ranks
366
+ let ranks: Record<string, string> | undefined
367
+ if (ranksRaw !== undefined) {
368
+ if (!isRecord(ranksRaw)) {
369
+ onWarning('ranks must be an object')
370
+ } else {
371
+ const out: Record<string, string> = {}
372
+ for (const [key, value] of Object.entries(ranksRaw)) {
373
+ if (typeof value === 'string' && value.trim() !== '') {
374
+ out[key] = value.trim().slice(0, VOICE_STAT_MAX)
375
+ } else {
376
+ onWarning('invalid rank name for ' + key)
377
+ }
378
+ }
379
+ if (Object.keys(out).length > 0) ranks = out
380
+ }
381
+ }
359
382
  if (
360
383
  overrides.status === undefined && overrides.tools === undefined
361
384
  && overrides.toolRemaining === undefined && overrides.whispers === undefined
362
- && panel === undefined
385
+ && panel === undefined && remarks === undefined && ranks === undefined
363
386
  ) {
364
387
  return undefined
365
388
  }
366
389
  return {
367
390
  overrides,
368
391
  ...(panel === undefined ? {} : { panel }),
392
+ ...(remarks === undefined ? {} : { remarks }),
393
+ ...(ranks === undefined ? {} : { ranks }),
369
394
  }
370
395
  }
371
396
 
@@ -379,6 +404,8 @@ export function mergeVoicePacks(...layers: (VoicePack | undefined)[]): VoicePack
379
404
  const overrides: VoicePackOverrides = {}
380
405
  const labels: NonNullable<PetPanelView['labels']> = {}
381
406
  const stats: NonNullable<PetPanelView['stats']> = {}
407
+ let remarks: PetRemarks | undefined
408
+ let ranks: Record<string, string> | undefined
382
409
  let actions: PanelAction[] | undefined
383
410
  let panelSeen = false
384
411
  let any = false
@@ -401,6 +428,12 @@ export function mergeVoicePacks(...layers: (VoicePack | undefined)[]): VoicePack
401
428
  if (layer.panel.stats !== undefined) Object.assign(stats, layer.panel.stats)
402
429
  if (layer.panel.actions !== undefined) actions = layer.panel.actions
403
430
  }
431
+ if (layer.remarks !== undefined) {
432
+ remarks = { ...(remarks ?? {}), ...layer.remarks }
433
+ }
434
+ if (layer.ranks !== undefined) {
435
+ ranks = { ...(ranks ?? {}), ...layer.ranks }
436
+ }
404
437
  }
405
438
  if (!any) return undefined
406
439
  const panel: PetPanelView = {
@@ -412,5 +445,7 @@ export function mergeVoicePacks(...layers: (VoicePack | undefined)[]): VoicePack
412
445
  return {
413
446
  overrides,
414
447
  ...(panelSeen && !panelEmpty ? { panel } : {}),
448
+ ...(remarks !== undefined ? { remarks } : {}),
449
+ ...(ranks !== undefined ? { ranks } : {}),
415
450
  }
416
451
  }