@applitools/eyes 1.33.3 → 1.34.0

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 (142) hide show
  1. package/CHANGELOG.md +96 -0
  2. package/dist/BatchClose.js +84 -0
  3. package/dist/Eyes.js +750 -0
  4. package/dist/Logger.js +122 -0
  5. package/dist/Runners.js +130 -0
  6. package/dist/SDK.js +45 -0
  7. package/dist/SessionEventHandlers.js +193 -0
  8. package/dist/cli/cli.js +56 -0
  9. package/dist/cli/load-config.js +73 -0
  10. package/dist/enums/AccessibilityGuidelinesVersion.js +9 -0
  11. package/dist/enums/AccessibilityLevel.js +9 -0
  12. package/dist/enums/AccessibilityRegionType.js +12 -0
  13. package/dist/enums/AccessibilityStatus.js +9 -0
  14. package/dist/enums/BrowserType.js +23 -0
  15. package/dist/enums/CorsIframeHandle.js +10 -0
  16. package/dist/enums/DeviceName.js +105 -0
  17. package/dist/enums/DynamicTextType.js +13 -0
  18. package/dist/enums/FailureReport.js +8 -0
  19. package/dist/enums/IosDeviceName.js +47 -0
  20. package/dist/enums/IosMultiDeviceTarget.js +30 -0
  21. package/dist/enums/IosVersion.js +10 -0
  22. package/dist/enums/MatchLevel.js +15 -0
  23. package/dist/enums/ScreenOrientation.js +8 -0
  24. package/dist/enums/SessionType.js +8 -0
  25. package/dist/enums/StitchMode.js +11 -0
  26. package/dist/enums/TestResultsStatus.js +9 -0
  27. package/dist/errors/DiffsFoundError.js +38 -0
  28. package/dist/errors/EyesError.js +6 -0
  29. package/dist/errors/NewTestError.js +38 -0
  30. package/dist/errors/TestFailedError.js +47 -0
  31. package/dist/index.js +128 -0
  32. package/dist/input/AUTProxySettings.js +2 -0
  33. package/dist/input/AccessibilityMatchSettings.js +109 -0
  34. package/dist/input/AccessibilitySettings.js +2 -0
  35. package/dist/input/BatchInfo.js +153 -0
  36. package/dist/input/CheckSettings.js +702 -0
  37. package/dist/input/Configuration.js +1179 -0
  38. package/dist/input/CutProvider.js +132 -0
  39. package/dist/input/DebugScreenshotProvider.js +2 -0
  40. package/dist/input/DensityMetrics.js +2 -0
  41. package/dist/input/ExactMatchSettings.js +102 -0
  42. package/dist/input/EyesSelector.js +2 -0
  43. package/dist/input/FloatingMatchSettings.js +152 -0
  44. package/dist/input/Image.js +2 -0
  45. package/dist/input/ImageMatchSettings.js +271 -0
  46. package/dist/input/ImageRotation.js +59 -0
  47. package/dist/input/LatestCommitInfo.js +2 -0
  48. package/dist/input/LazyLoadOptions.js +2 -0
  49. package/dist/input/Location.js +74 -0
  50. package/dist/input/LogHandler.js +90 -0
  51. package/dist/input/OCRRegion.js +2 -0
  52. package/dist/input/OCRSettings.js +2 -0
  53. package/dist/input/PropertyData.js +76 -0
  54. package/dist/input/ProxySettings.js +77 -0
  55. package/dist/input/RectangleSize.js +74 -0
  56. package/dist/input/Region.js +135 -0
  57. package/dist/input/RenderInfo.js +2 -0
  58. package/dist/input/RunnerOptions.js +56 -0
  59. package/dist/input/VisualLocatorSettings.js +2 -0
  60. package/dist/output/ApiUrls.js +102 -0
  61. package/dist/output/AppUrls.js +66 -0
  62. package/dist/output/MatchResult.js +66 -0
  63. package/dist/output/SessionUrls.js +66 -0
  64. package/dist/output/StepInfo.js +118 -0
  65. package/dist/output/TestAccessibilityStatus.js +2 -0
  66. package/dist/output/TestResultContainer.js +49 -0
  67. package/dist/output/TestResults.js +378 -0
  68. package/dist/output/TestResultsSummary.js +49 -0
  69. package/dist/output/TextRegion.js +2 -0
  70. package/dist/output/ValidationInfo.js +60 -0
  71. package/dist/output/ValidationResult.js +53 -0
  72. package/package.json +4 -3
  73. package/types/BatchClose.d.ts +23 -0
  74. package/types/Eyes.d.ts +255 -0
  75. package/types/Logger.d.ts +30 -0
  76. package/types/Runners.d.ts +41 -0
  77. package/types/SDK.d.ts +20 -0
  78. package/types/SessionEventHandlers.d.ts +78 -0
  79. package/types/cli/cli.d.ts +2 -0
  80. package/types/cli/load-config.d.ts +1 -0
  81. package/types/enums/AccessibilityGuidelinesVersion.d.ts +5 -0
  82. package/types/enums/AccessibilityLevel.d.ts +5 -0
  83. package/types/enums/AccessibilityRegionType.d.ts +8 -0
  84. package/types/enums/AccessibilityStatus.d.ts +5 -0
  85. package/types/enums/BrowserType.d.ts +20 -0
  86. package/types/enums/CorsIframeHandle.d.ts +7 -0
  87. package/types/enums/DeviceName.d.ts +101 -0
  88. package/types/enums/DynamicTextType.d.ts +9 -0
  89. package/types/enums/FailureReport.d.ts +5 -0
  90. package/types/enums/IosDeviceName.d.ts +43 -0
  91. package/types/enums/IosMultiDeviceTarget.d.ts +26 -0
  92. package/types/enums/IosVersion.d.ts +7 -0
  93. package/types/enums/MatchLevel.d.ts +12 -0
  94. package/types/enums/ScreenOrientation.d.ts +5 -0
  95. package/types/enums/SessionType.d.ts +5 -0
  96. package/types/enums/StitchMode.d.ts +8 -0
  97. package/types/enums/TestResultsStatus.d.ts +6 -0
  98. package/types/errors/DiffsFoundError.d.ts +6 -0
  99. package/types/errors/EyesError.d.ts +2 -0
  100. package/types/errors/NewTestError.d.ts +6 -0
  101. package/types/errors/TestFailedError.d.ts +9 -0
  102. package/types/index.d.ts +60 -0
  103. package/types/input/AUTProxySettings.d.ts +5 -0
  104. package/types/input/AccessibilityMatchSettings.d.ts +34 -0
  105. package/types/input/AccessibilitySettings.d.ts +6 -0
  106. package/types/input/BatchInfo.d.ts +47 -0
  107. package/types/input/CheckSettings.d.ts +280 -0
  108. package/types/input/Configuration.d.ts +437 -0
  109. package/types/input/CutProvider.d.ts +44 -0
  110. package/types/input/DebugScreenshotProvider.d.ts +5 -0
  111. package/types/input/DensityMetrics.d.ts +5 -0
  112. package/types/input/ExactMatchSettings.d.ts +34 -0
  113. package/types/input/EyesSelector.d.ts +6 -0
  114. package/types/input/FloatingMatchSettings.d.ts +50 -0
  115. package/types/input/Image.d.ts +11 -0
  116. package/types/input/ImageMatchSettings.d.ts +95 -0
  117. package/types/input/ImageRotation.d.ts +15 -0
  118. package/types/input/LatestCommitInfo.d.ts +4 -0
  119. package/types/input/LazyLoadOptions.d.ts +5 -0
  120. package/types/input/Location.d.ts +23 -0
  121. package/types/input/LogHandler.d.ts +45 -0
  122. package/types/input/OCRRegion.d.ts +9 -0
  123. package/types/input/OCRSettings.d.ts +6 -0
  124. package/types/input/PropertyData.d.ts +23 -0
  125. package/types/input/ProxySettings.d.ts +25 -0
  126. package/types/input/RectangleSize.d.ts +23 -0
  127. package/types/input/Region.d.ts +46 -0
  128. package/types/input/RenderInfo.d.ts +47 -0
  129. package/types/input/RunnerOptions.d.ts +21 -0
  130. package/types/input/VisualLocatorSettings.d.ts +4 -0
  131. package/types/output/ApiUrls.d.ts +41 -0
  132. package/types/output/AppUrls.d.ts +23 -0
  133. package/types/output/MatchResult.d.ts +23 -0
  134. package/types/output/SessionUrls.d.ts +23 -0
  135. package/types/output/StepInfo.d.ts +50 -0
  136. package/types/output/TestAccessibilityStatus.d.ts +8 -0
  137. package/types/output/TestResultContainer.d.ts +31 -0
  138. package/types/output/TestResults.d.ts +186 -0
  139. package/types/output/TestResultsSummary.d.ts +18 -0
  140. package/types/output/TextRegion.d.ts +7 -0
  141. package/types/output/ValidationInfo.d.ts +21 -0
  142. package/types/output/ValidationResult.d.ts +18 -0
package/dist/Eyes.js ADDED
@@ -0,0 +1,750 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.Eyes = void 0;
27
+ const SDK_1 = require("./SDK");
28
+ const SessionType_1 = require("./enums/SessionType");
29
+ const EyesError_1 = require("./errors/EyesError");
30
+ const NewTestError_1 = require("./errors/NewTestError");
31
+ const DiffsFoundError_1 = require("./errors/DiffsFoundError");
32
+ const TestFailedError_1 = require("./errors/TestFailedError");
33
+ const CheckSettings_1 = require("./input/CheckSettings");
34
+ const Configuration_1 = require("./input/Configuration");
35
+ const RectangleSize_1 = require("./input/RectangleSize");
36
+ const Region_1 = require("./input/Region");
37
+ const LogHandler_1 = require("./input/LogHandler");
38
+ const MatchResult_1 = require("./output/MatchResult");
39
+ const TestResults_1 = require("./output/TestResults");
40
+ const SessionEventHandlers_1 = require("./SessionEventHandlers");
41
+ const Runners_1 = require("./Runners");
42
+ const Logger_1 = require("./Logger");
43
+ const utils = __importStar(require("@applitools/utils"));
44
+ class Eyes {
45
+ get _sdk() {
46
+ return this.constructor._sdk;
47
+ }
48
+ static async getExecutionCloudUrl(config) {
49
+ const { core } = (0, SDK_1.initSDK)(this._sdk, config === null || config === void 0 ? void 0 : config.maskLog);
50
+ const client = await core.getECClient({
51
+ settings: {
52
+ proxy: config === null || config === void 0 ? void 0 : config.proxy,
53
+ options: { eyesServerUrl: config === null || config === void 0 ? void 0 : config.serverUrl, apiKey: config === null || config === void 0 ? void 0 : config.apiKey },
54
+ },
55
+ });
56
+ client.unref();
57
+ return client.url;
58
+ }
59
+ static async setViewportSize(driver, size) {
60
+ var _a;
61
+ const { core } = (0, SDK_1.initSDK)(this._sdk, true);
62
+ await ((_a = core.setViewportSize) === null || _a === void 0 ? void 0 : _a.call(core, { target: driver, size: { width: size.width, height: size.height } }));
63
+ }
64
+ static setMobileCapabilities(capabilities, config) {
65
+ var _a, _b;
66
+ const envs = {
67
+ APPLITOOLS_SERVER_URL: (_a = config === null || config === void 0 ? void 0 : config.serverUrl) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('SERVER_URL'),
68
+ APPLITOOLS_API_KEY: (_b = config === null || config === void 0 ? void 0 : config.apiKey) !== null && _b !== void 0 ? _b : utils.general.getEnvValue('API_KEY'),
69
+ };
70
+ if (config === null || config === void 0 ? void 0 : config.proxy) {
71
+ const url = new URL(config.proxy.url);
72
+ if (config.proxy.username)
73
+ url.username = config.proxy.username;
74
+ if (config.proxy.password)
75
+ url.password = config.proxy.password;
76
+ envs.APPLITOOLS_PROXY_URL = url.toString();
77
+ }
78
+ const isW3C = Object.keys(capabilities).some(capability => capability.includes(':'));
79
+ const prefix = isW3C ? 'appium:' : '';
80
+ return Object.assign(capabilities, {
81
+ [`${prefix}optionalIntentArguments`]: `--es APPLITOOLS '${JSON.stringify(envs)}'`,
82
+ [`${prefix}processArguments`]: JSON.stringify({
83
+ args: [],
84
+ env: {
85
+ DYLD_INSERT_LIBRARIES: '@executable_path/Frameworks/Applitools_iOS.xcframework/ios-arm64/Applitools_iOS.framework/Applitools_iOS:@executable_path/Frameworks/Applitools_iOS.xcframework/ios-arm64_x86_64-simulator/Applitools_iOS.framework/Applitools_iOS',
86
+ ...envs,
87
+ },
88
+ }),
89
+ });
90
+ }
91
+ constructor(runnerOrConfig, config) {
92
+ this._state = {};
93
+ this._events = new Map();
94
+ this._handlers = new SessionEventHandlers_1.SessionEventHandlers();
95
+ const maskLog = utils.types.instanceOf(runnerOrConfig, Runners_1.EyesRunner) ? runnerOrConfig._maskLog : undefined;
96
+ const sdk = (0, SDK_1.initSDK)(this._sdk, maskLog);
97
+ this._spec = sdk.spec;
98
+ this._core = sdk.core;
99
+ if (utils.types.instanceOf(runnerOrConfig, Runners_1.EyesRunner)) {
100
+ this._runner = runnerOrConfig;
101
+ this._config = new Configuration_1.ConfigurationData(config, this._spec);
102
+ }
103
+ else {
104
+ this._runner = new Runners_1.ClassicRunner();
105
+ this._config = new Configuration_1.ConfigurationData(runnerOrConfig !== null && runnerOrConfig !== void 0 ? runnerOrConfig : config, this._spec);
106
+ }
107
+ this._runner.attach(this._core);
108
+ this._handlers.attach(this);
109
+ this._logger = new Logger_1.Logger({ label: 'Eyes API' });
110
+ }
111
+ get logger() {
112
+ return this._logger;
113
+ }
114
+ getLogger() {
115
+ return this._logger;
116
+ }
117
+ get runner() {
118
+ return this._runner;
119
+ }
120
+ getRunner() {
121
+ return this.runner;
122
+ }
123
+ get driver() {
124
+ return this._driver;
125
+ }
126
+ getDriver() {
127
+ return this.driver;
128
+ }
129
+ get configuration() {
130
+ return this._config;
131
+ }
132
+ set configuration(config) {
133
+ this._config = new Configuration_1.ConfigurationData(config, this._spec);
134
+ }
135
+ getConfiguration() {
136
+ return this._config;
137
+ }
138
+ setConfiguration(config) {
139
+ this._config = new Configuration_1.ConfigurationData(config, this._spec);
140
+ }
141
+ get isOpen() {
142
+ var _a;
143
+ return Boolean((_a = this._eyes) === null || _a === void 0 ? void 0 : _a.running);
144
+ }
145
+ getIsOpen() {
146
+ return this.isOpen;
147
+ }
148
+ on(event, handler) {
149
+ if (utils.types.isFunction(event))
150
+ [handler, event] = [event, '*'];
151
+ let handlers = this._events.get(event);
152
+ if (!handlers) {
153
+ handlers = new Set();
154
+ this._events.set(event, handlers);
155
+ }
156
+ handlers.add(handler);
157
+ return () => handlers.delete(handler);
158
+ }
159
+ off(eventOrHandler) {
160
+ if (utils.types.isString(eventOrHandler)) {
161
+ this._events.delete(eventOrHandler);
162
+ }
163
+ else {
164
+ this._events.forEach(handlers => handlers.delete(eventOrHandler));
165
+ }
166
+ }
167
+ async getExecutionCloudUrl() {
168
+ return this.constructor.getExecutionCloudUrl(this._config);
169
+ }
170
+ setMobileCapabilities(capabilities) {
171
+ return this.constructor.setMobileCapabilities(capabilities, this._config);
172
+ }
173
+ async open(driverOrConfigOrAppName, configOrAppNameOrTestName, testNameOrViewportSize, viewportSizeOrSessionType, sessionType) {
174
+ var _a, _b, _c, _d, _e, _f;
175
+ var _g;
176
+ if (((_b = (_a = this._spec) === null || _a === void 0 ? void 0 : _a.isDriver) === null || _b === void 0 ? void 0 : _b.call(_a, driverOrConfigOrAppName)) || ((_d = (_c = this._spec) === null || _c === void 0 ? void 0 : _c.isSecondaryDriver) === null || _d === void 0 ? void 0 : _d.call(_c, driverOrConfigOrAppName))) {
177
+ this._driver = driverOrConfigOrAppName;
178
+ }
179
+ else {
180
+ sessionType = viewportSizeOrSessionType;
181
+ viewportSizeOrSessionType = testNameOrViewportSize;
182
+ testNameOrViewportSize = configOrAppNameOrTestName;
183
+ configOrAppNameOrTestName = driverOrConfigOrAppName;
184
+ }
185
+ if (this._config.isDisabled)
186
+ return this._driver;
187
+ const config = this._config.toJSON();
188
+ if (utils.types.instanceOf(configOrAppNameOrTestName, Configuration_1.ConfigurationData)) {
189
+ const transformedConfig = configOrAppNameOrTestName.toJSON();
190
+ config.open = { ...config.open, ...transformedConfig.open };
191
+ config.screenshot = { ...config.screenshot, ...transformedConfig.screenshot };
192
+ config.check = { ...config.check, ...transformedConfig.check };
193
+ config.close = { ...config.close, ...transformedConfig.close };
194
+ }
195
+ else if (utils.types.isObject(configOrAppNameOrTestName)) {
196
+ const transformedConfig = new Configuration_1.ConfigurationData(configOrAppNameOrTestName, this._spec).toJSON();
197
+ config.open = { ...config.open, ...transformedConfig.open };
198
+ config.screenshot = { ...config.screenshot, ...transformedConfig.screenshot };
199
+ config.check = { ...config.check, ...transformedConfig.check };
200
+ config.close = { ...config.close, ...transformedConfig.close };
201
+ }
202
+ else if (utils.types.isString(configOrAppNameOrTestName)) {
203
+ config.open.appName = configOrAppNameOrTestName;
204
+ }
205
+ if (utils.types.isString(testNameOrViewportSize))
206
+ config.open.testName = testNameOrViewportSize;
207
+ if (utils.types.has(viewportSizeOrSessionType, ['width', 'height'])) {
208
+ (_e = (_g = config.open).environment) !== null && _e !== void 0 ? _e : (_g.environment = {});
209
+ config.open.environment.viewportSize = {
210
+ width: viewportSizeOrSessionType.width,
211
+ height: viewportSizeOrSessionType.height,
212
+ };
213
+ }
214
+ if (utils.types.isEnumValue(sessionType, SessionType_1.SessionTypeEnum))
215
+ config.open.sessionType = sessionType;
216
+ this._state.appName = (_f = config.open) === null || _f === void 0 ? void 0 : _f.appName;
217
+ config.open.keepPlatformNameAsIs = true;
218
+ this._eyes = await this._runner.openEyes({
219
+ target: this._driver,
220
+ config,
221
+ logger: this._logger.getLogger(),
222
+ on: (name, data) => {
223
+ const globalHandlers = this._events.get('*');
224
+ if (globalHandlers)
225
+ globalHandlers.forEach(async (handler) => handler(name, data));
226
+ const namedHandlers = this._events.get(name);
227
+ if (namedHandlers)
228
+ namedHandlers.forEach(async (handler) => handler(data));
229
+ },
230
+ });
231
+ return (this._driver &&
232
+ new Proxy(this._driver, {
233
+ get(target, key) {
234
+ if (key === 'then')
235
+ return;
236
+ return Reflect.get(target, key);
237
+ },
238
+ }));
239
+ }
240
+ async check(checkSettingsOrTargetOrName, checkSettings) {
241
+ var _a, _b;
242
+ var _c;
243
+ if (this._config.isDisabled)
244
+ return null;
245
+ if (!this.isOpen)
246
+ throw new EyesError_1.EyesError('Eyes not open');
247
+ let serialized;
248
+ if (utils.types.isString(checkSettingsOrTargetOrName)) {
249
+ serialized = this._driver
250
+ ? new CheckSettings_1.CheckSettingsAutomationFluent(checkSettings, this._spec)
251
+ .name(checkSettingsOrTargetOrName)
252
+ .toJSON()
253
+ : new CheckSettings_1.CheckSettingsImageFluent(checkSettings)
254
+ .name(checkSettingsOrTargetOrName)
255
+ .toJSON();
256
+ }
257
+ else if (utils.types.has(checkSettingsOrTargetOrName, 'image')) {
258
+ serialized = new CheckSettings_1.CheckSettingsImageFluent(checkSettings, checkSettingsOrTargetOrName).toJSON();
259
+ }
260
+ else {
261
+ serialized = new CheckSettings_1.CheckSettingsAutomationFluent(checkSettingsOrTargetOrName, this._spec).toJSON();
262
+ }
263
+ const { target, settings } = serialized;
264
+ const config = this._config.toJSON();
265
+ // TODO remove when major version of sdk should be released
266
+ (_a = (_c = config.screenshot).fully) !== null && _a !== void 0 ? _a : (_c.fully = false);
267
+ let type;
268
+ if (this._runner.type === 'ufg' &&
269
+ ((_b = settings === null || settings === void 0 ? void 0 : settings.nmgOptions) === null || _b === void 0 ? void 0 : _b.nonNMGCheck) === 'addToAllDevices') {
270
+ type = 'classic';
271
+ settings.screenshotMode = 'default';
272
+ }
273
+ await this._eyes.check({ type, target, settings, config });
274
+ return new MatchResult_1.MatchResultData({});
275
+ }
276
+ /** @deprecated */
277
+ async checkWindow(name, timeout, fully = false) {
278
+ return this.check({ name, timeout, fully });
279
+ }
280
+ /** @deprecated */
281
+ async checkFrame(element, timeout, name) {
282
+ return this.check({ name, frames: [element], timeout, fully: true });
283
+ }
284
+ /** @deprecated */
285
+ async checkElement(element, timeout, name) {
286
+ return this.check({ name, region: element, timeout, fully: true });
287
+ }
288
+ /** @deprecated */
289
+ async checkElementBy(selector, timeout, name) {
290
+ return this.check({ name, region: selector, timeout, fully: true });
291
+ }
292
+ async checkRegion(imageOrRegion, regionOrName, nameOrTimeout, ignoreMismatch = false) {
293
+ return utils.types.has(imageOrRegion, ['x', 'y', 'width', 'height'])
294
+ ? this.check({ region: imageOrRegion, name: regionOrName, timeout: nameOrTimeout })
295
+ : this.check({ image: imageOrRegion }, { region: regionOrName, name: nameOrTimeout, ignoreMismatch });
296
+ }
297
+ /** @deprecated */
298
+ async checkRegionByElement(element, name, timeout) {
299
+ return this.check({ name, region: element, timeout });
300
+ }
301
+ /** @deprecated */
302
+ async checkRegionBy(selector, name, timeout, fully = false) {
303
+ return this.check({ name, region: selector, timeout, fully });
304
+ }
305
+ /** @deprecated */
306
+ async checkRegionInFrame(frame, selector, timeout, name, fully = false) {
307
+ return this.check({ name, region: selector, frames: [frame], timeout, fully });
308
+ }
309
+ /** @deprecated */
310
+ async checkImage(image, name, ignoreMismatch = false) {
311
+ return this.check({ image }, { name, ignoreMismatch });
312
+ }
313
+ async locate(targetOrSettings, settings) {
314
+ if (this._config.isDisabled)
315
+ return null;
316
+ if (!this.isOpen)
317
+ throw new EyesError_1.EyesError('Eyes not open');
318
+ let target;
319
+ if (utils.types.has(targetOrSettings, 'locatorNames')) {
320
+ settings = targetOrSettings;
321
+ if (utils.types.has(targetOrSettings, 'image')) {
322
+ target = { image: targetOrSettings.image };
323
+ }
324
+ else {
325
+ target = this._driver;
326
+ }
327
+ }
328
+ else {
329
+ target = targetOrSettings;
330
+ }
331
+ const config = this._config.toJSON();
332
+ const results = await this._core.locate({ target, settings: { ...this._state, ...settings }, config });
333
+ return Object.entries(results).reduce((results, [key, regions]) => {
334
+ results[key] = regions.map(region => new Region_1.RegionData(region));
335
+ return results;
336
+ }, {});
337
+ }
338
+ async extractTextRegions(targetOrSettings, settings) {
339
+ if (this._config.isDisabled)
340
+ return null;
341
+ if (!this.isOpen)
342
+ throw new EyesError_1.EyesError('Eyes not open');
343
+ let target;
344
+ if (utils.types.has(targetOrSettings, 'patterns')) {
345
+ settings = targetOrSettings;
346
+ if (utils.types.has(targetOrSettings, 'image')) {
347
+ target = { image: targetOrSettings.image };
348
+ }
349
+ else {
350
+ target = this._driver;
351
+ }
352
+ }
353
+ else {
354
+ target = targetOrSettings;
355
+ }
356
+ const config = this._config.toJSON();
357
+ return this._core.locateText({ target, settings: settings, config });
358
+ }
359
+ async extractText(targetOrSettings, settings) {
360
+ if (this._config.isDisabled)
361
+ return null;
362
+ if (!this.isOpen)
363
+ throw new EyesError_1.EyesError('Eyes not open');
364
+ let targets;
365
+ if (utils.types.isArray(targetOrSettings)) {
366
+ settings = targetOrSettings;
367
+ targets = targetOrSettings.map(settings => {
368
+ return utils.types.has(settings, 'image') ? { image: settings.image } : this._driver;
369
+ });
370
+ }
371
+ else {
372
+ targets = Array(settings.length).fill(targetOrSettings);
373
+ }
374
+ settings = settings.map(settings => ({
375
+ ...settings,
376
+ region: utils.types.isPlainObject(settings.target) && utils.types.has(settings.target, ['left', 'top'])
377
+ ? { ...settings.target, x: settings.target.left, y: settings.target.top }
378
+ : settings.target,
379
+ }));
380
+ const config = this._config.toJSON();
381
+ return await settings.reduce((results, settings, index) => {
382
+ return results.then(async (results) => {
383
+ return results.concat(await this._core.extractText({ target: targets[index], settings: settings, config }));
384
+ });
385
+ }, Promise.resolve([]));
386
+ }
387
+ async close(throwErr = true) {
388
+ if (this._config.isDisabled)
389
+ return null;
390
+ if (!this.isOpen)
391
+ throw new EyesError_1.EyesError('Eyes not open');
392
+ await this.closeAsync();
393
+ const [result] = await this.getResults(throwErr);
394
+ return result;
395
+ }
396
+ async closeAsync() {
397
+ var _a;
398
+ if (this._config.isDisabled)
399
+ return null;
400
+ const config = this._config.toJSON();
401
+ await ((_a = this._eyes) === null || _a === void 0 ? void 0 : _a.close({ config }));
402
+ }
403
+ async abort() {
404
+ if (!this.isOpen || this._config.isDisabled)
405
+ return null;
406
+ await this._eyes.abort();
407
+ const [result] = await this._eyes.getResults();
408
+ return new TestResults_1.TestResultsData({ result, core: this._core });
409
+ }
410
+ async abortAsync() {
411
+ var _a;
412
+ if (!this.isOpen || this._config.isDisabled)
413
+ return null;
414
+ await ((_a = this._eyes) === null || _a === void 0 ? void 0 : _a.abort());
415
+ }
416
+ /** @deprecated */
417
+ async abortIfNotClosed() {
418
+ return this.abort();
419
+ }
420
+ async getResults(throwErr = true) {
421
+ var _a;
422
+ if (this._config.isDisabled)
423
+ return null;
424
+ try {
425
+ const results = await this._eyes.getResults({ settings: { throwErr } });
426
+ return results.map(result => new TestResults_1.TestResultsData({ result, core: this._core }));
427
+ }
428
+ catch (error) {
429
+ if ((_a = error.info) === null || _a === void 0 ? void 0 : _a.result) {
430
+ const result = new TestResults_1.TestResultsData({ result: error.info.result, core: this._core });
431
+ if (error.reason === 'test failed') {
432
+ throw new TestFailedError_1.TestFailedError(error.message, result);
433
+ }
434
+ else if (error.reason === 'test different') {
435
+ throw new DiffsFoundError_1.DiffsFoundError(error.message, result);
436
+ }
437
+ else if (error.reason === 'test new') {
438
+ throw new NewTestError_1.NewTestError(error.message, result);
439
+ }
440
+ }
441
+ throw error;
442
+ }
443
+ }
444
+ // #region CONFIG
445
+ async getViewportSize() {
446
+ var _a;
447
+ return ((_a = this._config.getViewportSize()) !== null && _a !== void 0 ? _a : (this._core.getViewportSize
448
+ ? new RectangleSize_1.RectangleSizeData(await this._core.getViewportSize({ target: this._driver }))
449
+ : undefined));
450
+ }
451
+ async setViewportSize(size) {
452
+ var _a, _b;
453
+ utils.guard.notNull(size, { name: 'size' });
454
+ size = { width: size.width, height: size.height }; // ensure no extra props, and convert getters to enumerable props
455
+ if (!this._driver) {
456
+ this._config.setViewportSize(size);
457
+ }
458
+ else {
459
+ try {
460
+ await ((_b = (_a = this._core).setViewportSize) === null || _b === void 0 ? void 0 : _b.call(_a, { target: this._driver, size }));
461
+ this._config.setViewportSize(size);
462
+ }
463
+ catch (err) {
464
+ if (this._core.getViewportSize)
465
+ this._config.setViewportSize(await this._core.getViewportSize({ target: this._driver }));
466
+ throw new EyesError_1.EyesError('Failed to set the viewport size');
467
+ }
468
+ }
469
+ }
470
+ getScrollRootElement() {
471
+ return this._config.getScrollRootElement();
472
+ }
473
+ setScrollRootElement(scrollRootElement) {
474
+ this._config.setScrollRootElement(scrollRootElement);
475
+ }
476
+ setLogHandler(handler) {
477
+ this._logger.setLogHandler(handler);
478
+ }
479
+ getLogHandler() {
480
+ const handler = this._logger.getLogHandler();
481
+ if (handler) {
482
+ if (!utils.types.has(handler, 'type')) {
483
+ return handler;
484
+ }
485
+ else if (handler.type === 'file') {
486
+ return new LogHandler_1.FileLogHandlerData(true, handler.filename, handler.append);
487
+ }
488
+ else if (handler.type === 'console') {
489
+ return new LogHandler_1.ConsoleLogHandlerData(true);
490
+ }
491
+ }
492
+ return new LogHandler_1.NullLogHandlerData();
493
+ }
494
+ setCutProvider(cutProvider) {
495
+ this._config.setCut(cutProvider);
496
+ }
497
+ setImageCut(cutProvider) {
498
+ this.setCutProvider(cutProvider);
499
+ }
500
+ getIsCutProviderExplicitlySet() {
501
+ return Boolean(this._config.getCut());
502
+ }
503
+ getRotation() {
504
+ return this._config.getRotation();
505
+ }
506
+ setRotation(rotation) {
507
+ this._config.setRotation(rotation);
508
+ }
509
+ getScaleRatio() {
510
+ return this._config.getScaleRatio();
511
+ }
512
+ setScaleRatio(scaleRatio) {
513
+ this._config.setScaleRatio(scaleRatio);
514
+ }
515
+ getSaveDebugScreenshots() {
516
+ return this._config.getSaveDebugScreenshots();
517
+ }
518
+ setSaveDebugScreenshots(save) {
519
+ this._config.setSaveDebugScreenshots(save);
520
+ }
521
+ getDebugScreenshotsPath() {
522
+ return this._config.getDebugScreenshotsPath();
523
+ }
524
+ setDebugScreenshotsPath(path) {
525
+ this._config.setDebugScreenshotsPath(path);
526
+ }
527
+ getDebugScreenshotsPrefix() {
528
+ return this._config.getDebugScreenshotsPrefix();
529
+ }
530
+ setDebugScreenshotsPrefix(prefix) {
531
+ this._config.setDebugScreenshotsPrefix(prefix);
532
+ }
533
+ addProperty(name, value) {
534
+ return this._config.addProperty(name, value);
535
+ }
536
+ clearProperties() {
537
+ return this._config.setProperties([]);
538
+ }
539
+ getBatch() {
540
+ return this._config.getBatch();
541
+ }
542
+ setBatch(batchOrName, id, startedAt) {
543
+ if (utils.types.isString(batchOrName)) {
544
+ this._config.setBatch({ name: batchOrName, id, startedAt: new Date(startedAt) });
545
+ }
546
+ else {
547
+ this._config.setBatch(batchOrName);
548
+ }
549
+ }
550
+ getApiKey() {
551
+ return this._config.getApiKey();
552
+ }
553
+ setApiKey(apiKey) {
554
+ this._config.setApiKey(apiKey);
555
+ }
556
+ getTestName() {
557
+ return this._config.getTestName();
558
+ }
559
+ setTestName(testName) {
560
+ this._config.setTestName(testName);
561
+ }
562
+ getAppName() {
563
+ return this._config.getAppName();
564
+ }
565
+ setAppName(appName) {
566
+ this._config.setAppName(appName);
567
+ }
568
+ getBaselineBranchName() {
569
+ return this._config.getBaselineBranchName();
570
+ }
571
+ setBaselineBranchName(baselineBranchName) {
572
+ this._config.setBaselineBranchName(baselineBranchName);
573
+ }
574
+ /** @deprecated */
575
+ getBaselineName() {
576
+ return this.getBaselineEnvName();
577
+ }
578
+ /** @deprecated */
579
+ setBaselineName(baselineName) {
580
+ this.setBaselineEnvName(baselineName);
581
+ }
582
+ getBaselineEnvName() {
583
+ return this._config.getBaselineEnvName();
584
+ }
585
+ setBaselineEnvName(baselineEnvName) {
586
+ this._config.setBaselineEnvName(baselineEnvName);
587
+ }
588
+ getBranchName() {
589
+ return this._config.getBranchName();
590
+ }
591
+ setBranchName(branchName) {
592
+ this._config.setBranchName(branchName);
593
+ }
594
+ getHostApp() {
595
+ return this._config.getHostApp();
596
+ }
597
+ setHostApp(hostApp) {
598
+ this._config.setHostApp(hostApp);
599
+ }
600
+ getHostOS() {
601
+ return this._config.getHostOS();
602
+ }
603
+ setHostOS(hostOS) {
604
+ this._config.setHostOS(hostOS);
605
+ }
606
+ getHostAppInfo() {
607
+ return this._config.getHostAppInfo();
608
+ }
609
+ setHostAppInfo(hostAppInfo) {
610
+ this._config.setHostAppInfo(hostAppInfo);
611
+ }
612
+ getHostOSInfo() {
613
+ return this._config.getHostOSInfo();
614
+ }
615
+ setHostOSInfo(hostOSInfo) {
616
+ this._config.setHostOSInfo(hostOSInfo);
617
+ }
618
+ getDeviceInfo() {
619
+ return this._config.getDeviceInfo();
620
+ }
621
+ setDeviceInfo(deviceInfo) {
622
+ this._config.setDeviceInfo(deviceInfo);
623
+ }
624
+ setIgnoreCaret(ignoreCaret) {
625
+ this._config.setIgnoreCaret(ignoreCaret);
626
+ }
627
+ getIgnoreCaret() {
628
+ return this._config.getIgnoreCaret();
629
+ }
630
+ getIsDisabled() {
631
+ return this._config.getIsDisabled();
632
+ }
633
+ setIsDisabled(isDisabled) {
634
+ this._config.setIsDisabled(isDisabled);
635
+ }
636
+ getMatchLevel() {
637
+ return this._config.getMatchLevel();
638
+ }
639
+ setMatchLevel(matchLevel) {
640
+ this._config.setMatchLevel(matchLevel);
641
+ }
642
+ getMatchTimeout() {
643
+ return this._config.getMatchTimeout();
644
+ }
645
+ setMatchTimeout(matchTimeout) {
646
+ this._config.setMatchTimeout(matchTimeout);
647
+ }
648
+ getParentBranchName() {
649
+ return this._config.getParentBranchName();
650
+ }
651
+ setParentBranchName(parentBranchName) {
652
+ this._config.setParentBranchName(parentBranchName);
653
+ }
654
+ setProxy(proxyOrUrlOrIsDisabled, username, password, isHttpOnly) {
655
+ this._config.setProxy(proxyOrUrlOrIsDisabled, username, password, isHttpOnly);
656
+ return this;
657
+ }
658
+ getProxy() {
659
+ return this._config.getProxy();
660
+ }
661
+ getSaveDiffs() {
662
+ return this._config.saveDiffs;
663
+ }
664
+ setSaveDiffs(saveDiffs) {
665
+ this._config.saveDiffs = saveDiffs;
666
+ }
667
+ getSaveNewTests() {
668
+ return this._config.saveNewTests;
669
+ }
670
+ setSaveNewTests(saveNewTests) {
671
+ this._config.saveNewTests = saveNewTests;
672
+ }
673
+ getServerUrl() {
674
+ return this._config.getServerUrl();
675
+ }
676
+ setServerUrl(serverUrl) {
677
+ this._config.setServerUrl(serverUrl);
678
+ }
679
+ getSendDom() {
680
+ return this._config.getSendDom();
681
+ }
682
+ setSendDom(sendDom) {
683
+ this._config.setSendDom(sendDom);
684
+ }
685
+ getHideCaret() {
686
+ return this._config.getHideCaret();
687
+ }
688
+ setHideCaret(hideCaret) {
689
+ this._config.setHideCaret(hideCaret);
690
+ }
691
+ getHideScrollbars() {
692
+ return this._config.getHideScrollbars();
693
+ }
694
+ setHideScrollbars(hideScrollbars) {
695
+ this._config.setHideScrollbars(hideScrollbars);
696
+ }
697
+ getForceFullPageScreenshot() {
698
+ return this._config.getForceFullPageScreenshot();
699
+ }
700
+ setForceFullPageScreenshot(forceFullPageScreenshot) {
701
+ this._config.setForceFullPageScreenshot(forceFullPageScreenshot);
702
+ }
703
+ getWaitBeforeScreenshots() {
704
+ return this._config.getWaitBeforeScreenshots();
705
+ }
706
+ setWaitBeforeScreenshots(waitBeforeScreenshots) {
707
+ this._config.setWaitBeforeScreenshots(waitBeforeScreenshots);
708
+ }
709
+ getStitchMode() {
710
+ return this._config.getStitchMode();
711
+ }
712
+ setStitchMode(stitchMode) {
713
+ this._config.setStitchMode(stitchMode);
714
+ }
715
+ getStitchOverlap() {
716
+ return this._config.getStitchOverlap();
717
+ }
718
+ setStitchOverlap(stitchOverlap) {
719
+ this._config.setStitchOverlap(stitchOverlap);
720
+ }
721
+ /**
722
+ * @undocumented
723
+ * @deprecated
724
+ */
725
+ getSessionEventHandlers() {
726
+ return this._handlers;
727
+ }
728
+ /**
729
+ * @undocumented
730
+ * @deprecated
731
+ */
732
+ addSessionEventHandler(handler) {
733
+ this._handlers.addEventHandler(handler);
734
+ }
735
+ /**
736
+ * @undocumented
737
+ * @deprecated
738
+ */
739
+ removeSessionEventHandler(handler) {
740
+ this._handlers.removeEventHandler(handler);
741
+ }
742
+ /**
743
+ * @undocumented
744
+ * @deprecated
745
+ */
746
+ clearSessionEventHandlers() {
747
+ return this._handlers.clearEventHandlers();
748
+ }
749
+ }
750
+ exports.Eyes = Eyes;