@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.
- package/LICENSE +661 -0
- package/README.md +112 -2
- package/assets/desk-main.cjs +623 -0
- package/assets/desk-preload.cjs +116 -0
- package/assets/desk-probe.ps1 +213 -0
- package/assets/icon-snapshot.json +1 -0
- package/assets/pet/desk.html +2734 -0
- package/assets/pet/kit/body.js +1053 -0
- package/assets/pet/kit/rig.js +242 -0
- package/assets/pet/speech/zh.json +1 -0
- package/assets/pet/speech/zh.ogg +0 -0
- package/assets/pet/whale/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/feat/eyeL_hl.png +0 -0
- package/assets/pet/whale/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/feat/eyeR_hl.png +0 -0
- package/assets/pet/whale/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/feat/love_mouth.png +0 -0
- package/assets/pet/whale/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/figure.js +948 -0
- package/assets/pet/whale/figure.json +997 -0
- package/assets/pet/whale/model.json +1710 -0
- package/assets/pet/whale/outfits/cape/arm_far.png +0 -0
- package/assets/pet/whale/outfits/cape/arm_far_end_front.png +0 -0
- package/assets/pet/whale/outfits/cape/arm_near.png +0 -0
- package/assets/pet/whale/outfits/cape/cloak.png +0 -0
- package/assets/pet/whale/outfits/cape/cloak_shoulder_cover.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_back.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_fin_far.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_fin_near.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_front.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_lining.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_tie_far.png +0 -0
- package/assets/pet/whale/outfits/cape/hood_tie_near.png +0 -0
- package/assets/pet/whale/outfits/cape/leg_back.png +0 -0
- package/assets/pet/whale/outfits/cape/leg_front.png +0 -0
- package/assets/pet/whale/outfits/cape/scarf_neck.png +0 -0
- package/assets/pet/whale/outfits/cape/scarf_tail_back.png +0 -0
- package/assets/pet/whale/outfits/cape/scarf_tail_front.png +0 -0
- package/assets/pet/whale/outfits/cape/skirt.png +0 -0
- package/assets/pet/whale/outfits/cape/skirt_sit.png +0 -0
- package/assets/pet/whale/outfits/cape/spout.png +0 -0
- package/assets/pet/whale/outfits/crew/arm_far.png +0 -0
- package/assets/pet/whale/outfits/crew/arm_near.png +0 -0
- package/assets/pet/whale/outfits/crew/bow_near.png +0 -0
- package/assets/pet/whale/outfits/crew/headset.png +0 -0
- package/assets/pet/whale/outfits/crew/leg_back.png +0 -0
- package/assets/pet/whale/outfits/crew/leg_front.png +0 -0
- package/assets/pet/whale/outfits/crew/pony_bow.png +0 -0
- package/assets/pet/whale/outfits/crew/skirt_shadow.png +0 -0
- package/assets/pet/whale/outfits/crew/torso_up.png +0 -0
- package/assets/pet/whale/outfits/crew/visor.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/face.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/chatgpt/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/claude/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/face.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/claude/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/gemini/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/face.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/gemini/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/harness/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/face.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/harness/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/kimi/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/face.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/kimi/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/minimax/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/face.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/minimax/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/dizzy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/dizzy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/dizzy_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/drag_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/drag_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/drag_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeL_ball.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeL_iris.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeL_lash.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeR_ball.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeR_iris.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/eyeR_lash.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/happy_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/happy_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/happy_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/love_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/love_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/love_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/neutral_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/sleep_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/sleep_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/sleep_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/surprised_eyeL.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/surprised_eyeR.png +0 -0
- package/assets/pet/whale/schemes/qwen/feat/surprised_mouth.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/ahoge.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/arm_far.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/arm_near.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/bangs.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/bow.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/brows.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/eye_creases.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/face.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/fin_far.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/fin_near.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/hair_back.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/headdress.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/leg_back.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/leg_front.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/sidelocks.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/skirt.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/tail.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/torso_up.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/schemes/qwen/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/tex/ahoge.png +0 -0
- package/assets/pet/whale/tex/arm_far.png +0 -0
- package/assets/pet/whale/tex/arm_far_end_front.png +0 -0
- package/assets/pet/whale/tex/arm_near.png +0 -0
- package/assets/pet/whale/tex/bangs.png +0 -0
- package/assets/pet/whale/tex/bow.png +0 -0
- package/assets/pet/whale/tex/brows.png +0 -0
- package/assets/pet/whale/tex/crew_hair_back.png +0 -0
- package/assets/pet/whale/tex/crew_ponytail.png +0 -0
- package/assets/pet/whale/tex/crew_sidelocks.png +0 -0
- package/assets/pet/whale/tex/crew_skirt.png +0 -0
- package/assets/pet/whale/tex/crew_skirt_sit.png +0 -0
- package/assets/pet/whale/tex/eye_creases.png +0 -0
- package/assets/pet/whale/tex/face.png +0 -0
- package/assets/pet/whale/tex/fin_far.png +0 -0
- package/assets/pet/whale/tex/fin_near.png +0 -0
- package/assets/pet/whale/tex/hair_back.png +0 -0
- package/assets/pet/whale/tex/hair_back_curl.png +0 -0
- package/assets/pet/whale/tex/hair_front_left.png +0 -0
- package/assets/pet/whale/tex/hair_front_right.png +0 -0
- package/assets/pet/whale/tex/headdress.png +0 -0
- package/assets/pet/whale/tex/leg_back.png +0 -0
- package/assets/pet/whale/tex/leg_front.png +0 -0
- package/assets/pet/whale/tex/sidelocks.png +0 -0
- package/assets/pet/whale/tex/skirt.png +0 -0
- package/assets/pet/whale/tex/skirt_shadow.png +0 -0
- package/assets/pet/whale/tex/skirt_sit.png +0 -0
- package/assets/pet/whale/tex/tail.png +0 -0
- package/assets/pet/whale/tex/torso_up.png +0 -0
- package/assets/pet/whale/tex/waist_bow_front.png +0 -0
- package/assets/pet/whale/tex/waist_bow_sit_front.png +0 -0
- package/assets/pet/whale/thumbs/cape.png +0 -0
- package/assets/pet/whale/thumbs/chatgpt.png +0 -0
- package/assets/pet/whale/thumbs/claude.png +0 -0
- package/assets/pet/whale/thumbs/crew.png +0 -0
- package/assets/pet/whale/thumbs/deepseek.png +0 -0
- package/assets/pet/whale/thumbs/gemini.png +0 -0
- package/assets/pet/whale/thumbs/harness.png +0 -0
- package/assets/pet/whale/thumbs/kimi.png +0 -0
- package/assets/pet/whale/thumbs/maid.png +0 -0
- package/assets/pet/whale/thumbs/minimax.png +0 -0
- package/assets/pet/whale/thumbs/qwen.png +0 -0
- package/assets/restart-dsh.cmd +16 -0
- package/assets/restart-dsh.log +195 -0
- package/client.js +1169 -0
- package/cordis.patch.yml +3 -0
- package/icon.svg +8 -0
- package/index.js +1273 -0
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +50 -4
|
@@ -0,0 +1,623 @@
|
|
|
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
|
+
/**
|
|
8
|
+
* Coo 桌面模式(Electron 主进程)—— 全屏透明层版本。
|
|
9
|
+
*
|
|
10
|
+
* 用法:electron desk-main.cjs --url=http://127.0.0.1:PORT/dsh-coo-pet/desk.html
|
|
11
|
+
*
|
|
12
|
+
* 窗口铺满整个工作区、**从不移动**(挪透明窗要重合成,正是卡顿的来源)。
|
|
13
|
+
* 页面自己按世界坐标画全部内容;窗口只负责承载和鼠标穿透。
|
|
14
|
+
* 鼠标:整窗默认穿透,页面报命中框,主进程轮询光标决定要不要接管。
|
|
15
|
+
* 另提供只读探针:可见窗口矩形(坐边沿)和桌面图标位置(坐图标 / 拖图标)。
|
|
16
|
+
*
|
|
17
|
+
* 鼠标租约(照 dsh-pet 的 mouse-lease 补的保险丝):
|
|
18
|
+
* - 页面的每条消息都算一次「心跳」;只有心跳在 LEASE_MS 内,才允许拦鼠标;
|
|
19
|
+
* - 页面死了/卡死了:丢掉 dragging/menuOpen/hitBox,强制穿透——全屏玻璃
|
|
20
|
+
* 永远不可能再扣住鼠标不放;
|
|
21
|
+
* - 同一个判定最多 REASSERT_MS 就重申一次(重新调 setIgnoreMouseEvents),
|
|
22
|
+
* 系统把窗口状态弄丢时能自愈。
|
|
23
|
+
*/
|
|
24
|
+
const { app, BrowserWindow, screen, ipcMain, globalShortcut, session } = require('electron')
|
|
25
|
+
const { execFile } = require('node:child_process')
|
|
26
|
+
const fs = require('node:fs')
|
|
27
|
+
|
|
28
|
+
// 麦克风/语音识别权限放行:桌宠窗口要用浏览器语音识别本地开麦。
|
|
29
|
+
// (识别在她自己的窗口里跑——主窗口里的麦克风桥会被后台节流,主窗口一藏起来语音就哑)
|
|
30
|
+
try {
|
|
31
|
+
const micOk = (permission) => permission === 'media' || permission === 'speech' || permission === 'audioCapture'
|
|
32
|
+
session.defaultSession.setPermissionRequestHandler((_wc, permission, callback) => callback(micOk(permission)))
|
|
33
|
+
session.defaultSession.setPermissionCheckHandler((_wc, permission) => micOk(permission))
|
|
34
|
+
} catch {
|
|
35
|
+
/* 旧版 Electron 没有这些 API 就跳过 */
|
|
36
|
+
}
|
|
37
|
+
const path = require('node:path')
|
|
38
|
+
|
|
39
|
+
const arg = (name, fallback) => {
|
|
40
|
+
const hit = process.argv.find((item) => item.startsWith(`--${name}=`))
|
|
41
|
+
return hit ? hit.slice(name.length + 3) : fallback
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const url = arg('url', '')
|
|
45
|
+
const PROBE = path.join(__dirname, 'desk-probe.ps1')
|
|
46
|
+
const IS_WIN = process.platform === 'win32'
|
|
47
|
+
|
|
48
|
+
app.commandLine.appendSwitch('disable-renderer-backgrounding')
|
|
49
|
+
app.commandLine.appendSwitch('disable-background-timer-throttling')
|
|
50
|
+
app.commandLine.appendSwitch('disable-backgrounding-occluded-windows')
|
|
51
|
+
// Windows 的遮挡检测会把这块全屏透明窗当成「被盖住」,然后停掉它的绘制
|
|
52
|
+
app.commandLine.appendSwitch('disable-features', 'CalculateNativeWinOcclusion')
|
|
53
|
+
|
|
54
|
+
let win = null
|
|
55
|
+
let ignore = true
|
|
56
|
+
let hitBoxes = [] // 命中框列表:本体 + 影分身 + 菜单/输入框(光标落在任一框里就接管鼠标)
|
|
57
|
+
let dragging = false
|
|
58
|
+
let menuOpen = false
|
|
59
|
+
let cursorTimer = null
|
|
60
|
+
let origin = { x: 0, y: 0 }
|
|
61
|
+
let world = { x: 0, y: 0, w: 0, h: 0 }
|
|
62
|
+
|
|
63
|
+
/* ---------- 鼠标租约 ---------- */
|
|
64
|
+
/** 页面心跳的保鲜期:超过这么久没听到页面说话,就不许再拦鼠标。 */
|
|
65
|
+
const LEASE_MS = 1500
|
|
66
|
+
/** 同一个判定隔这么久就重申一次(重新调 setIgnoreMouseEvents,自愈丢状态)。 */
|
|
67
|
+
const REASSERT_MS = 2000
|
|
68
|
+
let lastBeat = 0
|
|
69
|
+
let lastIgnore = null
|
|
70
|
+
let lastApplyAt = 0
|
|
71
|
+
|
|
72
|
+
/** 页面的每条消息都算一次心跳。 */
|
|
73
|
+
function beat() {
|
|
74
|
+
lastBeat = Date.now()
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const LOG = path.join(app.getPath('temp'), 'coo-desk.log')
|
|
78
|
+
function log(line) {
|
|
79
|
+
try {
|
|
80
|
+
require('node:fs').appendFileSync(LOG, new Date().toISOString() + ' ' + line + '\n')
|
|
81
|
+
} catch {
|
|
82
|
+
/* ignore */
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function setIgnore(next, force = false) {
|
|
87
|
+
const now = Date.now()
|
|
88
|
+
// 判定没变时只在 REASSERT_MS 到点后重申(自愈);force 跳过去重与节流
|
|
89
|
+
if (!force && lastIgnore === next && now - lastApplyAt < REASSERT_MS) return
|
|
90
|
+
if (lastIgnore !== next) log('ignore -> ' + next)
|
|
91
|
+
lastIgnore = next
|
|
92
|
+
lastApplyAt = now
|
|
93
|
+
if (!win || win.isDestroyed()) return
|
|
94
|
+
ignore = next
|
|
95
|
+
win.setIgnoreMouseEvents(next)
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function workArea() {
|
|
99
|
+
return screen.getPrimaryDisplay().workArea
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/* DPI 换算:Win32 探针给的是物理像素,窗口里是逻辑像素(CSS)。
|
|
103
|
+
125% 缩放时两者差 25%——图标/窗口坐标必须在边界上统一换算,不然她永远走不到目标旁边。 */
|
|
104
|
+
let SF = 1
|
|
105
|
+
function refreshScale() {
|
|
106
|
+
try {
|
|
107
|
+
SF = screen.getPrimaryDisplay().scaleFactor || 1
|
|
108
|
+
} catch {
|
|
109
|
+
SF = 1
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const toCss = (v) => Math.round(v / SF)
|
|
113
|
+
const toPhys = (v) => Math.round(v * SF)
|
|
114
|
+
const toCssRects = (data) =>
|
|
115
|
+
(Array.isArray(data) ? data : []).map((it) => ({
|
|
116
|
+
...it,
|
|
117
|
+
x: toCss(Number(it.x) || 0),
|
|
118
|
+
y: toCss(Number(it.y) || 0),
|
|
119
|
+
...(typeof it.w === 'number' ? { w: toCss(it.w) } : {}),
|
|
120
|
+
...(typeof it.h === 'number' ? { h: toCss(it.h) } : {}),
|
|
121
|
+
}))
|
|
122
|
+
|
|
123
|
+
function sendOrigin() {
|
|
124
|
+
if (!win || win.isDestroyed()) return
|
|
125
|
+
win.webContents.send('coo-origin', { origin, world })
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** 窗口不再跟随,只记下她的位置(留给探针 / 以后要做取景窗时用) */
|
|
129
|
+
function moveView(anchor) {
|
|
130
|
+
if (!anchor) return
|
|
131
|
+
lastAnchor = anchor
|
|
132
|
+
// 诊断:她大幅挪窝时记一行(自由地面下 y 会变,固定地面下 y 恒定)
|
|
133
|
+
const l = lastAnchorLog
|
|
134
|
+
if (!l || Math.abs(anchor.x - l.x) > 40 || Math.abs(anchor.y - l.y) > 40) {
|
|
135
|
+
lastAnchorLog = { x: anchor.x, y: anchor.y }
|
|
136
|
+
log('anchor ' + Math.round(anchor.x) + ',' + Math.round(anchor.y))
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
let lastAnchor = null
|
|
141
|
+
let lastAnchorLog = null
|
|
142
|
+
|
|
143
|
+
function startCursorWatch() {
|
|
144
|
+
if (cursorTimer) clearInterval(cursorTimer)
|
|
145
|
+
cursorTimer = setInterval(() => {
|
|
146
|
+
if (!win || win.isDestroyed()) return
|
|
147
|
+
const now = Date.now()
|
|
148
|
+
// 心跳断了:页面死了或卡死了。全屏玻璃绝不允许扣着鼠标,丢状态强制穿透。
|
|
149
|
+
if (now - lastBeat >= LEASE_MS) {
|
|
150
|
+
if (dragging || menuOpen || hitBoxes.length) {
|
|
151
|
+
log('lease expired: no page heartbeat for ' + Math.round(now - lastBeat) + 'ms, force pass-through')
|
|
152
|
+
}
|
|
153
|
+
dragging = false
|
|
154
|
+
menuOpen = false
|
|
155
|
+
hitBoxes = []
|
|
156
|
+
setIgnore(true, true)
|
|
157
|
+
return
|
|
158
|
+
}
|
|
159
|
+
if (dragging || menuOpen) {
|
|
160
|
+
setIgnore(false)
|
|
161
|
+
return
|
|
162
|
+
}
|
|
163
|
+
const point = screen.getCursorScreenPoint()
|
|
164
|
+
if (!hitBoxes.length) {
|
|
165
|
+
setIgnore(true)
|
|
166
|
+
return
|
|
167
|
+
}
|
|
168
|
+
const inside = hitBoxes.some(
|
|
169
|
+
(b) =>
|
|
170
|
+
point.x >= b.x &&
|
|
171
|
+
point.x <= b.x + b.w &&
|
|
172
|
+
point.y >= b.y &&
|
|
173
|
+
point.y <= b.y + b.h
|
|
174
|
+
)
|
|
175
|
+
setIgnore(!inside)
|
|
176
|
+
}, 90)
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
let lastWinLog = null
|
|
180
|
+
function probe(mode, extra = [], timeout = 8000) {
|
|
181
|
+
return new Promise((resolve) => {
|
|
182
|
+
execFile(
|
|
183
|
+
'powershell.exe',
|
|
184
|
+
['-NoProfile', '-ExecutionPolicy', 'Bypass', '-File', PROBE, '-mode', mode, ...extra],
|
|
185
|
+
{ windowsHide: true, timeout },
|
|
186
|
+
(error, stdout) => {
|
|
187
|
+
if (error) {
|
|
188
|
+
if (mode === 'windows') log('probe windows FAIL: ' + String(error.message || error).slice(0, 120))
|
|
189
|
+
resolve({ ok: false, error: String(error.message || error) })
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
const text = String(stdout || '').trim()
|
|
193
|
+
if (!text) {
|
|
194
|
+
// 空输出≠桌面干净:按失败处理,闸门保持关闭(有窗口开着就不许碰图标)
|
|
195
|
+
if (mode === 'windows') log('probe windows EMPTY-OUTPUT (fail-closed)')
|
|
196
|
+
resolve({ ok: false, error: 'empty probe output' })
|
|
197
|
+
return
|
|
198
|
+
}
|
|
199
|
+
try {
|
|
200
|
+
const parsed = JSON.parse(text)
|
|
201
|
+
if (mode === 'windows') {
|
|
202
|
+
const n = Array.isArray(parsed) ? parsed.length : -1
|
|
203
|
+
const sig = 'ok n=' + n
|
|
204
|
+
if (sig !== lastWinLog) {
|
|
205
|
+
lastWinLog = sig
|
|
206
|
+
log('probe windows ' + sig + (n > 0 ? ' [' + parsed.slice(0, 3).map((w) => w.cls).join(',') + ']' : ''))
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
resolve({ ok: true, data: parsed })
|
|
210
|
+
} catch (parseError) {
|
|
211
|
+
if (mode === 'windows') log('probe windows PARSE-FAIL: ' + text.slice(0, 120))
|
|
212
|
+
resolve({ ok: false, error: String(parseError.message || parseError) })
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
)
|
|
216
|
+
})
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// 语音录音走 WebAudio:快捷键/鼠标键经 IPC 触发,不算页面用户手势,
|
|
220
|
+
// 不放开自动播放策略的话 AudioContext 会被创建成 suspended、一个字节都录不到
|
|
221
|
+
app.commandLine.appendSwitch('autoplay-policy', 'no-user-gesture-required')
|
|
222
|
+
|
|
223
|
+
app.whenReady().then(() => {
|
|
224
|
+
if (!url) {
|
|
225
|
+
app.quit()
|
|
226
|
+
return
|
|
227
|
+
}
|
|
228
|
+
const work = workArea()
|
|
229
|
+
refreshScale()
|
|
230
|
+
screen.on('display-metrics-changed', refreshScale)
|
|
231
|
+
world = { x: 0, y: 0, w: Math.round(work.width), h: Math.round(work.height) }
|
|
232
|
+
origin = { x: 0, y: 0 }
|
|
233
|
+
win = new BrowserWindow({
|
|
234
|
+
x: Math.round(work.x),
|
|
235
|
+
y: Math.round(work.y),
|
|
236
|
+
width: world.w,
|
|
237
|
+
height: world.h,
|
|
238
|
+
transparent: true,
|
|
239
|
+
frame: false,
|
|
240
|
+
resizable: false,
|
|
241
|
+
movable: false,
|
|
242
|
+
minimizable: false,
|
|
243
|
+
maximizable: false,
|
|
244
|
+
fullscreenable: false,
|
|
245
|
+
skipTaskbar: true,
|
|
246
|
+
alwaysOnTop: true,
|
|
247
|
+
hasShadow: false,
|
|
248
|
+
focusable: false,
|
|
249
|
+
show: false,
|
|
250
|
+
backgroundColor: '#00000000',
|
|
251
|
+
// Windows:置顶窗不声明成 toolbar,Chromium 会以为被别的程序挡住而停画
|
|
252
|
+
...(IS_WIN ? { type: 'toolbar' } : {}),
|
|
253
|
+
webPreferences: {
|
|
254
|
+
backgroundThrottling: false,
|
|
255
|
+
preload: path.join(__dirname, 'desk-preload.cjs'),
|
|
256
|
+
contextIsolation: false,
|
|
257
|
+
nodeIntegration: false,
|
|
258
|
+
},
|
|
259
|
+
})
|
|
260
|
+
win.setAlwaysOnTop(true, 'screen-saver')
|
|
261
|
+
if (process.platform === 'darwin') {
|
|
262
|
+
win.setVisibleOnAllWorkspaces(true, { visibleOnFullScreen: true, skipTransformProcessType: true })
|
|
263
|
+
}
|
|
264
|
+
setIgnore(true)
|
|
265
|
+
win.once('ready-to-show', () => {
|
|
266
|
+
win.showInactive()
|
|
267
|
+
sendOrigin()
|
|
268
|
+
log('shown ' + JSON.stringify(win.getBounds()) + ' world ' + JSON.stringify(world))
|
|
269
|
+
})
|
|
270
|
+
win.webContents.on('did-finish-load', () => sendOrigin())
|
|
271
|
+
win.loadURL(url)
|
|
272
|
+
startCursorWatch()
|
|
273
|
+
cleanupRestartTask()
|
|
274
|
+
win.on('closed', () => {
|
|
275
|
+
if (cursorTimer) clearInterval(cursorTimer)
|
|
276
|
+
cursorTimer = null
|
|
277
|
+
stopMouseWatch()
|
|
278
|
+
win = null
|
|
279
|
+
app.quit()
|
|
280
|
+
})
|
|
281
|
+
})
|
|
282
|
+
|
|
283
|
+
app.on('before-quit', () => stopMouseWatch())
|
|
284
|
+
|
|
285
|
+
ipcMain.on('coo-anchor', (_event, payload) => {
|
|
286
|
+
beat()
|
|
287
|
+
const item = payload || {}
|
|
288
|
+
const x = Number(item.x)
|
|
289
|
+
const y = Number(item.y)
|
|
290
|
+
if (!Number.isFinite(x) || !Number.isFinite(y)) return
|
|
291
|
+
moveView({ x, y })
|
|
292
|
+
})
|
|
293
|
+
|
|
294
|
+
ipcMain.on('coo-hitbox', (_event, box) => {
|
|
295
|
+
beat()
|
|
296
|
+
// 页面送来的是框列表:本体、影分身、菜单/输入框各一个(老版本是单框,兼容)
|
|
297
|
+
const list = Array.isArray(box) ? box : box ? [box] : []
|
|
298
|
+
hitBoxes = list
|
|
299
|
+
.filter((item) => item && typeof item === 'object')
|
|
300
|
+
.map((item) => ({
|
|
301
|
+
// 世界坐标即屏幕 DIP(窗口贴在工作区左上角且 origin 为 0)
|
|
302
|
+
x: Math.round((Number(item.x) || 0) + world.x),
|
|
303
|
+
y: Math.round((Number(item.y) || 0) + world.y),
|
|
304
|
+
w: Math.round(Number(item.w) || 0),
|
|
305
|
+
h: Math.round(Number(item.h) || 0),
|
|
306
|
+
}))
|
|
307
|
+
.filter((item) => item.w > 0 && item.h > 0)
|
|
308
|
+
})
|
|
309
|
+
|
|
310
|
+
ipcMain.on('coo-drag', (_event, flag) => {
|
|
311
|
+
beat()
|
|
312
|
+
dragging = flag === true
|
|
313
|
+
if (dragging) setIgnore(false)
|
|
314
|
+
})
|
|
315
|
+
|
|
316
|
+
ipcMain.on('coo-hit', (_event, hit) => {
|
|
317
|
+
beat()
|
|
318
|
+
// 菜单开着时鼠标必须一直被我们接住,否则点「外面」关不掉菜单
|
|
319
|
+
if (menuOpen) return
|
|
320
|
+
setIgnore(!hit)
|
|
321
|
+
})
|
|
322
|
+
ipcMain.on('coo-menu', (_event, open) => {
|
|
323
|
+
beat()
|
|
324
|
+
menuOpen = open === true
|
|
325
|
+
if (menuOpen) setIgnore(false)
|
|
326
|
+
})
|
|
327
|
+
ipcMain.on('coo-close', () => app.quit())
|
|
328
|
+
|
|
329
|
+
// 一键重启 DSH:脚本若由本进程直接拉起,会挂在 DSH 进程树下,被脚本自己的 taskkill /T 连树杀掉。
|
|
330
|
+
// 踩过的坑:WMI 在部分环境静默失败;explorer+vbs 在 wscript 被禁的机器上无声失败;
|
|
331
|
+
// schtasks /Create 默认"用电池不启动",笔记本电池供电时任务卡 Queued 永不执行。
|
|
332
|
+
// 现方案:spawn powershell(探针同款通道,本环境必通)注册一个"电池可用、错过补跑"的计划任务
|
|
333
|
+
// 并立即 Start——任务由 Task Scheduler 服务代跑,彻底脱离 DSH 进程树;新桌宠启动时清理残留任务。
|
|
334
|
+
ipcMain.handle('coo-restart-dsh', () => {
|
|
335
|
+
try {
|
|
336
|
+
const { execFile } = require('node:child_process')
|
|
337
|
+
const script = path.join(__dirname, 'restart-dsh.cmd')
|
|
338
|
+
const psCmd =
|
|
339
|
+
`$t = New-ScheduledTaskTrigger -Once -At ((Get-Date).AddMinutes(10)); ` +
|
|
340
|
+
`$s = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable -ExecutionTimeLimit (New-TimeSpan -Minutes 3); ` +
|
|
341
|
+
`$a = New-ScheduledTaskAction -Execute 'cmd.exe' -Argument ('/c \"' + '${script.replace(/'/g, "''")}' + '\"'); ` +
|
|
342
|
+
`Register-ScheduledTask -TaskName coo-restart-dsh -Trigger $t -Settings $s -Action $a -Force | Out-Null; ` +
|
|
343
|
+
`Start-ScheduledTask -TaskName coo-restart-dsh`
|
|
344
|
+
execFile(
|
|
345
|
+
'powershell.exe',
|
|
346
|
+
['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', psCmd],
|
|
347
|
+
{ windowsHide: true, timeout: 20000 },
|
|
348
|
+
(err, so, se) => {
|
|
349
|
+
log('restart-dsh register: ' + (err ? 'ERR ' + String(err.message || err).slice(0, 200) + ' ' + String(se || '').trim().slice(0, 200) : 'ok'))
|
|
350
|
+
}
|
|
351
|
+
)
|
|
352
|
+
log('restart-dsh via scheduled-task (battery-safe)')
|
|
353
|
+
return true
|
|
354
|
+
} catch (error) {
|
|
355
|
+
log('restart-dsh FAIL:', String(error && error.message ? error.message : error))
|
|
356
|
+
return false
|
|
357
|
+
}
|
|
358
|
+
})
|
|
359
|
+
|
|
360
|
+
// 启动时清理上一次重启留下的计划任务(任务触发时间设在 +10 分钟,
|
|
361
|
+
// 正常路径 1-2 秒内就执行完了;清不掉的兜底触发也早于新桌宠启动完成,不构成重启循环)
|
|
362
|
+
function cleanupRestartTask() {
|
|
363
|
+
const { execFile } = require('node:child_process')
|
|
364
|
+
execFile('schtasks.exe', ['/Delete', '/TN', 'coo-restart-dsh', '/F'], { windowsHide: true, timeout: 8000 }, () => {})
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
// 全屏透明窗是 focusable:false,拿不到键盘;语音快捷键只能走系统级注册
|
|
368
|
+
// 鼠标侧键(mouse3 中键 / mouse4 后退 / mouse5 前进)globalShortcut 不支持,
|
|
369
|
+
// 用 PowerShell 轮询 GetAsyncKeyState 盯状态变化,down/up 都回给页面(按住说话松开结束)
|
|
370
|
+
const MOUSE_VK = { 3: 0x04, 4: 0x05, 5: 0x06 } // VK_MBUTTON / VK_XBUTTON1 / VK_XBUTTON2
|
|
371
|
+
let mouseWatch = null
|
|
372
|
+
|
|
373
|
+
function stopMouseWatch() {
|
|
374
|
+
if (mouseWatch) {
|
|
375
|
+
try { mouseWatch.kill() } catch { /* ignore */ }
|
|
376
|
+
mouseWatch = null
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function startMouseWatch(button) {
|
|
381
|
+
stopMouseWatch()
|
|
382
|
+
const vk = MOUSE_VK[button]
|
|
383
|
+
if (!vk) return
|
|
384
|
+
const script =
|
|
385
|
+
"Add-Type -MemberDefinition '[DllImport(\"user32.dll\")] public static extern short GetAsyncKeyState(int k);' -Name U -Namespace W; " +
|
|
386
|
+
`$prev=$false; while($true){ $d=[W.U]::GetAsyncKeyState(${vk}); $down=(($d -band 0x8000) -ne 0); ` +
|
|
387
|
+
"if($down -ne $prev){ if($down){Write-Output 'down'}else{Write-Output 'up'} }; $prev=$down; Start-Sleep -m 40 }"
|
|
388
|
+
try {
|
|
389
|
+
mouseWatch = execFile(
|
|
390
|
+
'powershell.exe',
|
|
391
|
+
['-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', script],
|
|
392
|
+
{ windowsHide: true },
|
|
393
|
+
() => {}
|
|
394
|
+
)
|
|
395
|
+
let buf = ''
|
|
396
|
+
mouseWatch.stdout.on('data', (chunk) => {
|
|
397
|
+
buf += String(chunk)
|
|
398
|
+
let idx
|
|
399
|
+
while ((idx = buf.indexOf('\n')) >= 0) {
|
|
400
|
+
const line = buf.slice(0, idx).trim()
|
|
401
|
+
buf = buf.slice(idx + 1)
|
|
402
|
+
if (line === 'down' || line === 'up') {
|
|
403
|
+
log('mouse-hot ' + line)
|
|
404
|
+
if (win && !win.isDestroyed()) win.webContents.send('coo-hot', { state: line })
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
})
|
|
408
|
+
mouseWatch.on('exit', () => {
|
|
409
|
+
mouseWatch = null
|
|
410
|
+
})
|
|
411
|
+
} catch (error) {
|
|
412
|
+
log('mouse-watch FAIL: ' + String(error && error.message ? error.message : error))
|
|
413
|
+
mouseWatch = null
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
function registerHotkey(spec) {
|
|
418
|
+
try {
|
|
419
|
+
globalShortcut.unregisterAll()
|
|
420
|
+
} catch {
|
|
421
|
+
/* ignore */
|
|
422
|
+
}
|
|
423
|
+
const raw = String(spec || '').trim()
|
|
424
|
+
const mouseMatch = /^mouse([345])$/i.exec(raw)
|
|
425
|
+
if (mouseMatch) {
|
|
426
|
+
startMouseWatch(Number(mouseMatch[1]))
|
|
427
|
+
return
|
|
428
|
+
}
|
|
429
|
+
stopMouseWatch()
|
|
430
|
+
if (!raw) return
|
|
431
|
+
const parts = raw.split('+').map((s) => s.trim()).filter(Boolean)
|
|
432
|
+
const key = (parts.pop() || '').toUpperCase()
|
|
433
|
+
const mods = parts.map((p) => {
|
|
434
|
+
const l = p.toLowerCase()
|
|
435
|
+
if (l === 'ctrl' || l === 'control') return 'Control'
|
|
436
|
+
if (l === 'alt') return 'Alt'
|
|
437
|
+
if (l === 'shift') return 'Shift'
|
|
438
|
+
if (l === 'meta' || l === 'win') return 'Super'
|
|
439
|
+
return ''
|
|
440
|
+
})
|
|
441
|
+
const accel = [...mods.filter(Boolean), key].join('+')
|
|
442
|
+
try {
|
|
443
|
+
globalShortcut.register(accel, () => {
|
|
444
|
+
if (win && !win.isDestroyed()) win.webContents.send('coo-hot')
|
|
445
|
+
})
|
|
446
|
+
} catch {
|
|
447
|
+
/* 组合键不合法就忽略 */
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
ipcMain.on('coo-hotkey', (_event, spec) => {
|
|
452
|
+
beat()
|
|
453
|
+
registerHotkey(spec)
|
|
454
|
+
})
|
|
455
|
+
|
|
456
|
+
ipcMain.handle('coo-world', () => ({ world, origin, view: { w: world.w, h: world.h } }))
|
|
457
|
+
ipcMain.handle('coo-windows', async () => {
|
|
458
|
+
const out = await probe('windows')
|
|
459
|
+
if (!out.ok) return out
|
|
460
|
+
return { ok: true, data: toCssRects(out.data) }
|
|
461
|
+
})
|
|
462
|
+
ipcMain.handle('coo-icons', async () => {
|
|
463
|
+
const out = await probe('icons')
|
|
464
|
+
if (!out.ok) return out
|
|
465
|
+
return { ok: true, data: toCssRects(out.data) }
|
|
466
|
+
})
|
|
467
|
+
|
|
468
|
+
// 输入框要打字:窗口平时 focusable:false(不抢焦点),开输入框时临时借一下键盘
|
|
469
|
+
ipcMain.handle('coo-chat-focus', (_event, on) => {
|
|
470
|
+
try {
|
|
471
|
+
if (on) {
|
|
472
|
+
win.setFocusable(true)
|
|
473
|
+
win.focus()
|
|
474
|
+
// focusable 切换在 Windows 上会重建窗口句柄,补一下置顶顺序确保真拿到键盘焦点
|
|
475
|
+
win.moveTop()
|
|
476
|
+
} else {
|
|
477
|
+
win.blur()
|
|
478
|
+
win.setFocusable(false)
|
|
479
|
+
}
|
|
480
|
+
return { ok: true }
|
|
481
|
+
} catch (error) {
|
|
482
|
+
return { ok: false, error: String((error && error.message) || error) }
|
|
483
|
+
}
|
|
484
|
+
})
|
|
485
|
+
ipcMain.handle('coo-move-icon', (_event, payload) => {
|
|
486
|
+
const item = payload || {}
|
|
487
|
+
// 页面给的是 CSS 逻辑像素,LVM_SETITEMPOSITION 要物理像素
|
|
488
|
+
return probe('move', ['-index', String(Number(item.index) || 0), '-x', String(toPhys(Number(item.x) || 0)), '-y', String(toPhys(Number(item.y) || 0))])
|
|
489
|
+
})
|
|
490
|
+
|
|
491
|
+
// 图标快照/复位:她每次抱图标前存一档(历史栈),「图标复位」按名字回写并弹出一档,可连按连撤
|
|
492
|
+
const ICON_SNAPSHOT = path.join(__dirname, 'icon-snapshot.json') // 兼容旧版:最新一档的镜像
|
|
493
|
+
const ICON_SNAPSHOT_DIR = path.join(__dirname, 'icon-snapshots') // 历史栈目录
|
|
494
|
+
const ICON_SNAPSHOT_KEEP = 12 // 最多留 12 档,再早的自动清掉
|
|
495
|
+
|
|
496
|
+
function snapshotFiles() {
|
|
497
|
+
try {
|
|
498
|
+
return fs
|
|
499
|
+
.readdirSync(ICON_SNAPSHOT_DIR)
|
|
500
|
+
.filter((f) => /^snap-\d+\.json$/.test(f))
|
|
501
|
+
.sort()
|
|
502
|
+
} catch {
|
|
503
|
+
return []
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
ipcMain.handle('coo-icons-snapshot', async () => {
|
|
508
|
+
const out = await probe('icons')
|
|
509
|
+
if (!out.ok) return out
|
|
510
|
+
try {
|
|
511
|
+
fs.mkdirSync(ICON_SNAPSHOT_DIR, { recursive: true })
|
|
512
|
+
const file = path.join(ICON_SNAPSHOT_DIR, `snap-${Date.now()}.json`)
|
|
513
|
+
fs.writeFileSync(file, JSON.stringify(out.data), 'utf8')
|
|
514
|
+
fs.writeFileSync(ICON_SNAPSHOT, JSON.stringify(out.data), 'utf8') // 旧版镜像,兼容外部工具
|
|
515
|
+
// 只留最近 N 档
|
|
516
|
+
const olds = snapshotFiles().slice(0, -ICON_SNAPSHOT_KEEP)
|
|
517
|
+
for (const f of olds) {
|
|
518
|
+
try { fs.unlinkSync(path.join(ICON_SNAPSHOT_DIR, f)) } catch { /* ignore */ }
|
|
519
|
+
}
|
|
520
|
+
return { ok: true, n: Array.isArray(out.data) ? out.data.length : 0, kept: snapshotFiles().length }
|
|
521
|
+
} catch (error) {
|
|
522
|
+
return { ok: false, error: String((error && error.message) || error) }
|
|
523
|
+
}
|
|
524
|
+
})
|
|
525
|
+
ipcMain.handle('coo-icons-restore', async () => {
|
|
526
|
+
// 从最新一档恢复;恢复成功就弹出这一档(下次复位撤的是再上一次搬运),实现连撤
|
|
527
|
+
// 注意 probe 返回 {ok, data},n/ok 的真实值在 data 里(以前误读 out.n 导致快照永远弹不出,只能重复撤最后一档)
|
|
528
|
+
const snaps = snapshotFiles()
|
|
529
|
+
if (snaps.length) {
|
|
530
|
+
const file = path.join(ICON_SNAPSHOT_DIR, snaps[snaps.length - 1])
|
|
531
|
+
const out = await probe('restore', ['-from', file], 15000)
|
|
532
|
+
const d = (out && out.data) || {}
|
|
533
|
+
if (out && out.ok && (d.n || 0) > 0) {
|
|
534
|
+
try { fs.unlinkSync(file) } catch { /* ignore */ }
|
|
535
|
+
}
|
|
536
|
+
return { ok: !!(out && out.ok), n: d.n || 0, undosLeft: snapshotFiles().length }
|
|
537
|
+
}
|
|
538
|
+
// 没有历史档时退回旧的单快照(不弹出,老行为)
|
|
539
|
+
if (!fs.existsSync(ICON_SNAPSHOT)) return { ok: false, error: 'no snapshot' }
|
|
540
|
+
const out = await probe('restore', ['-from', ICON_SNAPSHOT], 15000)
|
|
541
|
+
const d = (out && out.data) || {}
|
|
542
|
+
return { ok: !!(out && out.ok), n: d.n || 0 }
|
|
543
|
+
})
|
|
544
|
+
|
|
545
|
+
// 一键全复位:把历史栈一档档全部撤光,回到她第一次搬乱前的样子
|
|
546
|
+
ipcMain.handle('coo-icons-restore-all', async () => {
|
|
547
|
+
let restored = 0
|
|
548
|
+
let last = null
|
|
549
|
+
for (let i = 0; i < 64; i++) {
|
|
550
|
+
const snaps = snapshotFiles()
|
|
551
|
+
if (!snaps.length) break
|
|
552
|
+
const file = path.join(ICON_SNAPSHOT_DIR, snaps[snaps.length - 1])
|
|
553
|
+
const out = await probe('restore', ['-from', file], 15000)
|
|
554
|
+
const d = (out && out.data) || {}
|
|
555
|
+
log('restore-all: iter ' + i + ' n=' + (d.n || 0))
|
|
556
|
+
last = out
|
|
557
|
+
if (out && out.ok && (d.n || 0) > 0) {
|
|
558
|
+
restored += 1
|
|
559
|
+
try { fs.unlinkSync(file) } catch { /* ignore */ }
|
|
560
|
+
} else {
|
|
561
|
+
break
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
log('restore-all: done, restored=' + restored)
|
|
565
|
+
// 历史栈撤光后兜底撤旧版单快照(老升级用户可能只有它)
|
|
566
|
+
if (!restored && fs.existsSync(ICON_SNAPSHOT)) {
|
|
567
|
+
const out = await probe('restore', ['-from', ICON_SNAPSHOT], 15000)
|
|
568
|
+
const d = (out && out.data) || {}
|
|
569
|
+
last = out
|
|
570
|
+
if (out && out.ok && (d.n || 0) > 0) restored = 1
|
|
571
|
+
}
|
|
572
|
+
return { ok: restored > 0, restored, ...((last && last.data) || {}) }
|
|
573
|
+
})
|
|
574
|
+
|
|
575
|
+
// 指令开软件:按名字在开始菜单里找快捷方式(支持模糊匹配),找不到就让 Windows 自己解析
|
|
576
|
+
ipcMain.handle('coo-launch', (_event, name) => {
|
|
577
|
+
beat()
|
|
578
|
+
const q = String(name || '').trim()
|
|
579
|
+
if (!q) return { ok: false, error: 'empty' }
|
|
580
|
+
// 特例:explorer 必须裸启动(CreateProcess,无参数)才能真正接管外壳恢复桌面;
|
|
581
|
+
// 走 cmd start / ShellExecute 只会开一个「此电脑」文件窗口
|
|
582
|
+
if (/^explorer(\.exe)?$/i.test(q)) {
|
|
583
|
+
const { spawn } = require('node:child_process')
|
|
584
|
+
spawn('explorer.exe', [], { detached: true, stdio: 'ignore' }).unref()
|
|
585
|
+
return { ok: true, app: 'explorer', shell: true }
|
|
586
|
+
}
|
|
587
|
+
const os = require('node:os')
|
|
588
|
+
const fsp = require('node:fs')
|
|
589
|
+
const dirs = [
|
|
590
|
+
path.join(os.homedir(), 'AppData', 'Roaming', 'Microsoft', 'Windows', 'Start Menu', 'Programs'),
|
|
591
|
+
'C:\\ProgramData\\Microsoft\\Windows\\Start Menu\\Programs',
|
|
592
|
+
// 桌面快捷方式也认:她走到桌面图标旁边戳一下,启动的就是那个图标
|
|
593
|
+
path.join(os.homedir(), 'Desktop'),
|
|
594
|
+
'C:\\Users\\Public\\Desktop',
|
|
595
|
+
]
|
|
596
|
+
let found = null
|
|
597
|
+
const want = q.toLowerCase()
|
|
598
|
+
const scan = (dir, depth) => {
|
|
599
|
+
if (depth > 5 || found) return
|
|
600
|
+
let list = []
|
|
601
|
+
try { list = fsp.readdirSync(dir, { withFileTypes: true }) } catch { return }
|
|
602
|
+
for (const d of list) {
|
|
603
|
+
const p = path.join(dir, d.name)
|
|
604
|
+
if (d.isDirectory()) {
|
|
605
|
+
scan(p, depth + 1)
|
|
606
|
+
} else if (/\.lnk$/i.test(d.name)) {
|
|
607
|
+
const base = d.name.replace(/\.lnk$/i, '')
|
|
608
|
+
const b = base.toLowerCase()
|
|
609
|
+
if ((b === want || b.includes(want)) && (!found || base.length < found.base.length)) {
|
|
610
|
+
found = { path: p, base }
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
for (const dir of dirs) scan(dir, 0)
|
|
616
|
+
if (found) {
|
|
617
|
+
execFile('cmd.exe', ['/c', 'start', '', found.path], { windowsHide: true }, () => {})
|
|
618
|
+
return { ok: true, app: found.base }
|
|
619
|
+
}
|
|
620
|
+
// 兜底:Windows 的 start 能解析 App Paths / PATH 里的名字(notepad、mspaint 这类)
|
|
621
|
+
execFile('cmd.exe', ['/c', 'start', '', q], { windowsHide: true }, () => {})
|
|
622
|
+
return { ok: true, app: q, guess: true }
|
|
623
|
+
})
|