@appium/support 4.0.1 → 4.0.2

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.
@@ -3,9 +3,8 @@
3
3
  *
4
4
  * @param {string} base64Image The string with base64 encoded image.
5
5
  * Supports all image formats natively supported by Sharp library.
6
- * @param {sharp.Region} rect The selected region of image
6
+ * @param {import('sharp').Region} rect The selected region of image
7
7
  * @return {Promise<string>} base64 encoded string of cropped image
8
8
  */
9
- export function cropBase64Image(base64Image: string, rect: sharp.Region): Promise<string>;
10
- import sharp from "sharp";
9
+ export function cropBase64Image(base64Image: string, rect: import('sharp').Region): Promise<string>;
11
10
  //# sourceMappingURL=image-util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"image-util.d.ts","sourceRoot":"","sources":["../../lib/image-util.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,6CALW,MAAM,QAEN,MAAM,MAAM,GACX,QAAQ,MAAM,CAAC,CAK1B"}
1
+ {"version":3,"file":"image-util.d.ts","sourceRoot":"","sources":["../../lib/image-util.js"],"names":[],"mappings":"AAoBA;;;;;;;GAOG;AACH,6CALW,MAAM,QAEN,OAAO,OAAO,EAAE,MAAM,GACrB,QAAQ,MAAM,CAAC,CAK1B"}
@@ -1,20 +1,33 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.cropBase64Image = void 0;
7
- const sharp_1 = __importDefault(require("sharp"));
4
+ let _sharp;
5
+ /**
6
+ * @returns {import('sharp')}
7
+ */
8
+ function requireSharp() {
9
+ if (!_sharp) {
10
+ try {
11
+ _sharp = require('sharp');
12
+ }
13
+ catch (err) {
14
+ throw new Error(`Cannot load the 'sharp' module needed for images processing. ` +
15
+ `Consider visiting https://sharp.pixelplumbing.com/install ` +
16
+ `for troubleshooting. Original error: ${err.message}`);
17
+ }
18
+ }
19
+ return _sharp;
20
+ }
8
21
  /**
9
22
  * Crop the image by given rectangle (use base64 string as input and output)
10
23
  *
11
24
  * @param {string} base64Image The string with base64 encoded image.
12
25
  * Supports all image formats natively supported by Sharp library.
13
- * @param {sharp.Region} rect The selected region of image
26
+ * @param {import('sharp').Region} rect The selected region of image
14
27
  * @return {Promise<string>} base64 encoded string of cropped image
15
28
  */
16
29
  async function cropBase64Image(base64Image, rect) {
17
- const buf = await (0, sharp_1.default)(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
30
+ const buf = await requireSharp()(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
18
31
  return buf.toString('base64');
19
32
  }
20
33
  exports.cropBase64Image = cropBase64Image;
@@ -1 +1 @@
1
- {"version":3,"file":"image-util.js","sourceRoot":"","sources":["../../lib/image-util.js"],"names":[],"mappings":";;;;;;AAAA,kDAA0B;AAE1B;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CAAC,WAAW,EAAE,IAAI;IACrD,MAAM,GAAG,GAAG,MAAM,IAAA,eAAK,EAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACrF,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAHD,0CAGC"}
1
+ {"version":3,"file":"image-util.js","sourceRoot":"","sources":["../../lib/image-util.js"],"names":[],"mappings":";;;AAAA,IAAI,MAAM,CAAC;AAEX;;GAEG;AACH,SAAS,YAAY;IACnB,IAAI,CAAC,MAAM,EAAE;QACX,IAAI;YACF,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;SAC3B;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,IAAI,KAAK,CACb,+DAA+D;gBAC/D,4DAA4D;gBAC5D,wCAAwC,GAAG,CAAC,OAAO,EAAE,CACtD,CAAC;SACH;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,eAAe,CAAC,WAAW,EAAE,IAAI;IACrD,MAAM,GAAG,GAAG,MAAM,YAAY,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC9F,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAChC,CAAC;AAHD,0CAGC"}
package/lib/image-util.js CHANGED
@@ -1,14 +1,32 @@
1
- import sharp from 'sharp';
1
+ let _sharp;
2
+
3
+ /**
4
+ * @returns {import('sharp')}
5
+ */
6
+ function requireSharp() {
7
+ if (!_sharp) {
8
+ try {
9
+ _sharp = require('sharp');
10
+ } catch (err) {
11
+ throw new Error(
12
+ `Cannot load the 'sharp' module needed for images processing. ` +
13
+ `Consider visiting https://sharp.pixelplumbing.com/install ` +
14
+ `for troubleshooting. Original error: ${err.message}`
15
+ );
16
+ }
17
+ }
18
+ return _sharp;
19
+ }
2
20
 
3
21
  /**
4
22
  * Crop the image by given rectangle (use base64 string as input and output)
5
23
  *
6
24
  * @param {string} base64Image The string with base64 encoded image.
7
25
  * Supports all image formats natively supported by Sharp library.
8
- * @param {sharp.Region} rect The selected region of image
26
+ * @param {import('sharp').Region} rect The selected region of image
9
27
  * @return {Promise<string>} base64 encoded string of cropped image
10
28
  */
11
29
  export async function cropBase64Image(base64Image, rect) {
12
- const buf = await sharp(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
30
+ const buf = await requireSharp()(Buffer.from(base64Image, 'base64')).extract(rect).toBuffer();
13
31
  return buf.toString('base64');
14
32
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appium/support",
3
- "version": "4.0.1",
3
+ "version": "4.0.2",
4
4
  "description": "Support libs used across appium packages",
5
5
  "keywords": [
6
6
  "automation",
@@ -42,7 +42,7 @@
42
42
  },
43
43
  "dependencies": {
44
44
  "@appium/tsconfig": "^0.3.0",
45
- "@appium/types": "^0.11.1",
45
+ "@appium/types": "^0.12.0",
46
46
  "@colors/colors": "1.5.0",
47
47
  "@types/archiver": "5.3.2",
48
48
  "@types/base64-stream": "1.0.2",
@@ -55,7 +55,7 @@
55
55
  "@types/ncp": "2.0.5",
56
56
  "@types/npmlog": "4.1.4",
57
57
  "@types/pluralize": "0.0.29",
58
- "@types/semver": "7.3.13",
58
+ "@types/semver": "7.5.0",
59
59
  "@types/shell-quote": "1.7.1",
60
60
  "@types/supports-color": "8.1.1",
61
61
  "@types/teen_process": "2.0.0",
@@ -86,17 +86,19 @@
86
86
  "read-pkg": "5.2.0",
87
87
  "resolve-from": "5.0.0",
88
88
  "sanitize-filename": "1.6.3",
89
- "semver": "7.5.0",
90
- "sharp": "0.32.1",
89
+ "semver": "7.5.1",
91
90
  "shell-quote": "1.8.1",
92
91
  "source-map-support": "0.5.21",
93
92
  "supports-color": "8.1.1",
94
93
  "teen_process": "2.0.2",
95
- "type-fest": "3.10.0",
94
+ "type-fest": "3.11.1",
96
95
  "uuid": "9.0.0",
97
96
  "which": "3.0.1",
98
97
  "yauzl": "2.10.0"
99
98
  },
99
+ "optionalDependencies": {
100
+ "sharp": "0.32.1"
101
+ },
100
102
  "engines": {
101
103
  "node": "^14.17.0 || ^16.13.0 || >=18.0.0",
102
104
  "npm": ">=8"
@@ -104,7 +106,7 @@
104
106
  "publishConfig": {
105
107
  "access": "public"
106
108
  },
107
- "gitHead": "ee365ad1687d3b4e13a43a737e45110c74e59235",
109
+ "gitHead": "d0ebbaa0c683eeba04d9d967af2d0fde76197950",
108
110
  "typedoc": {
109
111
  "entryPoint": "./lib/index.js"
110
112
  }