@appium/images-plugin 2.1.6 → 2.1.8

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.
@@ -1,3 +1,39 @@
1
- export type OccurrenceResult = import('@appium/opencv').OccurrenceResult;
2
- export function compareImages(next: import("@appium/types").NextPluginCallback<unknown>, driver: [string, string, string, any], ...args: Promise<import("@appium/opencv").OccurrenceResult>): Promise<unknown>;
1
+ export type Visualized = {
2
+ visualization: string | null | undefined;
3
+ };
4
+ export type MatchingResult = import('@appium/opencv').MatchingResult & Visualized;
5
+ export type OccurrenceResult = import('@appium/opencv').OccurrenceResult & Visualized;
6
+ export type SimilarityResult = import('@appium/opencv').SimilarityResult & Visualized;
7
+ export type ComparisonResult = MatchingResult | OccurrenceResult | SimilarityResult | SimilarityResult[];
8
+ /**
9
+ * @typedef {{visualization: string|null|undefined}} Visualized
10
+ * @typedef {import('@appium/opencv').MatchingResult & Visualized} MatchingResult
11
+ * @typedef {import('@appium/opencv').OccurrenceResult & Visualized} OccurrenceResult
12
+ * @typedef {import('@appium/opencv').SimilarityResult & Visualized} SimilarityResult
13
+ * @typedef {MatchingResult|OccurrenceResult|SimilarityResult|SimilarityResult[]} ComparisonResult
14
+ */
15
+ /**
16
+ * Performs images comparison using OpenCV framework features.
17
+ * It is expected that both OpenCV framework and opencv4nodejs
18
+ * module are installed on the machine where Appium server is running.
19
+ *
20
+ * @param {string} mode - One of possible comparison modes:
21
+ * matchFeatures, getSimilarity, matchTemplate
22
+ * @param {string|Buffer} firstImage - Base64-encoded image file.
23
+ * All image formats, that OpenCV library itself accepts, are supported.
24
+ * @param {string|Buffer} secondImage - Base64-encoded image file.
25
+ * All image formats, that OpenCV library itself accepts, are supported.
26
+ * @param {import('@appium/opencv').MatchingOptions
27
+ * |import('@appium/opencv').SimilarityOptions
28
+ * |import('@appium/opencv').OccurrenceOptions} [options={}] - The content of this dictionary depends
29
+ * on the actual `mode` value. See the documentation on `@appium/support`
30
+ * module for more details.
31
+ * @returns {Promise<ComparisonResult>} The content of the resulting dictionary depends
32
+ * on the actual `mode` and `options` values. See the documentation on
33
+ * `@appium/support` module for more details.
34
+ * @throws {Error} If required OpenCV modules are not installed or
35
+ * if `mode` value is incorrect or if there was an unexpected issue while
36
+ * matching the images.
37
+ */
38
+ export function compareImages(mode: string, firstImage: string | Buffer, secondImage: string | Buffer, options?: import("@appium/opencv").MatchingOptions | import("@appium/opencv").SimilarityOptions | import("@appium/opencv").OccurrenceOptions | undefined): Promise<ComparisonResult>;
3
39
  //# sourceMappingURL=compare.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":"+BAoFa,OAAO,gBAAgB,EAAE,gBAAgB;AAEkmC,+MAAsF"}
1
+ {"version":3,"file":"compare.d.ts","sourceRoot":"","sources":["../../lib/compare.js"],"names":[],"mappings":"yBAMa;IAAC,aAAa,EAAE,MAAM,GAAC,IAAI,GAAC,SAAS,CAAA;CAAC;6BACtC,OAAO,gBAAgB,EAAE,cAAc,GAAG,UAAU;+BACpD,OAAO,gBAAgB,EAAE,gBAAgB,GAAG,UAAU;+BACtD,OAAO,gBAAgB,EAAE,gBAAgB,GAAG,UAAU;+BACtD,cAAc,GAAC,gBAAgB,GAAC,gBAAgB,GAAC,gBAAgB,EAAE;AALhF;;;;;;GAMG;AAEH;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,oCAlBW,MAAM,cAEN,MAAM,GAAC,MAAM,eAEb,MAAM,GAAC,MAAM,6JAOX,QAAQ,gBAAgB,CAAC,CAgDrC"}
@@ -8,6 +8,13 @@ const lodash_1 = __importDefault(require("lodash"));
8
8
  const driver_1 = require("appium/driver");
9
9
  const opencv_1 = require("@appium/opencv");
10
10
  const constants_1 = require("./constants");
11
+ /**
12
+ * @typedef {{visualization: string|null|undefined}} Visualized
13
+ * @typedef {import('@appium/opencv').MatchingResult & Visualized} MatchingResult
14
+ * @typedef {import('@appium/opencv').OccurrenceResult & Visualized} OccurrenceResult
15
+ * @typedef {import('@appium/opencv').SimilarityResult & Visualized} SimilarityResult
16
+ * @typedef {MatchingResult|OccurrenceResult|SimilarityResult|SimilarityResult[]} ComparisonResult
17
+ */
11
18
  /**
12
19
  * Performs images comparison using OpenCV framework features.
13
20
  * It is expected that both OpenCV framework and opencv4nodejs
@@ -19,43 +26,44 @@ const constants_1 = require("./constants");
19
26
  * All image formats, that OpenCV library itself accepts, are supported.
20
27
  * @param {string|Buffer} secondImage - Base64-encoded image file.
21
28
  * All image formats, that OpenCV library itself accepts, are supported.
22
- * @param {object} [options] - The content of this dictionary depends
29
+ * @param {import('@appium/opencv').MatchingOptions
30
+ * |import('@appium/opencv').SimilarityOptions
31
+ * |import('@appium/opencv').OccurrenceOptions} [options={}] - The content of this dictionary depends
23
32
  * on the actual `mode` value. See the documentation on `@appium/support`
24
33
  * module for more details.
25
- * @returns {Promise<object|object[]>} The content of the resulting dictionary depends
34
+ * @returns {Promise<ComparisonResult>} The content of the resulting dictionary depends
26
35
  * on the actual `mode` and `options` values. See the documentation on
27
36
  * `@appium/support` module for more details.
28
37
  * @throws {Error} If required OpenCV modules are not installed or
29
38
  * if `mode` value is incorrect or if there was an unexpected issue while
30
39
  * matching the images.
31
40
  */
32
- /**
33
- * @type {import('@appium/types').PluginCommand<[string, string, string, object|undefined], Promise<OccurrenceResult>>}
34
- */
35
41
  async function compareImages(mode, firstImage, secondImage, options = {}) {
36
42
  const img1 = Buffer.isBuffer(firstImage) ? firstImage : Buffer.from(firstImage, 'base64');
37
43
  const img2 = Buffer.isBuffer(secondImage) ? secondImage : Buffer.from(secondImage, 'base64');
38
- let result = null;
44
+ let result;
39
45
  switch (lodash_1.default.toLower(mode)) {
40
46
  case constants_1.MATCH_FEATURES_MODE.toLowerCase():
41
47
  try {
42
- result = await (0, opencv_1.getImagesMatches)(img1, img2, options);
48
+ result = await (0, opencv_1.getImagesMatches)(img1, img2, /** @type {import('@appium/opencv').MatchingOptions} */ (options));
43
49
  }
44
50
  catch (err) {
45
51
  // might throw if no matches
46
- result = { count: 0 };
52
+ result = /** @type {import('@appium/opencv').MatchingResult} */ ({ count: 0 });
47
53
  }
48
54
  break;
49
55
  case constants_1.GET_SIMILARITY_MODE.toLowerCase():
50
- result = await (0, opencv_1.getImagesSimilarity)(img1, img2, options);
56
+ result = await (0, opencv_1.getImagesSimilarity)(img1, img2, /** @type {import('@appium/opencv').SimilarityOptions} */ (options));
51
57
  break;
52
- case constants_1.MATCH_TEMPLATE_MODE.toLowerCase():
58
+ case constants_1.MATCH_TEMPLATE_MODE.toLowerCase(): {
59
+ const opts = /** @type {import('@appium/opencv').OccurrenceOptions} */ (options);
53
60
  // firstImage/img1 is the full image and secondImage/img2 is the partial one
54
- result = await (0, opencv_1.getImageOccurrence)(img1, img2, options);
55
- if (options.multiple) {
61
+ result = await (0, opencv_1.getImageOccurrence)(img1, img2, opts);
62
+ if (opts.multiple) {
56
63
  return result.multiple.map(convertVisualizationToBase64);
57
64
  }
58
65
  break;
66
+ }
59
67
  default:
60
68
  throw new driver_1.errors.InvalidArgumentError(`'${mode}' images comparison mode is unknown. ` +
61
69
  `Only ${JSON.stringify([
@@ -71,16 +79,15 @@ exports.compareImages = compareImages;
71
79
  * base64 encodes the visualization part of the result
72
80
  * (if necessary)
73
81
  *
74
- * @param {OccurrenceResult} element - occurrence result
75
- *
82
+ * @param {Partial<{visualization: Buffer|null}>} element - occurrence result
83
+ * @returns {any} I know this looks ugly from the typing perspective
76
84
  **/
77
85
  function convertVisualizationToBase64(element) {
78
- if (!lodash_1.default.isEmpty(element.visualization)) {
79
- element.visualization = element.visualization.toString('base64');
80
- }
81
- return element;
86
+ return Buffer.isBuffer(element.visualization)
87
+ ? {
88
+ ...(element),
89
+ visualization: element.visualization.toString('base64')
90
+ }
91
+ : element;
82
92
  }
83
- /**
84
- * @typedef {import('@appium/opencv').OccurrenceResult} OccurrenceResult
85
- */
86
93
  //# sourceMappingURL=compare.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3C,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,aAAa,CAAC;QAC3C,CAAC,CAAC;YACA,GAAG,CAAC,OAAO,CAAC;YACZ,aAAa,EAAE,OAAO,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;SACxD;QACD,CAAC,CAAC,OAAO,CAAC;AACd,CAAC"}
@@ -3,8 +3,8 @@ export default class ImageElementFinder {
3
3
  * @param {number} max
4
4
  */
5
5
  constructor(max?: number);
6
- /** @type {LRU<string,ImageElement>} */
7
- _imgElCache: LRU<string, ImageElement>;
6
+ /** @type {LRUCache<string,ImageElement>} */
7
+ _imgElCache: LRUCache<string, ImageElement>;
8
8
  /**
9
9
  * @param {ImageElement} imgEl
10
10
  * @returns {Element}
@@ -25,7 +25,7 @@ export default class ImageElementFinder {
25
25
  * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
26
26
  * ignore defaultImageTemplateScale. It can be used when you would like to
27
27
  * scale template with defaultImageTemplateScale setting.
28
- * @property {import('@appium/types').Rect?} containerRect - The bounding
28
+ * @property {import('@appium/types').Rect?} [containerRect=null] - The bounding
29
29
  * rectangle to limit the search in
30
30
  */
31
31
  /**
@@ -60,7 +60,7 @@ export default class ImageElementFinder {
60
60
  * - The bounding
61
61
  * rectangle to limit the search in
62
62
  */
63
- containerRect: import('@appium/types').Rect | null;
63
+ containerRect?: import("@appium/types").Rect | null | undefined;
64
64
  }): Promise<Element | Element[] | ImageElement>;
65
65
  /**
66
66
  * Ensure that the image template sent in for a find is of a suitable size
@@ -85,13 +85,13 @@ export default class ImageElementFinder {
85
85
  }>;
86
86
  /**
87
87
  * @typedef ImageTemplateSettings
88
- * @property {boolean} fixImageTemplateScale - fixImageTemplateScale in device-settings
89
- * @property {number} defaultImageTemplateScale - defaultImageTemplateScale in device-settings
90
- * @property {boolean} ignoreDefaultImageTemplateScale - Ignore defaultImageTemplateScale if it has true.
88
+ * @property {boolean} [fixImageTemplateScale=false] - fixImageTemplateScale in device-settings
89
+ * @property {number} [defaultImageTemplateScale=DEFAULT_TEMPLATE_IMAGE_SCALE] - defaultImageTemplateScale in device-settings
90
+ * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Ignore defaultImageTemplateScale if it has true.
91
91
  * If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
92
92
  * this parameter should be true. e.g. click in image-element module
93
- * @property {number} xScale - Scale ratio for width
94
- * @property {number} yScale - Scale ratio for height
93
+ * @property {number} [xScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for width
94
+ * @property {number} [yScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for height
95
95
 
96
96
  */
97
97
  /**
@@ -108,25 +108,25 @@ export default class ImageElementFinder {
108
108
  /**
109
109
  * - fixImageTemplateScale in device-settings
110
110
  */
111
- fixImageTemplateScale: boolean;
111
+ fixImageTemplateScale?: boolean | undefined;
112
112
  /**
113
113
  * - defaultImageTemplateScale in device-settings
114
114
  */
115
- defaultImageTemplateScale: number;
115
+ defaultImageTemplateScale?: number | undefined;
116
116
  /**
117
117
  * - Ignore defaultImageTemplateScale if it has true.
118
118
  * If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
119
119
  * this parameter should be true. e.g. click in image-element module
120
120
  */
121
- ignoreDefaultImageTemplateScale: boolean;
121
+ ignoreDefaultImageTemplateScale?: boolean | undefined;
122
122
  /**
123
123
  * - Scale ratio for width
124
124
  */
125
- xScale: number;
125
+ xScale?: number | undefined;
126
126
  /**
127
127
  * - Scale ratio for height
128
128
  */
129
- yScale: number;
129
+ yScale?: number | undefined;
130
130
  }): Promise<Buffer>;
131
131
  }
132
132
  export type ExternalDriver = import('@appium/types').ExternalDriver;
@@ -147,5 +147,6 @@ export type ScreenshotScale = {
147
147
  */
148
148
  yScale: number;
149
149
  };
150
+ import { LRUCache } from 'lru-cache';
150
151
  import { ImageElement } from './image-element';
151
152
  //# sourceMappingURL=finder.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":"AAmCA;IAIE;;OAEG;IACH,kBAFW,MAAM,EAQhB;IAZD,uCAAuC;IACvC,uCAAY;IAaZ;;;OAGG;IACH,4BAHW,YAAY,GACV,OAAO,CAKnB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,YAAY,GAAC,SAAS,CAIlC;IAED,2BAEC;IAED;;;;;;;;;;;OAWG;IAEH;;;;;;;;;;OAUG;IACH,sBAPW,MAAM,UAEN,cAAc;;;;;;;;;;;;;;;;;;;;;uBAVX,OAAO,eAAe,EAAE,IAAI;QAa7B,QAAQ,OAAO,GAAC,OAAO,EAAE,GAAC,YAAY,CAAC,CAsInD;IAED;;;;;;;OAOG;IACH,6BALW,MAAM,WACN,OAAO,eAAe,EAAE,IAAI,GAE1B,QAAQ,MAAM,CAAC,CA0B3B;IAED;;;;;;;;OAQG;IACH,kCALW,cAAc,cACd,OAAO,eAAe,EAAE,IAAI;;OAiItC;IAED;;;;;;;;;;OAUG;IACH;;;;;;;;;OASG;IACH,gCANW,MAAM;;;;+BAbH,OAAO;;;;mCACP,MAAM;;;;;;yCACN,OAAO;;;;gBAGP,MAAM;;;;gBACN,MAAM;QAWP,QAAQ,MAAM,CAAC,CAkE3B;CACF;6BAGY,OAAO,eAAe,EAAE,cAAc;sBACtC,OAAO,eAAe,EAAE,OAAO;;;;;gBAK9B,MAAM;;;;;;YAKN,MAAM;;;;YACN,MAAM;;6BAjfO,iBAAiB"}
1
+ {"version":3,"file":"finder.d.ts","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":"AAmCA;IAIE;;OAEG;IACH,kBAFW,MAAM,EAQhB;IAZD,4CAA4C;IAC5C,aADW,SAAS,MAAM,EAAC,YAAY,CAAC,CAC5B;IAaZ;;;OAGG;IACH,4BAHW,YAAY,GACV,OAAO,CAKnB;IAED;;;OAGG;IACH,yBAHW,MAAM,GACJ,YAAY,GAAC,SAAS,CAIlC;IAED,2BAEC;IAED;;;;;;;;;;;OAWG;IAEH;;;;;;;;;;OAUG;IACH,sBAPW,MAAM,UAEN,cAAc;;;;;;;;;;;;;;;;;;;;;;QAGZ,QAAQ,OAAO,GAAC,OAAO,EAAE,GAAC,YAAY,CAAC,CA+InD;IAED;;;;;;;OAOG;IACH,6BALW,MAAM,WACN,OAAO,eAAe,EAAE,IAAI,GAE1B,QAAQ,MAAM,CAAC,CA6B3B;IAED;;;;;;;;OAQG;IACH,kCALW,cAAc,cACd,OAAO,eAAe,EAAE,IAAI;;OAiItC;IAED;;;;;;;;;;OAUG;IACH;;;;;;;;;OASG;IACH,gCANW,MAAM;;;;;;;;;;;;;;;;;;;;;;;QAIJ,QAAQ,MAAM,CAAC,CAqE3B;CACF;6BAGY,OAAO,eAAe,EAAE,cAAc;sBACtC,OAAO,eAAe,EAAE,OAAO;;;;;gBAK9B,MAAM;;;;;;YAKN,MAAM;;;;YACN,MAAM;;yBAlgBG,WAAW;6BAEP,iBAAiB"}
@@ -68,7 +68,7 @@ class ImageElementFinder {
68
68
  * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
69
69
  * ignore defaultImageTemplateScale. It can be used when you would like to
70
70
  * scale template with defaultImageTemplateScale setting.
71
- * @property {import('@appium/types').Rect?} containerRect - The bounding
71
+ * @property {import('@appium/types').Rect?} [containerRect=null] - The bounding
72
72
  * rectangle to limit the search in
73
73
  */
74
74
  /**
@@ -86,7 +86,7 @@ class ImageElementFinder {
86
86
  const settings = { ...constants_1.DEFAULT_SETTINGS, ...driver.settings.getSettings() };
87
87
  const { imageMatchThreshold: threshold, imageMatchMethod, fixImageTemplateSize, fixImageTemplateScale, defaultImageTemplateScale, getMatchedImageResult: visualize, } = settings;
88
88
  logger_1.default.info(`Finding image element with match threshold ${threshold}`);
89
- if (!driver.getWindowRect && !driver.getWindowSize) {
89
+ if (!driver.getWindowRect && !lodash_1.default.has(driver, 'getWindowSize')) {
90
90
  throw new Error("This driver does not support the required 'getWindowRect' command");
91
91
  }
92
92
  let screenSize;
@@ -98,7 +98,7 @@ class ImageElementFinder {
98
98
  };
99
99
  }
100
100
  else {
101
- // TODO: Drop the deprecated endpoint
101
+ // @ts-ignore TODO: Drop the deprecated endpoint
102
102
  screenSize = await driver.getWindowSize();
103
103
  }
104
104
  // someone might have sent in a template that's larger than the screen
@@ -112,15 +112,21 @@ class ImageElementFinder {
112
112
  });
113
113
  }
114
114
  const results = [];
115
- const condition = async () => {
115
+ let didFixTemplateImageScale = false;
116
+ const performLookup = async () => {
116
117
  try {
117
118
  const { screenshot, scale } = await this.getScreenshotForImageFind(driver, screenSize);
118
- template = await this.fixImageTemplateScale(template, {
119
- defaultImageTemplateScale,
120
- ignoreDefaultImageTemplateScale,
121
- fixImageTemplateScale,
122
- ...scale,
123
- });
119
+ if (!didFixTemplateImageScale) {
120
+ template = await this.fixImageTemplateScale(template, {
121
+ defaultImageTemplateScale,
122
+ ignoreDefaultImageTemplateScale,
123
+ fixImageTemplateScale,
124
+ ...(scale || {}),
125
+ });
126
+ // We do not want `template` to be mutated multiple times when the
127
+ // wrapping lambda is retried
128
+ didFixTemplateImageScale = true;
129
+ }
124
130
  const comparisonOpts = {
125
131
  threshold,
126
132
  visualize,
@@ -153,7 +159,7 @@ class ImageElementFinder {
153
159
  }
154
160
  };
155
161
  try {
156
- await driver.implicitWaitForCondition(condition);
162
+ await driver.implicitWaitForCondition(performLookup);
157
163
  }
158
164
  catch (err) {
159
165
  // this `implicitWaitForCondition` method will throw a 'Condition unmet'
@@ -203,6 +209,9 @@ class ImageElementFinder {
203
209
  async ensureTemplateSize(template, maxSize) {
204
210
  const imgObj = (0, sharp_1.default)(template);
205
211
  const { width: tplWidth, height: tplHeight } = await imgObj.metadata();
212
+ if (lodash_1.default.isNil(tplWidth) || lodash_1.default.isNil(tplHeight)) {
213
+ throw new Error(`Template width/height cannot be determined. Is it a valid image?`);
214
+ }
206
215
  logger_1.default.info(`Template image is ${tplWidth}x${tplHeight}. Bounding rectangle size is ${maxSize.width}x${maxSize.height}`);
207
216
  // if the template fits inside the screen dimensions, we're good
208
217
  if (tplWidth <= maxSize.width && tplHeight <= maxSize.height) {
@@ -213,8 +222,8 @@ class ImageElementFinder {
213
222
  // otherwise, scale it to fit inside the bounding rectangle dimensions:
214
223
  // https://sharp.pixelplumbing.com/api-resize
215
224
  return await imgObj.resize({
216
- width: parseInt(maxSize.width, 10),
217
- height: parseInt(maxSize.height, 10),
225
+ width: Math.trunc(maxSize.width),
226
+ height: Math.trunc(maxSize.height),
218
227
  fit: 'inside',
219
228
  })
220
229
  .toBuffer();
@@ -251,7 +260,7 @@ class ImageElementFinder {
251
260
  logger_1.default.info('Verifying screenshot size and aspect ratio');
252
261
  let imgObj = (0, sharp_1.default)(screenshot);
253
262
  let { width: shotWidth, height: shotHeight } = await imgObj.metadata();
254
- if (shotWidth < 1 || shotHeight < 1) {
263
+ if (!shotWidth || shotWidth < 1 || !shotHeight || shotHeight < 1) {
255
264
  logger_1.default.warn(`The retrieved screenshot size ${shotWidth}x${shotHeight} does ` +
256
265
  `not seem to be valid. No changes will be applied to the screenshot`);
257
266
  return { screenshot };
@@ -294,7 +303,7 @@ class ImageElementFinder {
294
303
  const yScale = (1.0 * shotHeight) / screenSize.height;
295
304
  const scaleFactor = Math.min(xScale, yScale);
296
305
  const [newWidth, newHeight] = [shotWidth * scaleFactor, shotHeight * scaleFactor]
297
- .map((x) => parseInt(x, 10));
306
+ .map(Math.trunc);
298
307
  logger_1.default.warn(`Resizing screenshot to ${newWidth}x${newHeight} to match ` +
299
308
  `screen aspect ratio so that image element coordinates have a ` +
300
309
  `greater chance of being correct.`);
@@ -315,8 +324,8 @@ class ImageElementFinder {
315
324
  logger_1.default.info(`Scaling screenshot from ${shotWidth}x${shotHeight} to match ` +
316
325
  `screen at ${screenSize.width}x${screenSize.height}`);
317
326
  imgObj = imgObj.resize({
318
- width: parseInt(screenSize.width, 10),
319
- height: parseInt(screenSize.height, 10),
327
+ width: Math.trunc(screenSize.width),
328
+ height: Math.trunc(screenSize.height),
320
329
  fit: 'fill',
321
330
  });
322
331
  scale.xScale *= (1.0 * screenSize.width) / shotWidth;
@@ -329,13 +338,13 @@ class ImageElementFinder {
329
338
  }
330
339
  /**
331
340
  * @typedef ImageTemplateSettings
332
- * @property {boolean} fixImageTemplateScale - fixImageTemplateScale in device-settings
333
- * @property {number} defaultImageTemplateScale - defaultImageTemplateScale in device-settings
334
- * @property {boolean} ignoreDefaultImageTemplateScale - Ignore defaultImageTemplateScale if it has true.
341
+ * @property {boolean} [fixImageTemplateScale=false] - fixImageTemplateScale in device-settings
342
+ * @property {number} [defaultImageTemplateScale=DEFAULT_TEMPLATE_IMAGE_SCALE] - defaultImageTemplateScale in device-settings
343
+ * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Ignore defaultImageTemplateScale if it has true.
335
344
  * If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
336
345
  * this parameter should be true. e.g. click in image-element module
337
- * @property {number} xScale - Scale ratio for width
338
- * @property {number} yScale - Scale ratio for height
346
+ * @property {number} [xScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for width
347
+ * @property {number} [yScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for height
339
348
 
340
349
  */
341
350
  /**
@@ -381,13 +390,16 @@ class ImageElementFinder {
381
390
  }
382
391
  let imgObj = (0, sharp_1.default)(template);
383
392
  const { width: baseTempWidth, height: baseTempHeigh } = await imgObj.metadata();
393
+ if (lodash_1.default.isNil(baseTempWidth) || lodash_1.default.isNil(baseTempHeigh)) {
394
+ throw new Error(`Template width/height cannot be determined. Is it a valid image?`);
395
+ }
384
396
  const scaledWidth = baseTempWidth * xScale;
385
397
  const scaledHeight = baseTempHeigh * yScale;
386
398
  logger_1.default.info(`Scaling template image from ${baseTempWidth}x${baseTempHeigh} to ${scaledWidth}x${scaledHeight}`);
387
399
  logger_1.default.info(`The ratio is ${xScale} and ${yScale}`);
388
400
  imgObj = imgObj.resize({
389
- width: parseInt(scaledWidth, 10),
390
- height: parseInt(scaledHeight, 10),
401
+ width: Math.trunc(scaledWidth),
402
+ height: Math.trunc(scaledHeight),
391
403
  fit: 'fill',
392
404
  });
393
405
  return await imgObj.toBuffer();
@@ -1 +1 @@
1
- {"version":3,"file":"finder.js","sourceRoot":"","sources":["../../lib/finder.js"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AACvB,yCAAqC;AACrC,0CAAqC;AACrC,mDAA6C;AAC7C,uCAAwC;AACxC,sDAA2B;AAC3B,2CAGqB;AACrB,kDAA0B;AAE1B,yCAAyC;AACzC,iFAAiF;AACjF,MAAM,eAAe,GAAG,MAAM,CAAC;AAC/B,MAAM,eAAe,GAAG,GAAG,CAAC;AAC5B,MAAM,gBAAgB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAE7C;;;;;;GAMG;AACH,SAAS,YAAY,CAAC,YAAY,EAAE,IAAI;IACtC,OAAO,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,YAAY,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC;WACpD,IAAI,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,KAAK,GAAG,IAAI,CAAC,CAAC;WAC1D,IAAI,CAAC,MAAM,IAAI,YAAY,CAAC,CAAC,GAAG,YAAY,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;AACtE,CAAC;AAED,MAAM,sBAAsB,GAAG,6BAA6B,CAAC;AAC7D,MAAM,uBAAuB,GAAG,iBAAiB,CAAC;AAGlD,MAAqB,kBAAkB;IAIrC;;OAEG;IACH,YAAY,GAAG,GAAG,eAAe;QAC/B,IAAI,CAAC,WAAW,GAAG,IAAI,oBAAQ,CAAC;YAC9B,GAAG,EAAE,gBAAgB;YACrB,cAAc,EAAE,IAAI;YACpB,GAAG;SACJ,CAAC,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,oBA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AAa,EAAC,GAAG,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;QAC9E,IAAI,gBAAC,CAAC,KAAK,CAAC,aAAa,CAAC,IAAI,gBAAC,CAAC,KAAK,CAAC,aAAa,CAAC,EAAE;YACpD,MAAM,IAAI,KAAK,CAAC,kEAAkE,CAAC,CAAC;SACrF;QAED,MAAM,WAAW,GAAG,aAAa,GAAG,MAAM,CAAC;QAC3C,MAAM,YAAY,GAAG,aAAa,GAAG,MAAM,CAAC;QAC5C,gBAAG,CAAC,IAAI,CACN,+BAA+B,aAAa,IAAI,aAAa,OAAO,WAAW,IAAI,YAAY,EAAE,CAClG,CAAC;QACF,gBAAG,CAAC,IAAI,CAAC,gBAAgB,MAAM,QAAQ,MAAM,EAAE,CAAC,CAAC;QACjD,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;YACrB,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC;YAC9B,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC;YAChC,GAAG,EAAE,MAAM;SACZ,CAAC,CAAC;QACH,OAAO,MAAM,MAAM,CAAC,QAAQ,EAAE,CAAC;IACjC,CAAC;CACF;AAjdD,qCAidC;AAED;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG"}
@@ -29,14 +29,14 @@ export default class ImageElement {
29
29
  *
30
30
  * @param {import('appium/driver').BaseDriver} driver - the driver to use for commands
31
31
  * @param {string} cmd - the name of the driver command
32
- * @param {string} imgElId - the id of the ImageElement to work with
32
+ * @param {any} imgEl - image element object
33
33
  * @param {string[]} args - Rest of arguments for executeScripts
34
34
  *
35
- * @returns {object} - the result of running a command
35
+ * @returns {Promise<any>} - the result of running a command
36
36
  */
37
- static execute(driver: import("appium/driver").BaseDriver<any, import("@appium/types").StringRecord, import("@appium/types").StringRecord, import("@appium/types").DefaultCreateSessionResult<any>, void, import("@appium/types").StringRecord>, imgEl: any, cmd: string, ...args: string[]): object;
37
+ static execute(driver: import("appium/driver").BaseDriver<any, import("@appium/types").StringRecord, import("@appium/types").StringRecord, import("@appium/types").DefaultCreateSessionResult<any>, void, import("@appium/types").StringRecord>, imgEl: any, cmd: string, ...args: string[]): Promise<any>;
38
38
  /**
39
- * @param {ImageElementOpts}
39
+ * @param {ImageElementOpts} options
40
40
  */
41
41
  constructor({ template, rect, score, match, finder, containerRect, }: ImageElementOpts);
42
42
  template: Buffer;
@@ -82,9 +82,9 @@ export default class ImageElement {
82
82
  * Use a driver to tap the screen at the center of this ImageElement's
83
83
  * position
84
84
  *
85
- * @param {BaseDriver} driver - driver for calling actions with
85
+ * @param {import('appium/driver').BaseDriver} driver - driver for calling actions with
86
86
  */
87
- click(driver: BaseDriver): Promise<any>;
87
+ click(driver: import("appium/driver").BaseDriver<any, import("@appium/types").StringRecord, import("@appium/types").StringRecord, import("@appium/types").DefaultCreateSessionResult<any>, void, import("@appium/types").StringRecord>): Promise<any>;
88
88
  /**
89
89
  * Perform lookup of image element(s) inside of the current element
90
90
  *
@@ -1 +1 @@
1
- {"version":3,"file":"image-element.d.ts","sourceRoot":"","sources":["../../lib/image-element.js"],"names":[],"mappings":"AAWA;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH;IAiNE;;;;;;;;;OASG;IACH,kQANW,MAAM,WAEN,MAAM,EAAE,GAEN,MAAM,CAoClB;IA5PD;;OAEG;IACH,sEAFW,gBAAgB,EAiB1B;IAPC,iBAAwB;IACxB,mCAAgB;IAChB,WAAmD;IACnD,qBAAkB;IAClB,cAAkB;IAClB,0CAAoB;IACpB,mDAAkC;IAGpC;;OAEG;IACH,sBAEC;IAED;;OAEG;IACH,yBAEC;IAED;;OAEG;IACH,uBAKC;IAED;;OAEG;IACH,4BAEC;IAED;;OAEG;IACH,kCAEC;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,cALW,YAAY,GAEV,OAAO,CAUnB;IAED;;;;;OAKG;IACH,wCAmGC;IAED;;;;;;;OAOG;IACH,eALW,OAAO,6OAEN,MAAM,EAAE,GACP,QAAQ,OAAO,GAAC,OAAO,EAAE,GAAC,YAAY,CAAC,CAYnD;CA+CF;;;;;WAxRa,MAAM;;;;YACN,MAAM;;;;;;OAKN,MAAM;;;;OACN,MAAM;;;;;;cAKN,MAAM;;;;UACN,IAAI;;;;;WACJ,MAAM;;;;WAEN,MAAM;;;;YACN,OAAO,UAAU,EAAE,OAAO;;;;;mBAC1B,OAAO,eAAe,EAAE,IAAI;;mBA2Q7B,OAAO,eAAe,EAAE,IAAI;sBAC5B,OAAO,eAAe,EAAE,OAAO"}
1
+ {"version":3,"file":"image-element.d.ts","sourceRoot":"","sources":["../../lib/image-element.js"],"names":[],"mappings":"AAWA;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH;IAmNE;;;;;;;;;OASG;IACH,wPALW,GAAG,OADH,MAAM,WAEN,MAAM,EAAE,GAEN,QAAQ,GAAG,CAAC,CAoCxB;IA9PD;;OAEG;IACH,sEAFW,gBAAgB,EAiB1B;IAPC,iBAAwB;IACxB,mCAAgB;IAChB,WAAmD;IACnD,qBAAkB;IAClB,cAAkB;IAClB,0CAAoB;IACpB,mDAAkC;IAGpC;;OAEG;IACH,sBAEC;IAED;;OAEG;IACH,yBAEC;IAED;;OAEG;IACH,uBAKC;IAED;;OAEG;IACH,4BAEC;IAED;;OAEG;IACH,kCAEC;IAED;;;OAGG;IACH,aAFa,OAAO,CAInB;IAED;;;;;OAKG;IACH,cALW,YAAY,GAEV,OAAO,CAUnB;IAED;;;;;OAKG;IACH,sPAqGC;IAED;;;;;;;OAOG;IACH,eALW,OAAO,6OAEN,MAAM,EAAE,GACP,QAAQ,OAAO,GAAC,OAAO,EAAE,GAAC,YAAY,CAAC,CAYnD;CA+CF;;;;;WA1Ra,MAAM;;;;YACN,MAAM;;;;;;OAKN,MAAM;;;;OACN,MAAM;;;;;;cAKN,MAAM;;;;UACN,IAAI;;;;;WACJ,MAAM;;;;WAEN,MAAM;;;;YACN,OAAO,UAAU,EAAE,OAAO;;;;;mBAC1B,OAAO,eAAe,EAAE,IAAI;;mBA6Q7B,OAAO,eAAe,EAAE,IAAI;sBAC5B,OAAO,eAAe,EAAE,OAAO"}
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.ImageElement = void 0;
7
7
  const lodash_1 = __importDefault(require("lodash"));
8
8
  const driver_1 = require("appium/driver");
9
- const support_1 = require("appium/support");
9
+ const support_1 = require("@appium/support");
10
10
  const logger_1 = __importDefault(require("./logger"));
11
11
  const constants_1 = require("./constants");
12
12
  const TAP_DURATION_MS = 125;
@@ -37,7 +37,7 @@ const TAP_DURATION_MS = 125;
37
37
  */
38
38
  class ImageElement {
39
39
  /**
40
- * @param {ImageElementOpts}
40
+ * @param {ImageElementOpts} options
41
41
  */
42
42
  constructor({ template, rect, score, match = null, finder = null, containerRect = null, }) {
43
43
  this.template = template;
@@ -104,12 +104,11 @@ class ImageElement {
104
104
  * Use a driver to tap the screen at the center of this ImageElement's
105
105
  * position
106
106
  *
107
- * @param {BaseDriver} driver - driver for calling actions with
107
+ * @param {import('appium/driver').BaseDriver} driver - driver for calling actions with
108
108
  */
109
109
  async click(driver) {
110
110
  // before we click we need to make sure the element is actually still there
111
111
  // where we expect it to be
112
- let newImgEl;
113
112
  const settings = Object.assign({}, constants_1.DEFAULT_SETTINGS, driver.settings.getSettings());
114
113
  const { autoUpdateImageElementPosition: updatePos, checkForImageElementStaleness, imageElementTapStrategy, } = settings;
115
114
  // validate tap strategy
@@ -118,16 +117,18 @@ class ImageElement {
118
117
  `'${imageElementTapStrategy}'. Must be one of ` +
119
118
  JSON.stringify(constants_1.IMAGE_TAP_STRATEGIES));
120
119
  }
120
+ let newImgEl;
121
121
  if (checkForImageElementStaleness || updatePos) {
122
122
  logger_1.default.info('Checking image element for staleness before clicking');
123
123
  try {
124
- newImgEl = await this.finder.findByImage(this.template, driver, {
124
+ newImgEl = /** @type {ImageElement} */ (await ( /** @type {import('./finder').default} */(this.finder))
125
+ .findByImage(this.template, driver, {
125
126
  shouldCheckStaleness: true,
126
127
  // Set ignoreDefaultImageTemplateScale because this.template is device screenshot based image
127
128
  // managed inside Appium after finidng image by template which managed by a user
128
129
  ignoreDefaultImageTemplateScale: true,
129
130
  containerRect: this.containerRect,
130
- });
131
+ }));
131
132
  }
132
133
  catch (err) {
133
134
  throw new driver_1.errors.StaleElementReferenceError();
@@ -166,7 +167,7 @@ class ImageElement {
166
167
  ],
167
168
  };
168
169
  // check if the driver has the appropriate performActions method
169
- if (driver.performActions) {
170
+ if ('performActions' in driver && lodash_1.default.isFunction(driver.performActions)) {
170
171
  return await driver.performActions([action]);
171
172
  }
172
173
  // if not, warn and fall back to the other method
@@ -179,7 +180,7 @@ class ImageElement {
179
180
  action: 'tap',
180
181
  options: { x, y },
181
182
  };
182
- if (driver.performTouch) {
183
+ if ('performTouch' in driver && lodash_1.default.isFunction(driver.performTouch)) {
183
184
  return await driver.performTouch([action]);
184
185
  }
185
186
  throw new Error("Driver did not implement the 'performTouch' command. " +
@@ -199,17 +200,17 @@ class ImageElement {
199
200
  if (strategy !== constants_1.IMAGE_STRATEGY) {
200
201
  throw new driver_1.errors.InvalidSelectorError(`Lookup strategies other than '${constants_1.IMAGE_STRATEGY}' are not supported`);
201
202
  }
202
- return await this.finder.findByImage(Buffer.from(selector, 'base64'), driver, { multiple, containerRect: this.rect });
203
+ return await ( /** @type {import('./finder').default} */(this.finder)).findByImage(Buffer.from(selector, 'base64'), driver, { multiple, containerRect: this.rect });
203
204
  }
204
205
  /**
205
206
  * Handle various Appium commands that involve an image element
206
207
  *
207
208
  * @param {import('appium/driver').BaseDriver} driver - the driver to use for commands
208
209
  * @param {string} cmd - the name of the driver command
209
- * @param {string} imgElId - the id of the ImageElement to work with
210
+ * @param {any} imgEl - image element object
210
211
  * @param {string[]} args - Rest of arguments for executeScripts
211
212
  *
212
- * @returns {object} - the result of running a command
213
+ * @returns {Promise<any>} - the result of running a command
213
214
  */
214
215
  static async execute(driver, imgEl, cmd, ...args) {
215
216
  switch (cmd) {
@@ -1 +1 @@
1
- {"version":3,"file":"image-element.js","sourceRoot":"","sources":["../../lib/image-element.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,0CAAqC;AACrC,4CAAoC;AACpC,sDAA2B;AAC3B,2CAGqB;AAErB,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;GAIG;AAEH;;;;GAIG;AAEH;;;;;;;;;;GAUG;AAEH;;;GAGG;AACH,MAAqB,YAAY;IAC/B;;OAEG;IACH,YAAY,EACV,QAAQ,EACR,IAAI,EACJ,KAAK,EACL,KAAK,GAAG,IAAI,EACZ,MAAM,GAAG,IAAI,EACb,aAAa,GAAG,IAAI,GACrB;QACC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,EAAE,GAAG,GAAG,gCAAoB,GAAG,cAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAED;;OAEG;IACH,IAAI,IAAI;QACN,OAAO,EAAC,KAAK,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,MAAM,EAAC,CAAC;IAC5D,CAAC;IAED;;OAEG;IACH,IAAI,QAAQ;QACV,OAAO,EAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,EAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,IAAI,MAAM;QACR,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KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YACnC,KAAK,wBAAwB;gBAC3B,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;YAClD,KAAK,yBAAyB;gBAC5B,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;YACjD,KAAK,kBAAkB;gBACrB,OAAO,IAAI,CAAC;YACd,KAAK,SAAS;gBACZ,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,KAAK,aAAa,CAAC;YACnB,KAAK,mBAAmB;gBACtB,OAAO,KAAK,CAAC,QAAQ,CAAC;YACxB,KAAK,gBAAgB;gBACnB,OAAO,KAAK,CAAC,IAAI,CAAC;YACpB,KAAK,sBAAsB;gBACzB,OAAO,KAAK,CAAC,aAAa,CAAC;YAC7B,KAAK,cAAc;gBACjB,yDAAyD;gBACzD,uFAAuF;gBACvF,8GAA8G;gBAC9G,QAAQ,IAAI,CAAC,CAAC,CAAC,EAAE;oBACf,KAAK,QAAQ;wBACX,OAAO,KAAK,CAAC,YAAY,CAAC;oBAC5B,KAAK,OAAO;wBACV,OAAO,KAAK,CAAC,KAAK,CAAC;oBACrB;wBACE,MAAM,IAAI,eAAM,CAAC,sBAAsB,EAAE,CAAC;iBAC7C;YACH;gBACE,MAAM,IAAI,eAAM,CAAC,sBAAsB,EAAE,CAAC;SAC7C;IACH,CAAC;CACF;AAhQD,+BAgQC;AAEO,oCAAY;AAEpB;;;GAGG"}
@@ -1,4 +1,4 @@
1
- export default class ImageElementPlugin {
1
+ export default class ImageElementPlugin extends BasePlugin {
2
2
  static newMethodMap: {
3
3
  readonly '/session/:sessionId/appium/compare_images': {
4
4
  readonly POST: {
@@ -13,12 +13,21 @@ export default class ImageElementPlugin {
13
13
  };
14
14
  constructor(pluginName: any);
15
15
  finder: ImageElementFinder;
16
- compareImages(next: any, driver: any, ...args: any[]): Promise<unknown>;
16
+ compareImages(next: any, driver: any, ...args: any[]): Promise<import("./compare").ComparisonResult>;
17
17
  findElement(next: any, driver: any, ...args: any[]): Promise<any>;
18
18
  findElements(next: any, driver: any, ...args: any[]): Promise<any>;
19
- _find(multiple: any, next: any, driver: any, ...args: any[]): Promise<any>;
19
+ /**
20
+ *
21
+ * @param {boolean} multiple
22
+ * @param {*} next
23
+ * @param {*} driver
24
+ * @param {...any} args
25
+ * @returns {Promise<any>}
26
+ */
27
+ _find(multiple: boolean, next: any, driver: any, ...args: any[]): Promise<any>;
20
28
  handle(next: any, driver: any, cmdName: any, ...args: any[]): Promise<any>;
21
29
  }
30
+ import { BasePlugin } from 'appium/plugin';
22
31
  import ImageElementFinder from './finder';
23
32
  export function getImgElFromArgs(args: any): any;
24
33
  import { IMAGE_STRATEGY } from './constants';
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":"AAcA;IAOE;;;;;;;;;;;MAWG;IAjBH,6BAGC;IADC,2BAAsC;IAiBxC,wEAEC;IAED,kEAEC;IAED,mEAEC;IAED,2EASC;IAED,2EAkBC;CACF;+BAtE8B,UAAU;AAIzC,iDAEC;+BAJkD,aAAa"}
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":"AAcA;IAOE;;;;;;;;;;;MAWG;IAjBH,6BAGC;IADC,2BAAsC;IAiBxC,qGAGC;IAED,kEAEC;IAED,mEAEC;IAED;;;;;;;OAOG;IACH,gBANW,OAAO,mCAGH,GAAG,KACL,QAAQ,GAAG,CAAC,CAWxB;IAED,2EAkBC;CACF;2BAjFwB,eAAe;+BAET,UAAU;AAIzC,iDAEC;+BAJkD,aAAa"}
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.IMAGE_STRATEGY = exports.getImgElFromArgs = exports.ImageElementPlugin = void 0;
8
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const driver_1 = require("appium/driver");
10
- const plugin_1 = __importDefault(require("appium/plugin"));
10
+ const plugin_1 = require("appium/plugin");
11
11
  const compare_1 = require("./compare");
12
12
  const finder_1 = __importDefault(require("./finder"));
13
13
  const image_element_1 = require("./image-element");
@@ -17,12 +17,13 @@ function getImgElFromArgs(args) {
17
17
  return args.find((arg) => lodash_1.default.isString(arg) && arg.startsWith(constants_1.IMAGE_ELEMENT_PREFIX));
18
18
  }
19
19
  exports.getImgElFromArgs = getImgElFromArgs;
20
- class ImageElementPlugin extends plugin_1.default {
20
+ class ImageElementPlugin extends plugin_1.BasePlugin {
21
21
  constructor(pluginName) {
22
22
  super(pluginName);
23
23
  this.finder = new finder_1.default();
24
24
  }
25
25
  async compareImages(next, driver, ...args) {
26
+ // @ts-ignore Arguments should be ok there
26
27
  return await (0, compare_1.compareImages)(...args);
27
28
  }
28
29
  async findElement(next, driver, ...args) {
@@ -31,6 +32,14 @@ class ImageElementPlugin extends plugin_1.default {
31
32
  async findElements(next, driver, ...args) {
32
33
  return await this._find(true, next, driver, ...args);
33
34
  }
35
+ /**
36
+ *
37
+ * @param {boolean} multiple
38
+ * @param {*} next
39
+ * @param {*} driver
40
+ * @param {...any} args
41
+ * @returns {Promise<any>}
42
+ */
34
43
  async _find(multiple, next, driver, ...args) {
35
44
  const [strategy, selector] = args;
36
45
  // if we're not actually finding by image, just do the normal thing
@@ -1 +1 @@
1
- {"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../lib/plugin.js"],"names":[],"mappings":";AAAA,yCAAyC;;;;;;AAEzC,oDAAuB;AACvB,0CAAqC;AACrC,2DAAuC;AACvC,uCAAwC;AACxC,sDAA0C;AAC1C,mDAA6C;AAC7C,2CAAiE;AAsEnB,+FAtEtC,0BAAc,OAsEsC;AApE5D,SAAS,gBAAgB,CAAC,IAAI;IAC5B,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,gBAAC,CAA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EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI;QACzC,4FAA4F;QAC5F,gCAAgC;QAChC,MAAM,OAAO,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,OAAO,EAAE;YACX,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC,KAAK,EAAE;gBACV,MAAM,IAAI,eAAM,CAAC,kBAAkB,EAAE,CAAC;aACvC;YACD,OAAO,MAAM,4BAAY,CAAC,OAAO,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC,CAAC;SACpE;QAED,IAAI,OAAO,KAAK,eAAe,EAAE;YAC/B,IAAI,CAAC,MAAM,CAAC,kBAAkB,EAAE,CAAC;SAClC;QAED,qCAAqC;QACrC,OAAO,MAAM,IAAI,EAAE,CAAC;IACtB,CAAC;;AAhED,+DAA+D;AACxD,+BAAY,GAAwB,CAAC;IAC1C,2CAA2C,EAAE;QAC3C,IAAI,EAAE;YACJ,OAAO,EAAE,eAAe;YACxB,aAAa,EAAE;gBACb,QAAQ,EAAE,CAAC,MAAM,EAAE,YAAY,EAAE,aAAa,CAAC;gBAC/C,QAAQ,EAAE,CAAC,SAAS,CAAC;aACtB;YACD,UAAU,EAAE,IAAI;SACjB;KACF;CACF,CAAC,CAAC;kBAlBgB,kBAAkB;AAyE/B,gDAAkB"}
package/lib/compare.js CHANGED
@@ -3,6 +3,14 @@ import {errors} from 'appium/driver';
3
3
  import {getImagesMatches, getImagesSimilarity, getImageOccurrence} from '@appium/opencv';
4
4
  import {MATCH_FEATURES_MODE, GET_SIMILARITY_MODE, MATCH_TEMPLATE_MODE} from './constants';
5
5
 
6
+ /**
7
+ * @typedef {{visualization: string|null|undefined}} Visualized
8
+ * @typedef {import('@appium/opencv').MatchingResult & Visualized} MatchingResult
9
+ * @typedef {import('@appium/opencv').OccurrenceResult & Visualized} OccurrenceResult
10
+ * @typedef {import('@appium/opencv').SimilarityResult & Visualized} SimilarityResult
11
+ * @typedef {MatchingResult|OccurrenceResult|SimilarityResult|SimilarityResult[]} ComparisonResult
12
+ */
13
+
6
14
  /**
7
15
  * Performs images comparison using OpenCV framework features.
8
16
  * It is expected that both OpenCV framework and opencv4nodejs
@@ -14,43 +22,48 @@ import {MATCH_FEATURES_MODE, GET_SIMILARITY_MODE, MATCH_TEMPLATE_MODE} from './c
14
22
  * All image formats, that OpenCV library itself accepts, are supported.
15
23
  * @param {string|Buffer} secondImage - Base64-encoded image file.
16
24
  * All image formats, that OpenCV library itself accepts, are supported.
17
- * @param {object} [options] - The content of this dictionary depends
25
+ * @param {import('@appium/opencv').MatchingOptions
26
+ * |import('@appium/opencv').SimilarityOptions
27
+ * |import('@appium/opencv').OccurrenceOptions} [options={}] - The content of this dictionary depends
18
28
  * on the actual `mode` value. See the documentation on `@appium/support`
19
29
  * module for more details.
20
- * @returns {Promise<object|object[]>} The content of the resulting dictionary depends
30
+ * @returns {Promise<ComparisonResult>} The content of the resulting dictionary depends
21
31
  * on the actual `mode` and `options` values. See the documentation on
22
32
  * `@appium/support` module for more details.
23
33
  * @throws {Error} If required OpenCV modules are not installed or
24
34
  * if `mode` value is incorrect or if there was an unexpected issue while
25
35
  * matching the images.
26
36
  */
27
-
28
- /**
29
- * @type {import('@appium/types').PluginCommand<[string, string, string, object|undefined], Promise<OccurrenceResult>>}
30
- */
31
37
  async function compareImages(mode, firstImage, secondImage, options = {}) {
32
38
  const img1 = Buffer.isBuffer(firstImage) ? firstImage : Buffer.from(firstImage, 'base64');
33
39
  const img2 = Buffer.isBuffer(secondImage) ? secondImage : Buffer.from(secondImage, 'base64');
34
- let result = null;
40
+ let result;
35
41
  switch (_.toLower(mode)) {
36
42
  case MATCH_FEATURES_MODE.toLowerCase():
37
43
  try {
38
- result = await getImagesMatches(img1, img2, options);
44
+ result = await getImagesMatches(
45
+ img1, img2, /** @type {import('@appium/opencv').MatchingOptions} */(options)
46
+ );
39
47
  } catch (err) {
40
48
  // might throw if no matches
41
- result = {count: 0};
49
+ result = /** @type {import('@appium/opencv').MatchingResult} */({count: 0});
42
50
  }
43
51
  break;
44
52
  case GET_SIMILARITY_MODE.toLowerCase():
45
- result = await getImagesSimilarity(img1, img2, options);
53
+ result = await getImagesSimilarity(
54
+ img1, img2, /** @type {import('@appium/opencv').SimilarityOptions} */(options));
46
55
  break;
47
- case MATCH_TEMPLATE_MODE.toLowerCase():
56
+ case MATCH_TEMPLATE_MODE.toLowerCase(): {
57
+ const opts = /** @type {import('@appium/opencv').OccurrenceOptions} */(options);
48
58
  // firstImage/img1 is the full image and secondImage/img2 is the partial one
49
- result = await getImageOccurrence(img1, img2, options);
50
- if (options.multiple) {
59
+ result = await getImageOccurrence(
60
+ img1, img2, opts
61
+ );
62
+ if (opts.multiple) {
51
63
  return result.multiple.map(convertVisualizationToBase64);
52
64
  }
53
65
  break;
66
+ }
54
67
  default:
55
68
  throw new errors.InvalidArgumentError(
56
69
  `'${mode}' images comparison mode is unknown. ` +
@@ -68,19 +81,16 @@ async function compareImages(mode, firstImage, secondImage, options = {}) {
68
81
  * base64 encodes the visualization part of the result
69
82
  * (if necessary)
70
83
  *
71
- * @param {OccurrenceResult} element - occurrence result
72
- *
84
+ * @param {Partial<{visualization: Buffer|null}>} element - occurrence result
85
+ * @returns {any} I know this looks ugly from the typing perspective
73
86
  **/
74
87
  function convertVisualizationToBase64(element) {
75
- if (!_.isEmpty(element.visualization)) {
76
- element.visualization = element.visualization.toString('base64');
77
- }
78
-
79
- return element;
88
+ return Buffer.isBuffer(element.visualization)
89
+ ? {
90
+ ...(element),
91
+ visualization: element.visualization.toString('base64')
92
+ }
93
+ : element;
80
94
  }
81
95
 
82
96
  export {compareImages};
83
-
84
- /**
85
- * @typedef {import('@appium/opencv').OccurrenceResult} OccurrenceResult
86
- */
package/lib/finder.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import _ from 'lodash';
2
- import { LRUCache } from 'lru-cache';
2
+ import {LRUCache} from 'lru-cache';
3
3
  import {errors} from 'appium/driver';
4
4
  import {ImageElement} from './image-element';
5
5
  import {compareImages} from './compare';
@@ -34,7 +34,7 @@ const CONDITION_UNMET_PATTERN = /Condition unmet/;
34
34
 
35
35
 
36
36
  export default class ImageElementFinder {
37
- /** @type {LRU<string,ImageElement>} */
37
+ /** @type {LRUCache<string,ImageElement>} */
38
38
  _imgElCache;
39
39
 
40
40
  /**
@@ -78,7 +78,7 @@ export default class ImageElementFinder {
78
78
  * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Whether we
79
79
  * ignore defaultImageTemplateScale. It can be used when you would like to
80
80
  * scale template with defaultImageTemplateScale setting.
81
- * @property {import('@appium/types').Rect?} containerRect - The bounding
81
+ * @property {import('@appium/types').Rect?} [containerRect=null] - The bounding
82
82
  * rectangle to limit the search in
83
83
  */
84
84
 
@@ -109,7 +109,7 @@ export default class ImageElementFinder {
109
109
  } = settings;
110
110
 
111
111
  log.info(`Finding image element with match threshold ${threshold}`);
112
- if (!driver.getWindowRect && !driver.getWindowSize) {
112
+ if (!driver.getWindowRect && !_.has(driver, 'getWindowSize')) {
113
113
  throw new Error("This driver does not support the required 'getWindowRect' command");
114
114
  }
115
115
  let screenSize;
@@ -120,7 +120,7 @@ export default class ImageElementFinder {
120
120
  height: screenRect.height,
121
121
  };
122
122
  } else {
123
- // TODO: Drop the deprecated endpoint
123
+ // @ts-ignore TODO: Drop the deprecated endpoint
124
124
  screenSize = await driver.getWindowSize();
125
125
  }
126
126
 
@@ -136,16 +136,23 @@ export default class ImageElementFinder {
136
136
  }
137
137
 
138
138
  const results = [];
139
- const condition = async () => {
139
+ let didFixTemplateImageScale = false;
140
+ const performLookup = async () => {
140
141
  try {
142
+
141
143
  const {screenshot, scale} = await this.getScreenshotForImageFind(driver, screenSize);
142
144
 
143
- template = await this.fixImageTemplateScale(template, {
144
- defaultImageTemplateScale,
145
- ignoreDefaultImageTemplateScale,
146
- fixImageTemplateScale,
147
- ...scale,
148
- });
145
+ if (!didFixTemplateImageScale) {
146
+ template = await this.fixImageTemplateScale(template, {
147
+ defaultImageTemplateScale,
148
+ ignoreDefaultImageTemplateScale,
149
+ fixImageTemplateScale,
150
+ ...(scale || {}),
151
+ });
152
+ // We do not want `template` to be mutated multiple times when the
153
+ // wrapping lambda is retried
154
+ didFixTemplateImageScale = true;
155
+ }
149
156
 
150
157
  const comparisonOpts = {
151
158
  threshold,
@@ -168,7 +175,9 @@ export default class ImageElementFinder {
168
175
  return true;
169
176
  };
170
177
 
171
- const elOrEls = await compareImages(MATCH_TEMPLATE_MODE, screenshot, template, comparisonOpts);
178
+ const elOrEls = await compareImages(
179
+ MATCH_TEMPLATE_MODE, screenshot, template, comparisonOpts
180
+ );
172
181
  return _.some((_.isArray(elOrEls) ? elOrEls : [elOrEls]).map(pushIfOk));
173
182
  } catch (err) {
174
183
  // if compareImages fails, we'll get a specific error, but we should
@@ -183,7 +192,7 @@ export default class ImageElementFinder {
183
192
  };
184
193
 
185
194
  try {
186
- await driver.implicitWaitForCondition(condition);
195
+ await driver.implicitWaitForCondition(performLookup);
187
196
  } catch (err) {
188
197
  // this `implicitWaitForCondition` method will throw a 'Condition unmet'
189
198
  // error if an element is not found eventually. In that case, we will
@@ -238,6 +247,9 @@ export default class ImageElementFinder {
238
247
  async ensureTemplateSize(template, maxSize) {
239
248
  const imgObj = sharp(template);
240
249
  const {width: tplWidth, height: tplHeight} = await imgObj.metadata();
250
+ if (_.isNil(tplWidth) || _.isNil(tplHeight)) {
251
+ throw new Error(`Template width/height cannot be determined. Is it a valid image?`);
252
+ }
241
253
 
242
254
  log.info(
243
255
  `Template image is ${tplWidth}x${tplHeight}. Bounding rectangle size is ${maxSize.width}x${maxSize.height}`
@@ -254,8 +266,8 @@ export default class ImageElementFinder {
254
266
  // otherwise, scale it to fit inside the bounding rectangle dimensions:
255
267
  // https://sharp.pixelplumbing.com/api-resize
256
268
  return await imgObj.resize({
257
- width: parseInt(maxSize.width, 10),
258
- height: parseInt(maxSize.height, 10),
269
+ width: Math.trunc(maxSize.width),
270
+ height: Math.trunc(maxSize.height),
259
271
  fit: 'inside',
260
272
  })
261
273
  .toBuffer();
@@ -301,7 +313,7 @@ export default class ImageElementFinder {
301
313
  let imgObj = sharp(screenshot);
302
314
  let {width: shotWidth, height: shotHeight} = await imgObj.metadata();
303
315
 
304
- if (shotWidth < 1 || shotHeight < 1) {
316
+ if (!shotWidth || shotWidth < 1 || !shotHeight || shotHeight < 1) {
305
317
  log.warn(
306
318
  `The retrieved screenshot size ${shotWidth}x${shotHeight} does ` +
307
319
  `not seem to be valid. No changes will be applied to the screenshot`
@@ -354,7 +366,7 @@ export default class ImageElementFinder {
354
366
  const yScale = (1.0 * shotHeight) / screenSize.height;
355
367
  const scaleFactor = Math.min(xScale, yScale);
356
368
  const [newWidth, newHeight] = [shotWidth * scaleFactor, shotHeight * scaleFactor]
357
- .map((x) => parseInt(x, 10));
369
+ .map(Math.trunc);
358
370
 
359
371
  log.warn(
360
372
  `Resizing screenshot to ${newWidth}x${newHeight} to match ` +
@@ -382,8 +394,8 @@ export default class ImageElementFinder {
382
394
  `screen at ${screenSize.width}x${screenSize.height}`
383
395
  );
384
396
  imgObj = imgObj.resize({
385
- width: parseInt(screenSize.width, 10),
386
- height: parseInt(screenSize.height, 10),
397
+ width: Math.trunc(screenSize.width),
398
+ height: Math.trunc(screenSize.height),
387
399
  fit: 'fill',
388
400
  });
389
401
 
@@ -399,13 +411,13 @@ export default class ImageElementFinder {
399
411
 
400
412
  /**
401
413
  * @typedef ImageTemplateSettings
402
- * @property {boolean} fixImageTemplateScale - fixImageTemplateScale in device-settings
403
- * @property {number} defaultImageTemplateScale - defaultImageTemplateScale in device-settings
404
- * @property {boolean} ignoreDefaultImageTemplateScale - Ignore defaultImageTemplateScale if it has true.
414
+ * @property {boolean} [fixImageTemplateScale=false] - fixImageTemplateScale in device-settings
415
+ * @property {number} [defaultImageTemplateScale=DEFAULT_TEMPLATE_IMAGE_SCALE] - defaultImageTemplateScale in device-settings
416
+ * @property {boolean} [ignoreDefaultImageTemplateScale=false] - Ignore defaultImageTemplateScale if it has true.
405
417
  * If the template has been scaled to defaultImageTemplateScale or should ignore the scale,
406
418
  * this parameter should be true. e.g. click in image-element module
407
- * @property {number} xScale - Scale ratio for width
408
- * @property {number} yScale - Scale ratio for height
419
+ * @property {number} [xScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for width
420
+ * @property {number} [yScale=DEFAULT_FIX_IMAGE_TEMPLATE_SCALE] - Scale ratio for height
409
421
 
410
422
  */
411
423
  /**
@@ -469,6 +481,9 @@ export default class ImageElementFinder {
469
481
 
470
482
  let imgObj = sharp(template);
471
483
  const {width: baseTempWidth, height: baseTempHeigh} = await imgObj.metadata();
484
+ if (_.isNil(baseTempWidth) || _.isNil(baseTempHeigh)) {
485
+ throw new Error(`Template width/height cannot be determined. Is it a valid image?`);
486
+ }
472
487
 
473
488
  const scaledWidth = baseTempWidth * xScale;
474
489
  const scaledHeight = baseTempHeigh * yScale;
@@ -477,8 +492,8 @@ export default class ImageElementFinder {
477
492
  );
478
493
  log.info(`The ratio is ${xScale} and ${yScale}`);
479
494
  imgObj = imgObj.resize({
480
- width: parseInt(scaledWidth, 10),
481
- height: parseInt(scaledHeight, 10),
495
+ width: Math.trunc(scaledWidth),
496
+ height: Math.trunc(scaledHeight),
482
497
  fit: 'fill',
483
498
  });
484
499
  return await imgObj.toBuffer();
@@ -1,6 +1,6 @@
1
1
  import _ from 'lodash';
2
2
  import {errors} from 'appium/driver';
3
- import {util} from 'appium/support';
3
+ import {util} from '@appium/support';
4
4
  import log from './logger';
5
5
  import {
6
6
  IMAGE_STRATEGY, DEFAULT_SETTINGS, IMAGE_TAP_STRATEGIES,
@@ -39,7 +39,7 @@ const TAP_DURATION_MS = 125;
39
39
  */
40
40
  export default class ImageElement {
41
41
  /**
42
- * @param {ImageElementOpts}
42
+ * @param {ImageElementOpts} options
43
43
  */
44
44
  constructor({
45
45
  template,
@@ -123,12 +123,11 @@ export default class ImageElement {
123
123
  * Use a driver to tap the screen at the center of this ImageElement's
124
124
  * position
125
125
  *
126
- * @param {BaseDriver} driver - driver for calling actions with
126
+ * @param {import('appium/driver').BaseDriver} driver - driver for calling actions with
127
127
  */
128
128
  async click(driver) {
129
129
  // before we click we need to make sure the element is actually still there
130
130
  // where we expect it to be
131
- let newImgEl;
132
131
  const settings = Object.assign({}, DEFAULT_SETTINGS, driver.settings.getSettings());
133
132
  const {
134
133
  autoUpdateImageElementPosition: updatePos,
@@ -145,16 +144,19 @@ export default class ImageElement {
145
144
  );
146
145
  }
147
146
 
147
+ let newImgEl;
148
148
  if (checkForImageElementStaleness || updatePos) {
149
149
  log.info('Checking image element for staleness before clicking');
150
150
  try {
151
- newImgEl = await this.finder.findByImage(this.template, driver, {
152
- shouldCheckStaleness: true,
153
- // Set ignoreDefaultImageTemplateScale because this.template is device screenshot based image
154
- // managed inside Appium after finidng image by template which managed by a user
155
- ignoreDefaultImageTemplateScale: true,
156
- containerRect: this.containerRect,
157
- });
151
+ newImgEl = /** @type {ImageElement} */ (await (/** @type {import('./finder').default} */ (this.finder))
152
+ .findByImage(
153
+ this.template, driver, {
154
+ shouldCheckStaleness: true,
155
+ // Set ignoreDefaultImageTemplateScale because this.template is device screenshot based image
156
+ // managed inside Appium after finidng image by template which managed by a user
157
+ ignoreDefaultImageTemplateScale: true,
158
+ containerRect: this.containerRect,
159
+ }));
158
160
  } catch (err) {
159
161
  throw new errors.StaleElementReferenceError();
160
162
  }
@@ -199,7 +201,7 @@ export default class ImageElement {
199
201
  };
200
202
 
201
203
  // check if the driver has the appropriate performActions method
202
- if (driver.performActions) {
204
+ if ('performActions' in driver && _.isFunction(driver.performActions)) {
203
205
  return await driver.performActions([action]);
204
206
  }
205
207
 
@@ -215,7 +217,7 @@ export default class ImageElement {
215
217
  options: {x, y},
216
218
  };
217
219
 
218
- if (driver.performTouch) {
220
+ if ('performTouch' in driver && _.isFunction(driver.performTouch)) {
219
221
  return await driver.performTouch([action]);
220
222
  }
221
223
 
@@ -239,7 +241,7 @@ export default class ImageElement {
239
241
  if (strategy !== IMAGE_STRATEGY) {
240
242
  throw new errors.InvalidSelectorError(`Lookup strategies other than '${IMAGE_STRATEGY}' are not supported`);
241
243
  }
242
- return await this.finder.findByImage(
244
+ return await (/** @type {import('./finder').default} */ (this.finder)).findByImage(
243
245
  Buffer.from(selector, 'base64'),
244
246
  driver,
245
247
  {multiple, containerRect: this.rect}
@@ -251,10 +253,10 @@ export default class ImageElement {
251
253
  *
252
254
  * @param {import('appium/driver').BaseDriver} driver - the driver to use for commands
253
255
  * @param {string} cmd - the name of the driver command
254
- * @param {string} imgElId - the id of the ImageElement to work with
256
+ * @param {any} imgEl - image element object
255
257
  * @param {string[]} args - Rest of arguments for executeScripts
256
258
  *
257
- * @returns {object} - the result of running a command
259
+ * @returns {Promise<any>} - the result of running a command
258
260
  */
259
261
  static async execute(driver, imgEl, cmd, ...args) {
260
262
  switch (cmd) {
package/lib/plugin.js CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  import _ from 'lodash';
4
4
  import {errors} from 'appium/driver';
5
- import BasePlugin from 'appium/plugin';
5
+ import {BasePlugin} from 'appium/plugin';
6
6
  import {compareImages} from './compare';
7
7
  import ImageElementFinder from './finder';
8
8
  import {ImageElement} from './image-element';
@@ -33,6 +33,7 @@ export default class ImageElementPlugin extends BasePlugin {
33
33
  });
34
34
 
35
35
  async compareImages(next, driver, ...args) {
36
+ // @ts-ignore Arguments should be ok there
36
37
  return await compareImages(...args);
37
38
  }
38
39
 
@@ -44,6 +45,14 @@ export default class ImageElementPlugin extends BasePlugin {
44
45
  return await this._find(true, next, driver, ...args);
45
46
  }
46
47
 
48
+ /**
49
+ *
50
+ * @param {boolean} multiple
51
+ * @param {*} next
52
+ * @param {*} driver
53
+ * @param {...any} args
54
+ * @returns {Promise<any>}
55
+ */
47
56
  async _find(multiple, next, driver, ...args) {
48
57
  const [strategy, selector] = args;
49
58
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/images-plugin",
3
- "version": "2.1.6",
3
+ "version": "2.1.8",
4
4
  "description": "Plugin for working with images and image elements in Appium",
5
5
  "keywords": [
6
6
  "automation",
@@ -39,14 +39,15 @@
39
39
  "test:unit": "mocha \"./test/unit/**/*.spec.js\""
40
40
  },
41
41
  "dependencies": {
42
- "@appium/opencv": "^2.1.5",
42
+ "@appium/opencv": "^2.1.6",
43
+ "@appium/support": "^4.1.10",
43
44
  "lodash": "4.17.21",
44
45
  "lru-cache": "10.0.1",
45
46
  "sharp": "0.32.6",
46
47
  "source-map-support": "0.5.21"
47
48
  },
48
49
  "peerDependencies": {
49
- "appium": "^2.0.0-beta.35"
50
+ "appium": "^2.0.0"
50
51
  },
51
52
  "engines": {
52
53
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
@@ -59,7 +60,7 @@
59
60
  "publishConfig": {
60
61
  "access": "public"
61
62
  },
62
- "gitHead": "bd6e3ac0b03e2e53c393423ac8954b814aaf09be",
63
+ "gitHead": "67504604b7d4602561db2cb3529860b241bec427",
63
64
  "typedoc": {
64
65
  "entryPoint": "./lib/plugin.js"
65
66
  }
package/tsconfig.json CHANGED
@@ -1,6 +1,9 @@
1
1
  {
2
2
  "compilerOptions": {
3
3
  "outDir": "build",
4
+ "checkJs": true,
5
+ "esModuleInterop": true,
6
+ "strict": false,
4
7
  "paths": {
5
8
  "@appium/opencv": ["../opencv"]
6
9
  }