@masterbble/dsh-coo-pet 0.0.0-stage → 0.6.29

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 (507) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +112 -2
  3. package/assets/desk-main.cjs +623 -0
  4. package/assets/desk-preload.cjs +116 -0
  5. package/assets/desk-probe.ps1 +213 -0
  6. package/assets/icon-snapshot.json +1 -0
  7. package/assets/pet/desk.html +2734 -0
  8. package/assets/pet/kit/body.js +1053 -0
  9. package/assets/pet/kit/rig.js +242 -0
  10. package/assets/pet/speech/zh.json +1 -0
  11. package/assets/pet/speech/zh.ogg +0 -0
  12. package/assets/pet/whale/feat/dizzy_eyeL.png +0 -0
  13. package/assets/pet/whale/feat/dizzy_eyeR.png +0 -0
  14. package/assets/pet/whale/feat/dizzy_mouth.png +0 -0
  15. package/assets/pet/whale/feat/drag_eyeL.png +0 -0
  16. package/assets/pet/whale/feat/drag_eyeR.png +0 -0
  17. package/assets/pet/whale/feat/drag_mouth.png +0 -0
  18. package/assets/pet/whale/feat/eyeL_ball.png +0 -0
  19. package/assets/pet/whale/feat/eyeL_hl.png +0 -0
  20. package/assets/pet/whale/feat/eyeL_iris.png +0 -0
  21. package/assets/pet/whale/feat/eyeL_lash.png +0 -0
  22. package/assets/pet/whale/feat/eyeR_ball.png +0 -0
  23. package/assets/pet/whale/feat/eyeR_hl.png +0 -0
  24. package/assets/pet/whale/feat/eyeR_iris.png +0 -0
  25. package/assets/pet/whale/feat/eyeR_lash.png +0 -0
  26. package/assets/pet/whale/feat/happy_eyeL.png +0 -0
  27. package/assets/pet/whale/feat/happy_eyeR.png +0 -0
  28. package/assets/pet/whale/feat/happy_mouth.png +0 -0
  29. package/assets/pet/whale/feat/love_eyeL.png +0 -0
  30. package/assets/pet/whale/feat/love_eyeR.png +0 -0
  31. package/assets/pet/whale/feat/love_mouth.png +0 -0
  32. package/assets/pet/whale/feat/neutral_mouth.png +0 -0
  33. package/assets/pet/whale/feat/sleep_eyeL.png +0 -0
  34. package/assets/pet/whale/feat/sleep_eyeR.png +0 -0
  35. package/assets/pet/whale/feat/sleep_mouth.png +0 -0
  36. package/assets/pet/whale/feat/surprised_eyeL.png +0 -0
  37. package/assets/pet/whale/feat/surprised_eyeR.png +0 -0
  38. package/assets/pet/whale/feat/surprised_mouth.png +0 -0
  39. package/assets/pet/whale/figure.js +948 -0
  40. package/assets/pet/whale/figure.json +997 -0
  41. package/assets/pet/whale/model.json +1710 -0
  42. package/assets/pet/whale/outfits/cape/arm_far.png +0 -0
  43. package/assets/pet/whale/outfits/cape/arm_far_end_front.png +0 -0
  44. package/assets/pet/whale/outfits/cape/arm_near.png +0 -0
  45. package/assets/pet/whale/outfits/cape/cloak.png +0 -0
  46. package/assets/pet/whale/outfits/cape/cloak_shoulder_cover.png +0 -0
  47. package/assets/pet/whale/outfits/cape/hood_back.png +0 -0
  48. package/assets/pet/whale/outfits/cape/hood_fin_far.png +0 -0
  49. package/assets/pet/whale/outfits/cape/hood_fin_near.png +0 -0
  50. package/assets/pet/whale/outfits/cape/hood_front.png +0 -0
  51. package/assets/pet/whale/outfits/cape/hood_lining.png +0 -0
  52. package/assets/pet/whale/outfits/cape/hood_tie_far.png +0 -0
  53. package/assets/pet/whale/outfits/cape/hood_tie_near.png +0 -0
  54. package/assets/pet/whale/outfits/cape/leg_back.png +0 -0
  55. package/assets/pet/whale/outfits/cape/leg_front.png +0 -0
  56. package/assets/pet/whale/outfits/cape/scarf_neck.png +0 -0
  57. package/assets/pet/whale/outfits/cape/scarf_tail_back.png +0 -0
  58. package/assets/pet/whale/outfits/cape/scarf_tail_front.png +0 -0
  59. package/assets/pet/whale/outfits/cape/skirt.png +0 -0
  60. package/assets/pet/whale/outfits/cape/skirt_sit.png +0 -0
  61. package/assets/pet/whale/outfits/cape/spout.png +0 -0
  62. package/assets/pet/whale/outfits/crew/arm_far.png +0 -0
  63. package/assets/pet/whale/outfits/crew/arm_near.png +0 -0
  64. package/assets/pet/whale/outfits/crew/bow_near.png +0 -0
  65. package/assets/pet/whale/outfits/crew/headset.png +0 -0
  66. package/assets/pet/whale/outfits/crew/leg_back.png +0 -0
  67. package/assets/pet/whale/outfits/crew/leg_front.png +0 -0
  68. package/assets/pet/whale/outfits/crew/pony_bow.png +0 -0
  69. package/assets/pet/whale/outfits/crew/skirt_shadow.png +0 -0
  70. package/assets/pet/whale/outfits/crew/torso_up.png +0 -0
  71. package/assets/pet/whale/outfits/crew/visor.png +0 -0
  72. package/assets/pet/whale/schemes/chatgpt/feat/dizzy_eyeL.png +0 -0
  73. package/assets/pet/whale/schemes/chatgpt/feat/dizzy_eyeR.png +0 -0
  74. package/assets/pet/whale/schemes/chatgpt/feat/dizzy_mouth.png +0 -0
  75. package/assets/pet/whale/schemes/chatgpt/feat/drag_eyeL.png +0 -0
  76. package/assets/pet/whale/schemes/chatgpt/feat/drag_eyeR.png +0 -0
  77. package/assets/pet/whale/schemes/chatgpt/feat/drag_mouth.png +0 -0
  78. package/assets/pet/whale/schemes/chatgpt/feat/eyeL_ball.png +0 -0
  79. package/assets/pet/whale/schemes/chatgpt/feat/eyeL_iris.png +0 -0
  80. package/assets/pet/whale/schemes/chatgpt/feat/eyeL_lash.png +0 -0
  81. package/assets/pet/whale/schemes/chatgpt/feat/eyeR_ball.png +0 -0
  82. package/assets/pet/whale/schemes/chatgpt/feat/eyeR_iris.png +0 -0
  83. package/assets/pet/whale/schemes/chatgpt/feat/eyeR_lash.png +0 -0
  84. package/assets/pet/whale/schemes/chatgpt/feat/happy_eyeL.png +0 -0
  85. package/assets/pet/whale/schemes/chatgpt/feat/happy_eyeR.png +0 -0
  86. package/assets/pet/whale/schemes/chatgpt/feat/happy_mouth.png +0 -0
  87. package/assets/pet/whale/schemes/chatgpt/feat/love_eyeL.png +0 -0
  88. package/assets/pet/whale/schemes/chatgpt/feat/love_eyeR.png +0 -0
  89. package/assets/pet/whale/schemes/chatgpt/feat/love_mouth.png +0 -0
  90. package/assets/pet/whale/schemes/chatgpt/feat/neutral_mouth.png +0 -0
  91. package/assets/pet/whale/schemes/chatgpt/feat/sleep_eyeL.png +0 -0
  92. package/assets/pet/whale/schemes/chatgpt/feat/sleep_eyeR.png +0 -0
  93. package/assets/pet/whale/schemes/chatgpt/feat/sleep_mouth.png +0 -0
  94. package/assets/pet/whale/schemes/chatgpt/feat/surprised_eyeL.png +0 -0
  95. package/assets/pet/whale/schemes/chatgpt/feat/surprised_eyeR.png +0 -0
  96. package/assets/pet/whale/schemes/chatgpt/feat/surprised_mouth.png +0 -0
  97. package/assets/pet/whale/schemes/chatgpt/tex/ahoge.png +0 -0
  98. package/assets/pet/whale/schemes/chatgpt/tex/arm_far.png +0 -0
  99. package/assets/pet/whale/schemes/chatgpt/tex/arm_far_end_front.png +0 -0
  100. package/assets/pet/whale/schemes/chatgpt/tex/arm_near.png +0 -0
  101. package/assets/pet/whale/schemes/chatgpt/tex/bangs.png +0 -0
  102. package/assets/pet/whale/schemes/chatgpt/tex/bow.png +0 -0
  103. package/assets/pet/whale/schemes/chatgpt/tex/brows.png +0 -0
  104. package/assets/pet/whale/schemes/chatgpt/tex/crew_hair_back.png +0 -0
  105. package/assets/pet/whale/schemes/chatgpt/tex/crew_ponytail.png +0 -0
  106. package/assets/pet/whale/schemes/chatgpt/tex/crew_sidelocks.png +0 -0
  107. package/assets/pet/whale/schemes/chatgpt/tex/crew_skirt.png +0 -0
  108. package/assets/pet/whale/schemes/chatgpt/tex/crew_skirt_sit.png +0 -0
  109. package/assets/pet/whale/schemes/chatgpt/tex/eye_creases.png +0 -0
  110. package/assets/pet/whale/schemes/chatgpt/tex/face.png +0 -0
  111. package/assets/pet/whale/schemes/chatgpt/tex/fin_far.png +0 -0
  112. package/assets/pet/whale/schemes/chatgpt/tex/fin_near.png +0 -0
  113. package/assets/pet/whale/schemes/chatgpt/tex/hair_back.png +0 -0
  114. package/assets/pet/whale/schemes/chatgpt/tex/hair_back_curl.png +0 -0
  115. package/assets/pet/whale/schemes/chatgpt/tex/hair_front_left.png +0 -0
  116. package/assets/pet/whale/schemes/chatgpt/tex/hair_front_right.png +0 -0
  117. package/assets/pet/whale/schemes/chatgpt/tex/headdress.png +0 -0
  118. package/assets/pet/whale/schemes/chatgpt/tex/leg_back.png +0 -0
  119. package/assets/pet/whale/schemes/chatgpt/tex/leg_front.png +0 -0
  120. package/assets/pet/whale/schemes/chatgpt/tex/sidelocks.png +0 -0
  121. package/assets/pet/whale/schemes/chatgpt/tex/skirt.png +0 -0
  122. package/assets/pet/whale/schemes/chatgpt/tex/skirt_sit.png +0 -0
  123. package/assets/pet/whale/schemes/chatgpt/tex/tail.png +0 -0
  124. package/assets/pet/whale/schemes/chatgpt/tex/torso_up.png +0 -0
  125. package/assets/pet/whale/schemes/chatgpt/tex/waist_bow_front.png +0 -0
  126. package/assets/pet/whale/schemes/chatgpt/tex/waist_bow_sit_front.png +0 -0
  127. package/assets/pet/whale/schemes/claude/feat/dizzy_eyeL.png +0 -0
  128. package/assets/pet/whale/schemes/claude/feat/dizzy_eyeR.png +0 -0
  129. package/assets/pet/whale/schemes/claude/feat/dizzy_mouth.png +0 -0
  130. package/assets/pet/whale/schemes/claude/feat/drag_eyeL.png +0 -0
  131. package/assets/pet/whale/schemes/claude/feat/drag_eyeR.png +0 -0
  132. package/assets/pet/whale/schemes/claude/feat/drag_mouth.png +0 -0
  133. package/assets/pet/whale/schemes/claude/feat/eyeL_ball.png +0 -0
  134. package/assets/pet/whale/schemes/claude/feat/eyeL_iris.png +0 -0
  135. package/assets/pet/whale/schemes/claude/feat/eyeL_lash.png +0 -0
  136. package/assets/pet/whale/schemes/claude/feat/eyeR_ball.png +0 -0
  137. package/assets/pet/whale/schemes/claude/feat/eyeR_iris.png +0 -0
  138. package/assets/pet/whale/schemes/claude/feat/eyeR_lash.png +0 -0
  139. package/assets/pet/whale/schemes/claude/feat/happy_eyeL.png +0 -0
  140. package/assets/pet/whale/schemes/claude/feat/happy_eyeR.png +0 -0
  141. package/assets/pet/whale/schemes/claude/feat/happy_mouth.png +0 -0
  142. package/assets/pet/whale/schemes/claude/feat/love_eyeL.png +0 -0
  143. package/assets/pet/whale/schemes/claude/feat/love_eyeR.png +0 -0
  144. package/assets/pet/whale/schemes/claude/feat/love_mouth.png +0 -0
  145. package/assets/pet/whale/schemes/claude/feat/neutral_mouth.png +0 -0
  146. package/assets/pet/whale/schemes/claude/feat/sleep_eyeL.png +0 -0
  147. package/assets/pet/whale/schemes/claude/feat/sleep_eyeR.png +0 -0
  148. package/assets/pet/whale/schemes/claude/feat/sleep_mouth.png +0 -0
  149. package/assets/pet/whale/schemes/claude/feat/surprised_eyeL.png +0 -0
  150. package/assets/pet/whale/schemes/claude/feat/surprised_eyeR.png +0 -0
  151. package/assets/pet/whale/schemes/claude/feat/surprised_mouth.png +0 -0
  152. package/assets/pet/whale/schemes/claude/tex/ahoge.png +0 -0
  153. package/assets/pet/whale/schemes/claude/tex/arm_far.png +0 -0
  154. package/assets/pet/whale/schemes/claude/tex/arm_far_end_front.png +0 -0
  155. package/assets/pet/whale/schemes/claude/tex/arm_near.png +0 -0
  156. package/assets/pet/whale/schemes/claude/tex/bangs.png +0 -0
  157. package/assets/pet/whale/schemes/claude/tex/bow.png +0 -0
  158. package/assets/pet/whale/schemes/claude/tex/brows.png +0 -0
  159. package/assets/pet/whale/schemes/claude/tex/crew_hair_back.png +0 -0
  160. package/assets/pet/whale/schemes/claude/tex/crew_ponytail.png +0 -0
  161. package/assets/pet/whale/schemes/claude/tex/crew_sidelocks.png +0 -0
  162. package/assets/pet/whale/schemes/claude/tex/crew_skirt.png +0 -0
  163. package/assets/pet/whale/schemes/claude/tex/crew_skirt_sit.png +0 -0
  164. package/assets/pet/whale/schemes/claude/tex/eye_creases.png +0 -0
  165. package/assets/pet/whale/schemes/claude/tex/face.png +0 -0
  166. package/assets/pet/whale/schemes/claude/tex/fin_far.png +0 -0
  167. package/assets/pet/whale/schemes/claude/tex/fin_near.png +0 -0
  168. package/assets/pet/whale/schemes/claude/tex/hair_back.png +0 -0
  169. package/assets/pet/whale/schemes/claude/tex/hair_back_curl.png +0 -0
  170. package/assets/pet/whale/schemes/claude/tex/hair_front_left.png +0 -0
  171. package/assets/pet/whale/schemes/claude/tex/hair_front_right.png +0 -0
  172. package/assets/pet/whale/schemes/claude/tex/headdress.png +0 -0
  173. package/assets/pet/whale/schemes/claude/tex/leg_back.png +0 -0
  174. package/assets/pet/whale/schemes/claude/tex/leg_front.png +0 -0
  175. package/assets/pet/whale/schemes/claude/tex/sidelocks.png +0 -0
  176. package/assets/pet/whale/schemes/claude/tex/skirt.png +0 -0
  177. package/assets/pet/whale/schemes/claude/tex/skirt_sit.png +0 -0
  178. package/assets/pet/whale/schemes/claude/tex/tail.png +0 -0
  179. package/assets/pet/whale/schemes/claude/tex/torso_up.png +0 -0
  180. package/assets/pet/whale/schemes/claude/tex/waist_bow_front.png +0 -0
  181. package/assets/pet/whale/schemes/claude/tex/waist_bow_sit_front.png +0 -0
  182. package/assets/pet/whale/schemes/gemini/feat/dizzy_eyeL.png +0 -0
  183. package/assets/pet/whale/schemes/gemini/feat/dizzy_eyeR.png +0 -0
  184. package/assets/pet/whale/schemes/gemini/feat/dizzy_mouth.png +0 -0
  185. package/assets/pet/whale/schemes/gemini/feat/drag_eyeL.png +0 -0
  186. package/assets/pet/whale/schemes/gemini/feat/drag_eyeR.png +0 -0
  187. package/assets/pet/whale/schemes/gemini/feat/drag_mouth.png +0 -0
  188. package/assets/pet/whale/schemes/gemini/feat/eyeL_ball.png +0 -0
  189. package/assets/pet/whale/schemes/gemini/feat/eyeL_iris.png +0 -0
  190. package/assets/pet/whale/schemes/gemini/feat/eyeL_lash.png +0 -0
  191. package/assets/pet/whale/schemes/gemini/feat/eyeR_ball.png +0 -0
  192. package/assets/pet/whale/schemes/gemini/feat/eyeR_iris.png +0 -0
  193. package/assets/pet/whale/schemes/gemini/feat/eyeR_lash.png +0 -0
  194. package/assets/pet/whale/schemes/gemini/feat/happy_eyeL.png +0 -0
  195. package/assets/pet/whale/schemes/gemini/feat/happy_eyeR.png +0 -0
  196. package/assets/pet/whale/schemes/gemini/feat/happy_mouth.png +0 -0
  197. package/assets/pet/whale/schemes/gemini/feat/love_eyeL.png +0 -0
  198. package/assets/pet/whale/schemes/gemini/feat/love_eyeR.png +0 -0
  199. package/assets/pet/whale/schemes/gemini/feat/love_mouth.png +0 -0
  200. package/assets/pet/whale/schemes/gemini/feat/neutral_mouth.png +0 -0
  201. package/assets/pet/whale/schemes/gemini/feat/sleep_eyeL.png +0 -0
  202. package/assets/pet/whale/schemes/gemini/feat/sleep_eyeR.png +0 -0
  203. package/assets/pet/whale/schemes/gemini/feat/sleep_mouth.png +0 -0
  204. package/assets/pet/whale/schemes/gemini/feat/surprised_eyeL.png +0 -0
  205. package/assets/pet/whale/schemes/gemini/feat/surprised_eyeR.png +0 -0
  206. package/assets/pet/whale/schemes/gemini/feat/surprised_mouth.png +0 -0
  207. package/assets/pet/whale/schemes/gemini/tex/ahoge.png +0 -0
  208. package/assets/pet/whale/schemes/gemini/tex/arm_far.png +0 -0
  209. package/assets/pet/whale/schemes/gemini/tex/arm_far_end_front.png +0 -0
  210. package/assets/pet/whale/schemes/gemini/tex/arm_near.png +0 -0
  211. package/assets/pet/whale/schemes/gemini/tex/bangs.png +0 -0
  212. package/assets/pet/whale/schemes/gemini/tex/bow.png +0 -0
  213. package/assets/pet/whale/schemes/gemini/tex/brows.png +0 -0
  214. package/assets/pet/whale/schemes/gemini/tex/crew_hair_back.png +0 -0
  215. package/assets/pet/whale/schemes/gemini/tex/crew_ponytail.png +0 -0
  216. package/assets/pet/whale/schemes/gemini/tex/crew_sidelocks.png +0 -0
  217. package/assets/pet/whale/schemes/gemini/tex/crew_skirt.png +0 -0
  218. package/assets/pet/whale/schemes/gemini/tex/crew_skirt_sit.png +0 -0
  219. package/assets/pet/whale/schemes/gemini/tex/eye_creases.png +0 -0
  220. package/assets/pet/whale/schemes/gemini/tex/face.png +0 -0
  221. package/assets/pet/whale/schemes/gemini/tex/fin_far.png +0 -0
  222. package/assets/pet/whale/schemes/gemini/tex/fin_near.png +0 -0
  223. package/assets/pet/whale/schemes/gemini/tex/hair_back.png +0 -0
  224. package/assets/pet/whale/schemes/gemini/tex/hair_back_curl.png +0 -0
  225. package/assets/pet/whale/schemes/gemini/tex/hair_front_left.png +0 -0
  226. package/assets/pet/whale/schemes/gemini/tex/hair_front_right.png +0 -0
  227. package/assets/pet/whale/schemes/gemini/tex/headdress.png +0 -0
  228. package/assets/pet/whale/schemes/gemini/tex/leg_back.png +0 -0
  229. package/assets/pet/whale/schemes/gemini/tex/leg_front.png +0 -0
  230. package/assets/pet/whale/schemes/gemini/tex/sidelocks.png +0 -0
  231. package/assets/pet/whale/schemes/gemini/tex/skirt.png +0 -0
  232. package/assets/pet/whale/schemes/gemini/tex/skirt_sit.png +0 -0
  233. package/assets/pet/whale/schemes/gemini/tex/tail.png +0 -0
  234. package/assets/pet/whale/schemes/gemini/tex/torso_up.png +0 -0
  235. package/assets/pet/whale/schemes/gemini/tex/waist_bow_front.png +0 -0
  236. package/assets/pet/whale/schemes/gemini/tex/waist_bow_sit_front.png +0 -0
  237. package/assets/pet/whale/schemes/harness/feat/dizzy_eyeL.png +0 -0
  238. package/assets/pet/whale/schemes/harness/feat/dizzy_eyeR.png +0 -0
  239. package/assets/pet/whale/schemes/harness/feat/dizzy_mouth.png +0 -0
  240. package/assets/pet/whale/schemes/harness/feat/drag_eyeL.png +0 -0
  241. package/assets/pet/whale/schemes/harness/feat/drag_eyeR.png +0 -0
  242. package/assets/pet/whale/schemes/harness/feat/drag_mouth.png +0 -0
  243. package/assets/pet/whale/schemes/harness/feat/eyeL_ball.png +0 -0
  244. package/assets/pet/whale/schemes/harness/feat/eyeL_iris.png +0 -0
  245. package/assets/pet/whale/schemes/harness/feat/eyeL_lash.png +0 -0
  246. package/assets/pet/whale/schemes/harness/feat/eyeR_ball.png +0 -0
  247. package/assets/pet/whale/schemes/harness/feat/eyeR_iris.png +0 -0
  248. package/assets/pet/whale/schemes/harness/feat/eyeR_lash.png +0 -0
  249. package/assets/pet/whale/schemes/harness/feat/happy_eyeL.png +0 -0
  250. package/assets/pet/whale/schemes/harness/feat/happy_eyeR.png +0 -0
  251. package/assets/pet/whale/schemes/harness/feat/happy_mouth.png +0 -0
  252. package/assets/pet/whale/schemes/harness/feat/love_eyeL.png +0 -0
  253. package/assets/pet/whale/schemes/harness/feat/love_eyeR.png +0 -0
  254. package/assets/pet/whale/schemes/harness/feat/love_mouth.png +0 -0
  255. package/assets/pet/whale/schemes/harness/feat/neutral_mouth.png +0 -0
  256. package/assets/pet/whale/schemes/harness/feat/sleep_eyeL.png +0 -0
  257. package/assets/pet/whale/schemes/harness/feat/sleep_eyeR.png +0 -0
  258. package/assets/pet/whale/schemes/harness/feat/sleep_mouth.png +0 -0
  259. package/assets/pet/whale/schemes/harness/feat/surprised_eyeL.png +0 -0
  260. package/assets/pet/whale/schemes/harness/feat/surprised_eyeR.png +0 -0
  261. package/assets/pet/whale/schemes/harness/feat/surprised_mouth.png +0 -0
  262. package/assets/pet/whale/schemes/harness/tex/ahoge.png +0 -0
  263. package/assets/pet/whale/schemes/harness/tex/arm_far.png +0 -0
  264. package/assets/pet/whale/schemes/harness/tex/arm_far_end_front.png +0 -0
  265. package/assets/pet/whale/schemes/harness/tex/arm_near.png +0 -0
  266. package/assets/pet/whale/schemes/harness/tex/bangs.png +0 -0
  267. package/assets/pet/whale/schemes/harness/tex/bow.png +0 -0
  268. package/assets/pet/whale/schemes/harness/tex/brows.png +0 -0
  269. package/assets/pet/whale/schemes/harness/tex/crew_hair_back.png +0 -0
  270. package/assets/pet/whale/schemes/harness/tex/crew_ponytail.png +0 -0
  271. package/assets/pet/whale/schemes/harness/tex/crew_sidelocks.png +0 -0
  272. package/assets/pet/whale/schemes/harness/tex/crew_skirt.png +0 -0
  273. package/assets/pet/whale/schemes/harness/tex/crew_skirt_sit.png +0 -0
  274. package/assets/pet/whale/schemes/harness/tex/eye_creases.png +0 -0
  275. package/assets/pet/whale/schemes/harness/tex/face.png +0 -0
  276. package/assets/pet/whale/schemes/harness/tex/fin_far.png +0 -0
  277. package/assets/pet/whale/schemes/harness/tex/fin_near.png +0 -0
  278. package/assets/pet/whale/schemes/harness/tex/hair_back.png +0 -0
  279. package/assets/pet/whale/schemes/harness/tex/hair_back_curl.png +0 -0
  280. package/assets/pet/whale/schemes/harness/tex/hair_front_left.png +0 -0
  281. package/assets/pet/whale/schemes/harness/tex/hair_front_right.png +0 -0
  282. package/assets/pet/whale/schemes/harness/tex/headdress.png +0 -0
  283. package/assets/pet/whale/schemes/harness/tex/leg_back.png +0 -0
  284. package/assets/pet/whale/schemes/harness/tex/leg_front.png +0 -0
  285. package/assets/pet/whale/schemes/harness/tex/sidelocks.png +0 -0
  286. package/assets/pet/whale/schemes/harness/tex/skirt.png +0 -0
  287. package/assets/pet/whale/schemes/harness/tex/skirt_sit.png +0 -0
  288. package/assets/pet/whale/schemes/harness/tex/tail.png +0 -0
  289. package/assets/pet/whale/schemes/harness/tex/torso_up.png +0 -0
  290. package/assets/pet/whale/schemes/harness/tex/waist_bow_front.png +0 -0
  291. package/assets/pet/whale/schemes/harness/tex/waist_bow_sit_front.png +0 -0
  292. package/assets/pet/whale/schemes/kimi/feat/dizzy_eyeL.png +0 -0
  293. package/assets/pet/whale/schemes/kimi/feat/dizzy_eyeR.png +0 -0
  294. package/assets/pet/whale/schemes/kimi/feat/dizzy_mouth.png +0 -0
  295. package/assets/pet/whale/schemes/kimi/feat/drag_eyeL.png +0 -0
  296. package/assets/pet/whale/schemes/kimi/feat/drag_eyeR.png +0 -0
  297. package/assets/pet/whale/schemes/kimi/feat/drag_mouth.png +0 -0
  298. package/assets/pet/whale/schemes/kimi/feat/eyeL_ball.png +0 -0
  299. package/assets/pet/whale/schemes/kimi/feat/eyeL_iris.png +0 -0
  300. package/assets/pet/whale/schemes/kimi/feat/eyeL_lash.png +0 -0
  301. package/assets/pet/whale/schemes/kimi/feat/eyeR_ball.png +0 -0
  302. package/assets/pet/whale/schemes/kimi/feat/eyeR_iris.png +0 -0
  303. package/assets/pet/whale/schemes/kimi/feat/eyeR_lash.png +0 -0
  304. package/assets/pet/whale/schemes/kimi/feat/happy_eyeL.png +0 -0
  305. package/assets/pet/whale/schemes/kimi/feat/happy_eyeR.png +0 -0
  306. package/assets/pet/whale/schemes/kimi/feat/happy_mouth.png +0 -0
  307. package/assets/pet/whale/schemes/kimi/feat/love_eyeL.png +0 -0
  308. package/assets/pet/whale/schemes/kimi/feat/love_eyeR.png +0 -0
  309. package/assets/pet/whale/schemes/kimi/feat/love_mouth.png +0 -0
  310. package/assets/pet/whale/schemes/kimi/feat/neutral_mouth.png +0 -0
  311. package/assets/pet/whale/schemes/kimi/feat/sleep_eyeL.png +0 -0
  312. package/assets/pet/whale/schemes/kimi/feat/sleep_eyeR.png +0 -0
  313. package/assets/pet/whale/schemes/kimi/feat/sleep_mouth.png +0 -0
  314. package/assets/pet/whale/schemes/kimi/feat/surprised_eyeL.png +0 -0
  315. package/assets/pet/whale/schemes/kimi/feat/surprised_eyeR.png +0 -0
  316. package/assets/pet/whale/schemes/kimi/feat/surprised_mouth.png +0 -0
  317. package/assets/pet/whale/schemes/kimi/tex/ahoge.png +0 -0
  318. package/assets/pet/whale/schemes/kimi/tex/arm_far.png +0 -0
  319. package/assets/pet/whale/schemes/kimi/tex/arm_far_end_front.png +0 -0
  320. package/assets/pet/whale/schemes/kimi/tex/arm_near.png +0 -0
  321. package/assets/pet/whale/schemes/kimi/tex/bangs.png +0 -0
  322. package/assets/pet/whale/schemes/kimi/tex/bow.png +0 -0
  323. package/assets/pet/whale/schemes/kimi/tex/brows.png +0 -0
  324. package/assets/pet/whale/schemes/kimi/tex/crew_hair_back.png +0 -0
  325. package/assets/pet/whale/schemes/kimi/tex/crew_ponytail.png +0 -0
  326. package/assets/pet/whale/schemes/kimi/tex/crew_sidelocks.png +0 -0
  327. package/assets/pet/whale/schemes/kimi/tex/crew_skirt.png +0 -0
  328. package/assets/pet/whale/schemes/kimi/tex/crew_skirt_sit.png +0 -0
  329. package/assets/pet/whale/schemes/kimi/tex/eye_creases.png +0 -0
  330. package/assets/pet/whale/schemes/kimi/tex/face.png +0 -0
  331. package/assets/pet/whale/schemes/kimi/tex/fin_far.png +0 -0
  332. package/assets/pet/whale/schemes/kimi/tex/fin_near.png +0 -0
  333. package/assets/pet/whale/schemes/kimi/tex/hair_back.png +0 -0
  334. package/assets/pet/whale/schemes/kimi/tex/hair_back_curl.png +0 -0
  335. package/assets/pet/whale/schemes/kimi/tex/hair_front_left.png +0 -0
  336. package/assets/pet/whale/schemes/kimi/tex/hair_front_right.png +0 -0
  337. package/assets/pet/whale/schemes/kimi/tex/headdress.png +0 -0
  338. package/assets/pet/whale/schemes/kimi/tex/leg_back.png +0 -0
  339. package/assets/pet/whale/schemes/kimi/tex/leg_front.png +0 -0
  340. package/assets/pet/whale/schemes/kimi/tex/sidelocks.png +0 -0
  341. package/assets/pet/whale/schemes/kimi/tex/skirt.png +0 -0
  342. package/assets/pet/whale/schemes/kimi/tex/skirt_sit.png +0 -0
  343. package/assets/pet/whale/schemes/kimi/tex/tail.png +0 -0
  344. package/assets/pet/whale/schemes/kimi/tex/torso_up.png +0 -0
  345. package/assets/pet/whale/schemes/kimi/tex/waist_bow_front.png +0 -0
  346. package/assets/pet/whale/schemes/kimi/tex/waist_bow_sit_front.png +0 -0
  347. package/assets/pet/whale/schemes/minimax/feat/dizzy_eyeL.png +0 -0
  348. package/assets/pet/whale/schemes/minimax/feat/dizzy_eyeR.png +0 -0
  349. package/assets/pet/whale/schemes/minimax/feat/dizzy_mouth.png +0 -0
  350. package/assets/pet/whale/schemes/minimax/feat/drag_eyeL.png +0 -0
  351. package/assets/pet/whale/schemes/minimax/feat/drag_eyeR.png +0 -0
  352. package/assets/pet/whale/schemes/minimax/feat/drag_mouth.png +0 -0
  353. package/assets/pet/whale/schemes/minimax/feat/eyeL_ball.png +0 -0
  354. package/assets/pet/whale/schemes/minimax/feat/eyeL_iris.png +0 -0
  355. package/assets/pet/whale/schemes/minimax/feat/eyeL_lash.png +0 -0
  356. package/assets/pet/whale/schemes/minimax/feat/eyeR_ball.png +0 -0
  357. package/assets/pet/whale/schemes/minimax/feat/eyeR_iris.png +0 -0
  358. package/assets/pet/whale/schemes/minimax/feat/eyeR_lash.png +0 -0
  359. package/assets/pet/whale/schemes/minimax/feat/happy_eyeL.png +0 -0
  360. package/assets/pet/whale/schemes/minimax/feat/happy_eyeR.png +0 -0
  361. package/assets/pet/whale/schemes/minimax/feat/happy_mouth.png +0 -0
  362. package/assets/pet/whale/schemes/minimax/feat/love_eyeL.png +0 -0
  363. package/assets/pet/whale/schemes/minimax/feat/love_eyeR.png +0 -0
  364. package/assets/pet/whale/schemes/minimax/feat/love_mouth.png +0 -0
  365. package/assets/pet/whale/schemes/minimax/feat/neutral_mouth.png +0 -0
  366. package/assets/pet/whale/schemes/minimax/feat/sleep_eyeL.png +0 -0
  367. package/assets/pet/whale/schemes/minimax/feat/sleep_eyeR.png +0 -0
  368. package/assets/pet/whale/schemes/minimax/feat/sleep_mouth.png +0 -0
  369. package/assets/pet/whale/schemes/minimax/feat/surprised_eyeL.png +0 -0
  370. package/assets/pet/whale/schemes/minimax/feat/surprised_eyeR.png +0 -0
  371. package/assets/pet/whale/schemes/minimax/feat/surprised_mouth.png +0 -0
  372. package/assets/pet/whale/schemes/minimax/tex/ahoge.png +0 -0
  373. package/assets/pet/whale/schemes/minimax/tex/arm_far.png +0 -0
  374. package/assets/pet/whale/schemes/minimax/tex/arm_far_end_front.png +0 -0
  375. package/assets/pet/whale/schemes/minimax/tex/arm_near.png +0 -0
  376. package/assets/pet/whale/schemes/minimax/tex/bangs.png +0 -0
  377. package/assets/pet/whale/schemes/minimax/tex/bow.png +0 -0
  378. package/assets/pet/whale/schemes/minimax/tex/brows.png +0 -0
  379. package/assets/pet/whale/schemes/minimax/tex/crew_hair_back.png +0 -0
  380. package/assets/pet/whale/schemes/minimax/tex/crew_ponytail.png +0 -0
  381. package/assets/pet/whale/schemes/minimax/tex/crew_sidelocks.png +0 -0
  382. package/assets/pet/whale/schemes/minimax/tex/crew_skirt.png +0 -0
  383. package/assets/pet/whale/schemes/minimax/tex/crew_skirt_sit.png +0 -0
  384. package/assets/pet/whale/schemes/minimax/tex/eye_creases.png +0 -0
  385. package/assets/pet/whale/schemes/minimax/tex/face.png +0 -0
  386. package/assets/pet/whale/schemes/minimax/tex/fin_far.png +0 -0
  387. package/assets/pet/whale/schemes/minimax/tex/fin_near.png +0 -0
  388. package/assets/pet/whale/schemes/minimax/tex/hair_back.png +0 -0
  389. package/assets/pet/whale/schemes/minimax/tex/hair_back_curl.png +0 -0
  390. package/assets/pet/whale/schemes/minimax/tex/hair_front_left.png +0 -0
  391. package/assets/pet/whale/schemes/minimax/tex/hair_front_right.png +0 -0
  392. package/assets/pet/whale/schemes/minimax/tex/headdress.png +0 -0
  393. package/assets/pet/whale/schemes/minimax/tex/leg_back.png +0 -0
  394. package/assets/pet/whale/schemes/minimax/tex/leg_front.png +0 -0
  395. package/assets/pet/whale/schemes/minimax/tex/sidelocks.png +0 -0
  396. package/assets/pet/whale/schemes/minimax/tex/skirt.png +0 -0
  397. package/assets/pet/whale/schemes/minimax/tex/skirt_sit.png +0 -0
  398. package/assets/pet/whale/schemes/minimax/tex/tail.png +0 -0
  399. package/assets/pet/whale/schemes/minimax/tex/torso_up.png +0 -0
  400. package/assets/pet/whale/schemes/minimax/tex/waist_bow_front.png +0 -0
  401. package/assets/pet/whale/schemes/minimax/tex/waist_bow_sit_front.png +0 -0
  402. package/assets/pet/whale/schemes/qwen/feat/dizzy_eyeL.png +0 -0
  403. package/assets/pet/whale/schemes/qwen/feat/dizzy_eyeR.png +0 -0
  404. package/assets/pet/whale/schemes/qwen/feat/dizzy_mouth.png +0 -0
  405. package/assets/pet/whale/schemes/qwen/feat/drag_eyeL.png +0 -0
  406. package/assets/pet/whale/schemes/qwen/feat/drag_eyeR.png +0 -0
  407. package/assets/pet/whale/schemes/qwen/feat/drag_mouth.png +0 -0
  408. package/assets/pet/whale/schemes/qwen/feat/eyeL_ball.png +0 -0
  409. package/assets/pet/whale/schemes/qwen/feat/eyeL_iris.png +0 -0
  410. package/assets/pet/whale/schemes/qwen/feat/eyeL_lash.png +0 -0
  411. package/assets/pet/whale/schemes/qwen/feat/eyeR_ball.png +0 -0
  412. package/assets/pet/whale/schemes/qwen/feat/eyeR_iris.png +0 -0
  413. package/assets/pet/whale/schemes/qwen/feat/eyeR_lash.png +0 -0
  414. package/assets/pet/whale/schemes/qwen/feat/happy_eyeL.png +0 -0
  415. package/assets/pet/whale/schemes/qwen/feat/happy_eyeR.png +0 -0
  416. package/assets/pet/whale/schemes/qwen/feat/happy_mouth.png +0 -0
  417. package/assets/pet/whale/schemes/qwen/feat/love_eyeL.png +0 -0
  418. package/assets/pet/whale/schemes/qwen/feat/love_eyeR.png +0 -0
  419. package/assets/pet/whale/schemes/qwen/feat/love_mouth.png +0 -0
  420. package/assets/pet/whale/schemes/qwen/feat/neutral_mouth.png +0 -0
  421. package/assets/pet/whale/schemes/qwen/feat/sleep_eyeL.png +0 -0
  422. package/assets/pet/whale/schemes/qwen/feat/sleep_eyeR.png +0 -0
  423. package/assets/pet/whale/schemes/qwen/feat/sleep_mouth.png +0 -0
  424. package/assets/pet/whale/schemes/qwen/feat/surprised_eyeL.png +0 -0
  425. package/assets/pet/whale/schemes/qwen/feat/surprised_eyeR.png +0 -0
  426. package/assets/pet/whale/schemes/qwen/feat/surprised_mouth.png +0 -0
  427. package/assets/pet/whale/schemes/qwen/tex/ahoge.png +0 -0
  428. package/assets/pet/whale/schemes/qwen/tex/arm_far.png +0 -0
  429. package/assets/pet/whale/schemes/qwen/tex/arm_far_end_front.png +0 -0
  430. package/assets/pet/whale/schemes/qwen/tex/arm_near.png +0 -0
  431. package/assets/pet/whale/schemes/qwen/tex/bangs.png +0 -0
  432. package/assets/pet/whale/schemes/qwen/tex/bow.png +0 -0
  433. package/assets/pet/whale/schemes/qwen/tex/brows.png +0 -0
  434. package/assets/pet/whale/schemes/qwen/tex/crew_hair_back.png +0 -0
  435. package/assets/pet/whale/schemes/qwen/tex/crew_ponytail.png +0 -0
  436. package/assets/pet/whale/schemes/qwen/tex/crew_sidelocks.png +0 -0
  437. package/assets/pet/whale/schemes/qwen/tex/crew_skirt.png +0 -0
  438. package/assets/pet/whale/schemes/qwen/tex/crew_skirt_sit.png +0 -0
  439. package/assets/pet/whale/schemes/qwen/tex/eye_creases.png +0 -0
  440. package/assets/pet/whale/schemes/qwen/tex/face.png +0 -0
  441. package/assets/pet/whale/schemes/qwen/tex/fin_far.png +0 -0
  442. package/assets/pet/whale/schemes/qwen/tex/fin_near.png +0 -0
  443. package/assets/pet/whale/schemes/qwen/tex/hair_back.png +0 -0
  444. package/assets/pet/whale/schemes/qwen/tex/hair_back_curl.png +0 -0
  445. package/assets/pet/whale/schemes/qwen/tex/hair_front_left.png +0 -0
  446. package/assets/pet/whale/schemes/qwen/tex/hair_front_right.png +0 -0
  447. package/assets/pet/whale/schemes/qwen/tex/headdress.png +0 -0
  448. package/assets/pet/whale/schemes/qwen/tex/leg_back.png +0 -0
  449. package/assets/pet/whale/schemes/qwen/tex/leg_front.png +0 -0
  450. package/assets/pet/whale/schemes/qwen/tex/sidelocks.png +0 -0
  451. package/assets/pet/whale/schemes/qwen/tex/skirt.png +0 -0
  452. package/assets/pet/whale/schemes/qwen/tex/skirt_sit.png +0 -0
  453. package/assets/pet/whale/schemes/qwen/tex/tail.png +0 -0
  454. package/assets/pet/whale/schemes/qwen/tex/torso_up.png +0 -0
  455. package/assets/pet/whale/schemes/qwen/tex/waist_bow_front.png +0 -0
  456. package/assets/pet/whale/schemes/qwen/tex/waist_bow_sit_front.png +0 -0
  457. package/assets/pet/whale/tex/ahoge.png +0 -0
  458. package/assets/pet/whale/tex/arm_far.png +0 -0
  459. package/assets/pet/whale/tex/arm_far_end_front.png +0 -0
  460. package/assets/pet/whale/tex/arm_near.png +0 -0
  461. package/assets/pet/whale/tex/bangs.png +0 -0
  462. package/assets/pet/whale/tex/bow.png +0 -0
  463. package/assets/pet/whale/tex/brows.png +0 -0
  464. package/assets/pet/whale/tex/crew_hair_back.png +0 -0
  465. package/assets/pet/whale/tex/crew_ponytail.png +0 -0
  466. package/assets/pet/whale/tex/crew_sidelocks.png +0 -0
  467. package/assets/pet/whale/tex/crew_skirt.png +0 -0
  468. package/assets/pet/whale/tex/crew_skirt_sit.png +0 -0
  469. package/assets/pet/whale/tex/eye_creases.png +0 -0
  470. package/assets/pet/whale/tex/face.png +0 -0
  471. package/assets/pet/whale/tex/fin_far.png +0 -0
  472. package/assets/pet/whale/tex/fin_near.png +0 -0
  473. package/assets/pet/whale/tex/hair_back.png +0 -0
  474. package/assets/pet/whale/tex/hair_back_curl.png +0 -0
  475. package/assets/pet/whale/tex/hair_front_left.png +0 -0
  476. package/assets/pet/whale/tex/hair_front_right.png +0 -0
  477. package/assets/pet/whale/tex/headdress.png +0 -0
  478. package/assets/pet/whale/tex/leg_back.png +0 -0
  479. package/assets/pet/whale/tex/leg_front.png +0 -0
  480. package/assets/pet/whale/tex/sidelocks.png +0 -0
  481. package/assets/pet/whale/tex/skirt.png +0 -0
  482. package/assets/pet/whale/tex/skirt_shadow.png +0 -0
  483. package/assets/pet/whale/tex/skirt_sit.png +0 -0
  484. package/assets/pet/whale/tex/tail.png +0 -0
  485. package/assets/pet/whale/tex/torso_up.png +0 -0
  486. package/assets/pet/whale/tex/waist_bow_front.png +0 -0
  487. package/assets/pet/whale/tex/waist_bow_sit_front.png +0 -0
  488. package/assets/pet/whale/thumbs/cape.png +0 -0
  489. package/assets/pet/whale/thumbs/chatgpt.png +0 -0
  490. package/assets/pet/whale/thumbs/claude.png +0 -0
  491. package/assets/pet/whale/thumbs/crew.png +0 -0
  492. package/assets/pet/whale/thumbs/deepseek.png +0 -0
  493. package/assets/pet/whale/thumbs/gemini.png +0 -0
  494. package/assets/pet/whale/thumbs/harness.png +0 -0
  495. package/assets/pet/whale/thumbs/kimi.png +0 -0
  496. package/assets/pet/whale/thumbs/maid.png +0 -0
  497. package/assets/pet/whale/thumbs/minimax.png +0 -0
  498. package/assets/pet/whale/thumbs/qwen.png +0 -0
  499. package/assets/restart-dsh.cmd +16 -0
  500. package/assets/restart-dsh.log +195 -0
  501. package/client.js +1169 -0
  502. package/cordis.patch.yml +3 -0
  503. package/icon.svg +8 -0
  504. package/index.js +1273 -0
  505. package/locale/en.json +6 -0
  506. package/locale/zh.json +6 -0
  507. package/package.json +50 -4
package/client.js ADDED
@@ -0,0 +1,1169 @@
1
+ /*
2
+ * coo-pet — desktop pet plugin for DeepSeek Harness
3
+ * Copyright (C) 2026 Masterbble
4
+ * Based on the desktop pet Coopanion by Pal-AI-Lab: https://github.com/Pal-AI-Lab/Coopanion
5
+ * SPDX-License-Identifier: AGPL-3.0-or-later (see LICENSE; third-party notices in THIRD_PARTY_NOTICES.md)
6
+ */
7
+ window.__ModuleLoader__.load({
8
+ id: '@masterbble/dsh-coo-pet',
9
+ factory(require) {
10
+ const React = require('react')
11
+ const h = React.createElement
12
+
13
+ const BUILD = '0.6.29'
14
+ const STATE_URL = '/dsh-coo-pet/pulse'
15
+ const SETTINGS_URL = '/dsh-coo-pet/prefs'
16
+ const PET = '/dsh-coo-pet/pet'
17
+
18
+ const FALLBACK = {
19
+ petName: '你的鱼',
20
+ attachSession: '',
21
+ menuOrder: 'open,input,stay,free,duty,actions,look,outfit,clone,none,reset,resetAll,restart',
22
+ actOff: '',
23
+ look: 'deepseek',
24
+ outfit: 'crew',
25
+ size: 190,
26
+ opacity: 1,
27
+ speed: 1.2,
28
+ wander: false,
29
+ answerBubble: true,
30
+ idleBubble: true,
31
+ greet: true,
32
+ display: 'desktop',
33
+ marginBottom: 0,
34
+ voice: true,
35
+ voiceMode: 'babble',
36
+ voiceName: '',
37
+ voiceRate: 1.05,
38
+ voicePitch: 0.9,
39
+ hotkey: 'mouse5',
40
+ hotkeyOn: true,
41
+ sfx: true,
42
+ idleLines: '',
43
+ idleEvery: 20,
44
+ idleUnit: 'sec',
45
+ actIcons: true,
46
+ actSit: true,
47
+ carryEvery: 5,
48
+ carryUnit: 'sec',
49
+ }
50
+
51
+ const SCHEME_LABELS = {
52
+ deepseek: 'DeepSeek 蓝',
53
+ harness: 'Harness 灰',
54
+ chatgpt: 'ChatGPT 白',
55
+ claude: 'Claude 橙',
56
+ gemini: 'Gemini 彩',
57
+ qwen: 'Qwen 紫',
58
+ kimi: 'Kimi 蓝',
59
+ minimax: 'MiniMax 粉',
60
+ }
61
+
62
+ const OUTFIT_LABELS = { maid: '女仆装', cape: '斗篷', crew: '制服' }
63
+
64
+ function idleLinesOf(cfg) {
65
+ const raw = String((cfg && cfg.idleLines) ?? '').trim()
66
+ if (!raw) return []
67
+ const who = String((cfg && cfg.petName) ?? '').trim() || '你的鱼'
68
+ return raw
69
+ .split('\n')
70
+ .map((line) => line.trim().replace(/\{name\}/g, who))
71
+ .filter(Boolean)
72
+ }
73
+
74
+ /* ---------------- 音效(WebAudio 现场合成,不带资源文件) ---------------- */
75
+
76
+
77
+ const styles = `
78
+ .card { background: rgba(20,24,32,0.55); border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; padding: 14px 16px; margin-bottom: 12px; font-family: -apple-system, 'Segoe UI', 'Microsoft YaHei', 'PingFang SC', sans-serif; font-size: 13px; }
79
+ .card .sub { font-size: 13px; font-weight: 600; margin-bottom: 8px; opacity: .9; letter-spacing: .02em; }
80
+ .card .grid { display: flex; flex-wrap: wrap; gap: 8px; }
81
+ .card .preview { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
82
+ .card .preview img { width: 56px; height: 56px; object-fit: contain; border-radius: 10px; }
83
+ .card .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; justify-content: space-between; }
84
+ .card .row > label { font-size: 13px; opacity: .8; }
85
+ .card .hint { font-size: 12px; opacity: .55; line-height: 1.6; margin-top: 6px; }
86
+ .card .switch { position: relative; flex: none; width: 38px; height: 20px; border-radius: 10px; background: rgba(255,255,255,0.18); cursor: pointer; transition: background .15s; }
87
+ .card .switch::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,0.3); transition: left .15s; }
88
+ .card .switch.on { background: #34c759; }
89
+ .card .switch.on::after { left: 20px; }
90
+ .card .switch.disabled { cursor: default; }
91
+ .card input[type=text], .card input[type=number], .card select, .card textarea {
92
+ background: rgba(0,0,0,0.28); color: inherit; border: 1px solid rgba(255,255,255,0.14);
93
+ border-radius: 8px; padding: 5px 8px; font-size: 13px; min-width: 120px;
94
+ }
95
+ .card textarea { width: 100%; min-height: 60px; resize: vertical; }
96
+ .card input[type=range] { width: 160px; }
97
+ .card button { background: rgba(255,255,255,0.1); color: inherit; border: 1px solid rgba(255,255,255,0.14); border-radius: 8px; padding: 4px 10px; font-size: 12px; cursor: pointer; }
98
+ .card button:hover { background: rgba(255,255,255,0.16); }
99
+ .card button.primary { background: #2f6bff; border-color: #2f6bff; color: #fff; }
100
+ .card .mini { padding: 2px 7px; font-size: 12px; line-height: 1.4; }
101
+ .card .gallery { display: flex; flex-wrap: wrap; gap: 10px; }
102
+ .card .look { width: 78px; text-align: center; cursor: pointer; border-radius: 10px; padding: 6px 4px; border: 1px solid transparent; }
103
+ .card .look.on, .card .look[data-active='1'] { border-color: #2f6bff; background: rgba(47,107,255,0.12); }
104
+ .card .look img { width: 64px; height: 64px; object-fit: contain; display: block; margin: 0 auto 4px; }
105
+ .card .look span { font-size: 11px; opacity: .75; }
106
+ .card .pill { font-size: 11px; opacity: .6; margin-left: 8px; }
107
+ .card .line-row { display: flex; gap: 6px; align-items: center; margin: 6px 0; }
108
+ .card .line-row input[type=text] { flex: 1; }
109
+ .card .foot { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
110
+ `
111
+ function schemeOf(cfg) {
112
+ return `${cfg.look}-${cfg.outfit}`
113
+ }
114
+
115
+ function thumbOf(kind, id) {
116
+ return `${PET}/asset?p=${encodeURIComponent(`whale/thumbs/${id}.png`)}`
117
+ }
118
+
119
+ function reportTo(status, payload) {
120
+ try {
121
+ fetch('/dsh-coo-pet/report', {
122
+ method: 'POST',
123
+ headers: { 'content-type': 'application/json' },
124
+ credentials: 'same-origin',
125
+ body: JSON.stringify({ status, ...payload }),
126
+ }).catch(() => {})
127
+ } catch {
128
+ /* ignore */
129
+ }
130
+ }
131
+
132
+ // 页面跑在 dsh-app:// 私有协议里,跨源请求得用宿主报的 http 源
133
+ const petBase = { value: '' }
134
+ let lastCfg = null
135
+ // 未点「保存」的暂存改动:轮询拉到服务器配置时叠在上面,界面不被 2 秒轮询冲掉
136
+ const pendingOverlay = { current: {} }
137
+ function useSettings() {
138
+ const [base, setBase] = React.useState('')
139
+ const [cfg, setCfg] = React.useState(FALLBACK)
140
+ const [ready, setReady] = React.useState(false)
141
+ const readyRef = React.useRef(false)
142
+ const cfgRef = React.useRef(cfg)
143
+ cfgRef.current = cfg
144
+ lastCfg = cfg
145
+ React.useEffect(() => {
146
+ let alive = true
147
+ let timer = 0
148
+ const apply = (config) => {
149
+ if (!alive || !config) return
150
+ const merged = Object.keys(pendingOverlay.current).length ? { ...config, ...pendingOverlay.current } : config
151
+ setCfg((prev) => (JSON.stringify(prev) === JSON.stringify(merged) ? prev : merged))
152
+ }
153
+ const pull = async () => {
154
+ try {
155
+ const res = await fetch(SETTINGS_URL, { credentials: 'same-origin' })
156
+ if (res.ok) {
157
+ const body = await res.json()
158
+ if (alive && body && body.config) {
159
+ if (typeof body.base === 'string' && body.base !== '') {
160
+ petBase.value = body.base
161
+ setBase((prev) => (prev === body.base ? prev : body.base))
162
+ }
163
+ apply(body.config)
164
+ // 首次读到服务器配置:标记「配置就绪」,没就绪前禁止写回(防止把默认值当用户改动存脏)
165
+ if (!readyRef.current) {
166
+ readyRef.current = true
167
+ setReady(true)
168
+ }
169
+ }
170
+ }
171
+ } catch {
172
+ /* ignore */
173
+ }
174
+ if (alive) timer = window.setTimeout(pull, 2000)
175
+ }
176
+ const onLocal = (event) => apply(event && event.detail)
177
+ const onStorage = (event) => {
178
+ if (event && event.key === 'dsh-coo-pet:cfg' && event.newValue) {
179
+ try {
180
+ apply(JSON.parse(event.newValue))
181
+ } catch {
182
+ /* ignore */
183
+ }
184
+ }
185
+ }
186
+ window.addEventListener('dsh-coo-pet:cfg', onLocal)
187
+ window.addEventListener('storage', onStorage)
188
+ pull()
189
+ return () => {
190
+ alive = false
191
+ window.clearTimeout(timer)
192
+ window.removeEventListener('dsh-coo-pet:cfg', onLocal)
193
+ window.removeEventListener('storage', onStorage)
194
+ }
195
+ }, [])
196
+ const save = React.useCallback(async (patch, clearKeys) => {
197
+ // 防脏写闸门:从没成功读到服务器配置前(界面是默认值兜底),禁止把任何改动写回
198
+ if (!readyRef.current) {
199
+ console.warn('[coo-pet] save blocked: server config not loaded yet')
200
+ return
201
+ }
202
+ const optimistic = { ...cfgRef.current, ...patch }
203
+ setCfg(optimistic)
204
+ // 通知同页面的其它实例(设置页保存 → 桌宠立刻变),也通知别的窗口
205
+ try {
206
+ window.dispatchEvent(new CustomEvent('dsh-coo-pet:cfg', { detail: optimistic }))
207
+ window.localStorage.setItem('dsh-coo-pet:cfg', JSON.stringify(optimistic))
208
+ } catch {
209
+ /* ignore */
210
+ }
211
+ try {
212
+ const res = await fetch(SETTINGS_URL, {
213
+ method: 'POST',
214
+ headers: { 'content-type': 'application/json' },
215
+ credentials: 'same-origin',
216
+ body: JSON.stringify(patch),
217
+ })
218
+ if (res.ok) {
219
+ const body = await res.json()
220
+ if (body && body.config) {
221
+ // 服务器确认落盘了,才清掉这次提交的暂存键;失败则留着,界面不回退、可重试
222
+ if (Array.isArray(clearKeys) && clearKeys.length) {
223
+ const nextOverlay = { ...pendingOverlay.current }
224
+ for (const k of clearKeys) delete nextOverlay[k]
225
+ pendingOverlay.current = nextOverlay
226
+ }
227
+ const merged = Object.keys(pendingOverlay.current).length ? { ...body.config, ...pendingOverlay.current } : body.config
228
+ setCfg(merged)
229
+ try {
230
+ window.dispatchEvent(new CustomEvent('dsh-coo-pet:cfg', { detail: body.config }))
231
+ window.localStorage.setItem('dsh-coo-pet:cfg', JSON.stringify(body.config))
232
+ } catch {
233
+ /* ignore */
234
+ }
235
+ }
236
+ }
237
+ } catch {
238
+ /* ignore */
239
+ }
240
+ }, [])
241
+ return [cfg, save, base, ready]
242
+ }
243
+ function Slider({ label, value, min, max, step, suffix, onChange }) {
244
+ return h(
245
+ 'div',
246
+ { className: 'row' },
247
+ h('label', null, label),
248
+ h('input', {
249
+ type: 'range',
250
+ min,
251
+ max,
252
+ step,
253
+ value,
254
+ onChange: (event) => onChange(Number(event.target.value)),
255
+ }),
256
+ h('span', { className: 'val' }, `${value}${suffix ?? ''}`)
257
+ )
258
+ }
259
+
260
+ function Toggle({ label, checked, onChange, disabled }) {
261
+ // 扁长腰圆滑块:开时底色变绿、圆点靠右;点一下即切换
262
+ return h(
263
+ 'div',
264
+ { className: 'row', style: disabled ? { opacity: 0.45 } : undefined },
265
+ h('label', null, label),
266
+ h('div', {
267
+ className: 'switch' + (checked ? ' on' : '') + (disabled ? ' disabled' : ''),
268
+ role: 'switch',
269
+ 'aria-checked': !!checked,
270
+ title: checked ? '开着,点一下关' : '关着,点一下开',
271
+ onClick: () => {
272
+ if (disabled) return
273
+ onChange(!checked)
274
+ },
275
+ })
276
+ )
277
+ }
278
+
279
+ function parseHotkey(spec) {
280
+ const text = String(spec || '').trim()
281
+ if (!text) return null
282
+ const parts = text.split('+').map((part) => part.trim()).filter(Boolean)
283
+ if (parts.length === 0) return null
284
+ const out = { alt: false, ctrl: false, shift: false, meta: false, key: '' }
285
+ for (const part of parts) {
286
+ const low = part.toLowerCase()
287
+ if (low === 'alt' || low === 'option') out.alt = true
288
+ else if (low === 'ctrl' || low === 'control') out.ctrl = true
289
+ else if (low === 'shift') out.shift = true
290
+ else if (low === 'cmd' || low === 'meta' || low === 'win') out.meta = true
291
+ else out.key = part.length === 1 ? low : low
292
+ }
293
+ if (!out.key) return null
294
+ return out
295
+ }
296
+
297
+ function matchHotkey(event, spec) {
298
+ const parsed = parseHotkey(spec)
299
+ if (!parsed) return false
300
+ if (Boolean(event.altKey) !== parsed.alt) return false
301
+ if (Boolean(event.ctrlKey) !== parsed.ctrl) return false
302
+ if (Boolean(event.shiftKey) !== parsed.shift) return false
303
+ if (Boolean(event.metaKey) !== parsed.meta) return false
304
+ const code = String(event.key || '').toLowerCase()
305
+ const wanted = parsed.key
306
+ if (code === wanted) return true
307
+ if (wanted === 'space' && code === ' ') return true
308
+ if (/^f\d{1,2}$/.test(wanted) && code === wanted) return true
309
+ return false
310
+ }
311
+
312
+ /* 系统语音列表:0.6.1 重写时漏了这两个定义,设置页一渲染就 ReferenceError(白屏元凶) */
313
+ function refreshVoices() {
314
+ try {
315
+ const synth = window.speechSynthesis
316
+ if (!synth) return []
317
+ const got = synth.getVoices()
318
+ return got && got.length ? [...got] : []
319
+ } catch {
320
+ return []
321
+ }
322
+ }
323
+ function hookVoices(cb) {
324
+ try {
325
+ const synth = window.speechSynthesis
326
+ if (!synth || !synth.addEventListener) return () => {}
327
+ const onChange = () => {
328
+ try { cb(refreshVoices()) } catch { /* ignore */ }
329
+ }
330
+ synth.addEventListener('voiceschanged', onChange)
331
+ // 立刻给一次:voiceschanged 只在列表变化时触发,首次可能已经就绪
332
+ onChange()
333
+ return () => {
334
+ try { synth.removeEventListener('voiceschanged', onChange) } catch { /* ignore */ }
335
+ }
336
+ } catch {
337
+ return () => {}
338
+ }
339
+ }
340
+
341
+ function hotkeyFromEvent(event) {
342
+ const key = String(event.key || '')
343
+ if (!key || key === 'Control' || key === 'Alt' || key === 'Shift' || key === 'Meta') return ''
344
+ const parts = []
345
+ if (event.ctrlKey) parts.push('Ctrl')
346
+ if (event.altKey) parts.push('Alt')
347
+ if (event.shiftKey) parts.push('Shift')
348
+ if (event.metaKey) parts.push('Meta')
349
+ const named = key === ' ' ? 'Space' : key.length === 1 ? key.toUpperCase() : key
350
+ parts.push(named)
351
+ return parts.join('+')
352
+ }
353
+
354
+ function CooSettingsInner() {
355
+ const [cfg, saveServer, base, cfgReady] = useSettings()
356
+ const [meta, setMeta] = React.useState({ looks: [], outfits: [], defaults: null })
357
+ const [saved, setSaved] = React.useState('')
358
+ const [voiceList, setVoiceList] = React.useState(() => refreshVoices())
359
+ const [recHotkey, setRecHotkey] = React.useState(false)
360
+ const [pending, setPending] = React.useState({})
361
+ const [dragIdx, setDragIdx] = React.useState(-1)
362
+ const pendingRef = React.useRef(pending)
363
+ pendingRef.current = pending
364
+ const deskMode = cfg.display !== 'none'
365
+
366
+ // 暂存:界面立刻变(轮询用 overlay 兜住不回退),点卡片「保存」才写回服务器并同步桌宠
367
+ const save = (patch) => {
368
+ pendingOverlay.current = { ...pendingOverlay.current, ...patch }
369
+ // 同步更新 ref,不等渲染:快速点「保存」时 commitCard 才不会拿到旧值
370
+ pendingRef.current = { ...pendingRef.current, ...patch }
371
+ try {
372
+ window.dispatchEvent(new CustomEvent('dsh-coo-pet:cfg', { detail: { ...cfg, ...patch } }))
373
+ } catch {
374
+ /* ignore */
375
+ }
376
+ setPending(pendingRef.current)
377
+ }
378
+ // 把某张卡暂存的项写回服务器(独立保存,其他卡不受影响)
379
+ // overlay 里的键等 POST 成功后才清掉:期间轮询拿到旧配置也不会把界面打回去
380
+ const commitCard = (keys) => {
381
+ const list = keys || []
382
+ const patch = {}
383
+ for (const k of list) {
384
+ if (Object.prototype.hasOwnProperty.call(pendingRef.current, k)) patch[k] = pendingRef.current[k]
385
+ }
386
+ const ks = Object.keys(patch)
387
+ if (!ks.length) {
388
+ flash('这张卡没有要保存的改动')
389
+ return
390
+ }
391
+ const nextPending = { ...pendingRef.current }
392
+ for (const k of ks) delete nextPending[k]
393
+ pendingRef.current = nextPending
394
+ setPending(nextPending)
395
+ saveServer(patch, ks)
396
+ flash(`已保存 ${ks.length} 项,同步到桌宠`)
397
+ }
398
+ // 下拉列表拖拽排序:按住把手上下拖,拖到哪行就排到哪(暂存,点「保存」生效)
399
+ // 用 window 级指针监听,不依赖元素上的 capture:重排行会移动 DOM 节点,capture 会被打断导致只能拖一格
400
+ const dragFrom = React.useRef(-1)
401
+ const rowEls = React.useRef({})
402
+ const menuIdsRef = React.useRef([])
403
+ const reorderMenu = (from, to) => {
404
+ const cur = menuIdsRef.current
405
+ if (from < 0 || to < 0 || from === to || to >= cur.length) return
406
+ const next = cur.slice()
407
+ const [it] = next.splice(from, 1)
408
+ next.splice(to, 0, it)
409
+ menuIdsRef.current = next // 立即更新,拖动过程中连续换位不丢帧
410
+ save({ menuOrder: next.join(',') })
411
+ dragFrom.current = to
412
+ setDragIdx(to)
413
+ }
414
+ const beginMenuDrag = (index) => {
415
+ dragFrom.current = index
416
+ setDragIdx(index)
417
+ const onMove = (ev) => {
418
+ const from = dragFrom.current
419
+ if (from < 0) return
420
+ const y = ev.clientY
421
+ const ids = menuIdsRef.current
422
+ let hit = -1
423
+ for (let i = 0; i < ids.length; i++) {
424
+ const el = rowEls.current[ids[i]]
425
+ if (!el) continue
426
+ const r = el.getBoundingClientRect()
427
+ if (y >= r.top - 2 && y <= r.bottom + 2) {
428
+ hit = i
429
+ break
430
+ }
431
+ }
432
+ if (hit < 0) {
433
+ // 指针落在行间隙里:取中心最近的行
434
+ let best = Infinity
435
+ for (let i = 0; i < ids.length; i++) {
436
+ const el = rowEls.current[ids[i]]
437
+ if (!el) continue
438
+ const r = el.getBoundingClientRect()
439
+ const d = Math.abs((r.top + r.bottom) / 2 - y)
440
+ if (d < best) {
441
+ best = d
442
+ hit = i
443
+ }
444
+ }
445
+ }
446
+ if (hit >= 0 && hit !== from) reorderMenu(from, hit)
447
+ }
448
+ const onUp = () => {
449
+ dragFrom.current = -1
450
+ setDragIdx(-1)
451
+ window.removeEventListener('pointermove', onMove)
452
+ window.removeEventListener('pointerup', onUp)
453
+ window.removeEventListener('pointercancel', onUp)
454
+ }
455
+ window.addEventListener('pointermove', onMove)
456
+ window.addEventListener('pointerup', onUp)
457
+ window.addEventListener('pointercancel', onUp)
458
+ }
459
+
460
+ React.useEffect(() => {
461
+ reportTo('settings-ui', { build: BUILD, cards: 8 })
462
+ }, [])
463
+
464
+ React.useEffect(() => {
465
+ if (!recHotkey) return undefined
466
+ // 键盘:直接采组合键;鼠标:中键/侧键也收(DOM 键值 → 插件的 mouse3/4/5)
467
+ const mouseName = (button) => (button === 1 ? 'mouse3' : button === 3 ? 'mouse4' : button === 4 ? 'mouse5' : null)
468
+ const onKey = (event) => {
469
+ event.preventDefault()
470
+ event.stopPropagation()
471
+ if (event.key === 'Escape') {
472
+ setRecHotkey(false)
473
+ return
474
+ }
475
+ const spec = hotkeyFromEvent(event)
476
+ if (!spec) return
477
+ save({ hotkey: spec })
478
+ setRecHotkey(false)
479
+ flash(`快捷键改成 ${spec}`)
480
+ }
481
+ const onMouse = (event) => {
482
+ event.preventDefault()
483
+ event.stopPropagation()
484
+ const spec = mouseName(event.button)
485
+ if (!spec) return
486
+ save({ hotkey: spec })
487
+ setRecHotkey(false)
488
+ const zh = { mouse3: '鼠标中键', mouse4: '鼠标后退键', mouse5: '鼠标前进键' }
489
+ flash(`快捷键改成 ${zh[spec]}`)
490
+ }
491
+ window.addEventListener('keydown', onKey, true)
492
+ window.addEventListener('mousedown', onMouse, true)
493
+ window.addEventListener('auxclick', onMouse, true)
494
+ return () => {
495
+ window.removeEventListener('keydown', onKey, true)
496
+ window.removeEventListener('mousedown', onMouse, true)
497
+ window.removeEventListener('auxclick', onMouse, true)
498
+ }
499
+ }, [recHotkey])
500
+
501
+ React.useEffect(() => {
502
+ let alive = true
503
+ fetch(SETTINGS_URL, { credentials: 'same-origin' })
504
+ .then((res) => (res.ok ? res.json() : null))
505
+ .then((body) => {
506
+ if (alive && body) setMeta({ looks: body.looks ?? [], outfits: body.outfits ?? [], defaults: body.defaults ?? null })
507
+ })
508
+ .catch(() => {})
509
+ return () => {
510
+ alive = false
511
+ }
512
+ }, [])
513
+
514
+ React.useEffect(() => {
515
+ hookVoices((list) => setVoiceList([...list]))
516
+ }, [])
517
+
518
+ const flash = (text) => {
519
+ setSaved(text)
520
+ window.setTimeout(() => setSaved(''), 1600)
521
+ }
522
+
523
+ const openExternal = (target) => {
524
+ fetch(`${meta.base || ''}/dsh-coo-pet/open`, {
525
+ method: 'POST',
526
+ headers: { 'content-type': 'application/json' },
527
+ body: JSON.stringify({ target }),
528
+ }).catch(() => {})
529
+ }
530
+
531
+ const pushSay = (text, mode) => {
532
+ const body = JSON.stringify({ text: String(text || ''), mode: mode || '' })
533
+ fetch(`${petBase.value}/dsh-coo-pet/say`, {
534
+ method: 'POST',
535
+ headers: { 'content-type': 'application/json; charset=utf-8' },
536
+ body,
537
+ }).catch(() => {})
538
+ }
539
+
540
+ const defaults = meta.defaults || FALLBACK
541
+
542
+ const cardFooter = (resetKeys) => {
543
+ const keys = resetKeys || []
544
+ const dirty = keys.filter((k) => Object.prototype.hasOwnProperty.call(pending, k))
545
+ return h(
546
+ 'div',
547
+ { className: 'row', style: { marginTop: 8 } },
548
+ h(
549
+ 'button',
550
+ {
551
+ className: dirty.length ? 'primary' : '',
552
+ onClick: () => commitCard(keys),
553
+ },
554
+ dirty.length ? `保存(${dirty.length} 项未保存)` : '保存'
555
+ ),
556
+ resetKeys && resetKeys.length
557
+ ? h(
558
+ 'button',
559
+ {
560
+ onClick: () => {
561
+ const patch = {}
562
+ for (const k of keys) patch[k] = defaults[k]
563
+ // 恢复初始是明确动作:直接写服务器并清掉这些键的暂存
564
+ const nextOverlay = { ...pendingOverlay.current }
565
+ const nextPending = { ...pendingRef.current }
566
+ for (const k of keys) {
567
+ delete nextOverlay[k]
568
+ delete nextPending[k]
569
+ }
570
+ pendingOverlay.current = nextOverlay
571
+ pendingRef.current = nextPending
572
+ setPending(nextPending)
573
+ saveServer(patch)
574
+ flash('这页恢复初始了,已同步到桌宠')
575
+ },
576
+ },
577
+ '恢复初始'
578
+ )
579
+ : null,
580
+ h('span', { className: 'hint' }, '改动先暂存,点「保存」写回并同步到桌宠'),
581
+ saved ? h('span', { className: 'pill' }, saved) : null
582
+ )
583
+ }
584
+
585
+ const card = (resetKeys, ...kids) => h('div', { className: 'card' }, ...kids, cardFooter(resetKeys))
586
+
587
+ /* 碎碎念:一条一项,可编辑 / 上下移 / 删除 */
588
+ const linesOf = (text) =>
589
+ String(text || '')
590
+ .split('\n')
591
+ .map((s) => s.trim())
592
+ .filter(Boolean)
593
+ const lineList = linesOf(cfg.idleLines)
594
+ const setLineList = (arr) => save({ idleLines: arr.join('\n') })
595
+ const editLine = (index, text) => {
596
+ const next = lineList.slice()
597
+ next[index] = text
598
+ setLineList(next.filter((s) => String(s || '').trim() !== ''))
599
+ }
600
+ const moveLine = (index, delta) => {
601
+ const next = lineList.slice()
602
+ const to = index + delta
603
+ if (to < 0 || to >= next.length) return
604
+ const tmp = next[index]
605
+ next[index] = next[to]
606
+ next[to] = tmp
607
+ setLineList(next)
608
+ }
609
+ const delLine = (index) => {
610
+ const next = lineList.slice()
611
+ next.splice(index, 1)
612
+ setLineList(next)
613
+ }
614
+ const addLine = () => setLineList([...lineList, '新的一句碎碎念'])
615
+
616
+ /* 下拉列表:顺序可调(拖拽排序,不提供删除——12 项固定全在,只排序) */
617
+ const MENU_LABELS = {
618
+ open: '打开DSH',
619
+ input: '输入…',
620
+ restart: '重启DSH',
621
+ reset: '图标复位',
622
+ resetAll: '一键全复位',
623
+ clone: '影分身',
624
+ stay: '原地待着',
625
+ free: '自由活动',
626
+ duty: '安静模式',
627
+ actions: '特殊动作',
628
+ look: '换形象',
629
+ outfit: '换衣服',
630
+ none: '藏起来',
631
+ }
632
+ const menuIds = String(cfg.menuOrder || 'open,input,restart,reset,resetAll,stay,free,duty,actions,look,outfit,clone,none')
633
+ .split(',')
634
+ .map((s) => s.trim())
635
+ .filter((id) => Object.hasOwn(MENU_LABELS, id))
636
+ // 新功能项补位:老自定义排序里没有的新项,插到「藏起来」前面(和桌宠侧同一套规则)
637
+ for (const nid of ['resetAll', 'clone']) {
638
+ if (!menuIds.includes(nid)) {
639
+ const i = menuIds.indexOf('none')
640
+ if (i >= 0) menuIds.splice(i, 0, nid)
641
+ else menuIds.push(nid)
642
+ }
643
+ }
644
+ menuIdsRef.current = menuIds
645
+
646
+ /* 动作一览已删;「试一下」保留给图标复位按钮用 */
647
+ const tryAct = (id) => {
648
+ window.dispatchEvent(new CustomEvent('dsh-coo-pet:act', { detail: { act: id } }))
649
+ try {
650
+ fetch(`${petBase.value}/dsh-coo-pet/act`, {
651
+ method: 'POST',
652
+ headers: { 'content-type': 'application/json' },
653
+ body: JSON.stringify({ act: id }),
654
+ }).catch(() => {})
655
+ } catch {
656
+ /* ignore */
657
+ }
658
+ }
659
+
660
+ const rowBtn = (label, onClick, key) =>
661
+ h('button', { key: key || label, type: 'button', className: 'mini', onClick }, label)
662
+
663
+ const looks = meta.looks.length > 0 ? meta.looks : Object.keys(SCHEME_LABELS).map((id) => ({ id, label: SCHEME_LABELS[id] }))
664
+ const outfits = meta.outfits.length > 0 ? meta.outfits : Object.keys(OUTFIT_LABELS).map((id) => ({ id, label: OUTFIT_LABELS[id] }))
665
+
666
+ const zhVoices = voiceList.filter((v) => /^(zh|cmn)/i.test(v.lang))
667
+ const otherVoices = voiceList.filter((v) => !/^(zh|cmn)/i.test(v.lang))
668
+
669
+ return h(
670
+ 'div',
671
+ { className: 'coo-set' },
672
+ h('style', null, styles),
673
+ !cfgReady
674
+ ? h(
675
+ 'div',
676
+ { className: 'card', style: { borderColor: '#dc2626' } },
677
+ h('div', { className: 'sub', style: { color: '#dc2626' } }, '⚠ 还没连上设置服务器'),
678
+ h('div', { className: 'hint' }, '下面显示的是默认值兜底,不是你的真实配置;编辑和保存已暂时锁定,等连接成功(或刷新页面)后再改')
679
+ )
680
+ : null,
681
+ h('h2', null, cfg.petName || '你的鱼'),
682
+
683
+ card(
684
+ ['petName', 'size', 'opacity', 'speed', 'answerBubble', 'idleBubble', 'look', 'outfit', 'display'],
685
+ h(
686
+ 'div',
687
+ { className: 'row' },
688
+ h('label', null, '姓名'),
689
+ h('input', {
690
+ key: 'pet-name',
691
+ value: cfg.petName || '',
692
+ placeholder: '你的鱼',
693
+ maxLength: 20,
694
+ style: { width: '160px' },
695
+ onChange: (event) => save({ petName: event.target.value }),
696
+ })
697
+ ),
698
+
699
+ h(Slider, { label: '大小', value: cfg.size, min: 64, max: 420, step: 2, suffix: 'px', onChange: (v) => save({ size: v }) }),
700
+ h(Slider, { label: '透明度', value: Math.round(cfg.opacity * 100), min: 20, max: 100, step: 5, suffix: '%', onChange: (v) => save({ opacity: v / 100 }) }),
701
+ h(Slider, { label: '动作速度', value: cfg.speed, min: 0.2, max: 3, step: 0.1, suffix: '×', onChange: (v) => save({ speed: v }) }),
702
+
703
+ h('div', { className: 'sub' }, '换装'),
704
+ h('div', { className: 'preview' },
705
+ h('img', { src: thumbOf('look', cfg.look), alt: '' }),
706
+ h('div', null,
707
+ h('div', { style: { fontSize: 13, fontWeight: 600 } },
708
+ `鲸鱼娘 · ${SCHEME_LABELS[cfg.look] ?? cfg.look} · ${OUTFIT_LABELS[cfg.outfit] ?? cfg.outfit}`),
709
+ h('div', { className: 'hint' }, `大小 ${cfg.size}px · 透明度 ${Math.round(cfg.opacity * 100)}% · 速度 ×${cfg.speed}`),
710
+ saved ? h('span', { className: 'pill' }, saved) : null
711
+ )
712
+ ),
713
+ h('div', { className: 'sub' }, '会动的鲸鱼娘'),
714
+ h(
715
+ 'div',
716
+ { className: 'grid' },
717
+ looks.map((look) =>
718
+ h(
719
+ 'div',
720
+ {
721
+ key: look.id,
722
+ className: 'look',
723
+ 'data-active': cfg.look === look.id ? '1' : '0',
724
+ onClick: () => {
725
+ save({ look: look.id })
726
+ flash('已切换')
727
+ },
728
+ },
729
+ h('img', { src: look.thumb ?? thumbOf('look', look.id), alt: '' }),
730
+ h('span', null, look.label)
731
+ )
732
+ )
733
+ ),
734
+ h('div', { className: 'sub' }, '衣服'),
735
+ h(
736
+ 'div',
737
+ { className: 'grid' },
738
+ outfits.map((outfit) =>
739
+ h(
740
+ 'div',
741
+ {
742
+ key: outfit.id,
743
+ className: 'look',
744
+ 'data-active': cfg.outfit === outfit.id ? '1' : '0',
745
+ onClick: () => {
746
+ save({ outfit: outfit.id })
747
+ flash('已换衣服')
748
+ },
749
+ },
750
+ h('img', { src: outfit.thumb ?? thumbOf('outfit', outfit.id), alt: '' }),
751
+ h('span', null, outfit.label)
752
+ )
753
+ )
754
+ ),
755
+ h(
756
+ 'div',
757
+ { className: 'row' },
758
+ h('label', null, '显示'),
759
+ h(
760
+ 'select',
761
+ {
762
+ value: cfg.display === 'none' ? 'none' : 'desktop',
763
+ onChange: (event) => save({ display: event.target.value }),
764
+ },
765
+ h('option', { value: 'desktop' }, '在桌面显示'),
766
+ h('option', { value: 'none' }, '藏起来')
767
+ )
768
+ ),
769
+ h(Toggle, { label: '回答气泡', checked: cfg.answerBubble !== false, onChange: (v) => save({ answerBubble: v }) }),
770
+ h(Toggle, { label: '碎碎念气泡', checked: cfg.idleBubble !== false, onChange: (v) => save({ idleBubble: v }) }),
771
+ ),
772
+
773
+ card(
774
+ ['attachSession'],
775
+ h(
776
+ 'div',
777
+ { className: 'row' },
778
+ h('label', null, '插入会话'),
779
+ h('input', {
780
+ key: 'attach-session',
781
+ value: cfg.attachSession || '',
782
+ placeholder: '填SessionID(留空跟当前会话)',
783
+ maxLength: 200,
784
+ style: { width: '220px' },
785
+ onChange: (event) => save({ attachSession: event.target.value }),
786
+ })
787
+ ),
788
+ h('div', { className: 'hint' }, '填了之后,桌宠对话框和语音输入都发进这个会话,回答显示在她的气泡里并朗读')
789
+ ),
790
+
791
+ card(
792
+ ['hotkeyOn', 'hotkey', 'voice', 'voiceMode', 'voiceName', 'voiceRate', 'voicePitch', 'sfx'],
793
+ h('div', { className: 'sub' }, '语音设置'),
794
+ h(Toggle, { label: '说话出声', checked: cfg.voice, onChange: (v) => save({ voice: v }) }),
795
+ h(
796
+ 'div',
797
+ { className: 'row' },
798
+ h('label', null, '声音'),
799
+ h(
800
+ 'select',
801
+ {
802
+ value: cfg.voiceMode ?? 'babble',
803
+ onChange: (event) => {
804
+ const mode = event.target.value
805
+ save({ voiceMode: mode })
806
+ if (mode === 'tts') pushSay('这样说话能听懂吧', 'tts')
807
+ else pushSay('咱是这样说话的哦', 'babble')
808
+ flash('声音已换')
809
+ },
810
+ },
811
+ h('option', { value: 'babble' }, '咿呀声(内置音库)'),
812
+ h('option', { value: 'tts' }, '系统朗读(能听懂)')
813
+ )
814
+ ),
815
+ h(
816
+ 'div',
817
+ { className: 'row' },
818
+ h('label', null, '音色'),
819
+ h(
820
+ 'select',
821
+ {
822
+ value: cfg.voiceName,
823
+ onChange: (event) => {
824
+ save({ voiceName: event.target.value })
825
+ flash('音色已换')
826
+ },
827
+ },
828
+ h('option', { value: '' }, '自动(优先中文女声)'),
829
+ zhVoices.length
830
+ ? h('optgroup', { label: '中文' }, zhVoices.map((v) => h('option', { key: v.name, value: v.name }, `${v.name}`)))
831
+ : null,
832
+ otherVoices.length
833
+ ? h('optgroup', { label: '其它语言' }, otherVoices.map((v) => h('option', { key: v.name, value: v.name }, `${v.name}(${v.lang})`)))
834
+ : null
835
+ )
836
+ ),
837
+ h(Slider, { label: '语速', value: cfg.voiceRate, min: 0.5, max: 2, step: 0.05, suffix: '×', onChange: (v) => save({ voiceRate: v }) }),
838
+ h(Slider, { label: '音调', value: cfg.voicePitch, min: 0.5, max: 2, step: 0.05, suffix: '', onChange: (v) => save({ voicePitch: v }) }),
839
+ h(Toggle, { label: '音效', checked: cfg.sfx !== false, onChange: (v) => save({ sfx: v }) }),
840
+
841
+ h(Toggle, { label: '启用快捷键', checked: cfg.hotkeyOn, onChange: (v) => save({ hotkeyOn: v }) }),
842
+ h(
843
+ 'div',
844
+ { className: 'row' },
845
+ h('label', null, '按键'),
846
+ h(
847
+ 'button',
848
+ {
849
+ className: recHotkey ? 'primary' : '',
850
+ onClick: () => setRecHotkey((on) => !on),
851
+ },
852
+ recHotkey ? '按哪个键就用哪个…(Esc 取消)' : `${cfg.hotkey || '(没设)'} 修改`
853
+ ),
854
+ h(
855
+ 'button',
856
+ {
857
+ onClick: () => {
858
+ save({ hotkey: '' })
859
+ flash('快捷键清掉了')
860
+ },
861
+ },
862
+ '清除'
863
+ )
864
+ ),
865
+ h('div', { className: 'hint' }, '点「修改」后按哪个键就定哪个键:键盘任意单键或组合键、鼠标中键/侧键都行。键盘按一下开麦再按一下闭麦;鼠标键按住说话松开结束。')
866
+ ),
867
+
868
+ card(
869
+ ['wander', 'actIcons', 'actSit', 'carryEvery', 'carryUnit'],
870
+ h('div', { className: 'sub' }, '动作'),
871
+ deskMode ? null : h('div', { className: 'hint' }, '先把「显示」切成「在桌面显示」,这里才生效'),
872
+ h(Toggle, {
873
+ label: '溜达',
874
+ checked: cfg.wander === true,
875
+ disabled: !deskMode,
876
+ onChange: (v) => save({ wander: v }),
877
+ }),
878
+ h(Toggle, {
879
+ label: '搬运图标',
880
+ checked: cfg.actIcons === true,
881
+ disabled: !deskMode || cfg.display !== 'desktop',
882
+ onChange: (v) => save({ actIcons: v }),
883
+ }),
884
+ h('div', { className: 'hint' }, '搬运图标:桌面无窗口时(包括最小化)她会随意搬运你桌面的图标'),
885
+ h(
886
+ 'div',
887
+ { className: 'row', style: { alignItems: 'center' } },
888
+ h('label', null, '搬运间隔'),
889
+ h('input', {
890
+ type: 'number',
891
+ min: 0,
892
+ max: 720,
893
+ value: cfg.carryEvery ?? 0,
894
+ style: { width: '76px' },
895
+ onChange: (event) => save({ carryEvery: Math.max(0, Math.round(Number(event.target.value) || 0)) }),
896
+ }),
897
+ h(
898
+ 'select',
899
+ {
900
+ value: cfg.carryUnit === 'sec' ? 'sec' : 'min',
901
+ onChange: (event) => save({ carryUnit: event.target.value === 'sec' ? 'sec' : 'min' }),
902
+ },
903
+ h('option', { value: 'min' }, '分钟'),
904
+ h('option', { value: 'sec' }, '秒')
905
+ )
906
+ ),
907
+ h('div', { className: 'hint' }, '搬运间隔:两次搬图标之间至少隔这么久;填 0 = 不限制'),
908
+ h(
909
+ 'div',
910
+ { className: 'row', key: 'reset-pet', style: { alignItems: 'center' } },
911
+ h('span', { style: { minWidth: '96px' } }, '图标复位'),
912
+ rowBtn('一键全复位', () => {
913
+ tryAct('resetAll')
914
+ flash('一键全复位:撤光全部快照,恢复到她第一次搬乱前的样子')
915
+ }, 'reset-pet')
916
+ ),
917
+ h('div', { className: 'hint' }, '图标复位:把她搬乱的桌面图标按名字放回最近一档快照的位置;点一键全部复位可恢复初始状态'),
918
+ h(Toggle, {
919
+ label: '随便坐',
920
+ checked: cfg.actSit === true,
921
+ disabled: !deskMode,
922
+ onChange: (v) => save({ actSit: v }),
923
+ }),
924
+ h('div', { className: 'hint' }, '随便坐:她会坐在桌面图标上,或者坐在任意窗口的边沿上')
925
+ ),
926
+
927
+ card(
928
+ ['menuOrder'],
929
+ h('div', { className: 'sub' }, '下拉列表(右键她弹出来的那些)'),
930
+ h('div', { className: 'hint' }, '按住每行右侧的 ⠿ 把手上下拖动排序'),
931
+ ...menuIds.map((id, index) =>
932
+ h(
933
+ 'div',
934
+ {
935
+ className: 'row',
936
+ key: 'menu-' + id,
937
+ ref: (el) => {
938
+ if (el) rowEls.current[id] = el
939
+ else delete rowEls.current[id]
940
+ },
941
+ style: { alignItems: 'center', opacity: dragIdx === index ? 0.45 : 1, userSelect: 'none' },
942
+ },
943
+ h('span', { style: { minWidth: '140px' } }, (index + 1) + '. ' + (MENU_LABELS[id] || id)),
944
+ h('span', {
945
+ style: {
946
+ marginLeft: 'auto',
947
+ cursor: dragIdx === index ? 'grabbing' : 'grab',
948
+ userSelect: 'none',
949
+ padding: '2px 10px',
950
+ fontSize: 16,
951
+ lineHeight: '22px',
952
+ touchAction: 'none',
953
+ },
954
+ title: '按住上下拖动排序',
955
+ onPointerDown: (event) => {
956
+ event.preventDefault()
957
+ beginMenuDrag(index)
958
+ },
959
+ }, '⠿')
960
+ )
961
+ )
962
+ ),
963
+
964
+ card(
965
+ ['greet', 'idleLines', 'idleEvery', 'idleUnit'],
966
+ h('div', { className: 'sub' }, '碎碎念'),
967
+ h(Toggle, { label: '开启碎碎念', checked: cfg.greet, onChange: (v) => save({ greet: v }) }),
968
+ h(
969
+ 'div',
970
+ { className: 'row' },
971
+ h('label', null, '隔'),
972
+ h('input', {
973
+ type: 'number',
974
+ min: 1,
975
+ max: 999,
976
+ value: cfg.idleEvery ?? 20,
977
+ style: { width: '76px' },
978
+ onChange: (event) => save({ idleEvery: Number(event.target.value) || 1 }),
979
+ }),
980
+ h(
981
+ 'select',
982
+ {
983
+ value: cfg.idleUnit ?? 'min',
984
+ onChange: (event) => save({ idleUnit: event.target.value }),
985
+ },
986
+ h('option', { value: 'sec' }, '秒'),
987
+ h('option', { value: 'min' }, '分钟'),
988
+ h('option', { value: 'hour' }, '小时')
989
+ ),
990
+ h('span', { className: 'hint' }, '说一句'),
991
+ ),
992
+ h('div', { className: 'hint' }, '碎碎念全自定义,一行一句;句子里写 {name} 会换成上面填的姓名,姓名空着就说「你的鱼」;留空她就不说'),
993
+ ...lineList.map((line, index) =>
994
+ h(
995
+ 'div',
996
+ { key: 'line-' + index },
997
+ h(
998
+ 'div',
999
+ { className: 'row', style: { alignItems: 'center' } },
1000
+ h('input', {
1001
+ defaultValue: line,
1002
+ style: { flex: '1', minWidth: '220px' },
1003
+ onBlur: (event) => editLine(index, event.target.value),
1004
+ onKeyDown: (event) => {
1005
+ if (event.key === 'Enter') editLine(index, event.target.value)
1006
+ },
1007
+ }),
1008
+ rowBtn('↑', () => moveLine(index, -1), 'lu-' + index),
1009
+ rowBtn('↓', () => moveLine(index, 1), 'ld-' + index),
1010
+ rowBtn('删除', () => delLine(index), 'lx-' + index)
1011
+ ),
1012
+ /\{name\}/.test(line)
1013
+ ? h('div', { className: 'hint', style: { marginLeft: 8, marginTop: -4 } }, '实际会说:' + line.replace(/\{name\}/g, cfg.petName || '你的鱼'))
1014
+ : null
1015
+ )
1016
+ ),
1017
+ h(
1018
+ 'div',
1019
+ { className: 'row' },
1020
+ h('button', { className: 'primary', onClick: () => { addLine(); flash('加了一条') } }, '新增一条'),
1021
+ h('span', { className: 'hint' }, '关掉「开启碎碎念」她就不乱说了')
1022
+ )
1023
+ ),
1024
+
1025
+ )
1026
+ }
1027
+
1028
+ // 同一个页面里可能被重复挂载(热重载/多次 register),只让最早那个实例真的画出来
1029
+ const mounts = []
1030
+
1031
+
1032
+ /* ---------------- 麦克风桥:网页这边只剩这个 -----------------
1033
+ 注意:cfg 只在设置组件里有,这里用 lastCfg(useSettings 每次渲染都会同步到模块级);
1034
+ base 参数挂载处不传,轮询一律走 root()(petBase 有值用绝对,没有就相对路径 + 先摸一次 /prefs 记下 base) */
1035
+ function MicBridge() {
1036
+ const recogRef = React.useRef(null)
1037
+ const pendingRef = React.useRef(false)
1038
+
1039
+ const root = () => (petBase && petBase.value) || ''
1040
+
1041
+ // 识别文字转发:中间结果和最终文字都发 /voicetext,桌面窗轮询拿去
1042
+ // 实时填进她的输入框;最终一句由桌面自己走提交流程(「打开XX」本地指令也在那边拦)
1043
+ const postText = (text, final) => {
1044
+ fetch(`${root()}/dsh-coo-pet/voicetext`, {
1045
+ method: 'POST',
1046
+ headers: { 'content-type': 'application/json; charset=utf-8' },
1047
+ body: JSON.stringify({ text: String(text || ''), final: final === true }),
1048
+ }).catch(() => {})
1049
+ }
1050
+
1051
+ const stopMic = () => {
1052
+ try {
1053
+ recogRef.current?.stop()
1054
+ } catch {
1055
+ /* ignore */
1056
+ }
1057
+ }
1058
+
1059
+ const startMic = () => {
1060
+ const SR = window.SpeechRecognition || window.webkitSpeechRecognition
1061
+ if (!SR) {
1062
+ postText('(这个窗口不支持语音识别)', true)
1063
+ return
1064
+ }
1065
+ try {
1066
+ const rec = new SR()
1067
+ rec.lang = 'zh-CN'
1068
+ rec.interimResults = true
1069
+ rec.continuous = false
1070
+ rec.onresult = (event) => {
1071
+ let said = ''
1072
+ for (let i = 0; i < event.results.length; i += 1) said += event.results[i][0].transcript
1073
+ rec._said = said
1074
+ postText(said, false)
1075
+ }
1076
+ rec.onend = () => {
1077
+ recogRef.current = null
1078
+ if (pendingRef.current) {
1079
+ pendingRef.current = false
1080
+ postText(rec._said, true)
1081
+ }
1082
+ }
1083
+ rec.onerror = () => {
1084
+ // 出错也要收尾:桌面窗那边等着 final 才收输入框
1085
+ recogRef.current = null
1086
+ if (pendingRef.current) {
1087
+ pendingRef.current = false
1088
+ postText(rec._said || '', true)
1089
+ }
1090
+ }
1091
+ rec.start()
1092
+ recogRef.current = rec
1093
+ } catch {
1094
+ /* 麦克风打不开就算了,桌宠照样活着 */
1095
+ }
1096
+ }
1097
+
1098
+ React.useEffect(() => {
1099
+ let alive = true
1100
+ let seq = 0
1101
+ let timer = 0
1102
+ // 先摸一次 base:设置页没开时 petBase 是空的,摸到就记下来给后面的绝对路径用
1103
+ fetch(`${root()}/dsh-coo-pet/prefs`, { credentials: 'same-origin' })
1104
+ .then((res) => (res.ok ? res.json() : null))
1105
+ .then((body) => {
1106
+ if (body && typeof body.base === 'string' && body.base) petBase.value = body.base
1107
+ })
1108
+ .catch(() => {})
1109
+ const tick = async () => {
1110
+ try {
1111
+ const res = await fetch(`${root()}/dsh-coo-pet/voice?since=${seq}`, { credentials: 'same-origin' })
1112
+ if (res.ok) {
1113
+ const body = await res.json().catch(() => null)
1114
+ if (alive && body && typeof body.seq === 'number') {
1115
+ seq = body.seq
1116
+ const cmd = body.voice
1117
+ if (cmd && typeof cmd.on === 'boolean') {
1118
+ if (cmd.on) {
1119
+ pendingRef.current = true
1120
+ if (!recogRef.current) startMic()
1121
+ } else {
1122
+ pendingRef.current = false
1123
+ stopMic()
1124
+ }
1125
+ }
1126
+ }
1127
+ }
1128
+ } catch {
1129
+ /* offline */
1130
+ }
1131
+ if (alive) timer = window.setTimeout(tick, 700)
1132
+ }
1133
+ tick()
1134
+ return () => {
1135
+ alive = false
1136
+ window.clearTimeout(timer)
1137
+ }
1138
+ }, [])
1139
+
1140
+ return null
1141
+ }
1142
+
1143
+
1144
+ function CooSettings() {
1145
+ try {
1146
+ return h(CooSettingsInner)
1147
+ } catch (error) {
1148
+ return h(
1149
+ 'div',
1150
+ { className: 'card' },
1151
+ h('div', { className: 'sub' }, '你的鱼 · 设置页出错了'),
1152
+ h('div', { className: 'hint' }, String((error && error.message) || error))
1153
+ )
1154
+ }
1155
+ }
1156
+
1157
+ return {
1158
+ inject: ['slots'],
1159
+ apply(ctx) {
1160
+ ctx.slots.inject('shell.overlay', () =>
1161
+ ctx.slots.register({ name: 'shell.overlay', id: 'coo-pet-mic', order: 60, label: '你的鱼·麦克风' }, MicBridge)
1162
+ )
1163
+ ctx.slots.inject('settings.section', () =>
1164
+ ctx.slots.register({ name: 'settings.section', id: 'coo-pet', order: 80, label: '你的鱼' }, CooSettings)
1165
+ )
1166
+ },
1167
+ }
1168
+ },
1169
+ })