@midscene/ios 1.0.1-beta-20251022061922.0 → 1.0.1-beta-20251024063839.0

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/lib/index.js CHANGED
@@ -234,19 +234,45 @@ class IOSWebDriverClient extends webdriver_namespaceObject.WebDriverClient {
234
234
  }
235
235
  async swipe(fromX, fromY, toX, toY, duration = 500) {
236
236
  this.ensureSession();
237
- try {
238
- await this.makeRequest('POST', `/session/${this.sessionId}/wda/dragfromtoforduration`, {
239
- fromX,
240
- fromY,
241
- toX,
242
- toY,
243
- duration: duration / 1000
244
- });
245
- debugIOS(`Swiped from (${fromX}, ${fromY}) to (${toX}, ${toY}) in ${duration}ms`);
246
- } catch (error) {
247
- debugIOS(`Failed to swipe from (${fromX}, ${fromY}) to (${toX}, ${toY}): ${error}`);
248
- throw new Error(`Failed to swipe: ${error}`);
249
- }
237
+ const actions = {
238
+ actions: [
239
+ {
240
+ type: 'pointer',
241
+ id: 'finger1',
242
+ parameters: {
243
+ pointerType: 'touch'
244
+ },
245
+ actions: [
246
+ {
247
+ type: 'pointerMove',
248
+ duration: 0,
249
+ x: fromX,
250
+ y: fromY
251
+ },
252
+ {
253
+ type: 'pointerDown',
254
+ button: 0
255
+ },
256
+ {
257
+ type: 'pause',
258
+ duration: 100
259
+ },
260
+ {
261
+ type: 'pointerMove',
262
+ duration,
263
+ x: toX,
264
+ y: toY
265
+ },
266
+ {
267
+ type: 'pointerUp',
268
+ button: 0
269
+ }
270
+ ]
271
+ }
272
+ ]
273
+ };
274
+ await this.makeRequest('POST', `/session/${this.sessionId}/actions`, actions);
275
+ debugIOS(`Swiped using W3C Actions from (${fromX}, ${fromY}) to (${toX}, ${toY}) in ${duration}ms`);
250
276
  }
251
277
  async longPress(x, y, duration = 1000) {
252
278
  this.ensureSession();
@@ -392,8 +418,7 @@ class IOSDevice {
392
418
  await this.swipe(from.center[0], from.center[1], to.center[0], to.center[1]);
393
419
  }),
394
420
  (0, device_namespaceObject.defineActionKeyboardPress)(async (param)=>{
395
- const key = param.keyName;
396
- await this.pressKey(key);
421
+ await this.pressKey(param.keyName);
397
422
  }),
398
423
  (0, device_namespaceObject.defineAction)({
399
424
  name: 'IOSHomeButton',
@@ -549,23 +574,23 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
549
574
  return '';
550
575
  }
551
576
  async tap(x, y) {
552
- await this.wdaBackend.tap(x, y);
577
+ await this.wdaBackend.tap(Math.round(x), Math.round(y));
553
578
  }
554
579
  async mouseClick(x, y) {
555
580
  debugDevice(`mouseClick at coordinates (${x}, ${y})`);
556
581
  await this.tap(x, y);
557
582
  }
558
583
  async doubleTap(x, y) {
559
- await this.wdaBackend.doubleTap(x, y);
584
+ await this.wdaBackend.doubleTap(Math.round(x), Math.round(y));
560
585
  }
561
586
  async tripleTap(x, y) {
562
- await this.wdaBackend.tripleTap(x, y);
587
+ await this.wdaBackend.tripleTap(Math.round(x), Math.round(y));
563
588
  }
564
589
  async longPress(x, y, duration = 1000) {
565
- await this.wdaBackend.longPress(x, y, duration);
590
+ await this.wdaBackend.longPress(Math.round(x), Math.round(y), duration);
566
591
  }
567
592
  async swipe(fromX, fromY, toX, toY, duration = 500) {
568
- await this.wdaBackend.swipe(fromX, fromY, toX, toY, duration);
593
+ await this.wdaBackend.swipe(Math.round(fromX), Math.round(fromY), Math.round(toX), Math.round(toY), duration);
569
594
  }
570
595
  async typeText(text, options) {
571
596
  var _this_options;
@@ -588,49 +613,49 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
588
613
  async scrollUp(distance, startPoint) {
589
614
  const { width, height } = await this.size();
590
615
  const start = startPoint ? {
591
- x: startPoint.left,
592
- y: startPoint.top
616
+ x: Math.round(startPoint.left),
617
+ y: Math.round(startPoint.top)
593
618
  } : {
594
- x: width / 2,
595
- y: height / 2
619
+ x: Math.round(width / 2),
620
+ y: Math.round(height / 2)
596
621
  };
597
- const scrollDistance = distance || height / 3;
622
+ const scrollDistance = Math.round(distance || height / 3);
598
623
  await this.swipe(start.x, start.y, start.x, start.y + scrollDistance);
599
624
  }
600
625
  async scrollDown(distance, startPoint) {
601
626
  const { width, height } = await this.size();
602
627
  const start = startPoint ? {
603
- x: startPoint.left,
604
- y: startPoint.top
628
+ x: Math.round(startPoint.left),
629
+ y: Math.round(startPoint.top)
605
630
  } : {
606
- x: width / 2,
607
- y: height / 2
631
+ x: Math.round(width / 2),
632
+ y: Math.round(height / 2)
608
633
  };
609
- const scrollDistance = distance || height / 3;
634
+ const scrollDistance = Math.round(distance || height / 3);
610
635
  await this.swipe(start.x, start.y, start.x, start.y - scrollDistance);
611
636
  }
612
637
  async scrollLeft(distance, startPoint) {
613
638
  const { width, height } = await this.size();
614
639
  const start = startPoint ? {
615
- x: startPoint.left,
616
- y: startPoint.top
640
+ x: Math.round(startPoint.left),
641
+ y: Math.round(startPoint.top)
617
642
  } : {
618
- x: width / 2,
619
- y: height / 2
643
+ x: Math.round(width / 2),
644
+ y: Math.round(height / 2)
620
645
  };
621
- const scrollDistance = distance || width / 3;
646
+ const scrollDistance = Math.round(distance || 0.7 * width);
622
647
  await this.swipe(start.x, start.y, start.x + scrollDistance, start.y);
623
648
  }
624
649
  async scrollRight(distance, startPoint) {
625
650
  const { width, height } = await this.size();
626
651
  const start = startPoint ? {
627
- x: startPoint.left,
628
- y: startPoint.top
652
+ x: Math.round(startPoint.left),
653
+ y: Math.round(startPoint.top)
629
654
  } : {
630
- x: width / 2,
631
- y: height / 2
655
+ x: Math.round(width / 2),
656
+ y: Math.round(height / 2)
632
657
  };
633
- const scrollDistance = distance || width / 3;
658
+ const scrollDistance = Math.round(distance || 0.7 * width);
634
659
  await this.swipe(start.x, start.y, start.x - scrollDistance, start.y);
635
660
  }
636
661
  async scrollUntilTop(startPoint) {
@@ -671,32 +696,32 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
671
696
  const { width, height } = await this.size();
672
697
  let start;
673
698
  if (startPoint) start = {
674
- x: startPoint.left,
675
- y: startPoint.top
699
+ x: Math.round(startPoint.left),
700
+ y: Math.round(startPoint.top)
676
701
  };
677
702
  else switch(direction){
678
703
  case 'up':
679
704
  start = {
680
- x: width / 2,
681
- y: 0.2 * height
705
+ x: Math.round(width / 2),
706
+ y: Math.round(0.2 * height)
682
707
  };
683
708
  break;
684
709
  case 'down':
685
710
  start = {
686
- x: width / 2,
687
- y: 0.8 * height
711
+ x: Math.round(width / 2),
712
+ y: Math.round(0.8 * height)
688
713
  };
689
714
  break;
690
715
  case 'left':
691
716
  start = {
692
- x: 0.8 * width,
693
- y: height / 2
717
+ x: Math.round(0.8 * width),
718
+ y: Math.round(height / 2)
694
719
  };
695
720
  break;
696
721
  case 'right':
697
722
  start = {
698
- x: 0.2 * width,
699
- y: height / 2
723
+ x: Math.round(0.2 * width),
724
+ y: Math.round(height / 2)
700
725
  };
701
726
  break;
702
727
  }
@@ -723,7 +748,7 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
723
748
  break;
724
749
  }
725
750
  lastScreenshot = currentScreenshot;
726
- const scrollDistance = 'left' === direction || 'right' === direction ? 0.6 * width : 0.6 * height;
751
+ const scrollDistance = Math.round('left' === direction || 'right' === direction ? 0.6 * width : 0.6 * height);
727
752
  debugDevice(`Performing scroll: ${direction}, distance: ${scrollDistance}`);
728
753
  switch(direction){
729
754
  case 'up':
@@ -760,9 +785,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
760
785
  try {
761
786
  debugDevice('Triggering app switcher with slow swipe up gesture');
762
787
  const { width, height } = await this.size();
763
- const centerX = width / 2;
764
- const startY = height - 5;
765
- const endY = 0.5 * height;
788
+ const centerX = Math.round(width / 2);
789
+ const startY = Math.round(height - 5);
790
+ const endY = Math.round(0.5 * height);
766
791
  await this.wdaBackend.swipe(centerX, startY, centerX, endY, 1500);
767
792
  await (0, utils_namespaceObject.sleep)(800);
768
793
  } catch (error) {
@@ -780,9 +805,9 @@ ScreenSize: ${size.width}x${size.height} (DPR: ${size.scale})
780
805
  return true;
781
806
  }
782
807
  const windowSize = await this.wdaBackend.getWindowSize();
783
- const centerX = windowSize.width / 2;
784
- const startY = 0.33 * windowSize.height;
785
- const endY = 0.33 * windowSize.height + 10;
808
+ const centerX = Math.round(windowSize.width / 2);
809
+ const startY = Math.round(0.33 * windowSize.height);
810
+ const endY = Math.round(0.33 * windowSize.height + 10);
786
811
  await this.swipe(centerX, startY, centerX, endY, 50);
787
812
  debugDevice('Dismissed keyboard with swipe down gesture at screen one-third position');
788
813
  await (0, utils_namespaceObject.sleep)(300);
@@ -927,13 +952,7 @@ async function agentFromWebDriverAgent(opts) {
927
952
  debugAgent('Creating iOS agent with WebDriverAgent auto-detection');
928
953
  const envCheck = await checkIOSEnvironment();
929
954
  if (!envCheck.available) throw new Error(`iOS environment not available: ${envCheck.error}`);
930
- const device = new IOSDevice({
931
- autoDismissKeyboard: null == opts ? void 0 : opts.autoDismissKeyboard,
932
- customActions: null == opts ? void 0 : opts.customActions,
933
- wdaPort: null == opts ? void 0 : opts.wdaPort,
934
- wdaHost: null == opts ? void 0 : opts.wdaHost,
935
- useWDA: null == opts ? void 0 : opts.useWDA
936
- });
955
+ const device = new IOSDevice(opts || {});
937
956
  await device.connect();
938
957
  return new IOSAgent(device, opts);
939
958
  }
@@ -4,6 +4,8 @@ import { AgentOpt } from '@midscene/core/agent';
4
4
  import { DeviceAction } from '@midscene/core';
5
5
  import type { ElementInfo } from '@midscene/shared/extractor';
6
6
  import { InterfaceType } from '@midscene/core';
7
+ import { IOSDeviceInputOpt } from '@midscene/core/device';
8
+ import { IOSDeviceOpt } from '@midscene/core/device';
7
9
  import { overrideAIConfig } from '@midscene/shared/env';
8
10
  import { Point } from '@midscene/core';
9
11
  import { Size } from '@midscene/core';
@@ -94,18 +96,6 @@ export declare class IOSDevice implements AbstractInterface {
94
96
  destroy(): Promise<void>;
95
97
  }
96
98
 
97
- declare type IOSDeviceInputOpt = {
98
- autoDismissKeyboard?: boolean;
99
- };
100
-
101
- declare type IOSDeviceOpt = {
102
- deviceId?: string;
103
- customActions?: DeviceAction<any>[];
104
- wdaPort?: number;
105
- wdaHost?: string;
106
- useWDA?: boolean;
107
- } & IOSDeviceInputOpt;
108
-
109
99
  export declare class IOSWebDriverClient extends WebDriverClient {
110
100
  launchApp(bundleId: string): Promise<void>;
111
101
  activateApp(bundleId: string): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@midscene/ios",
3
- "version": "1.0.1-beta-20251022061922.0",
3
+ "version": "1.0.1-beta-20251024063839.0",
4
4
  "description": "iOS automation library for Midscene",
5
5
  "keywords": [
6
6
  "iOS UI automation",
@@ -38,9 +38,9 @@
38
38
  "dependencies": {
39
39
  "@inquirer/prompts": "^7.8.6",
40
40
  "open": "10.1.0",
41
- "@midscene/shared": "1.0.1-beta-20251022061922.0",
42
- "@midscene/core": "1.0.1-beta-20251022061922.0",
43
- "@midscene/webdriver": "1.0.1-beta-20251022061922.0"
41
+ "@midscene/core": "1.0.1-beta-20251024063839.0",
42
+ "@midscene/webdriver": "1.0.1-beta-20251024063839.0",
43
+ "@midscene/shared": "1.0.1-beta-20251024063839.0"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@rslib/core": "^0.11.2",
@@ -49,7 +49,7 @@
49
49
  "typescript": "^5.8.3",
50
50
  "tsx": "^4.19.2",
51
51
  "vitest": "3.0.5",
52
- "@midscene/playground": "1.0.1-beta-20251022061922.0"
52
+ "@midscene/playground": "1.0.1-beta-20251024063839.0"
53
53
  },
54
54
  "license": "MIT",
55
55
  "scripts": {
package/static/index.html CHANGED
@@ -1 +1 @@
1
- <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.88bfef40.js"></script><script defer src="/static/js/63.b6f8c5e5.js"></script><script defer src="/static/js/index.fd41dad8.js"></script><link href="/static/css/index.44466eb4.css" rel="stylesheet"></head><body><div id="root"></div></body></html>
1
+ <!doctype html><html><head><link rel="icon" href="/favicon.ico"><title>Midscene Playground</title><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><script defer src="/static/js/lib-react.88bfef40.js"></script><script defer src="/static/js/63.b6f8c5e5.js"></script><script defer src="/static/js/index.1a0f1b0a.js"></script><link href="/static/css/index.44466eb4.css" rel="stylesheet"></head><body><div id="root"></div></body></html>