@appium/images-plugin 4.2.8 → 5.0.1

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/lib/logger.ts CHANGED
@@ -1,3 +1,3 @@
1
- import {logger} from 'appium/support';
1
+ import {logger} from 'appium/support.js';
2
2
 
3
3
  export const log = logger.getLogger('ImageElementPlugin');
package/lib/plugin.ts CHANGED
@@ -1,13 +1,13 @@
1
1
  import type {MatchingOptions, OccurrenceOptions, SimilarityOptions} from '@appium/opencv';
2
2
  import {util} from '@appium/support';
3
3
  import type {ActionSequence, Element, ExternalDriver, MethodMap} from '@appium/types';
4
- import {errors} from 'appium/driver';
5
- import {BasePlugin} from 'appium/plugin';
4
+ import {errors} from 'appium/driver.js';
5
+ import {BasePlugin} from 'appium/plugin.js';
6
6
 
7
- import {compareImages} from './compare';
8
- import {IMAGE_ELEMENT_PREFIX, IMAGE_STRATEGY} from './constants';
9
- import {ImageElementFinder} from './finder';
10
- import {ImageElement} from './image-element';
7
+ import {compareImages} from './compare.js';
8
+ import {IMAGE_ELEMENT_PREFIX, IMAGE_STRATEGY} from './constants.js';
9
+ import {ImageElementFinder} from './finder.js';
10
+ import {ImageElement} from './image-element.js';
11
11
 
12
12
  export class ImageElementPlugin extends BasePlugin {
13
13
  // this plugin supports a non-standard 'compare images' command
@@ -94,9 +94,10 @@ export class ImageElementPlugin extends BasePlugin {
94
94
  throw new errors.NoSuchElementError();
95
95
  }
96
96
 
97
- // Add the element's center coordinates to the offset value.
98
- actionWithEl.x += imgEl.center.x;
99
- actionWithEl.y += imgEl.center.y;
97
+ // Add the element's center to the offset. An unset offset must count as
98
+ // zero, otherwise the resulting coordinate is NaN.
99
+ actionWithEl.x = (actionWithEl.x ?? 0) + imgEl.center.x;
100
+ actionWithEl.y = (actionWithEl.y ?? 0) + imgEl.center.y;
100
101
  // Set the origin to the viewport so that the external driver can process it using coordinates.
101
102
  delete actionWithEl.origin;
102
103
  }
package/lib/types.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import type {MatchingResult, OccurrenceResult, SimilarityResult} from '@appium/opencv';
2
2
  import type {Rect} from '@appium/types';
3
3
 
4
- import type {IMAGE_EL_TAP_STRATEGY_MJSONWP, IMAGE_EL_TAP_STRATEGY_W3C} from './constants';
5
- import type {ImageElementFinder} from './finder';
4
+ import type {IMAGE_EL_TAP_STRATEGY_MJSONWP, IMAGE_EL_TAP_STRATEGY_W3C} from './constants.js';
5
+ import type {ImageElementFinder} from './finder.js';
6
6
 
7
7
  /**
8
8
  * Image settings interface for device settings
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@appium/images-plugin",
3
- "version": "4.2.8",
4
- "gitHead": "f7b20335eab4022e5cbbb627ec86866a994444f8",
3
+ "version": "5.0.1",
4
+ "gitHead": "eb5ce47b17c6e3da79e57e0c2b3e4afa649878e4",
5
5
  "description": "Plugin for working with images and image elements in Appium",
6
6
  "keywords": [
7
7
  "android",
@@ -30,22 +30,30 @@
30
30
  "lib",
31
31
  "tsconfig.json"
32
32
  ],
33
+ "type": "module",
33
34
  "main": "./build/lib/index.js",
34
35
  "types": "./build/lib/index.d.ts",
36
+ "exports": {
37
+ ".": {
38
+ "types": "./build/lib/index.d.ts",
39
+ "import": "./build/lib/index.js"
40
+ },
41
+ "./package.json": "./package.json"
42
+ },
35
43
  "publishConfig": {
36
44
  "access": "public"
37
45
  },
38
46
  "scripts": {
39
47
  "test": "npm run test:unit",
40
48
  "test:smoke": "node ./build/lib/index.js",
41
- "test:unit": "node --test --enable-source-maps --test-timeout=5000 \"./build/test/unit/**/*.spec.js\"",
49
+ "test:unit": "node --test --experimental-test-module-mocks --enable-source-maps --test-timeout=10000 \"./build/test/unit/**/*.spec.js\"",
42
50
  "test:e2e": "node --test --enable-source-maps --test-force-exit --test-concurrency=1 --test-timeout=20000 \"./build/test/e2e/**/*.spec.js\""
43
51
  },
44
52
  "dependencies": {
45
- "@appium/opencv": "4.1.7",
46
- "@appium/support": "7.2.6",
47
- "lru-cache": "11.5.2",
48
- "sharp": "0.35.3"
53
+ "@appium/opencv": "5.0.1",
54
+ "@appium/support": "7.2.8",
55
+ "lru-cache": "11.5.3",
56
+ "sharp": "0.35.4"
49
57
  },
50
58
  "peerDependencies": {
51
59
  "appium": "^3.0.0-beta.0"
package/tsconfig.json CHANGED
@@ -5,8 +5,14 @@
5
5
  "checkJs": true,
6
6
  "esModuleInterop": true,
7
7
  "strict": true,
8
+ "module": "NodeNext",
9
+ "moduleResolution": "NodeNext",
8
10
  "paths": {
9
- "@appium/opencv": ["../opencv"]
11
+ "@appium/opencv": ["../opencv"],
12
+ "appium": ["../appium"],
13
+ "appium/driver.js": ["../appium/driver.d.ts"],
14
+ "appium/plugin.js": ["../appium/plugin.d.ts"],
15
+ "appium/support.js": ["../appium/support.d.ts"]
10
16
  },
11
17
  "types": ["node"]
12
18
  },