@adhdev/daemon-core 0.5.28 → 0.5.30

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/dist/index.js CHANGED
@@ -3861,6 +3861,41 @@ async function handleResolveAction(h, args) {
3861
3861
  var fs4 = __toESM(require("fs"));
3862
3862
  var path5 = __toESM(require("path"));
3863
3863
  var os6 = __toESM(require("os"));
3864
+ var KEY_TO_VK = {
3865
+ Backspace: 8,
3866
+ Tab: 9,
3867
+ Enter: 13,
3868
+ Escape: 27,
3869
+ Space: 32,
3870
+ ArrowLeft: 37,
3871
+ ArrowUp: 38,
3872
+ ArrowRight: 39,
3873
+ ArrowDown: 40,
3874
+ Delete: 46,
3875
+ Home: 36,
3876
+ End: 35,
3877
+ PageUp: 33,
3878
+ PageDown: 34,
3879
+ Insert: 45,
3880
+ F1: 112,
3881
+ F2: 113,
3882
+ F3: 114,
3883
+ F4: 115,
3884
+ F5: 116,
3885
+ F6: 117,
3886
+ F7: 118,
3887
+ F8: 119,
3888
+ F9: 120,
3889
+ F10: 121,
3890
+ F11: 122,
3891
+ F12: 123,
3892
+ Control: 17,
3893
+ Shift: 16,
3894
+ Alt: 18,
3895
+ Meta: 91,
3896
+ CapsLock: 20,
3897
+ " ": 32
3898
+ };
3864
3899
  async function handleCdpEval(h, args) {
3865
3900
  if (!h.getCdp()?.isConnected) return { success: false, error: "CDP not connected" };
3866
3901
  const expression = args?.expression || args?.script;
@@ -3921,18 +3956,40 @@ async function handleCdpRemoteAction(h, args) {
3921
3956
  try {
3922
3957
  switch (action) {
3923
3958
  case "input_key": {
3924
- const { key, modifiers } = params;
3925
- await h.getCdp().send("Input.dispatchKeyEvent", {
3926
- type: "keyDown",
3927
- key,
3928
- ...modifiers?.ctrl ? { modifiers: 2 } : {},
3929
- ...modifiers?.shift ? { modifiers: 8 } : {}
3930
- });
3931
- await h.getCdp().send("Input.dispatchKeyEvent", { type: "keyUp", key });
3959
+ const { type: evType, key, code, text, unmodifiedText, modifiers } = params;
3960
+ const mod = typeof modifiers === "number" ? modifiers : 0;
3961
+ const vk = KEY_TO_VK[key] || (key.length === 1 ? key.charCodeAt(0) : 0);
3962
+ if (evType === "char") {
3963
+ await h.getCdp().send("Input.dispatchKeyEvent", {
3964
+ type: "char",
3965
+ key,
3966
+ code,
3967
+ text: text || key,
3968
+ unmodifiedText: unmodifiedText || text || key,
3969
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
3970
+ ...mod ? { modifiers: mod } : {}
3971
+ });
3972
+ } else {
3973
+ await h.getCdp().send("Input.dispatchKeyEvent", {
3974
+ type: "rawKeyDown",
3975
+ key,
3976
+ code,
3977
+ ...text ? { text } : {},
3978
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
3979
+ ...mod ? { modifiers: mod } : {}
3980
+ });
3981
+ await h.getCdp().send("Input.dispatchKeyEvent", {
3982
+ type: "keyUp",
3983
+ key,
3984
+ code,
3985
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
3986
+ ...mod ? { modifiers: mod } : {}
3987
+ });
3988
+ }
3932
3989
  return { success: true };
3933
3990
  }
3934
3991
  case "input_click": {
3935
- let { x, y, nx, ny, button: btn } = params;
3992
+ let { x, y, nx, ny, button: btn, clickCount } = params;
3936
3993
  if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
3937
3994
  const viewport = await h.getCdp().evaluate(
3938
3995
  "JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
@@ -3944,19 +4001,20 @@ async function handleCdpRemoteAction(h, args) {
3944
4001
  if (x === void 0 || y === void 0) {
3945
4002
  return { success: false, error: "No coordinates provided (x,y or nx,ny required)" };
3946
4003
  }
4004
+ const cc = clickCount || 1;
3947
4005
  await h.getCdp().send("Input.dispatchMouseEvent", {
3948
4006
  type: "mousePressed",
3949
4007
  x,
3950
4008
  y,
3951
4009
  button: btn || "left",
3952
- clickCount: 1
4010
+ clickCount: cc
3953
4011
  });
3954
4012
  await h.getCdp().send("Input.dispatchMouseEvent", {
3955
4013
  type: "mouseReleased",
3956
4014
  x,
3957
4015
  y,
3958
4016
  button: btn || "left",
3959
- clickCount: 1
4017
+ clickCount: cc
3960
4018
  });
3961
4019
  return { success: true, x, y };
3962
4020
  }
@@ -3964,11 +4022,11 @@ async function handleCdpRemoteAction(h, args) {
3964
4022
  const { text } = params;
3965
4023
  for (const char of text || "") {
3966
4024
  await h.getCdp().send("Input.dispatchKeyEvent", {
3967
- type: "keyDown",
4025
+ type: "char",
3968
4026
  text: char,
3969
- key: char
4027
+ key: char,
4028
+ unmodifiedText: char
3970
4029
  });
3971
- await h.getCdp().send("Input.dispatchKeyEvent", { type: "keyUp", key: char });
3972
4030
  }
3973
4031
  return { success: true };
3974
4032
  }
@@ -3999,6 +4057,23 @@ async function handleCdpRemoteAction(h, args) {
3999
4057
  });
4000
4058
  return { success: true };
4001
4059
  }
4060
+ case "input_mouseMoved": {
4061
+ let { x, y, nx, ny } = params;
4062
+ if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
4063
+ const viewport = await h.getCdp().evaluate(
4064
+ "JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
4065
+ );
4066
+ const { w, h: vh } = JSON.parse(viewport);
4067
+ x = Math.round(nx * w);
4068
+ y = Math.round(ny * vh);
4069
+ }
4070
+ await h.getCdp().send("Input.dispatchMouseEvent", {
4071
+ type: "mouseMoved",
4072
+ x: x || 0,
4073
+ y: y || 0
4074
+ });
4075
+ return { success: true };
4076
+ }
4002
4077
  default:
4003
4078
  return { success: false, error: `Unknown remote action: ${action}` };
4004
4079
  }