adhdev 0.5.28 → 0.5.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/dist/cli/index.js CHANGED
@@ -20162,6 +20162,41 @@ var require_dist = __commonJS({
20162
20162
  var fs4 = __toESM2(require("fs"));
20163
20163
  var path5 = __toESM2(require("path"));
20164
20164
  var os6 = __toESM2(require("os"));
20165
+ var KEY_TO_VK = {
20166
+ Backspace: 8,
20167
+ Tab: 9,
20168
+ Enter: 13,
20169
+ Escape: 27,
20170
+ Space: 32,
20171
+ ArrowLeft: 37,
20172
+ ArrowUp: 38,
20173
+ ArrowRight: 39,
20174
+ ArrowDown: 40,
20175
+ Delete: 46,
20176
+ Home: 36,
20177
+ End: 35,
20178
+ PageUp: 33,
20179
+ PageDown: 34,
20180
+ Insert: 45,
20181
+ F1: 112,
20182
+ F2: 113,
20183
+ F3: 114,
20184
+ F4: 115,
20185
+ F5: 116,
20186
+ F6: 117,
20187
+ F7: 118,
20188
+ F8: 119,
20189
+ F9: 120,
20190
+ F10: 121,
20191
+ F11: 122,
20192
+ F12: 123,
20193
+ Control: 17,
20194
+ Shift: 16,
20195
+ Alt: 18,
20196
+ Meta: 91,
20197
+ CapsLock: 20,
20198
+ " ": 32
20199
+ };
20165
20200
  async function handleCdpEval(h, args) {
20166
20201
  if (!h.getCdp()?.isConnected) return { success: false, error: "CDP not connected" };
20167
20202
  const expression = args?.expression || args?.script;
@@ -20222,18 +20257,40 @@ var require_dist = __commonJS({
20222
20257
  try {
20223
20258
  switch (action) {
20224
20259
  case "input_key": {
20225
- const { key, modifiers } = params;
20226
- await h.getCdp().send("Input.dispatchKeyEvent", {
20227
- type: "keyDown",
20228
- key,
20229
- ...modifiers?.ctrl ? { modifiers: 2 } : {},
20230
- ...modifiers?.shift ? { modifiers: 8 } : {}
20231
- });
20232
- await h.getCdp().send("Input.dispatchKeyEvent", { type: "keyUp", key });
20260
+ const { type: evType, key, code, text, unmodifiedText, modifiers } = params;
20261
+ const mod = typeof modifiers === "number" ? modifiers : 0;
20262
+ const vk = KEY_TO_VK[key] || (key.length === 1 ? key.charCodeAt(0) : 0);
20263
+ if (evType === "char") {
20264
+ await h.getCdp().send("Input.dispatchKeyEvent", {
20265
+ type: "char",
20266
+ key,
20267
+ code,
20268
+ text: text || key,
20269
+ unmodifiedText: unmodifiedText || text || key,
20270
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
20271
+ ...mod ? { modifiers: mod } : {}
20272
+ });
20273
+ } else {
20274
+ await h.getCdp().send("Input.dispatchKeyEvent", {
20275
+ type: "rawKeyDown",
20276
+ key,
20277
+ code,
20278
+ ...text ? { text } : {},
20279
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
20280
+ ...mod ? { modifiers: mod } : {}
20281
+ });
20282
+ await h.getCdp().send("Input.dispatchKeyEvent", {
20283
+ type: "keyUp",
20284
+ key,
20285
+ code,
20286
+ ...vk ? { windowsVirtualKeyCode: vk, nativeVirtualKeyCode: vk } : {},
20287
+ ...mod ? { modifiers: mod } : {}
20288
+ });
20289
+ }
20233
20290
  return { success: true };
20234
20291
  }
20235
20292
  case "input_click": {
20236
- let { x, y, nx, ny, button: btn } = params;
20293
+ let { x, y, nx, ny, button: btn, clickCount } = params;
20237
20294
  if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
20238
20295
  const viewport = await h.getCdp().evaluate(
20239
20296
  "JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
@@ -20245,19 +20302,20 @@ var require_dist = __commonJS({
20245
20302
  if (x === void 0 || y === void 0) {
20246
20303
  return { success: false, error: "No coordinates provided (x,y or nx,ny required)" };
20247
20304
  }
20305
+ const cc = clickCount || 1;
20248
20306
  await h.getCdp().send("Input.dispatchMouseEvent", {
20249
20307
  type: "mousePressed",
20250
20308
  x,
20251
20309
  y,
20252
20310
  button: btn || "left",
20253
- clickCount: 1
20311
+ clickCount: cc
20254
20312
  });
20255
20313
  await h.getCdp().send("Input.dispatchMouseEvent", {
20256
20314
  type: "mouseReleased",
20257
20315
  x,
20258
20316
  y,
20259
20317
  button: btn || "left",
20260
- clickCount: 1
20318
+ clickCount: cc
20261
20319
  });
20262
20320
  return { success: true, x, y };
20263
20321
  }
@@ -20265,11 +20323,11 @@ var require_dist = __commonJS({
20265
20323
  const { text } = params;
20266
20324
  for (const char of text || "") {
20267
20325
  await h.getCdp().send("Input.dispatchKeyEvent", {
20268
- type: "keyDown",
20326
+ type: "char",
20269
20327
  text: char,
20270
- key: char
20328
+ key: char,
20329
+ unmodifiedText: char
20271
20330
  });
20272
- await h.getCdp().send("Input.dispatchKeyEvent", { type: "keyUp", key: char });
20273
20331
  }
20274
20332
  return { success: true };
20275
20333
  }
@@ -20300,6 +20358,23 @@ var require_dist = __commonJS({
20300
20358
  });
20301
20359
  return { success: true };
20302
20360
  }
20361
+ case "input_mouseMoved": {
20362
+ let { x, y, nx, ny } = params;
20363
+ if ((x === void 0 || y === void 0) && nx !== void 0 && ny !== void 0) {
20364
+ const viewport = await h.getCdp().evaluate(
20365
+ "JSON.stringify({ w: window.innerWidth, h: window.innerHeight })"
20366
+ );
20367
+ const { w, h: vh } = JSON.parse(viewport);
20368
+ x = Math.round(nx * w);
20369
+ y = Math.round(ny * vh);
20370
+ }
20371
+ await h.getCdp().send("Input.dispatchMouseEvent", {
20372
+ type: "mouseMoved",
20373
+ x: x || 0,
20374
+ y: y || 0
20375
+ });
20376
+ return { success: true };
20377
+ }
20303
20378
  default:
20304
20379
  return { success: false, error: `Unknown remote action: ${action}` };
20305
20380
  }
@@ -30207,7 +30282,7 @@ var init_adhdev_daemon = __esm({
30207
30282
  path2 = __toESM(require("path"));
30208
30283
  crypto2 = __toESM(require("crypto"));
30209
30284
  import_chalk = __toESM(require("chalk"));
30210
- pkgVersion = "0.5.28";
30285
+ pkgVersion = "0.5.29";
30211
30286
  if (pkgVersion === "unknown") {
30212
30287
  try {
30213
30288
  const possiblePaths = [