@swmansion/argent 0.15.1-next.2 → 0.15.1-next.3

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.
@@ -126784,10 +126784,11 @@ async function typeSimulatorServer(registry2, device, params) {
126784
126784
  }
126785
126785
  keysPressed++;
126786
126786
  };
126787
+ let namedKeyCode;
126787
126788
  if (params.key) {
126788
126789
  const lower = params.key.toLowerCase();
126789
- const code = Object.hasOwn(NAMED_KEYS, lower) ? NAMED_KEYS[lower] : void 0;
126790
- if (code == null) {
126790
+ namedKeyCode = Object.hasOwn(NAMED_KEYS, lower) ? NAMED_KEYS[lower] : void 0;
126791
+ if (namedKeyCode == null) {
126791
126792
  throw new InvalidToolInputError(
126792
126793
  `Unknown key "${params.key}". Supported: ${Object.keys(NAMED_KEYS).join(", ")}`,
126793
126794
  {
@@ -126797,7 +126798,6 @@ async function typeSimulatorServer(registry2, device, params) {
126797
126798
  }
126798
126799
  );
126799
126800
  }
126800
- await pressKeyCode(code);
126801
126801
  }
126802
126802
  if (params.text) {
126803
126803
  for (const char of params.text) {
@@ -126812,6 +126812,9 @@ async function typeSimulatorServer(registry2, device, params) {
126812
126812
  await sleep8(delay2);
126813
126813
  }
126814
126814
  }
126815
+ if (namedKeyCode != null) {
126816
+ await pressKeyCode(namedKeyCode);
126817
+ }
126815
126818
  return { typed: params.text ?? params.key ?? "", keys: keysPressed };
126816
126819
  }
126817
126820
 
@@ -126955,9 +126958,10 @@ var sleep9 = (ms) => new Promise((r) => setTimeout(r, ms));
126955
126958
  async function runChromium(api, params) {
126956
126959
  const delay2 = params.delayMs ?? 50;
126957
126960
  let keysPressed = 0;
126961
+ let named;
126958
126962
  if (params.key) {
126959
126963
  const lower = params.key.toLowerCase();
126960
- const named = Object.hasOwn(CHROMIUM_NAMED_KEYS, lower) ? CHROMIUM_NAMED_KEYS[lower] : void 0;
126964
+ named = Object.hasOwn(CHROMIUM_NAMED_KEYS, lower) ? CHROMIUM_NAMED_KEYS[lower] : void 0;
126961
126965
  if (!named) {
126962
126966
  throw new InvalidToolInputError(
126963
126967
  `Unknown key "${params.key}". Supported: ${Object.keys(CHROMIUM_NAMED_KEYS).join(", ")}`,
@@ -126968,20 +126972,6 @@ async function runChromium(api, params) {
126968
126972
  }
126969
126973
  );
126970
126974
  }
126971
- await api.dispatchKeyEvent({
126972
- type: "keyDown",
126973
- key: named.key,
126974
- code: named.code,
126975
- windowsVirtualKeyCode: named.windowsVirtualKeyCode
126976
- });
126977
- await sleep9(delay2);
126978
- await api.dispatchKeyEvent({
126979
- type: "keyUp",
126980
- key: named.key,
126981
- code: named.code,
126982
- windowsVirtualKeyCode: named.windowsVirtualKeyCode
126983
- });
126984
- keysPressed++;
126985
126975
  }
126986
126976
  if (params.text) {
126987
126977
  for (const char of params.text) {
@@ -127010,6 +127000,22 @@ async function runChromium(api, params) {
127010
127000
  await sleep9(delay2);
127011
127001
  }
127012
127002
  }
127003
+ if (named) {
127004
+ await api.dispatchKeyEvent({
127005
+ type: "keyDown",
127006
+ key: named.key,
127007
+ code: named.code,
127008
+ windowsVirtualKeyCode: named.windowsVirtualKeyCode
127009
+ });
127010
+ await sleep9(delay2);
127011
+ await api.dispatchKeyEvent({
127012
+ type: "keyUp",
127013
+ key: named.key,
127014
+ code: named.code,
127015
+ windowsVirtualKeyCode: named.windowsVirtualKeyCode
127016
+ });
127017
+ keysPressed++;
127018
+ }
127013
127019
  return { typed: params.text ?? params.key ?? "", keys: keysPressed };
127014
127020
  }
127015
127021
  function makeChromiumImpl(registry2) {
@@ -127093,7 +127099,7 @@ async function injectViaInputd(subcommands) {
127093
127099
  async function injectVegaButtons(buttons) {
127094
127100
  await injectViaInputd(remoteButtonsToKeycodes(buttons).map((code) => `button_press ${code}`));
127095
127101
  }
127096
- async function injectVegaNamedKey(name) {
127102
+ function resolveVegaNamedKeycode(name) {
127097
127103
  const lower = name.toLowerCase();
127098
127104
  const code = Object.hasOwn(NAMED_KEYCODES, lower) ? NAMED_KEYCODES[lower] : void 0;
127099
127105
  if (!code) {
@@ -127106,7 +127112,10 @@ async function injectVegaNamedKey(name) {
127106
127112
  }
127107
127113
  );
127108
127114
  }
127109
- await injectViaInputd([`button_press ${code}`]);
127115
+ return code;
127116
+ }
127117
+ async function injectVegaNamedKey(name) {
127118
+ await injectViaInputd([`button_press ${resolveVegaNamedKeycode(name)}`]);
127110
127119
  }
127111
127120
  async function injectVegaText(text) {
127112
127121
  if (/[\n\r]/.test(text)) {
@@ -127122,14 +127131,15 @@ async function injectVegaText(text) {
127122
127131
  // ../tool-server/src/tools/keyboard/platforms/vega.ts
127123
127132
  async function runVega2(params) {
127124
127133
  let keysPressed = 0;
127125
- if (params.key) {
127126
- await injectVegaNamedKey(params.key);
127127
- keysPressed++;
127128
- }
127134
+ if (params.key) resolveVegaNamedKeycode(params.key);
127129
127135
  if (params.text) {
127130
127136
  await injectVegaText(params.text);
127131
127137
  keysPressed += [...params.text].length;
127132
127138
  }
127139
+ if (params.key) {
127140
+ await injectVegaNamedKey(params.key);
127141
+ keysPressed++;
127142
+ }
127133
127143
  return { typed: params.text ?? params.key ?? "", keys: keysPressed };
127134
127144
  }
127135
127145
  var vegaImpl4 = {
@@ -127144,7 +127154,7 @@ var zodSchema24 = external_exports.object({
127144
127154
  ),
127145
127155
  text: external_exports.string().optional().describe("Text to type character by character. Handles uppercase and common punctuation."),
127146
127156
  key: external_exports.string().optional().describe(
127147
- "Named key to press: enter, escape, backspace, tab, space, arrow-up, arrow-down, arrow-left, arrow-right, f1\u2013f12. Not supported on TV targets \u2014 move focus with `tv-remote` (up/down/left/right) instead."
127157
+ "Named key to press: enter, escape, backspace, tab, space, arrow-up, arrow-down, arrow-left, arrow-right, f1\u2013f12. When combined with `text`, the key is pressed AFTER the text is typed (so text + enter types and submits). Not supported on TV targets \u2014 move focus with `tv-remote` (up/down/left/right) instead."
127148
127158
  ),
127149
127159
  delayMs: external_exports.number().optional().describe(
127150
127160
  "Delay in ms between key presses (default 50). Ignored on Android phones/tablets (typed via `adb input text`, which has no per-key cadence), on Vega (text/keys injected in a single shot), and on TV targets (Apple TV / Android TV type the whole string at the daemon's own cadence)."
@@ -127166,7 +127176,7 @@ Returns { typed: string, keys: number }. Fails if an unsupported key name is pro
127166
127176
  - text: types a string (supports uppercase, digits, common punctuation)
127167
127177
  - key: presses a single named key (enter, escape, backspace, tab, arrow-up/down/left/right, f1\u2013f12) \u2014 NOT supported on TV targets; move focus with \`tv-remote\` instead.
127168
127178
  On a TV target (runtimeKind 'tv') only \`text\` applies \u2014 focus a text field first (with \`tv-remote\`), then type into it (injected HID keyboard on Apple TV, \`adb input text\` on Android TV).
127169
- Provide text, key, or both.`,
127179
+ Provide text, key, or both \u2014 when both are given, the text is typed first and the key is pressed after it (text + key:"enter" types and submits).`,
127170
127180
  zodSchema: zodSchema24,
127171
127181
  capability: capability16,
127172
127182
  searchHint: "type text keyboard input named key enter escape arrow tv vega fire tv search field hid leanback",
@@ -133565,7 +133575,7 @@ Allowed tools and their args (udid is auto-injected, do NOT include it in args):
133565
133575
  gesture-pinch: { centerX: number, centerY: number, startDistance: number, endDistance: number, angle?: number, durationMs?: number } [ios only]
133566
133576
  gesture-rotate: { centerX: number, centerY: number, radius: number, startAngle: number, endAngle: number, durationMs?: number } [ios only]
133567
133577
  button: { button: "home"|"back"|"power"|"volumeUp"|"volumeDown"|"appSwitch"|"actionButton" } [ios/android]
133568
- keyboard: { text?: string, key?: string, delayMs?: number } (TV: text only) [ios/android/chromium/vega/tv]
133578
+ keyboard: { text?: string, key?: string, delayMs?: number } (key pressed after text; TV: text only) [ios/android/chromium/vega/tv]
133569
133579
  rotate: { orientation: "Portrait"|"LandscapeLeft"|"LandscapeRight"|"PortraitUpsideDown" } [ios/android]
133570
133580
  tv-remote: { button: <remote button | array of them>, repeat?: number } [apple tv/android tv/vega]
133571
133581
  buttons: up/down/left/right/select/back/home/menu/playPause (+ rewind/fastForward/next/previous/volumeUp/volumeDown/mute \u2014 work on Android TV and Vega; rejected on the Apple TV simulator)
@@ -133578,10 +133588,9 @@ Example \u2014 scroll down three times (use gesture-scroll with positive deltaY
133578
133588
  { "tool": "gesture-swipe", "args": { "fromX": 0.5, "fromY": 0.7, "toX": 0.5, "toY": 0.3 } }
133579
133589
  ]}
133580
133590
 
133581
- Example \u2014 type text and submit:
133591
+ Example \u2014 type text and submit (one step: the key is pressed after the text is typed):
133582
133592
  { "udid": "<UDID>", "steps": [
133583
- { "tool": "keyboard", "args": { "text": "hello world" } },
133584
- { "tool": "keyboard", "args": { "key": "enter" } }
133593
+ { "tool": "keyboard", "args": { "text": "hello world", "key": "enter" } }
133585
133594
  ]}
133586
133595
 
133587
133596
  Example \u2014 TV: move focus right twice then activate (one tv-remote step with a path is cheaper):
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/argent",
3
- "version": "0.15.1-next.2",
3
+ "version": "0.15.1-next.3",
4
4
  "description": "MCP server for iOS Simulator and Android Emulator control",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {