1 | "use strict";
|
2 | var __extends = (this && this.__extends) || (function () {
|
3 | var extendStatics = function (d, b) {
|
4 | extendStatics = Object.setPrototypeOf ||
|
5 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
6 | function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
7 | return extendStatics(d, b);
|
8 | };
|
9 | return function (d, b) {
|
10 | if (typeof b !== "function" && b !== null)
|
11 | throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
12 | extendStatics(d, b);
|
13 | function __() { this.constructor = d; }
|
14 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
15 | };
|
16 | })();
|
17 | Object.defineProperty(exports, "__esModule", { value: true });
|
18 | exports.TextCommand = exports.keyEventCommand = exports.SwipeCommand = exports.TapCommand = exports.CommandBase = void 0;
|
19 | var utils_1 = require("./utils");
|
20 | var CommandBase = (function () {
|
21 | function CommandBase(options) {
|
22 | this.id = "command-".concat(CommandBase.commandCount++);
|
23 | this.preDelay = 500;
|
24 | this.postDelay = 500;
|
25 | if (options === null || options === void 0 ? void 0 : options.preDelay)
|
26 | this.preDelay = options.preDelay;
|
27 | if (options === null || options === void 0 ? void 0 : options.postDelay)
|
28 | this.postDelay = options.postDelay;
|
29 | }
|
30 | CommandBase.commandCount = 0;
|
31 | return CommandBase;
|
32 | }());
|
33 | exports.CommandBase = CommandBase;
|
34 | var TapCommand = (function (_super) {
|
35 | __extends(TapCommand, _super);
|
36 | function TapCommand(options) {
|
37 | var _this = _super.call(this, options) || this;
|
38 | _this.targetPos = (0, utils_1.getRandomPosition)(options.rect);
|
39 | return _this;
|
40 | }
|
41 | TapCommand.prototype.getCommandArgs = function (resolutionRatio) {
|
42 | return ["input", "tap", String(this.targetPos.x * resolutionRatio.x), String(this.targetPos.y * resolutionRatio.y)];
|
43 | };
|
44 | return TapCommand;
|
45 | }(CommandBase));
|
46 | exports.TapCommand = TapCommand;
|
47 | var SwipeCommand = (function (_super) {
|
48 | __extends(SwipeCommand, _super);
|
49 | function SwipeCommand(options) {
|
50 | var _this = _super.call(this, options) || this;
|
51 | _this.originPos = (0, utils_1.getRandomPosition)(options.originRect);
|
52 | _this.targetPos = (0, utils_1.getRandomPosition)(options.targetRect);
|
53 | _this.duration = options.duration || 500;
|
54 | return _this;
|
55 | }
|
56 | SwipeCommand.prototype.getCommandArgs = function (resolutionRatio) {
|
57 | return [
|
58 | "input",
|
59 | "swipe",
|
60 | String(this.originPos.x * resolutionRatio.x),
|
61 | String(this.originPos.y * resolutionRatio.y),
|
62 | String(this.targetPos.x * resolutionRatio.x),
|
63 | String(this.targetPos.y * resolutionRatio.y),
|
64 | String(this.duration),
|
65 | ];
|
66 | };
|
67 | return SwipeCommand;
|
68 | }(CommandBase));
|
69 | exports.SwipeCommand = SwipeCommand;
|
70 | var keyEventCommand = (function (_super) {
|
71 | __extends(keyEventCommand, _super);
|
72 | function keyEventCommand(options) {
|
73 | var _this = _super.call(this, options) || this;
|
74 | _this.keyCode = options.keyCode;
|
75 | return _this;
|
76 | }
|
77 | keyEventCommand.prototype.getCommandArgs = function () {
|
78 | return ["input", "keyevent", String(this.keyCode)];
|
79 | };
|
80 | return keyEventCommand;
|
81 | }(CommandBase));
|
82 | exports.keyEventCommand = keyEventCommand;
|
83 | var TextCommand = (function (_super) {
|
84 | __extends(TextCommand, _super);
|
85 | function TextCommand(options) {
|
86 | var _this = _super.call(this, options) || this;
|
87 | _this.content = options.content;
|
88 | return _this;
|
89 | }
|
90 | TextCommand.prototype.getCommandArgs = function () {
|
91 | return ["input", "text", this.content];
|
92 | };
|
93 | return TextCommand;
|
94 | }(CommandBase));
|
95 | exports.TextCommand = TextCommand;
|