askui 0.1.6 → 0.2.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.
Files changed (223) hide show
  1. package/README.md +6 -0
  2. package/bin/askui-postinstall +35 -0
  3. package/dist/cjs/core/model/test-case-dto/custom-element.d.ts +2 -2
  4. package/dist/cjs/core/model/test-case-dto/custom-element.js +2 -2
  5. package/dist/cjs/core/model/test-case-dto/custom-element.spec.js +7 -6
  6. package/dist/cjs/core/model/test-case-dto/index.js +1 -3
  7. package/dist/cjs/core/model/test-case-dto/test-step.d.ts +3 -7
  8. package/dist/cjs/core/model/test-case-dto/test-step.js +0 -12
  9. package/dist/cjs/core/ui-control-commands/control-command.d.ts +1 -0
  10. package/dist/cjs/core/ui-control-commands/control-command.js +5 -0
  11. package/dist/cjs/core/ui-control-commands/input-event.d.ts +1 -2
  12. package/dist/cjs/core/ui-control-commands/input-event.js +0 -1
  13. package/dist/cjs/execution/dsl.d.ts +6 -17
  14. package/dist/cjs/execution/dsl.js +4 -21
  15. package/dist/cjs/execution/execution-runtime.d.ts +7 -5
  16. package/dist/cjs/execution/execution-runtime.js +35 -23
  17. package/dist/cjs/execution/index.d.ts +2 -1
  18. package/dist/cjs/execution/index.js +5 -3
  19. package/dist/cjs/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
  20. package/dist/cjs/execution/{control-your-ui-api.js → inference-client.js} +9 -9
  21. package/dist/cjs/execution/ui-control-client-error.d.ts +2 -0
  22. package/dist/cjs/execution/ui-control-client-error.js +6 -0
  23. package/dist/cjs/execution/ui-control-client.d.ts +79 -0
  24. package/dist/cjs/execution/ui-control-client.js +185 -0
  25. package/dist/cjs/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  26. package/dist/cjs/execution/ui-controller-client-connection-state.js +10 -0
  27. package/dist/cjs/execution/ui-controller-client-interface.d.ts +27 -0
  28. package/dist/cjs/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  29. package/dist/cjs/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  30. package/dist/cjs/execution/{control-your-ui-client.js → ui-controller-client.js} +28 -28
  31. package/dist/cjs/lib/copy-example-project.js +2 -1
  32. package/dist/cjs/lib/download-binaries.js +10 -9
  33. package/dist/cjs/lib/index.d.ts +1 -1
  34. package/dist/cjs/lib/index.js +3 -3
  35. package/dist/cjs/lib/libfuse-error.d.ts +2 -0
  36. package/dist/cjs/lib/libfuse-error.js +6 -0
  37. package/dist/cjs/lib/logger.js +1 -1
  38. package/dist/cjs/lib/timeout-error.d.ts +0 -2
  39. package/dist/cjs/lib/timeout-error.js +0 -5
  40. package/dist/cjs/lib/ui-controller-args.d.ts +47 -0
  41. package/dist/cjs/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  42. package/dist/cjs/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  43. package/dist/cjs/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +7 -7
  44. package/dist/cjs/lib/ui-controller-darwin.d.ts +6 -0
  45. package/dist/cjs/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +8 -8
  46. package/dist/cjs/lib/ui-controller-facade.d.ts +17 -0
  47. package/dist/cjs/lib/{control-ui-server-facade.js → ui-controller-facade.js} +22 -16
  48. package/dist/cjs/lib/ui-controller-linux.d.ts +5 -0
  49. package/dist/cjs/lib/ui-controller-linux.js +52 -0
  50. package/dist/cjs/lib/ui-controller-win32.d.ts +3 -0
  51. package/dist/cjs/lib/ui-controller-win32.js +7 -0
  52. package/dist/cjs/lib/ui-controller.d.ts +8 -0
  53. package/dist/cjs/lib/{askui-control-server.js → ui-controller.js} +9 -9
  54. package/dist/cjs/lib/unkown-error.d.ts +0 -2
  55. package/dist/cjs/lib/unkown-error.js +0 -5
  56. package/dist/cjs/lib/wayland-error.d.ts +2 -0
  57. package/dist/cjs/lib/wayland-error.js +6 -0
  58. package/dist/cjs/main.d.ts +3 -2
  59. package/dist/cjs/main.js +6 -3
  60. package/dist/cjs/shared/index.d.ts +1 -0
  61. package/dist/cjs/shared/index.js +5 -0
  62. package/dist/cjs/utils/analytics/analytics-interface.d.ts +3 -0
  63. package/dist/cjs/utils/analytics/analytics-interface.js +2 -0
  64. package/dist/cjs/utils/analytics/analytics.d.ts +5 -0
  65. package/dist/cjs/utils/analytics/analytics.js +38 -0
  66. package/dist/cjs/utils/analytics/index.d.ts +1 -0
  67. package/dist/cjs/utils/analytics/index.js +5 -0
  68. package/dist/cjs/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  69. package/dist/cjs/utils/analytics/installation-timestamp-create-error.js +9 -0
  70. package/dist/cjs/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  71. package/dist/cjs/utils/analytics/installation-timestamp-get-error.js +9 -0
  72. package/dist/cjs/utils/analytics/installation-timestamp.d.ts +7 -0
  73. package/dist/cjs/utils/analytics/installation-timestamp.js +68 -0
  74. package/dist/cjs/utils/analytics/user-identifier-interface.d.ts +3 -0
  75. package/dist/cjs/utils/analytics/user-identifier-interface.js +2 -0
  76. package/dist/cjs/utils/analytics/user-identifier.d.ts +4 -0
  77. package/dist/cjs/utils/analytics/user-identifier.js +22 -0
  78. package/dist/cjs/utils/base_64_image/base-64-image-error.d.ts +2 -0
  79. package/dist/cjs/utils/base_64_image/base-64-image-error.js +6 -0
  80. package/dist/cjs/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  81. package/dist/cjs/utils/base_64_image/base-64-image-string-error.js +11 -0
  82. package/dist/cjs/utils/base_64_image/base-64-image.d.ts +18 -0
  83. package/dist/cjs/utils/base_64_image/base-64-image.js +86 -0
  84. package/dist/cjs/utils/http/custom-errors/http-client-error.d.ts +0 -2
  85. package/dist/cjs/utils/http/custom-errors/http-client-error.js +0 -5
  86. package/dist/cjs/utils/http/http-client-got.d.ts +6 -5
  87. package/dist/cjs/utils/http/http-client-got.js +11 -11
  88. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  89. package/dist/cjs/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  90. package/dist/cjs/utils/image-resize-errors/index.d.ts +0 -1
  91. package/dist/cjs/utils/image-resize-errors/index.js +1 -3
  92. package/dist/cjs/utils/path.d.ts +1 -0
  93. package/dist/cjs/utils/path.js +11 -0
  94. package/dist/cjs/utils/transformations.d.ts +0 -2
  95. package/dist/cjs/utils/transformations.js +11 -44
  96. package/dist/esm/core/model/test-case-dto/custom-element.d.ts +2 -2
  97. package/dist/esm/core/model/test-case-dto/custom-element.js +2 -2
  98. package/dist/esm/core/model/test-case-dto/custom-element.spec.js +7 -6
  99. package/dist/esm/core/model/test-case-dto/index.js +0 -1
  100. package/dist/esm/core/model/test-case-dto/test-step.d.ts +3 -7
  101. package/dist/esm/core/model/test-case-dto/test-step.js +1 -10
  102. package/dist/esm/core/ui-control-commands/control-command.d.ts +1 -0
  103. package/dist/esm/core/ui-control-commands/control-command.js +5 -0
  104. package/dist/esm/core/ui-control-commands/input-event.d.ts +1 -2
  105. package/dist/esm/core/ui-control-commands/input-event.js +0 -1
  106. package/dist/esm/execution/dsl.d.ts +6 -17
  107. package/dist/esm/execution/dsl.js +3 -21
  108. package/dist/esm/execution/execution-runtime.d.ts +7 -5
  109. package/dist/esm/execution/execution-runtime.js +35 -23
  110. package/dist/esm/execution/index.d.ts +2 -1
  111. package/dist/esm/execution/index.js +2 -1
  112. package/dist/esm/execution/{control-your-ui-api.d.ts → inference-client.d.ts} +4 -4
  113. package/dist/esm/execution/{control-your-ui-api.js → inference-client.js} +7 -7
  114. package/dist/esm/execution/ui-control-client-error.d.ts +2 -0
  115. package/dist/esm/execution/ui-control-client-error.js +2 -0
  116. package/dist/esm/execution/ui-control-client.d.ts +79 -0
  117. package/dist/esm/execution/ui-control-client.js +181 -0
  118. package/dist/esm/execution/{client-connection-state.d.ts → ui-controller-client-connection-state.d.ts} +1 -1
  119. package/dist/esm/execution/ui-controller-client-connection-state.js +7 -0
  120. package/dist/esm/execution/ui-controller-client-interface.d.ts +27 -0
  121. package/dist/esm/execution/{client-interface.js → ui-controller-client-interface.js} +0 -0
  122. package/dist/esm/execution/{control-your-ui-client.d.ts → ui-controller-client.d.ts} +6 -6
  123. package/dist/esm/execution/{control-your-ui-client.js → ui-controller-client.js} +26 -26
  124. package/dist/esm/lib/copy-example-project.js +2 -1
  125. package/dist/esm/lib/download-binaries.js +10 -9
  126. package/dist/esm/lib/index.d.ts +1 -1
  127. package/dist/esm/lib/index.js +1 -1
  128. package/dist/esm/lib/libfuse-error.d.ts +2 -0
  129. package/dist/esm/lib/libfuse-error.js +2 -0
  130. package/dist/esm/lib/logger.js +1 -1
  131. package/dist/esm/lib/timeout-error.d.ts +0 -2
  132. package/dist/esm/lib/timeout-error.js +0 -5
  133. package/dist/esm/lib/ui-controller-args.d.ts +47 -0
  134. package/dist/esm/lib/{control-ui-server-args.js → ui-controller-args.js} +0 -0
  135. package/dist/esm/lib/{control-ui-server-args.spec.d.ts → ui-controller-args.spec.d.ts} +0 -0
  136. package/dist/esm/lib/{control-ui-server-args.spec.js → ui-controller-args.spec.js} +1 -1
  137. package/dist/esm/lib/ui-controller-darwin.d.ts +6 -0
  138. package/dist/esm/lib/{control-ui-server-darwin.js → ui-controller-darwin.js} +6 -6
  139. package/dist/esm/lib/ui-controller-facade.d.ts +17 -0
  140. package/dist/esm/lib/{control-ui-server-facade.js → ui-controller-facade.js} +17 -11
  141. package/dist/esm/lib/ui-controller-linux.d.ts +5 -0
  142. package/dist/esm/lib/ui-controller-linux.js +48 -0
  143. package/dist/esm/lib/ui-controller-win32.d.ts +3 -0
  144. package/dist/esm/lib/ui-controller-win32.js +3 -0
  145. package/dist/esm/lib/ui-controller.d.ts +8 -0
  146. package/dist/esm/lib/{askui-control-server.js → ui-controller.js} +7 -7
  147. package/dist/esm/lib/unkown-error.d.ts +0 -2
  148. package/dist/esm/lib/unkown-error.js +0 -5
  149. package/dist/esm/lib/wayland-error.d.ts +2 -0
  150. package/dist/esm/lib/wayland-error.js +2 -0
  151. package/dist/esm/main.d.ts +3 -2
  152. package/dist/esm/main.js +3 -2
  153. package/dist/esm/shared/index.d.ts +1 -0
  154. package/dist/esm/shared/index.js +1 -0
  155. package/dist/esm/utils/analytics/analytics-interface.d.ts +3 -0
  156. package/dist/esm/utils/analytics/analytics-interface.js +1 -0
  157. package/dist/esm/utils/analytics/analytics.d.ts +5 -0
  158. package/dist/esm/utils/analytics/analytics.js +31 -0
  159. package/dist/esm/utils/analytics/index.d.ts +1 -0
  160. package/dist/esm/utils/analytics/index.js +1 -0
  161. package/dist/esm/utils/analytics/installation-timestamp-create-error.d.ts +4 -0
  162. package/dist/esm/utils/analytics/installation-timestamp-create-error.js +5 -0
  163. package/dist/esm/utils/analytics/installation-timestamp-get-error.d.ts +4 -0
  164. package/dist/esm/utils/analytics/installation-timestamp-get-error.js +5 -0
  165. package/dist/esm/utils/analytics/installation-timestamp.d.ts +7 -0
  166. package/dist/esm/utils/analytics/installation-timestamp.js +61 -0
  167. package/dist/esm/utils/analytics/user-identifier-interface.d.ts +3 -0
  168. package/dist/esm/utils/analytics/user-identifier-interface.js +1 -0
  169. package/dist/esm/utils/analytics/user-identifier.d.ts +4 -0
  170. package/dist/esm/utils/analytics/user-identifier.js +18 -0
  171. package/dist/esm/utils/base_64_image/base-64-image-error.d.ts +2 -0
  172. package/dist/esm/utils/base_64_image/base-64-image-error.js +2 -0
  173. package/dist/esm/utils/base_64_image/base-64-image-string-error.d.ts +4 -0
  174. package/dist/esm/utils/base_64_image/base-64-image-string-error.js +7 -0
  175. package/dist/esm/utils/base_64_image/base-64-image.d.ts +18 -0
  176. package/dist/esm/utils/base_64_image/base-64-image.js +79 -0
  177. package/dist/esm/utils/http/custom-errors/http-client-error.d.ts +0 -2
  178. package/dist/esm/utils/http/custom-errors/http-client-error.js +0 -5
  179. package/dist/esm/utils/http/http-client-got.d.ts +6 -5
  180. package/dist/esm/utils/http/http-client-got.js +11 -11
  181. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.d.ts +0 -2
  182. package/dist/esm/utils/image-resize-errors/image-resizing-base-error.js +0 -5
  183. package/dist/esm/utils/image-resize-errors/index.d.ts +0 -1
  184. package/dist/esm/utils/image-resize-errors/index.js +0 -1
  185. package/dist/esm/utils/path.d.ts +1 -0
  186. package/dist/esm/utils/path.js +4 -0
  187. package/dist/esm/utils/transformations.d.ts +0 -2
  188. package/dist/esm/utils/transformations.js +11 -39
  189. package/dist/example_projects_templates/typescript_jest/test/helper/jest.setup.ts +7 -7
  190. package/dist/example_projects_templates/typescript_jest/test/jest.config.ts +3 -0
  191. package/package.json +15 -8
  192. package/dist/cjs/execution/client-connection-state.js +0 -10
  193. package/dist/cjs/execution/client-error.d.ts +0 -2
  194. package/dist/cjs/execution/client-error.js +0 -6
  195. package/dist/cjs/execution/client-interface.d.ts +0 -13
  196. package/dist/cjs/execution/client.d.ts +0 -25
  197. package/dist/cjs/execution/client.js +0 -116
  198. package/dist/cjs/lib/askui-control-server.d.ts +0 -8
  199. package/dist/cjs/lib/control-ui-server-args.d.ts +0 -21
  200. package/dist/cjs/lib/control-ui-server-darwin.d.ts +0 -6
  201. package/dist/cjs/lib/control-ui-server-facade.d.ts +0 -16
  202. package/dist/cjs/lib/control-ui-server-linux.d.ts +0 -4
  203. package/dist/cjs/lib/control-ui-server-linux.js +0 -13
  204. package/dist/cjs/lib/control-ui-server-win32.d.ts +0 -3
  205. package/dist/cjs/lib/control-ui-server-win32.js +0 -7
  206. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  207. package/dist/cjs/utils/image-resize-errors/invalid-base64-image-error.js +0 -7
  208. package/dist/esm/execution/client-connection-state.js +0 -7
  209. package/dist/esm/execution/client-error.d.ts +0 -2
  210. package/dist/esm/execution/client-error.js +0 -2
  211. package/dist/esm/execution/client-interface.d.ts +0 -13
  212. package/dist/esm/execution/client.d.ts +0 -25
  213. package/dist/esm/execution/client.js +0 -112
  214. package/dist/esm/lib/askui-control-server.d.ts +0 -8
  215. package/dist/esm/lib/control-ui-server-args.d.ts +0 -21
  216. package/dist/esm/lib/control-ui-server-darwin.d.ts +0 -6
  217. package/dist/esm/lib/control-ui-server-facade.d.ts +0 -16
  218. package/dist/esm/lib/control-ui-server-linux.d.ts +0 -4
  219. package/dist/esm/lib/control-ui-server-linux.js +0 -9
  220. package/dist/esm/lib/control-ui-server-win32.d.ts +0 -3
  221. package/dist/esm/lib/control-ui-server-win32.js +0 -3
  222. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.d.ts +0 -3
  223. package/dist/esm/utils/image-resize-errors/invalid-base64-image-error.js +0 -3
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Base64ImageError = void 0;
4
+ class Base64ImageError extends Error {
5
+ }
6
+ exports.Base64ImageError = Base64ImageError;
@@ -0,0 +1,4 @@
1
+ import { Base64ImageError } from './base-64-image-error';
2
+ export declare class Base64ImageStringError extends Base64ImageError {
3
+ constructor(str: string, prefix: string);
4
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Base64ImageStringError = void 0;
4
+ const base_64_image_error_1 = require("./base-64-image-error");
5
+ class Base64ImageStringError extends base_64_image_error_1.Base64ImageError {
6
+ constructor(str, prefix) {
7
+ super(`Can't create Base64Image instance from string:\n${str}\n\n`
8
+ + `String should start with "${prefix}".`);
9
+ }
10
+ }
11
+ exports.Base64ImageStringError = Base64ImageStringError;
@@ -0,0 +1,18 @@
1
+ /// <reference types="node" />
2
+ export declare class Base64Image {
3
+ private readonly aSharp;
4
+ private info;
5
+ private buffer;
6
+ static readonly strPrefix = "data:image/png;base64,";
7
+ private constructor();
8
+ private static fromSharp;
9
+ static fromPathOrString(pathOrStr: string): Promise<Base64Image>;
10
+ static fromPath(path: string): Promise<Base64Image>;
11
+ static fromString(str: string): Promise<Base64Image>;
12
+ static fromBuffer(buffer: Buffer): Promise<Base64Image>;
13
+ get width(): number;
14
+ get height(): number;
15
+ resizeToFitInto(dimension: number): Promise<Base64Image>;
16
+ toString(): string;
17
+ toBuffer(): Buffer;
18
+ }
@@ -0,0 +1,86 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.Base64Image = void 0;
16
+ const sharp_1 = __importDefault(require("sharp"));
17
+ const base_64_image_string_error_1 = require("./base-64-image-string-error");
18
+ class Base64Image {
19
+ constructor(aSharp, info, buffer) {
20
+ this.aSharp = aSharp;
21
+ this.info = info;
22
+ this.buffer = buffer;
23
+ }
24
+ static fromSharp(s) {
25
+ return __awaiter(this, void 0, void 0, function* () {
26
+ const { info, data } = yield s.toBuffer({ resolveWithObject: true });
27
+ return new Base64Image(s, info, data);
28
+ });
29
+ }
30
+ static fromPathOrString(pathOrStr) {
31
+ return __awaiter(this, void 0, void 0, function* () {
32
+ try {
33
+ return yield Base64Image.fromString(pathOrStr);
34
+ }
35
+ catch (error) {
36
+ if (!(error instanceof base_64_image_string_error_1.Base64ImageStringError)) {
37
+ throw error;
38
+ }
39
+ }
40
+ return Base64Image.fromPath(pathOrStr);
41
+ });
42
+ }
43
+ static fromPath(path) {
44
+ return __awaiter(this, void 0, void 0, function* () {
45
+ return Base64Image.fromSharp((0, sharp_1.default)(path));
46
+ });
47
+ }
48
+ static fromString(str) {
49
+ return __awaiter(this, void 0, void 0, function* () {
50
+ if (!str.startsWith(Base64Image.strPrefix)) {
51
+ throw new base_64_image_string_error_1.Base64ImageStringError(str, Base64Image.strPrefix);
52
+ }
53
+ const data = str.substring(Base64Image.strPrefix.length);
54
+ return Base64Image.fromSharp((0, sharp_1.default)(Buffer.from(data, 'base64')));
55
+ });
56
+ }
57
+ static fromBuffer(buffer) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ return Base64Image.fromSharp((0, sharp_1.default)(buffer));
60
+ });
61
+ }
62
+ get width() {
63
+ return this.info.width;
64
+ }
65
+ get height() {
66
+ return this.info.height;
67
+ }
68
+ resizeToFitInto(dimension) {
69
+ return __awaiter(this, void 0, void 0, function* () {
70
+ const buffer = yield this.aSharp.resize({
71
+ width: this.width >= this.height ? dimension : undefined,
72
+ height: this.height > this.width ? dimension : undefined,
73
+ fit: sharp_1.default.fit.contain,
74
+ }).toBuffer();
75
+ return Base64Image.fromBuffer(buffer);
76
+ });
77
+ }
78
+ toString() {
79
+ return `${Base64Image.strPrefix}${this.buffer.toString('base64')}`;
80
+ }
81
+ toBuffer() {
82
+ return this.buffer;
83
+ }
84
+ }
85
+ exports.Base64Image = Base64Image;
86
+ Base64Image.strPrefix = 'data:image/png;base64,';
@@ -1,4 +1,2 @@
1
1
  export declare class HttpClientError extends Error {
2
- contructorName: string;
3
- constructor(message: string);
4
2
  }
@@ -2,10 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpClientError = void 0;
4
4
  class HttpClientError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.contructorName = this.constructor.name;
8
- this.name = this.contructorName;
9
- }
10
5
  }
11
6
  exports.HttpClientError = HttpClientError;
@@ -1,11 +1,12 @@
1
1
  import { OptionsOfJSONResponseBody } from 'got';
2
2
  import { CredentialArgs } from './credentials';
3
3
  export declare class HttpClientGot {
4
- private credentialArgs?;
5
- private credentials;
6
- constructor(credentialArgs?: CredentialArgs | undefined);
7
- private get headers();
8
- private injectAuthHeader;
4
+ readonly credentialArgs?: CredentialArgs | undefined;
5
+ readonly customHeaders?: Record<string, string> | undefined;
6
+ private headers;
7
+ constructor(credentialArgs?: CredentialArgs | undefined, customHeaders?: Record<string, string> | undefined);
8
+ private initHeaders;
9
+ private injectHeaders;
9
10
  post<T>(url: string, data: Record<string | number | symbol, unknown>): Promise<T>;
10
11
  get<T>(url: string, options?: OptionsOfJSONResponseBody): Promise<T>;
11
12
  }
@@ -17,22 +17,22 @@ const got_1 = __importDefault(require("got"));
17
17
  const credentials_1 = require("./credentials");
18
18
  const custom_errors_1 = require("./custom-errors");
19
19
  class HttpClientGot {
20
- constructor(credentialArgs) {
20
+ constructor(credentialArgs, customHeaders) {
21
21
  this.credentialArgs = credentialArgs;
22
- this.credentials = this.credentialArgs ? new credentials_1.Credentials(this.credentialArgs) : undefined;
22
+ this.customHeaders = customHeaders;
23
+ this.headers = {};
24
+ this.initHeaders(credentialArgs, customHeaders);
23
25
  }
24
- get headers() {
25
- var _a;
26
- return {
27
- Authorization: `Basic ${(_a = this.credentials) === null || _a === void 0 ? void 0 : _a.base64Encoded}`,
28
- };
26
+ initHeaders(credentialArgs, customHeaders = {}) {
27
+ const credentials = credentialArgs ? new credentials_1.Credentials(credentialArgs) : undefined;
28
+ this.headers = Object.assign(Object.assign({}, (credentials ? { Authorization: `Basic ${credentials === null || credentials === void 0 ? void 0 : credentials.base64Encoded}` } : {})), customHeaders);
29
29
  }
30
- injectAuthHeader(options) {
31
- return this.credentials ? Object.assign(Object.assign({}, options), { headers: this.headers }) : options;
30
+ injectHeaders(options) {
31
+ return Object.assign(Object.assign({}, options), { headers: this.headers });
32
32
  }
33
33
  post(url, data) {
34
34
  return __awaiter(this, void 0, void 0, function* () {
35
- const options = this.injectAuthHeader({ json: data, responseType: 'json', throwHttpErrors: false });
35
+ const options = this.injectHeaders({ json: data, responseType: 'json', throwHttpErrors: false });
36
36
  const { body, statusCode } = yield got_1.default.post(url, options);
37
37
  if (statusCode !== 200) {
38
38
  throw (0, custom_errors_1.httpClientErrorHandler)(statusCode, JSON.stringify(body));
@@ -42,7 +42,7 @@ class HttpClientGot {
42
42
  }
43
43
  get(url, options = { responseType: 'json' }) {
44
44
  return __awaiter(this, void 0, void 0, function* () {
45
- const response = yield got_1.default.get(url, this.injectAuthHeader(options));
45
+ const response = yield got_1.default.get(url, this.injectHeaders(options));
46
46
  return response.body;
47
47
  });
48
48
  }
@@ -1,4 +1,2 @@
1
1
  export declare class ImageResizingError extends Error {
2
- contructorName: string;
3
- constructor(message: string);
4
2
  }
@@ -2,10 +2,5 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ImageResizingError = void 0;
4
4
  class ImageResizingError extends Error {
5
- constructor(message) {
6
- super(message);
7
- this.contructorName = this.constructor.name;
8
- this.name = this.contructorName;
9
- }
10
5
  }
11
6
  exports.ImageResizingError = ImageResizingError;
@@ -1,2 +1 @@
1
1
  export { ImageResizingError } from './image-resizing-base-error';
2
- export { InvalidBase64Image } from './invalid-base64-image-error';
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidBase64Image = exports.ImageResizingError = void 0;
3
+ exports.ImageResizingError = void 0;
4
4
  var image_resizing_base_error_1 = require("./image-resizing-base-error");
5
5
  Object.defineProperty(exports, "ImageResizingError", { enumerable: true, get: function () { return image_resizing_base_error_1.ImageResizingError; } });
6
- var invalid_base64_image_error_1 = require("./invalid-base64-image-error");
7
- Object.defineProperty(exports, "InvalidBase64Image", { enumerable: true, get: function () { return invalid_base64_image_error_1.InvalidBase64Image; } });
@@ -0,0 +1 @@
1
+ export declare function getPathToNodeModulesRoot(): string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getPathToNodeModulesRoot = void 0;
7
+ const path_1 = __importDefault(require("path"));
8
+ function getPathToNodeModulesRoot() {
9
+ return path_1.default.join(__dirname, '..', '..');
10
+ }
11
+ exports.getPathToNodeModulesRoot = getPathToNodeModulesRoot;
@@ -1,6 +1,4 @@
1
1
  import { ResizedImage } from './resized-image-interface';
2
- export declare function toBase64Image(imagePath: string): Promise<string>;
3
- export declare function toBase64ImageIfNeeded(pngPathOrBase64Image: string): Promise<string>;
4
2
  /**
5
3
  * Resizes a base64image only when the height or the width is bigger than the maxEdge Param,so that
6
4
  * the returned image keeps the same aspect ratio but have a max size equal to the threshold.
@@ -8,35 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.resizeBase64ImageWithSameRatio = exports.toBase64ImageIfNeeded = exports.toBase64Image = void 0;
16
- const fs_1 = __importDefault(require("fs"));
17
- const jimp_1 = require("jimp");
12
+ exports.resizeBase64ImageWithSameRatio = void 0;
18
13
  const lib_1 = require("../lib");
14
+ const base_64_image_1 = require("./base_64_image/base-64-image");
19
15
  const image_resize_errors_1 = require("./image-resize-errors");
20
- function toBase64Image(imagePath) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- if (!(fs_1.default.existsSync(imagePath))) {
23
- throw new Error(`the image ${imagePath} does not exists!`);
24
- }
25
- const image = yield (0, jimp_1.read)(imagePath);
26
- return image.getBase64Async('image/png');
27
- });
28
- }
29
- exports.toBase64Image = toBase64Image;
30
- function toBase64ImageIfNeeded(pngPathOrBase64Image) {
31
- return __awaiter(this, void 0, void 0, function* () {
32
- const isBase64Image = pngPathOrBase64Image.startsWith('data:image');
33
- if (!isBase64Image) {
34
- return toBase64Image(pngPathOrBase64Image);
35
- }
36
- return pngPathOrBase64Image;
37
- });
38
- }
39
- exports.toBase64ImageIfNeeded = toBase64ImageIfNeeded;
40
16
  /**
41
17
  * Resizes a base64image only when the height or the width is bigger than the maxEdge Param,so that
42
18
  * the returned image keeps the same aspect ratio but have a max size equal to the threshold.
@@ -50,28 +26,19 @@ exports.toBase64ImageIfNeeded = toBase64ImageIfNeeded;
50
26
  function resizeBase64ImageWithSameRatio(base64ImageString, maxEdge = 1400) {
51
27
  return __awaiter(this, void 0, void 0, function* () {
52
28
  lib_1.logger.debug('Image resizing');
53
- if (!(base64ImageString.startsWith('data:image'))) {
54
- Promise.reject(new image_resize_errors_1.InvalidBase64Image('Invalid base64 image string'));
55
- }
56
29
  try {
57
- let resizeRatio = 1;
58
- const orignalImage = yield (0, jimp_1.read)(Buffer.from(base64ImageString.replace(/^data:image\/png;base64,/, ''), 'base64'));
59
- const imageHeight = orignalImage.getHeight();
60
- const imageWidth = orignalImage.getWidth();
61
- if (Math.max(imageHeight, imageWidth) <= maxEdge) {
62
- return yield Promise.resolve({ base64Image: base64ImageString, resizeRatio });
30
+ const image = yield base_64_image_1.Base64Image.fromString(base64ImageString);
31
+ if (image.height <= maxEdge && image.width <= maxEdge) {
32
+ return { base64Image: base64ImageString, resizeRatio: 1 };
63
33
  }
64
- const imageRatio = imageHeight / imageWidth;
65
- const isHeigthBiggerThanWidth = imageRatio > 1;
66
- const newHeigh = isHeigthBiggerThanWidth ? maxEdge : maxEdge * imageRatio;
67
- const newWidth = isHeigthBiggerThanWidth ? maxEdge / imageRatio : maxEdge;
68
- const newImage = orignalImage.resize(newWidth, newHeigh);
69
- resizeRatio = imageHeight / newHeigh;
70
- const newImageBase64 = yield newImage.getBase64Async('image/png');
71
- return yield Promise.resolve({ base64Image: newImageBase64, resizeRatio });
34
+ const resizedImage = yield image.resizeToFitInto(maxEdge);
35
+ return {
36
+ base64Image: resizedImage.toString(),
37
+ resizeRatio: image.width / resizedImage.width,
38
+ };
72
39
  }
73
40
  catch (error) {
74
- return Promise.reject(new image_resize_errors_1.ImageResizingError(`A Problem has occured during the resizeing of the image. Error: ${error}`));
41
+ throw new image_resize_errors_1.ImageResizingError(`A Problem has occured during the resizing of the image. Error: ${error}`);
75
42
  }
76
43
  });
77
44
  }
@@ -4,13 +4,13 @@ export declare class CustomElement implements CustomElementJson {
4
4
  name?: string | undefined;
5
5
  threshold?: number | undefined;
6
6
  rotationDegreePerStep?: number | undefined;
7
- imageCompareFormat?: "grayscale" | "RGB" | undefined;
7
+ imageCompareFormat?: "RGB" | "grayscale" | undefined;
8
8
  mask?: {
9
9
  x: number;
10
10
  y: number;
11
11
  }[] | undefined;
12
12
  private static schema;
13
- constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "grayscale" | "RGB" | undefined, mask?: {
13
+ constructor(customImage: string, name?: string | undefined, threshold?: number | undefined, rotationDegreePerStep?: number | undefined, imageCompareFormat?: "RGB" | "grayscale" | undefined, mask?: {
14
14
  x: number;
15
15
  y: number;
16
16
  }[] | undefined);
@@ -8,7 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { array, number, object, ValidationError, } from 'yup';
11
- import { toBase64ImageIfNeeded } from '../../../utils/transformations';
11
+ import { Base64Image } from '../../../utils/base_64_image/base-64-image';
12
12
  export class CustomElement {
13
13
  constructor(customImage, name, threshold, rotationDegreePerStep, imageCompareFormat, mask) {
14
14
  this.customImage = customImage;
@@ -25,7 +25,7 @@ export class CustomElement {
25
25
  }
26
26
  static fromJsonWithImagePathOrImage(ceJson) {
27
27
  return __awaiter(this, void 0, void 0, function* () {
28
- const customImage = yield toBase64ImageIfNeeded(ceJson.customImage);
28
+ const customImage = (yield Base64Image.fromPathOrString(ceJson.customImage)).toString();
29
29
  const customElement = CustomElement.fromJson(Object.assign(Object.assign({}, ceJson), { customImage }));
30
30
  customElement.validate();
31
31
  return customElement;
@@ -8,12 +8,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  import { CustomElement } from './custom-element';
11
+ const base64ImageString = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAAA8CAYAAADWibxkAAAACXBIWXMAABYlAAAWJQFJUiTwAAAN20lEQVRogXVa3XrbSg7T7XHsfZyNneSJtm2cOH1/7UeCIMCRz4Xa2NYPhwRBkKPtdv7e306P/e3le7+dP+v43t9eHvt7HOfH/nb53q/12/vLdx5vL/f97RT/x/G53y73/e1S19Q5ccS9buc7zrt87+/nL1x/wvW3Sxz3/f3lnr/p/Pgu7HrUb/c8j/fC/XHdR9rJa2F7rieeV3/zmrhv3OP9BWvZciF1QvxwO9339xNPlvF+cX4+h2E/fe3bJf7GZxj2MMfiPrn4s84LJ9wu4bwwBosOJ6dN6Rhcm8+OxedBp69BgG08ImBxwB4G5qccEvbhui2ih+jy4jKAjokHnL73jzO9HOf/qRv/mEfj7wfuEWioB8O4QNGjIljO+k8hxc4nCuHQOF/RC4eEEyayLHCJQDoLqILzfvaP89884AA4vh1wLU9h8X9ycXQGoISFEdpKE0LUUBKQPoX36RQaGAbFgiKVaCzgncYy5c50UhyKWEY9I+8OKBsqRRk0OBUO78iffwp5SNc4cJ9HOEAGZ3RPf0YeEZaZ/5EambcF3YhWQ7VQE7A+uQPKmbHgiHwiipwh1DDKXFin3eW+Xy8RJMv9QiKDQFjLQfMz0MM0/oOUK3u3fFgQUhrCiMXfIsbXl9/pGPEFcwzOohG4jukjx3Ua8EikhBP4LEsBg+fMa6WCf5cQN9LryGcgxCfOY7Lvvm+3jAhvsOYibpDGVlT9YjA4HfAjBr945YCh7dyGvKVHoUWcYc+oRQZaWDGUolU9ysFMNRD0dKAqhx8POIBGzCMgj1xRBMETOIqR0wGAcqYSr3GvR/5npOHYhPMpokQO4EKRo5OHCHM5INO2iVYl0T+vaRVph8/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uFBLAvQ8FB+tmhLE2dtRm4lvTlbmK2xRJQ3Xfp+ONunSGPPgfeXWBtONjm8pspaGTZGH16ndrcF2JTItb/k86oFFA2gqQYrweyJEt9zoCq0UvgUcVPx+XzCU9JVo1rsZ0MRkfeGkzjY4M6w5n5MkV5kaXwuzrfKD5I6FyWn0hlzEdh9amQ96R6nA3wQsozpvLny8jck8HTSpsXUgkrgNOk4MbZj8BtTZZDQmBI7lH1/cZ0/fu7/Pf3aX/9RykjXe/laecml72y/Z/5XeT9V+TUnbMxlqDtWgjgRbAmx4xGG6PDNEfURjIhHfpHEPamZkUA6zBzlOHz+zjLNhbh0Zkl27pj7hdraxznbUGIDxrEQ9gDrBod3bEepTLU1RYpYXjM7J1lqiDlWG+e1TZwHfM8ehVrCbNOz+Q7RIQU+rXxZu2u9/SwxrAaAnIaiaz4ufcDoID/36z/6ngq0ecPIVAGaQxF33NxWW6T82gD16/64bnvW3a2sj0X+6irhg9SuHN5EWat8lK84Mt9NPrv66+bniV2H/ckDaZqSbVu0FpIie57NGRs8MAcSLFVeruQAzQ7YJQ4uaX6Z7xtN5TZl8GEy1LZIq/jmzUDL4ZUaG4baMNcD/H8hlYADpzRH1QAAAABJRU5ErkJggg==';
11
12
  describe('CustomElement', () => {
12
13
  describe('fromJsonWithImagePathOrImage', () => {
13
14
  test('should return CustomElement if CustomElement created from JSON is valid', () => __awaiter(void 0, void 0, void 0, function* () {
14
- const expected = new CustomElement('data:image', 'Dummy_element', 0.7, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
15
+ const expected = new CustomElement(base64ImageString, 'Dummy_element', 0.7, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
15
16
  const actual = yield CustomElement.fromJsonWithImagePathOrImage({
16
- customImage: 'data:image',
17
+ customImage: base64ImageString,
17
18
  name: 'Dummy_element',
18
19
  threshold: 0.7,
19
20
  rotationDegreePerStep: 10,
@@ -24,25 +25,25 @@ describe('CustomElement', () => {
24
25
  }));
25
26
  test('should throw ValidationError if threshold is invalid', () => {
26
27
  expect(() => {
27
- const customElement = new CustomElement('data:image', 'Dummy_element', 1.1, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
28
+ const customElement = new CustomElement(base64ImageString, 'Dummy_element', 1.1, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
28
29
  customElement.validate();
29
30
  }).toThrow('threshold must be less than or equal to 1');
30
31
  });
31
32
  test('should throw ValidationError if rotationDegreePerStep is invalid', () => {
32
33
  expect(() => {
33
- const customElement = new CustomElement('data:image', 'Dummy_element', 0.9, -90, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
34
+ const customElement = new CustomElement(base64ImageString, 'Dummy_element', 0.9, -90, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 3, y: 4 }]);
34
35
  customElement.validate();
35
36
  }).toThrow('rotationDegreePerStep must be greater than or equal to 0');
36
37
  });
37
38
  test('should throw ValidationError if mask is invalid', () => {
38
39
  expect(() => {
39
- const customElement = new CustomElement('data:image', 'Dummy_element', 0.9, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
40
+ const customElement = new CustomElement(base64ImageString, 'Dummy_element', 0.9, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
40
41
  customElement.validate();
41
42
  }).toThrow('mask must contain at least 3 points');
42
43
  });
43
44
  test('should throw ValidationError if mask and threshold are both invalid', () => {
44
45
  expect(() => {
45
- const customElement = new CustomElement('data:image', 'Dummy_element', 90, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
46
+ const customElement = new CustomElement(base64ImageString, 'Dummy_element', 90, 10, 'RGB', [{ x: 0, y: 1 }, { x: 1, y: 2 }]);
46
47
  customElement.validate();
47
48
  }).toThrow('threshold must be less than or equal to 1, mask must contain at least 3 points');
48
49
  });
@@ -1,2 +1 @@
1
1
  export { CustomElement } from './custom-element';
2
- export { TestStep } from './test-step';
@@ -1,10 +1,6 @@
1
1
  import { CustomElement } from './custom-element';
2
- import { CustomElementJson } from './custom-element-json';
3
- export declare class TestStep {
2
+ export interface TestStep {
4
3
  instruction: string;
5
- customElements: CustomElement[];
6
- constructor(instruction: string, customElements?: CustomElement[]);
7
- static fromJson(step: TestStep & {
8
- customElements: CustomElementJson[];
9
- }): TestStep;
4
+ customElements?: CustomElement[];
5
+ secretText?: string | undefined;
10
6
  }
@@ -1,10 +1 @@
1
- import { CustomElement } from './custom-element';
2
- export class TestStep {
3
- constructor(instruction, customElements = []) {
4
- this.instruction = instruction;
5
- this.customElements = customElements;
6
- }
7
- static fromJson(step) {
8
- return new TestStep(step.instruction, (step.customElements || []).map((customELement) => CustomElement.fromJson(customELement)));
9
- }
10
- }
1
+ export {};
@@ -6,4 +6,5 @@ export declare class ControlCommand {
6
6
  tryToRepeat: boolean;
7
7
  constructor(code: ControlCommandCode, actions: Action[], tryToRepeat?: boolean);
8
8
  static fromJson(json: ControlCommand, resizeRatio?: number): ControlCommand;
9
+ setTextToBeTyped(text: string): void;
9
10
  }
@@ -1,5 +1,6 @@
1
1
  import { Action } from './action';
2
2
  import { ControlCommandCode } from './control-command-code';
3
+ import { InputEvent } from './input-event';
3
4
  export class ControlCommand {
4
5
  constructor(code, actions, tryToRepeat = false) {
5
6
  this.code = code;
@@ -9,4 +10,8 @@ export class ControlCommand {
9
10
  static fromJson(json, resizeRatio = 1) {
10
11
  return new ControlCommand(ControlCommandCode[json.code], json.actions.map((action) => Action.fromJson(action, resizeRatio)), json.tryToRepeat);
11
12
  }
13
+ setTextToBeTyped(text) {
14
+ this.actions = this.actions.map((action) => ([InputEvent.TYPE, InputEvent.TYPE_TEXT].includes(action.inputEvent)
15
+ ? new Action(action.inputEvent, action.position, text) : action));
16
+ }
12
17
  }
@@ -16,6 +16,5 @@ export declare enum InputEvent {
16
16
  MOUSE_MOVE = "MOUSE_MOVE",
17
17
  MOUSE_DOWN = "MOUSE_DOWN",
18
18
  MOUSE_UP = "MOUSE_UP",
19
- EXECUTE_COMMAND = "EXECUTE_COMMAND",
20
- WAIT = "WAIT"
19
+ EXECUTE_COMMAND = "EXECUTE_COMMAND"
21
20
  }
@@ -18,5 +18,4 @@ export var InputEvent;
18
18
  InputEvent["MOUSE_DOWN"] = "MOUSE_DOWN";
19
19
  InputEvent["MOUSE_UP"] = "MOUSE_UP";
20
20
  InputEvent["EXECUTE_COMMAND"] = "EXECUTE_COMMAND";
21
- InputEvent["WAIT"] = "WAIT";
22
21
  })(InputEvent || (InputEvent = {}));
@@ -1,9 +1,4 @@
1
1
  import { CustomElementJson } from '../core/model/test-case-dto';
2
- export declare enum TimeUnit {
3
- MS = "millisecond",
4
- S = "seconds",
5
- MIN = "minutes"
6
- }
7
2
  export declare type PC_KEY = 'backspace' | 'delete' | 'enter' | 'tab' | 'escape' | 'up' | 'down' | 'right' | 'left' | 'home' | 'end' | 'pageup' | 'pagedown' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'space' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'A' | 'B' | 'C' | 'D' | 'E' | 'F' | 'G' | 'H' | 'I' | 'J' | 'K' | 'L' | 'M' | 'N' | 'O' | 'P' | 'Q' | 'R' | 'S' | 'T' | 'U' | 'V' | 'W' | 'X' | 'Y' | 'Z' | '!' | '"' | '#' | '$' | '%' | '&' | "'" | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~ ';
8
3
  export declare type ANDROID_KEY = 'home' | 'back' | 'call' | 'endcall' | '0' | '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' | '9' | 'star' | 'pound' | 'dpad_up' | 'dpad_down' | 'dpad_left' | 'dpad_right' | 'dpad_center' | 'volume_up' | 'volume_down' | 'power' | 'camera' | 'clear' | 'a' | 'b' | 'c' | 'd' | 'e' | 'f' | 'g' | 'h' | 'i' | 'j' | 'k' | 'l' | 'm' | 'n' | 'o' | 'p' | 'q' | 'r' | 's' | 't' | 'u' | 'v' | 'w' | 'x' | 'y' | 'z' | 'comma' | 'period' | 'alt_left' | 'alt_right' | 'shift_left' | 'shift_right' | 'tab' | 'space' | 'sym' | 'explorer' | 'envelope' | 'enter' | 'del' | 'grave' | 'minus' | 'equals' | 'left_bracket' | 'right_bracket' | 'backslash' | 'semicolon' | 'apostrophe' | 'slash' | 'at' | 'num' | 'headsethook' | 'focus' | 'plus' | 'menu' | 'notification' | 'search' | 'media_play_pause' | 'media_stop' | 'media_next' | 'media_previous' | 'media_rewind' | 'media_fast_forward' | 'mute' | 'page_up' | 'page_down' | 'switch_charset' | 'escape' | 'forward_del' | 'ctrl_left' | 'ctrl_right' | 'caps_lock' | 'scroll_lock' | 'function' | 'break' | 'move_home' | 'move_end' | 'insert' | 'forward' | 'media_play' | 'media_pause' | 'media_close' | 'media_eject' | 'media_record' | 'f1' | 'f2' | 'f3' | 'f4' | 'f5' | 'f6' | 'f7' | 'f8' | 'f9' | 'f10' | 'f11' | 'f12' | 'num_lock' | 'numpad_0' | 'numpad_1' | 'numpad_2' | 'numpad_3' | 'numpad_4' | 'numpad_5' | 'numpad_6' | 'numpad_7' | 'numpad_8' | 'numpad_9' | 'numpad_divide' | 'numpad_multiply' | 'numpad_subtract' | 'numpad_add' | 'numpad_dot' | 'numpad_comma' | 'numpad_enter' | 'numpad_equals' | 'numpad_left_paren' | 'numpad_right_paren' | 'volume_mute' | 'info' | 'channel_up' | 'channel_down' | 'zoom_in' | 'zoom_out' | 'window' | 'guide' | 'bookmark' | 'captions' | 'settings' | 'app_switch' | 'language_switch' | 'contacts' | 'calendar' | 'music' | 'calculator' | 'assist' | 'brightness_down' | 'brightness_up' | 'media_audio_track' | 'sleep' | 'wakeup' | 'pairing' | 'media_top_menu' | 'last_channel' | 'tv_data_service' | 'voice_assist' | 'help' | 'navigate_previous' | 'navigate_next' | 'navigate_in' | 'navigate_out' | 'dpad_up_left' | 'dpad_down_left' | 'dpad_up_right' | 'dpad_down_right' | 'media_skip_forward' | 'media_skip_backward' | 'media_step_forward' | 'media_step_backward' | 'soft_sleep' | 'cut' | 'copy' | 'paste' | 'all_apps' | 'refresh';
9
4
  export declare type MODIFIER_KEY = 'command' | 'alt' | 'control' | 'shift' | 'right_shift';
@@ -19,7 +14,10 @@ declare abstract class FluentBase {
19
14
  protected get textStr(): string;
20
15
  protected get params(): Map<string, unknown>;
21
16
  }
22
- declare class Exec extends FluentBase {
17
+ export interface Executable {
18
+ exec(): Promise<void>;
19
+ }
20
+ export declare class Exec extends FluentBase implements Executable {
23
21
  exec(): Promise<void>;
24
22
  }
25
23
  export declare class FluentFilters extends FluentBase {
@@ -1333,14 +1331,14 @@ export declare abstract class FluentCommand extends FluentBase {
1333
1331
  */
1334
1332
  typeIn(text: string): FluentFilters;
1335
1333
  /**
1336
- * Scrolls in the x and y direction, e.g., until an element is visible.
1334
+ * Moves mouse to the filtered element and scrolls in the x and y direction
1337
1335
  *
1338
1336
  * @param {number} x_offset - A (positive/negative) x direction.
1339
1337
  * @param {number} y_offset - A (positive/negative) y direction.
1340
1338
  *
1341
1339
  * @return {FluentFilters}
1342
1340
  */
1343
- scrollUntil(x_offset: number, y_offset: number): FluentFilters;
1341
+ scrollInside(x_offset: number, y_offset: number): FluentFilters;
1344
1342
  /**
1345
1343
  * Moves the mouse relatively to an element in the direction.
1346
1344
  * This can be used when the mouse should not hover over on an element anymore.
@@ -1368,15 +1366,6 @@ export declare abstract class FluentCommand extends FluentBase {
1368
1366
  * @return {Exec}
1369
1367
  */
1370
1368
  type(text: string): Exec;
1371
- /**
1372
- * Waits for `<timeValue> <timeUnit>`, e.g., 10 seconds.
1373
- *
1374
- * @param {number} timeValue - A number of time unit, e.g., ms or min, to wait for.
1375
- * @param {TimeUnit} timeUnit - A time unit, e.g., ms, s or min.
1376
- *
1377
- * @return {Exec}
1378
- */
1379
- waitFor(timeValue: number, timeUnit: TimeUnit): Exec;
1380
1369
  /**
1381
1370
  * Moves the mouse from the current position (relative) in x and y direction.
1382
1371
  *
@@ -2,12 +2,6 @@
2
2
  /* eslint-disable @typescript-eslint/naming-convention */
3
3
  /* eslint-disable max-classes-per-file */
4
4
  // Autogenerated from typescript.template file
5
- export var TimeUnit;
6
- (function (TimeUnit) {
7
- TimeUnit["MS"] = "millisecond";
8
- TimeUnit["S"] = "seconds";
9
- TimeUnit["MIN"] = "minutes";
10
- })(TimeUnit || (TimeUnit = {}));
11
5
  class FluentBase {
12
6
  constructor(prev) {
13
7
  this.prev = prev;
@@ -39,7 +33,7 @@ class FluentBase {
39
33
  get textStr() { return this._textStr; }
40
34
  get params() { return this._params; }
41
35
  }
42
- class Exec extends FluentBase {
36
+ export class Exec extends FluentBase {
43
37
  exec() {
44
38
  return this.commandStringBuilder();
45
39
  }
@@ -1870,14 +1864,14 @@ export class FluentCommand extends FluentBase {
1870
1864
  return new FluentFilters(this);
1871
1865
  }
1872
1866
  /**
1873
- * Scrolls in the x and y direction, e.g., until an element is visible.
1867
+ * Moves mouse to the filtered element and scrolls in the x and y direction
1874
1868
  *
1875
1869
  * @param {number} x_offset - A (positive/negative) x direction.
1876
1870
  * @param {number} y_offset - A (positive/negative) y direction.
1877
1871
  *
1878
1872
  * @return {FluentFilters}
1879
1873
  */
1880
- scrollUntil(x_offset, y_offset) {
1874
+ scrollInside(x_offset, y_offset) {
1881
1875
  this._textStr = `Scroll x ${x_offset} y ${y_offset} in`;
1882
1876
  return new FluentFilters(this);
1883
1877
  }
@@ -1917,18 +1911,6 @@ export class FluentCommand extends FluentBase {
1917
1911
  this._textStr = `Type "${text}"`;
1918
1912
  return new Exec(this);
1919
1913
  }
1920
- /**
1921
- * Waits for `<timeValue> <timeUnit>`, e.g., 10 seconds.
1922
- *
1923
- * @param {number} timeValue - A number of time unit, e.g., ms or min, to wait for.
1924
- * @param {TimeUnit} timeUnit - A time unit, e.g., ms, s or min.
1925
- *
1926
- * @return {Exec}
1927
- */
1928
- waitFor(timeValue, timeUnit) {
1929
- this._textStr = `Wait for ${timeValue} ${timeUnit}`;
1930
- return new Exec(this);
1931
- }
1932
1914
  /**
1933
1915
  * Moves the mouse from the current position (relative) in x and y direction.
1934
1916
  *