@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
@@ -0,0 +1,702 @@
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.Target = exports.TargetAutomation = exports.TargetImage = exports.CheckSettingsAutomationFluent = exports.CheckSettingsImageFluent = exports.CheckSettingsBaseFluent = void 0;
27
+ const AccessibilityRegionType_1 = require("../enums/AccessibilityRegionType");
28
+ const MatchLevel_1 = require("../enums/MatchLevel");
29
+ const utils = __importStar(require("@applitools/utils"));
30
+ class CheckSettingsBaseFluent {
31
+ constructor(settings, parent) {
32
+ var _a;
33
+ this._settings = {};
34
+ this.childs = [];
35
+ this._settings = utils.types.instanceOf(settings, CheckSettingsBaseFluent) ? settings.toObject() : settings !== null && settings !== void 0 ? settings : {};
36
+ this.parent = (parent !== null && parent !== void 0 ? parent : settings === null || settings === void 0 ? void 0 : settings.parent);
37
+ if (parent) {
38
+ (_a = parent.childs) !== null && _a !== void 0 ? _a : (parent.childs = []);
39
+ parent.childs.push(this);
40
+ }
41
+ else {
42
+ this._settings = utils.types.instanceOf(settings, CheckSettingsBaseFluent) ? settings.toObject() : settings !== null && settings !== void 0 ? settings : {};
43
+ }
44
+ }
45
+ region(region) {
46
+ this._settings.region = region;
47
+ return this;
48
+ }
49
+ name(name) {
50
+ this._settings.name = name;
51
+ return this;
52
+ }
53
+ withName(name) {
54
+ return this.name(name);
55
+ }
56
+ ignoreRegion(region) {
57
+ if (region) {
58
+ if (!this._settings.ignoreRegions)
59
+ this._settings.ignoreRegions = [];
60
+ this._settings.ignoreRegions.push(region);
61
+ }
62
+ return this;
63
+ }
64
+ ignoreRegions(...regions) {
65
+ regions.forEach(region => this.ignoreRegion(region));
66
+ return this;
67
+ }
68
+ /** @deprecated */
69
+ ignore(region) {
70
+ return this.ignoreRegion(region);
71
+ }
72
+ /** @deprecated */
73
+ ignores(...regions) {
74
+ return this.ignoreRegions(...regions);
75
+ }
76
+ layoutRegion(region) {
77
+ if (region) {
78
+ if (!this._settings.layoutRegions)
79
+ this._settings.layoutRegions = [];
80
+ this._settings.layoutRegions.push(region);
81
+ }
82
+ return this;
83
+ }
84
+ layoutRegions(...regions) {
85
+ regions.forEach(region => this.layoutRegion(region));
86
+ return this;
87
+ }
88
+ strictRegion(region) {
89
+ if (region) {
90
+ if (!this._settings.strictRegions)
91
+ this._settings.strictRegions = [];
92
+ this._settings.strictRegions.push(region);
93
+ }
94
+ return this;
95
+ }
96
+ strictRegions(...regions) {
97
+ regions.forEach(region => this.strictRegion(region));
98
+ return this;
99
+ }
100
+ contentRegion(region) {
101
+ if (region) {
102
+ if (!this._settings.contentRegions)
103
+ this._settings.contentRegions = [];
104
+ this._settings.contentRegions.push(region);
105
+ }
106
+ return this;
107
+ }
108
+ contentRegions(...regions) {
109
+ regions.forEach(region => this.contentRegion(region));
110
+ return this;
111
+ }
112
+ floatingRegion(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset) {
113
+ if (region) {
114
+ let floatingRegion;
115
+ if (utils.types.has(region, 'region')) {
116
+ const { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, ...rest } = region;
117
+ floatingRegion = {
118
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
119
+ ...rest,
120
+ };
121
+ }
122
+ else {
123
+ floatingRegion = {
124
+ region,
125
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
126
+ };
127
+ }
128
+ if (!this._settings.floatingRegions)
129
+ this._settings.floatingRegions = [];
130
+ this._settings.floatingRegions.push(floatingRegion);
131
+ }
132
+ return this;
133
+ }
134
+ floatingRegions(regionOrMaxOffset, ...regions) {
135
+ let maxOffset;
136
+ if (utils.types.isNumber(regionOrMaxOffset)) {
137
+ maxOffset = regionOrMaxOffset;
138
+ }
139
+ else {
140
+ this.floatingRegion(regionOrMaxOffset);
141
+ }
142
+ regions.forEach(region => {
143
+ if (utils.types.has(region, 'region'))
144
+ this.floatingRegion(region);
145
+ else
146
+ this.floatingRegion(region, maxOffset, maxOffset, maxOffset, maxOffset);
147
+ });
148
+ return this;
149
+ }
150
+ floating(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset) {
151
+ if (utils.types.has(region, 'region'))
152
+ return this.floatingRegion(region);
153
+ else
154
+ return this.floatingRegion(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset);
155
+ }
156
+ floatings(regionOrMaxOffset, ...regions) {
157
+ return this.floatingRegions(regionOrMaxOffset, ...regions);
158
+ }
159
+ accessibilityRegion(region, type) {
160
+ if (region) {
161
+ const accessibilityRegion = utils.types.has(region, 'region') ? region : { region, type };
162
+ if (!this._settings.accessibilityRegions)
163
+ this._settings.accessibilityRegions = [];
164
+ this._settings.accessibilityRegions.push(accessibilityRegion);
165
+ }
166
+ return this;
167
+ }
168
+ accessibilityRegions(regionOrType, ...regions) {
169
+ let type;
170
+ if (utils.types.isEnumValue(regionOrType, AccessibilityRegionType_1.AccessibilityRegionTypeEnum)) {
171
+ type = regionOrType;
172
+ }
173
+ else {
174
+ this.accessibilityRegion(regionOrType);
175
+ }
176
+ regions.forEach(region => {
177
+ if (utils.types.has(region, 'region'))
178
+ this.accessibilityRegion(region);
179
+ else
180
+ this.accessibilityRegion(region, type);
181
+ });
182
+ return this;
183
+ }
184
+ dynamicRegion(region, type) {
185
+ if (region) {
186
+ const dynamicRegion = utils.types.has(region, 'region') ? region : { region, type };
187
+ if (!this._settings.dynamicRegions)
188
+ this._settings.dynamicRegions = [];
189
+ this._settings.dynamicRegions.push(dynamicRegion);
190
+ }
191
+ return this;
192
+ }
193
+ dynamicRegions(regionOrTypes, ...regions) {
194
+ let types;
195
+ if (utils.types.isArray(regionOrTypes) || utils.types.isString(regionOrTypes)) {
196
+ types = regionOrTypes;
197
+ }
198
+ else {
199
+ this.dynamicRegions(regionOrTypes);
200
+ }
201
+ regions.forEach(region => {
202
+ if (utils.types.has(region, 'region'))
203
+ this.dynamicRegion(region);
204
+ else
205
+ this.dynamicRegion(region, types);
206
+ });
207
+ return this;
208
+ }
209
+ matchLevel(matchLevel) {
210
+ this._settings.matchLevel = matchLevel;
211
+ return this;
212
+ }
213
+ layout() {
214
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Layout;
215
+ return this;
216
+ }
217
+ exact() {
218
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Exact;
219
+ return this;
220
+ }
221
+ strict() {
222
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Strict;
223
+ return this;
224
+ }
225
+ ignoreColors() {
226
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.IgnoreColors;
227
+ return this;
228
+ }
229
+ dynamic() {
230
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Dynamic;
231
+ return this;
232
+ }
233
+ /** @deprecated */
234
+ content() {
235
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Content;
236
+ return this;
237
+ }
238
+ enablePatterns(enablePatterns = true) {
239
+ this._settings.enablePatterns = enablePatterns;
240
+ return this;
241
+ }
242
+ ignoreDisplacements(ignoreDisplacements = true) {
243
+ this._settings.ignoreDisplacements = ignoreDisplacements;
244
+ return this;
245
+ }
246
+ ignoreCaret(ignoreCaret = true) {
247
+ this._settings.ignoreCaret = ignoreCaret;
248
+ return this;
249
+ }
250
+ useDom(useDom = true) {
251
+ this._settings.useDom = useDom;
252
+ return this;
253
+ }
254
+ sendDom(sendDom = true) {
255
+ this._settings.sendDom = sendDom;
256
+ return this;
257
+ }
258
+ pageId(pageId) {
259
+ this._settings.pageId = pageId;
260
+ return this;
261
+ }
262
+ variationGroupId(variationGroupId) {
263
+ this._settings.variationGroupId = variationGroupId;
264
+ return this;
265
+ }
266
+ /** @internal */
267
+ toObject() {
268
+ return this._settings;
269
+ }
270
+ /** @internal */
271
+ toString() {
272
+ return utils.general.toString(this);
273
+ }
274
+ /** @internal */
275
+ assumesMutability() {
276
+ // if this is a leaf of a linked list (i.e., has no children and all ancestors have exactly one child), them making the CheckSettings mutable is safe
277
+ if (this.childs.length)
278
+ return true;
279
+ for (let parent = this.parent; parent; parent = parent.parent) {
280
+ if (parent.childs.length !== 1)
281
+ return true;
282
+ }
283
+ return undefined;
284
+ }
285
+ static makeMutableTreeProxy(self, ctor) {
286
+ const shouldNotBeProxied = ['assumesMutability', 'childs', 'parent']; // these properties should not be proxied as they are used to determine if the tree is mutable
287
+ const shouldNotCreateChild = ['toObject', 'toJSON', 'toString']; // these properties should not create a child
288
+ return new Proxy(self, {
289
+ get(target, prop, receiver) {
290
+ if (shouldNotBeProxied.includes(String(prop)))
291
+ return Reflect.get(target, prop, receiver);
292
+ let rootTarget = target;
293
+ while (rootTarget.parent)
294
+ rootTarget = rootTarget.parent;
295
+ const origProp = Reflect.get(rootTarget, prop, receiver);
296
+ if (typeof origProp !== 'function')
297
+ return origProp;
298
+ if (shouldNotCreateChild.includes(String(prop)))
299
+ return origProp;
300
+ return function (...args) {
301
+ // @ts-ignore
302
+ const result = origProp.call(rootTarget, ...args);
303
+ if (result instanceof CheckSettingsBaseFluent) {
304
+ if (result instanceof CheckSettingsImageFluent || result instanceof CheckSettingsAutomationFluent) {
305
+ return new ctor(null, null, target);
306
+ }
307
+ else {
308
+ // should not happen - the only known types to be proxied are CheckSettingsImageFluent and CheckSettingsAutomationFluent
309
+ throw new Error('Unknown CheckSettings type');
310
+ }
311
+ }
312
+ return result;
313
+ };
314
+ },
315
+ });
316
+ }
317
+ // protected toCoreCodedRegion(region: CodedRegion<TRegion>): Core.CodedRegion<TRegion | utils.Region>
318
+ // protected toCoreCodedRegion(region: Region | LegacyRegion | TRegion): utils.Region | TRegion
319
+ toCoreCodedRegion(region) {
320
+ if (utils.types.has(region, ['region'])) {
321
+ return { ...region, region: this.toCoreRegion(region.region) };
322
+ }
323
+ else {
324
+ return this.toCoreRegion(region);
325
+ }
326
+ }
327
+ toCoreCodedFloatingRegion(region) {
328
+ if (utils.types.has(region, 'region')) {
329
+ const { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, ...rest } = region;
330
+ return {
331
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
332
+ ...this.toCoreCodedRegion(rest),
333
+ };
334
+ }
335
+ else {
336
+ return this.toCoreRegion(region);
337
+ }
338
+ }
339
+ toCoreRegion(region) {
340
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
341
+ return { x: region.left, y: region.top, width: region.width, height: region.height };
342
+ }
343
+ else {
344
+ return region;
345
+ }
346
+ }
347
+ }
348
+ exports.CheckSettingsBaseFluent = CheckSettingsBaseFluent;
349
+ class CheckSettingsImageFluent extends CheckSettingsBaseFluent {
350
+ constructor(settings, target, parent) {
351
+ super(undefined, parent);
352
+ const self = CheckSettingsBaseFluent.makeMutableTreeProxy(this, CheckSettingsImageFluent);
353
+ this._target = null;
354
+ self._target = target !== null && target !== void 0 ? target : settings === null || settings === void 0 ? void 0 : settings._target;
355
+ self._settings = utils.types.instanceOf(settings, CheckSettingsImageFluent) ? settings.toObject() : settings !== null && settings !== void 0 ? settings : {};
356
+ if (settings instanceof CheckSettingsImageFluent) {
357
+ parent !== null && parent !== void 0 ? parent : (parent = settings.parent);
358
+ // copy constructor does not considered as a new child
359
+ parent === null || parent === void 0 ? void 0 : parent.childs.pop();
360
+ }
361
+ return self;
362
+ }
363
+ image(image) {
364
+ var _a;
365
+ (_a = this._target) !== null && _a !== void 0 ? _a : (this._target = {});
366
+ this._target.image = image;
367
+ return this;
368
+ }
369
+ buffer(imageBuffer) {
370
+ return this.image(imageBuffer);
371
+ }
372
+ base64(imageBase64) {
373
+ return this.image(imageBase64);
374
+ }
375
+ path(imagePath) {
376
+ return this.image(imagePath);
377
+ }
378
+ url(imageUrl) {
379
+ return this.image(imageUrl);
380
+ }
381
+ name(name) {
382
+ this._target.name = name;
383
+ return super.name(name);
384
+ }
385
+ withDom(dom) {
386
+ this._settings.sendDom = true;
387
+ this._target.dom = dom;
388
+ return this;
389
+ }
390
+ withLocation(locationInViewport) {
391
+ this._target.locationInViewport = locationInViewport;
392
+ return this;
393
+ }
394
+ /** @internal */
395
+ toJSON() {
396
+ var _a, _b, _c, _d, _e, _f, _g;
397
+ return {
398
+ target: this._target,
399
+ settings: utils.general.removeUndefinedProps({
400
+ name: this._settings.name,
401
+ region: this._settings.region ? this.toCoreRegion(this._settings.region) : this._settings.region,
402
+ matchLevel: this._settings.matchLevel,
403
+ useDom: this._settings.useDom,
404
+ sendDom: this._settings.sendDom,
405
+ enablePatterns: this._settings.enablePatterns,
406
+ ignoreDisplacements: this._settings.ignoreDisplacements,
407
+ ignoreCaret: this._settings.ignoreCaret,
408
+ ignoreRegions: (_a = this._settings.ignoreRegions) === null || _a === void 0 ? void 0 : _a.map(this.toCoreCodedRegion),
409
+ layoutRegions: (_b = this._settings.layoutRegions) === null || _b === void 0 ? void 0 : _b.map(this.toCoreCodedRegion),
410
+ strictRegions: (_c = this._settings.strictRegions) === null || _c === void 0 ? void 0 : _c.map(this.toCoreCodedRegion),
411
+ contentRegions: (_d = this._settings.contentRegions) === null || _d === void 0 ? void 0 : _d.map(this.toCoreCodedRegion),
412
+ floatingRegions: (_e = this._settings.floatingRegions) === null || _e === void 0 ? void 0 : _e.map(this.toCoreCodedFloatingRegion),
413
+ accessibilityRegions: (_f = this._settings.accessibilityRegions) === null || _f === void 0 ? void 0 : _f.map(this.toCoreCodedRegion),
414
+ dynamicRegions: (_g = this._settings.dynamicRegions) === null || _g === void 0 ? void 0 : _g.map(this.toCoreCodedRegion),
415
+ pageId: this._settings.pageId,
416
+ userCommandId: this._settings.variationGroupId,
417
+ assumesMutability: this.assumesMutability(),
418
+ }),
419
+ };
420
+ }
421
+ }
422
+ exports.CheckSettingsImageFluent = CheckSettingsImageFluent;
423
+ class CheckSettingsAutomationFluent extends CheckSettingsBaseFluent {
424
+ _isElementReference(value) {
425
+ var _a, _b, _c;
426
+ const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
427
+ return !!((_b = spec.isElement) === null || _b === void 0 ? void 0 : _b.call(spec, value)) || !!((_c = spec.isSecondaryElement) === null || _c === void 0 ? void 0 : _c.call(spec, value)) || this._isSelectorReference(value);
428
+ }
429
+ _isSelectorReference(selector) {
430
+ var _a, _b, _c, _d, _e;
431
+ const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
432
+ return (!!((_b = spec.isSelector) === null || _b === void 0 ? void 0 : _b.call(spec, selector)) ||
433
+ !!((_c = spec.isSecondarySelector) === null || _c === void 0 ? void 0 : _c.call(spec, selector)) ||
434
+ utils.types.isString(selector) ||
435
+ (utils.types.isPlainObject(selector) &&
436
+ utils.types.has(selector, 'selector') &&
437
+ (utils.types.isString(selector.selector) ||
438
+ !!((_d = spec.isSelector) === null || _d === void 0 ? void 0 : _d.call(spec, selector.selector)) ||
439
+ !!((_e = spec.isSecondarySelector) === null || _e === void 0 ? void 0 : _e.call(spec, selector)))));
440
+ }
441
+ _isFrameReference(value) {
442
+ return utils.types.isNumber(value) || utils.types.isString(value) || this._isElementReference(value);
443
+ }
444
+ constructor(settings, spec, parent) {
445
+ super(undefined, parent !== null && parent !== void 0 ? parent : settings === null || settings === void 0 ? void 0 : settings.parent);
446
+ this._settings = null;
447
+ this._spec = null;
448
+ const self = CheckSettingsBaseFluent.makeMutableTreeProxy(this, (CheckSettingsAutomationFluent));
449
+ self._spec = spec;
450
+ self._settings = utils.types.instanceOf(settings, CheckSettingsAutomationFluent)
451
+ ? settings.toObject()
452
+ : settings !== null && settings !== void 0 ? settings : {};
453
+ if (settings instanceof CheckSettingsAutomationFluent) {
454
+ parent !== null && parent !== void 0 ? parent : (parent = settings.parent);
455
+ // copy constructor does not considered as a new child
456
+ parent === null || parent === void 0 ? void 0 : parent.childs.pop();
457
+ }
458
+ return self;
459
+ }
460
+ region(region) {
461
+ if (this._isSelectorReference(region) &&
462
+ this._isSelectorReference(this._settings.region) &&
463
+ utils.types.has(this._settings.region, 'selector')) {
464
+ let lastSelector = this._settings.region;
465
+ while (lastSelector.shadow)
466
+ lastSelector = lastSelector.shadow;
467
+ lastSelector.shadow = region;
468
+ return this;
469
+ }
470
+ return super.region(region);
471
+ }
472
+ shadow(selector) {
473
+ selector = utils.types.has(selector, 'selector') ? selector : { selector };
474
+ if (!this._settings.region) {
475
+ this._settings.region = selector;
476
+ }
477
+ else if (this._isSelectorReference(this._settings.region)) {
478
+ let lastSelector;
479
+ if (utils.types.has(this._settings.region, 'selector')) {
480
+ lastSelector = this._settings.region;
481
+ while (lastSelector.shadow)
482
+ lastSelector = lastSelector.shadow;
483
+ }
484
+ else {
485
+ lastSelector = { selector: this._settings.region };
486
+ }
487
+ lastSelector.shadow = selector;
488
+ }
489
+ return this;
490
+ }
491
+ frame(contextOrFrame, scrollRootElement) {
492
+ const context = this._isFrameReference(contextOrFrame) || this._isSelectorReference(contextOrFrame)
493
+ ? { frame: contextOrFrame, scrollRootElement }
494
+ : contextOrFrame;
495
+ if (!this._settings.frames)
496
+ this._settings.frames = [];
497
+ this._settings.frames.push(context);
498
+ return this;
499
+ }
500
+ webview(webview) {
501
+ this._settings.webview = webview !== null && webview !== void 0 ? webview : true;
502
+ return this;
503
+ }
504
+ scrollRootElement(scrollRootElement) {
505
+ if (this._settings.frames && this._settings.frames.length > 0) {
506
+ const context = this._settings.frames[this._settings.frames.length - 1];
507
+ context.scrollRootElement = scrollRootElement;
508
+ }
509
+ this._settings.scrollRootElement = scrollRootElement;
510
+ return this;
511
+ }
512
+ fully(fully = true) {
513
+ this._settings.fully = fully;
514
+ return this;
515
+ }
516
+ /** @deprecated */
517
+ stitchContent(stitchContent = true) {
518
+ return this.fully(stitchContent);
519
+ }
520
+ disableBrowserFetching(disableBrowserFetching) {
521
+ this._settings.disableBrowserFetching = disableBrowserFetching;
522
+ return this;
523
+ }
524
+ layoutBreakpoints(breakpoints = true, heightBreakpointsOrSettings, settings) {
525
+ if (utils.types.isBoolean(heightBreakpointsOrSettings)) {
526
+ this._settings.layoutBreakpoints = {
527
+ breakpoints: breakpoints,
528
+ heightBreakpoints: heightBreakpointsOrSettings,
529
+ reload: settings === null || settings === void 0 ? void 0 : settings.reload,
530
+ };
531
+ }
532
+ else {
533
+ this._settings.layoutBreakpoints = {
534
+ breakpoints: utils.types.isArray(breakpoints)
535
+ ? Array.from(new Set(breakpoints)).sort((a, b) => (a < b ? 1 : -1))
536
+ : breakpoints,
537
+ reload: heightBreakpointsOrSettings === null || heightBreakpointsOrSettings === void 0 ? void 0 : heightBreakpointsOrSettings.reload,
538
+ };
539
+ }
540
+ return this;
541
+ }
542
+ hook(name, script) {
543
+ this._settings.hooks = { ...this._settings.hooks, [name]: script };
544
+ return this;
545
+ }
546
+ beforeRenderScreenshotHook(script) {
547
+ return this.hook('beforeCaptureScreenshot', script);
548
+ }
549
+ /** @deprecated */
550
+ webHook(script) {
551
+ return this.beforeRenderScreenshotHook(script);
552
+ }
553
+ ufgOption(key, value) {
554
+ this._settings.ufgOptions = { ...this._settings.ufgOptions, [key]: value };
555
+ return this;
556
+ }
557
+ ufgOptions(options) {
558
+ this._settings.ufgOptions = options;
559
+ return this;
560
+ }
561
+ /** @deprecated */
562
+ nmgOption(key, value) {
563
+ this._settings.nmgOptions = { ...this._settings.nmgOptions, [key]: value };
564
+ return this;
565
+ }
566
+ /** @deprecated */
567
+ nmgOptions(options) {
568
+ this._settings.nmgOptions = options;
569
+ return this;
570
+ }
571
+ /** @deprecated */
572
+ visualGridOption(key, value) {
573
+ return this.ufgOption(key, value);
574
+ }
575
+ /** @deprecated */
576
+ visualGridOptions(options) {
577
+ return this.ufgOptions(options);
578
+ }
579
+ useSystemScreenshot(useSystemScreenshot = true) {
580
+ this._settings.useSystemScreenshot = useSystemScreenshot;
581
+ return this;
582
+ }
583
+ timeout(timeout) {
584
+ this._settings.timeout = timeout;
585
+ return this;
586
+ }
587
+ waitBeforeCapture(waitBeforeCapture) {
588
+ this._settings.waitBeforeCapture = waitBeforeCapture;
589
+ return this;
590
+ }
591
+ lazyLoad(options) {
592
+ this._settings.lazyLoad = options !== null && options !== void 0 ? options : true;
593
+ return this;
594
+ }
595
+ densityMetrics(options) {
596
+ this._settings.densityMetrics = options;
597
+ return this;
598
+ }
599
+ stitchMode(stitchMode) {
600
+ this._settings.stitchMode = stitchMode;
601
+ return this;
602
+ }
603
+ /** @internal */
604
+ toLayoutBreakpoints() {
605
+ var _a;
606
+ let layoutBreakpoints;
607
+ if (utils.types.has(this._settings.layoutBreakpoints, 'breakpoints')) {
608
+ layoutBreakpoints = this._settings.layoutBreakpoints;
609
+ }
610
+ else {
611
+ layoutBreakpoints = { breakpoints: (_a = this._settings.layoutBreakpoints) !== null && _a !== void 0 ? _a : false };
612
+ }
613
+ return layoutBreakpoints;
614
+ }
615
+ /** @internal */
616
+ toJSON() {
617
+ var _a, _b, _c, _d, _e, _f, _g, _h;
618
+ return {
619
+ target: undefined,
620
+ settings: utils.general.removeUndefinedProps({
621
+ name: this._settings.name,
622
+ region: this._settings.region ? this.toCoreRegion(this._settings.region) : this._settings.region,
623
+ frames: this._settings.frames,
624
+ webview: this._settings.webview,
625
+ scrollRootElement: this._settings.scrollRootElement,
626
+ fully: this._settings.fully,
627
+ matchLevel: this._settings.matchLevel,
628
+ useDom: this._settings.useDom,
629
+ sendDom: this._settings.sendDom,
630
+ enablePatterns: this._settings.enablePatterns,
631
+ ignoreDisplacements: this._settings.ignoreDisplacements,
632
+ ignoreCaret: this._settings.ignoreCaret,
633
+ ignoreRegions: (_a = this._settings.ignoreRegions) === null || _a === void 0 ? void 0 : _a.map(this.toCoreCodedRegion),
634
+ layoutRegions: (_b = this._settings.layoutRegions) === null || _b === void 0 ? void 0 : _b.map(this.toCoreCodedRegion),
635
+ strictRegions: (_c = this._settings.strictRegions) === null || _c === void 0 ? void 0 : _c.map(this.toCoreCodedRegion),
636
+ contentRegions: (_d = this._settings.contentRegions) === null || _d === void 0 ? void 0 : _d.map(this.toCoreCodedRegion),
637
+ floatingRegions: (_e = this._settings.floatingRegions) === null || _e === void 0 ? void 0 : _e.map(this.toCoreCodedFloatingRegion),
638
+ accessibilityRegions: (_f = this._settings.accessibilityRegions) === null || _f === void 0 ? void 0 : _f.map(this.toCoreCodedRegion),
639
+ dynamicRegions: (_g = this._settings.dynamicRegions) === null || _g === void 0 ? void 0 : _g.map(this.toCoreCodedRegion),
640
+ disableBrowserFetching: this._settings.disableBrowserFetching,
641
+ layoutBreakpoints: utils.types.isDefined(this._settings.layoutBreakpoints)
642
+ ? this.toLayoutBreakpoints()
643
+ : undefined,
644
+ ufgOptions: (_h = this._settings.ufgOptions) !== null && _h !== void 0 ? _h : this._settings.visualGridOptions,
645
+ nmgOptions: this._settings.nmgOptions,
646
+ screenshotMode: this._settings.useSystemScreenshot ? 'default' : undefined,
647
+ hooks: this._settings.hooks,
648
+ pageId: this._settings.pageId,
649
+ lazyLoad: this._settings.lazyLoad,
650
+ waitBeforeCapture: this._settings.waitBeforeCapture,
651
+ retryTimeout: this._settings.timeout,
652
+ userCommandId: this._settings.variationGroupId,
653
+ densityMetrics: this._settings.densityMetrics,
654
+ assumesMutability: this.assumesMutability(),
655
+ stitchMode: this._settings.stitchMode,
656
+ }),
657
+ };
658
+ }
659
+ }
660
+ exports.CheckSettingsAutomationFluent = CheckSettingsAutomationFluent;
661
+ exports.TargetImage = {
662
+ image(image) {
663
+ return new CheckSettingsImageFluent().image(image);
664
+ },
665
+ buffer(imageBuffer) {
666
+ return new CheckSettingsImageFluent().image(imageBuffer);
667
+ },
668
+ base64(imageBase64) {
669
+ return new CheckSettingsImageFluent().image(imageBase64);
670
+ },
671
+ path(imagePath) {
672
+ return new CheckSettingsImageFluent().image(imagePath);
673
+ },
674
+ url(imageUrl) {
675
+ return new CheckSettingsImageFluent().image(imageUrl);
676
+ },
677
+ };
678
+ exports.TargetAutomation = {
679
+ spec: null,
680
+ window() {
681
+ return new CheckSettingsAutomationFluent({}, this.spec);
682
+ },
683
+ region(region) {
684
+ if (!region) {
685
+ // eslint-disable-next-line no-console
686
+ console.warn('Target.region() called with no region. Will take a screenshot of the entire window instead.');
687
+ // eslint-disable-next-line no-console
688
+ console.trace();
689
+ }
690
+ return new CheckSettingsAutomationFluent({}, this.spec).region(region);
691
+ },
692
+ frame(contextOrFrame, scrollRootElement) {
693
+ return new CheckSettingsAutomationFluent({}, this.spec).frame(contextOrFrame, scrollRootElement);
694
+ },
695
+ shadow(selector) {
696
+ return new CheckSettingsAutomationFluent({}, this.spec).shadow(selector);
697
+ },
698
+ webview(webview) {
699
+ return new CheckSettingsAutomationFluent({}, this.spec).webview(webview);
700
+ },
701
+ };
702
+ exports.Target = { ...exports.TargetImage, ...exports.TargetAutomation };