@applitools/eyes 1.0.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 (136) hide show
  1. package/LICENSE +26 -0
  2. package/dist/BatchClose.js +74 -0
  3. package/dist/Eyes.js +716 -0
  4. package/dist/Logger.js +128 -0
  5. package/dist/Runners.js +126 -0
  6. package/dist/SDK.js +41 -0
  7. package/dist/SessionEventHandlers.js +193 -0
  8. package/dist/enums/AccessibilityGuidelinesVersion.js +8 -0
  9. package/dist/enums/AccessibilityLevel.js +8 -0
  10. package/dist/enums/AccessibilityRegionType.js +11 -0
  11. package/dist/enums/AccessibilityStatus.js +8 -0
  12. package/dist/enums/AndroidDeviceName.js +31 -0
  13. package/dist/enums/AndroidVersion.js +8 -0
  14. package/dist/enums/BrowserType.js +23 -0
  15. package/dist/enums/CorsIframeHandle.js +10 -0
  16. package/dist/enums/DeviceName.js +75 -0
  17. package/dist/enums/FailureReport.js +8 -0
  18. package/dist/enums/IosDeviceName.js +31 -0
  19. package/dist/enums/IosVersion.js +10 -0
  20. package/dist/enums/MatchLevel.js +14 -0
  21. package/dist/enums/ScreenOrientation.js +8 -0
  22. package/dist/enums/SessionType.js +8 -0
  23. package/dist/enums/StitchMode.js +11 -0
  24. package/dist/enums/TestResultsStatus.js +9 -0
  25. package/dist/errors/DiffsFoundError.js +38 -0
  26. package/dist/errors/EyesError.js +6 -0
  27. package/dist/errors/NewTestError.js +38 -0
  28. package/dist/errors/TestFailedError.js +46 -0
  29. package/dist/index.js +130 -0
  30. package/dist/input/AUTProxySettings.js +2 -0
  31. package/dist/input/AccessibilityMatchSettings.js +109 -0
  32. package/dist/input/AccessibilitySettings.js +2 -0
  33. package/dist/input/BatchInfo.js +153 -0
  34. package/dist/input/CheckSettings.js +547 -0
  35. package/dist/input/Configuration.js +1048 -0
  36. package/dist/input/CutProvider.js +132 -0
  37. package/dist/input/DebugScreenshotProvider.js +2 -0
  38. package/dist/input/DensityMetrics.js +2 -0
  39. package/dist/input/ExactMatchSettings.js +102 -0
  40. package/dist/input/EyesSelector.js +2 -0
  41. package/dist/input/FloatingMatchSettings.js +152 -0
  42. package/dist/input/Image.js +2 -0
  43. package/dist/input/ImageMatchSettings.js +271 -0
  44. package/dist/input/ImageRotation.js +59 -0
  45. package/dist/input/LazyLoadOptions.js +2 -0
  46. package/dist/input/Location.js +74 -0
  47. package/dist/input/LogHandler.js +90 -0
  48. package/dist/input/OCRRegion.js +2 -0
  49. package/dist/input/OCRSettings.js +2 -0
  50. package/dist/input/PropertyData.js +76 -0
  51. package/dist/input/ProxySettings.js +77 -0
  52. package/dist/input/RectangleSize.js +74 -0
  53. package/dist/input/Region.js +135 -0
  54. package/dist/input/RenderInfo.js +2 -0
  55. package/dist/input/RunnerOptions.js +56 -0
  56. package/dist/input/VisualLocatorSettings.js +2 -0
  57. package/dist/output/ApiUrls.js +96 -0
  58. package/dist/output/AppUrls.js +66 -0
  59. package/dist/output/MatchResult.js +66 -0
  60. package/dist/output/SessionUrls.js +66 -0
  61. package/dist/output/StepInfo.js +118 -0
  62. package/dist/output/TestAccessibilityStatus.js +2 -0
  63. package/dist/output/TestResultContainer.js +46 -0
  64. package/dist/output/TestResults.js +365 -0
  65. package/dist/output/TestResultsSummary.js +49 -0
  66. package/dist/output/TextRegion.js +2 -0
  67. package/dist/output/ValidationInfo.js +60 -0
  68. package/dist/output/ValidationResult.js +53 -0
  69. package/package.json +68 -0
  70. package/types/BatchClose.d.ts +23 -0
  71. package/types/Eyes.d.ts +245 -0
  72. package/types/Logger.d.ts +32 -0
  73. package/types/Runners.d.ts +50 -0
  74. package/types/SDK.d.ts +10 -0
  75. package/types/SessionEventHandlers.d.ts +78 -0
  76. package/types/enums/AccessibilityGuidelinesVersion.d.ts +5 -0
  77. package/types/enums/AccessibilityLevel.d.ts +5 -0
  78. package/types/enums/AccessibilityRegionType.d.ts +8 -0
  79. package/types/enums/AccessibilityStatus.d.ts +5 -0
  80. package/types/enums/AndroidDeviceName.d.ts +28 -0
  81. package/types/enums/AndroidVersion.d.ts +5 -0
  82. package/types/enums/BrowserType.d.ts +20 -0
  83. package/types/enums/CorsIframeHandle.d.ts +7 -0
  84. package/types/enums/DeviceName.d.ts +70 -0
  85. package/types/enums/FailureReport.d.ts +5 -0
  86. package/types/enums/IosDeviceName.d.ts +28 -0
  87. package/types/enums/IosVersion.d.ts +7 -0
  88. package/types/enums/MatchLevel.d.ts +11 -0
  89. package/types/enums/ScreenOrientation.d.ts +5 -0
  90. package/types/enums/SessionType.d.ts +5 -0
  91. package/types/enums/StitchMode.d.ts +8 -0
  92. package/types/enums/TestResultsStatus.d.ts +6 -0
  93. package/types/errors/DiffsFoundError.d.ts +6 -0
  94. package/types/errors/EyesError.d.ts +2 -0
  95. package/types/errors/NewTestError.d.ts +6 -0
  96. package/types/errors/TestFailedError.d.ts +9 -0
  97. package/types/index.d.ts +60 -0
  98. package/types/input/AUTProxySettings.d.ts +5 -0
  99. package/types/input/AccessibilityMatchSettings.d.ts +34 -0
  100. package/types/input/AccessibilitySettings.d.ts +6 -0
  101. package/types/input/BatchInfo.d.ts +47 -0
  102. package/types/input/CheckSettings.d.ts +231 -0
  103. package/types/input/Configuration.d.ts +368 -0
  104. package/types/input/CutProvider.d.ts +44 -0
  105. package/types/input/DebugScreenshotProvider.d.ts +5 -0
  106. package/types/input/DensityMetrics.d.ts +5 -0
  107. package/types/input/ExactMatchSettings.d.ts +34 -0
  108. package/types/input/EyesSelector.d.ts +6 -0
  109. package/types/input/FloatingMatchSettings.d.ts +50 -0
  110. package/types/input/Image.d.ts +11 -0
  111. package/types/input/ImageMatchSettings.d.ts +95 -0
  112. package/types/input/ImageRotation.d.ts +15 -0
  113. package/types/input/LazyLoadOptions.d.ts +5 -0
  114. package/types/input/Location.d.ts +23 -0
  115. package/types/input/LogHandler.d.ts +45 -0
  116. package/types/input/OCRRegion.d.ts +9 -0
  117. package/types/input/OCRSettings.d.ts +6 -0
  118. package/types/input/PropertyData.d.ts +23 -0
  119. package/types/input/ProxySettings.d.ts +25 -0
  120. package/types/input/RectangleSize.d.ts +23 -0
  121. package/types/input/Region.d.ts +46 -0
  122. package/types/input/RenderInfo.d.ts +37 -0
  123. package/types/input/RunnerOptions.d.ts +16 -0
  124. package/types/input/VisualLocatorSettings.d.ts +4 -0
  125. package/types/output/ApiUrls.d.ts +38 -0
  126. package/types/output/AppUrls.d.ts +23 -0
  127. package/types/output/MatchResult.d.ts +23 -0
  128. package/types/output/SessionUrls.d.ts +23 -0
  129. package/types/output/StepInfo.d.ts +50 -0
  130. package/types/output/TestAccessibilityStatus.d.ts +8 -0
  131. package/types/output/TestResultContainer.d.ts +31 -0
  132. package/types/output/TestResults.d.ts +177 -0
  133. package/types/output/TestResultsSummary.d.ts +18 -0
  134. package/types/output/TextRegion.d.ts +7 -0
  135. package/types/output/ValidationInfo.d.ts +21 -0
  136. package/types/output/ValidationResult.d.ts +18 -0
@@ -0,0 +1,153 @@
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.BatchInfoData = void 0;
27
+ const utils = __importStar(require("@applitools/utils"));
28
+ const PropertyData_1 = require("./PropertyData");
29
+ class BatchInfoData {
30
+ constructor(batchOrName, startedAt, id) {
31
+ var _a, _b, _c, _d, _e, _f, _g;
32
+ const batch = utils.types.isNull(batchOrName) || utils.types.isString(batchOrName)
33
+ ? { name: batchOrName, id, startedAt }
34
+ : batchOrName;
35
+ utils.guard.isString(batch.id, { name: 'id', strict: false });
36
+ utils.guard.isString(batch.name, { name: 'name', strict: false });
37
+ utils.guard.isString(batch.sequenceName, { name: 'sequenceName', strict: false });
38
+ utils.guard.isBoolean(batch.notifyOnCompletion, { name: 'notifyOnCompletion', strict: false });
39
+ utils.guard.isArray(batch.properties, { name: 'properties', strict: false });
40
+ this._batch = {
41
+ id: (_b = (_a = batch.id) !== null && _a !== void 0 ? _a : utils.general.getEnvValue('BATCH_ID')) !== null && _b !== void 0 ? _b : `generated-${utils.general.guid()}`,
42
+ name: (_c = batch.name) !== null && _c !== void 0 ? _c : utils.general.getEnvValue('BATCH_NAME'),
43
+ sequenceName: (_d = batch.sequenceName) !== null && _d !== void 0 ? _d : utils.general.getEnvValue('BATCH_SEQUENCE'),
44
+ startedAt: (_e = batch.startedAt) !== null && _e !== void 0 ? _e : new Date(),
45
+ notifyOnCompletion: (_g = (_f = batch.notifyOnCompletion) !== null && _f !== void 0 ? _f : utils.general.getEnvValue('BATCH_NOTIFY', 'boolean')) !== null && _g !== void 0 ? _g : false,
46
+ properties: batch.properties,
47
+ };
48
+ }
49
+ get id() {
50
+ return this._batch.id;
51
+ }
52
+ set id(id) {
53
+ utils.guard.isString(id, { name: 'id', strict: false });
54
+ this._batch.id = id;
55
+ }
56
+ getId() {
57
+ return this.id;
58
+ }
59
+ setId(id) {
60
+ this.id = id;
61
+ return this;
62
+ }
63
+ get name() {
64
+ return this._batch.name;
65
+ }
66
+ set name(name) {
67
+ utils.guard.isString(name, { name: 'name', strict: false });
68
+ this._batch.name = name;
69
+ }
70
+ getName() {
71
+ return this.name;
72
+ }
73
+ setName(name) {
74
+ this.name = name;
75
+ return this;
76
+ }
77
+ get sequenceName() {
78
+ return this._batch.sequenceName;
79
+ }
80
+ set sequenceName(sequenceName) {
81
+ utils.guard.isString(sequenceName, { name: 'sequenceName', strict: false });
82
+ this._batch.sequenceName = sequenceName;
83
+ }
84
+ getSequenceName() {
85
+ return this.sequenceName;
86
+ }
87
+ setSequenceName(sequenceName) {
88
+ this.sequenceName = sequenceName;
89
+ return this;
90
+ }
91
+ get startedAt() {
92
+ return this._batch.startedAt;
93
+ }
94
+ set startedAt(startedAt) {
95
+ this._batch.startedAt = new Date(startedAt);
96
+ }
97
+ getStartedAt() {
98
+ return this.startedAt;
99
+ }
100
+ setStartedAt(startedAt) {
101
+ this.startedAt = startedAt;
102
+ return this;
103
+ }
104
+ get notifyOnCompletion() {
105
+ return this._batch.notifyOnCompletion;
106
+ }
107
+ set notifyOnCompletion(notifyOnCompletion) {
108
+ utils.guard.isBoolean(notifyOnCompletion, { name: 'notifyOnCompletion', strict: false });
109
+ this._batch.notifyOnCompletion = notifyOnCompletion;
110
+ }
111
+ getNotifyOnCompletion() {
112
+ return this.notifyOnCompletion;
113
+ }
114
+ setNotifyOnCompletion(notifyOnCompletion) {
115
+ this.notifyOnCompletion = notifyOnCompletion;
116
+ return this;
117
+ }
118
+ get properties() {
119
+ return this._batch.properties;
120
+ }
121
+ set properties(properties) {
122
+ utils.guard.isArray(properties, { name: 'properties', strict: false });
123
+ this._batch.properties = properties;
124
+ }
125
+ getProperties() {
126
+ var _a, _b;
127
+ return (_b = (_a = this.properties) === null || _a === void 0 ? void 0 : _a.map(property => new PropertyData_1.PropertyDataData(property))) !== null && _b !== void 0 ? _b : [];
128
+ }
129
+ setProperties(properties) {
130
+ this.properties = properties;
131
+ return this;
132
+ }
133
+ addProperty(propOrName, value) {
134
+ const property = utils.types.isString(propOrName) ? { name: propOrName, value: value } : propOrName;
135
+ if (!this.properties)
136
+ this.properties = [];
137
+ this.properties.push(property);
138
+ return this;
139
+ }
140
+ /** @internal */
141
+ toObject() {
142
+ return this._batch;
143
+ }
144
+ /** @internal */
145
+ toJSON() {
146
+ return utils.general.toJSON(this._batch);
147
+ }
148
+ /** @internal */
149
+ toString() {
150
+ return utils.general.toString(this);
151
+ }
152
+ }
153
+ exports.BatchInfoData = BatchInfoData;
@@ -0,0 +1,547 @@
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) {
32
+ this._settings = {};
33
+ this._settings = utils.types.instanceOf(settings, CheckSettingsBaseFluent) ? settings.toObject() : settings !== null && settings !== void 0 ? settings : {};
34
+ }
35
+ region(region) {
36
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
37
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
38
+ }
39
+ this._settings.region = region;
40
+ return this;
41
+ }
42
+ name(name) {
43
+ this._settings.name = name;
44
+ return this;
45
+ }
46
+ withName(name) {
47
+ return this.name(name);
48
+ }
49
+ ignoreRegion(region) {
50
+ if (!this._settings.ignoreRegions)
51
+ this._settings.ignoreRegions = [];
52
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
53
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
54
+ }
55
+ this._settings.ignoreRegions.push(region);
56
+ return this;
57
+ }
58
+ ignoreRegions(...regions) {
59
+ regions.forEach(region => this.ignoreRegion(region));
60
+ return this;
61
+ }
62
+ /** @deprecated */
63
+ ignore(region) {
64
+ return this.ignoreRegion(region);
65
+ }
66
+ /** @deprecated */
67
+ ignores(...regions) {
68
+ return this.ignoreRegions(...regions);
69
+ }
70
+ layoutRegion(region) {
71
+ if (!this._settings.layoutRegions)
72
+ this._settings.layoutRegions = [];
73
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
74
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
75
+ }
76
+ this._settings.layoutRegions.push(region);
77
+ return this;
78
+ }
79
+ layoutRegions(...regions) {
80
+ regions.forEach(region => this.layoutRegion(region));
81
+ return this;
82
+ }
83
+ strictRegion(region) {
84
+ if (!this._settings.strictRegions)
85
+ this._settings.strictRegions = [];
86
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
87
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
88
+ }
89
+ this._settings.strictRegions.push(region);
90
+ return this;
91
+ }
92
+ strictRegions(...regions) {
93
+ regions.forEach(region => this.strictRegion(region));
94
+ return this;
95
+ }
96
+ contentRegion(region) {
97
+ if (!this._settings.contentRegions)
98
+ this._settings.contentRegions = [];
99
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
100
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
101
+ }
102
+ this._settings.contentRegions.push(region);
103
+ return this;
104
+ }
105
+ contentRegions(...regions) {
106
+ regions.forEach(region => this.contentRegion(region));
107
+ return this;
108
+ }
109
+ floatingRegion(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset) {
110
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
111
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
112
+ }
113
+ let floatingRegion;
114
+ if (utils.types.has(region, 'region')) {
115
+ const { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, ...rest } = region;
116
+ floatingRegion = {
117
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
118
+ ...rest,
119
+ };
120
+ }
121
+ else {
122
+ floatingRegion = {
123
+ region,
124
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
125
+ };
126
+ }
127
+ if (!this._settings.floatingRegions)
128
+ this._settings.floatingRegions = [];
129
+ this._settings.floatingRegions.push(floatingRegion);
130
+ return this;
131
+ }
132
+ floatingRegions(regionOrMaxOffset, ...regions) {
133
+ let maxOffset;
134
+ if (utils.types.isNumber(regionOrMaxOffset)) {
135
+ maxOffset = regionOrMaxOffset;
136
+ }
137
+ else {
138
+ this.floatingRegion(regionOrMaxOffset);
139
+ }
140
+ regions.forEach(region => {
141
+ if (utils.types.has(region, 'region'))
142
+ this.floatingRegion(region);
143
+ else
144
+ this.floatingRegion(region, maxOffset, maxOffset, maxOffset, maxOffset);
145
+ });
146
+ return this;
147
+ }
148
+ floating(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset) {
149
+ if (utils.types.has(region, 'region'))
150
+ return this.floatingRegion(region);
151
+ else
152
+ return this.floatingRegion(region, maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset);
153
+ }
154
+ floatings(regionOrMaxOffset, ...regions) {
155
+ return this.floatingRegions(regionOrMaxOffset, ...regions);
156
+ }
157
+ accessibilityRegion(region, type) {
158
+ if (utils.types.has(region, ['left', 'top', 'width', 'height'])) {
159
+ region = { x: region.left, y: region.top, width: region.width, height: region.height };
160
+ }
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
+ return this;
166
+ }
167
+ accessibilityRegions(regionOrType, ...regions) {
168
+ let type;
169
+ if (utils.types.isEnumValue(regionOrType, AccessibilityRegionType_1.AccessibilityRegionTypeEnum)) {
170
+ type = regionOrType;
171
+ }
172
+ else {
173
+ this.accessibilityRegion(regionOrType);
174
+ }
175
+ regions.forEach(region => {
176
+ if (utils.types.has(region, 'region'))
177
+ this.accessibilityRegion(region);
178
+ else
179
+ this.accessibilityRegion(region, type);
180
+ });
181
+ return this;
182
+ }
183
+ matchLevel(matchLevel) {
184
+ this._settings.matchLevel = matchLevel;
185
+ return this;
186
+ }
187
+ layout() {
188
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Layout;
189
+ return this;
190
+ }
191
+ exact() {
192
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Exact;
193
+ return this;
194
+ }
195
+ strict() {
196
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Strict;
197
+ return this;
198
+ }
199
+ ignoreColors() {
200
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.IgnoreColors;
201
+ return this;
202
+ }
203
+ /** @deprecated */
204
+ content() {
205
+ this._settings.matchLevel = MatchLevel_1.MatchLevelEnum.Content;
206
+ return this;
207
+ }
208
+ enablePatterns(enablePatterns = true) {
209
+ this._settings.enablePatterns = enablePatterns;
210
+ return this;
211
+ }
212
+ ignoreDisplacements(ignoreDisplacements = true) {
213
+ this._settings.ignoreDisplacements = ignoreDisplacements;
214
+ return this;
215
+ }
216
+ ignoreCaret(ignoreCaret = true) {
217
+ this._settings.ignoreCaret = ignoreCaret;
218
+ return this;
219
+ }
220
+ useDom(useDom = true) {
221
+ this._settings.useDom = useDom;
222
+ return this;
223
+ }
224
+ sendDom(sendDom = true) {
225
+ this._settings.sendDom = sendDom;
226
+ return this;
227
+ }
228
+ pageId(pageId) {
229
+ this._settings.pageId = pageId;
230
+ return this;
231
+ }
232
+ variationGroupId(variationGroupId) {
233
+ this._settings.variationGroupId = variationGroupId;
234
+ return this;
235
+ }
236
+ /** @internal */
237
+ toObject() {
238
+ return this._settings;
239
+ }
240
+ /** @internal */
241
+ toString() {
242
+ return utils.general.toString(this);
243
+ }
244
+ }
245
+ exports.CheckSettingsBaseFluent = CheckSettingsBaseFluent;
246
+ class CheckSettingsImageFluent extends CheckSettingsBaseFluent {
247
+ constructor(settings, target) {
248
+ super(settings);
249
+ this._target = target !== null && target !== void 0 ? target : settings === null || settings === void 0 ? void 0 : settings._target;
250
+ }
251
+ image(image) {
252
+ var _a;
253
+ (_a = this._target) !== null && _a !== void 0 ? _a : (this._target = {});
254
+ this._target.image = image;
255
+ return this;
256
+ }
257
+ buffer(imageBuffer) {
258
+ return this.image(imageBuffer);
259
+ }
260
+ base64(imageBase64) {
261
+ return this.image(imageBase64);
262
+ }
263
+ path(imagePath) {
264
+ return this.image(imagePath);
265
+ }
266
+ url(imageUrl) {
267
+ return this.image(imageUrl);
268
+ }
269
+ name(name) {
270
+ this._target.name = name;
271
+ return super.name(name);
272
+ }
273
+ withDom(dom) {
274
+ this._settings.sendDom = true;
275
+ this._target.dom = dom;
276
+ return this;
277
+ }
278
+ withLocation(locationInViewport) {
279
+ this._target.locationInViewport = locationInViewport;
280
+ return this;
281
+ }
282
+ /** @internal */
283
+ toJSON() {
284
+ return {
285
+ target: this._target,
286
+ settings: utils.general.removeUndefinedProps({
287
+ name: this._settings.name,
288
+ region: this._settings.region,
289
+ matchLevel: this._settings.matchLevel,
290
+ useDom: this._settings.useDom,
291
+ sendDom: this._settings.sendDom,
292
+ enablePatterns: this._settings.enablePatterns,
293
+ ignoreDisplacements: this._settings.ignoreDisplacements,
294
+ ignoreCaret: this._settings.ignoreCaret,
295
+ ignoreRegions: this._settings.ignoreRegions,
296
+ layoutRegions: this._settings.layoutRegions,
297
+ strictRegions: this._settings.strictRegions,
298
+ contentRegions: this._settings.contentRegions,
299
+ floatingRegions: this._settings.floatingRegions,
300
+ accessibilityRegions: this._settings.accessibilityRegions,
301
+ pageId: this._settings.pageId,
302
+ userCommandId: this._settings.variationGroupId,
303
+ }),
304
+ };
305
+ }
306
+ }
307
+ exports.CheckSettingsImageFluent = CheckSettingsImageFluent;
308
+ class CheckSettingsAutomationFluent extends CheckSettingsBaseFluent {
309
+ _isElementReference(value) {
310
+ var _a, _b;
311
+ const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
312
+ return !!((_b = spec.isElement) === null || _b === void 0 ? void 0 : _b.call(spec, value)) || this._isSelectorReference(value);
313
+ }
314
+ _isSelectorReference(selector) {
315
+ var _a, _b, _c;
316
+ const spec = (_a = this._spec) !== null && _a !== void 0 ? _a : this.constructor._spec;
317
+ return (!!((_b = spec.isSelector) === null || _b === void 0 ? void 0 : _b.call(spec, selector)) ||
318
+ utils.types.isString(selector) ||
319
+ (utils.types.isPlainObject(selector) &&
320
+ utils.types.has(selector, 'selector') &&
321
+ (utils.types.isString(selector.selector) || !!((_c = spec.isSelector) === null || _c === void 0 ? void 0 : _c.call(spec, selector.selector)))));
322
+ }
323
+ _isFrameReference(value) {
324
+ return utils.types.isNumber(value) || utils.types.isString(value) || this._isElementReference(value);
325
+ }
326
+ constructor(settings, spec) {
327
+ var _a;
328
+ super(settings);
329
+ this._spec = spec;
330
+ (_a = this._settings) !== null && _a !== void 0 ? _a : (this._settings = {});
331
+ }
332
+ region(region) {
333
+ if (this._isSelectorReference(region) &&
334
+ this._isSelectorReference(this._settings.region) &&
335
+ utils.types.has(this._settings.region, 'selector')) {
336
+ let lastSelector = this._settings.region;
337
+ while (lastSelector.shadow)
338
+ lastSelector = lastSelector.shadow;
339
+ lastSelector.shadow = region;
340
+ return this;
341
+ }
342
+ return super.region(region);
343
+ }
344
+ shadow(selector) {
345
+ selector = utils.types.has(selector, 'selector') ? selector : { selector };
346
+ if (!this._settings.region) {
347
+ this._settings.region = selector;
348
+ }
349
+ else if (this._isSelectorReference(this._settings.region)) {
350
+ let lastSelector;
351
+ if (utils.types.has(this._settings.region, 'selector')) {
352
+ lastSelector = this._settings.region;
353
+ while (lastSelector.shadow)
354
+ lastSelector = lastSelector.shadow;
355
+ }
356
+ else {
357
+ lastSelector = { selector: this._settings.region };
358
+ }
359
+ lastSelector.shadow = selector;
360
+ }
361
+ return this;
362
+ }
363
+ frame(contextOrFrame, scrollRootElement) {
364
+ const context = this._isFrameReference(contextOrFrame) || this._isSelectorReference(contextOrFrame)
365
+ ? { frame: contextOrFrame, scrollRootElement }
366
+ : contextOrFrame;
367
+ if (!this._settings.frames)
368
+ this._settings.frames = [];
369
+ this._settings.frames.push(context);
370
+ return this;
371
+ }
372
+ webview(webview) {
373
+ this._settings.webview = webview !== null && webview !== void 0 ? webview : true;
374
+ return this;
375
+ }
376
+ scrollRootElement(scrollRootElement) {
377
+ if (this._settings.frames && this._settings.frames.length > 0) {
378
+ const context = this._settings.frames[this._settings.frames.length - 1];
379
+ context.scrollRootElement = scrollRootElement;
380
+ }
381
+ this._settings.scrollRootElement = scrollRootElement;
382
+ return this;
383
+ }
384
+ fully(fully = true) {
385
+ this._settings.fully = fully;
386
+ return this;
387
+ }
388
+ /** @deprecated */
389
+ stitchContent(stitchContent = true) {
390
+ return this.fully(stitchContent);
391
+ }
392
+ disableBrowserFetching(disableBrowserFetching) {
393
+ this._settings.disableBrowserFetching = disableBrowserFetching;
394
+ return this;
395
+ }
396
+ layoutBreakpoints(layoutBreakpoints = true) {
397
+ if (!utils.types.isArray(layoutBreakpoints)) {
398
+ this._settings.layoutBreakpoints = layoutBreakpoints;
399
+ }
400
+ else if (layoutBreakpoints.length === 0) {
401
+ this._settings.layoutBreakpoints = false;
402
+ }
403
+ else {
404
+ this._settings.layoutBreakpoints = Array.from(new Set(layoutBreakpoints)).sort((a, b) => (a < b ? 1 : -1));
405
+ }
406
+ return this;
407
+ }
408
+ hook(name, script) {
409
+ this._settings.hooks = { ...this._settings.hooks, [name]: script };
410
+ return this;
411
+ }
412
+ beforeRenderScreenshotHook(script) {
413
+ return this.hook('beforeCaptureScreenshot', script);
414
+ }
415
+ /** @deprecated */
416
+ webHook(script) {
417
+ return this.beforeRenderScreenshotHook(script);
418
+ }
419
+ ufgOption(key, value) {
420
+ this._settings.visualGridOptions = { ...this._settings.visualGridOptions, [key]: value };
421
+ return this;
422
+ }
423
+ ufgOptions(options) {
424
+ this._settings.visualGridOptions = options;
425
+ return this;
426
+ }
427
+ /** @deprecated */
428
+ visualGridOption(key, value) {
429
+ return this.ufgOption(key, value);
430
+ }
431
+ /** @deprecated */
432
+ visualGridOptions(options) {
433
+ return this.ufgOptions(options);
434
+ }
435
+ nmgOption(key, value) {
436
+ this._settings.nmgOptions = { ...this._settings.nmgOptions, [key]: value };
437
+ return this;
438
+ }
439
+ nmgOptions(options) {
440
+ this._settings.nmgOptions = options;
441
+ return this;
442
+ }
443
+ renderId(renderId) {
444
+ this._settings.renderId = renderId;
445
+ return this;
446
+ }
447
+ timeout(timeout) {
448
+ this._settings.timeout = timeout;
449
+ return this;
450
+ }
451
+ waitBeforeCapture(waitBeforeCapture) {
452
+ this._settings.waitBeforeCapture = waitBeforeCapture;
453
+ return this;
454
+ }
455
+ lazyLoad(options) {
456
+ this._settings.lazyLoad = options !== null && options !== void 0 ? options : true;
457
+ return this;
458
+ }
459
+ densityMetrics(options) {
460
+ this._settings.densityMetrics = options;
461
+ return this;
462
+ }
463
+ /** @internal */
464
+ toJSON() {
465
+ return {
466
+ target: undefined,
467
+ settings: utils.general.removeUndefinedProps({
468
+ name: this._settings.name,
469
+ region: this._settings.region,
470
+ frames: this._settings.frames,
471
+ webview: this._settings.webview,
472
+ scrollRootElement: this._settings.scrollRootElement,
473
+ fully: this._settings.fully,
474
+ matchLevel: this._settings.matchLevel,
475
+ useDom: this._settings.useDom,
476
+ sendDom: this._settings.sendDom,
477
+ enablePatterns: this._settings.enablePatterns,
478
+ ignoreDisplacements: this._settings.ignoreDisplacements,
479
+ ignoreCaret: this._settings.ignoreCaret,
480
+ ignoreRegions: this._settings.ignoreRegions,
481
+ layoutRegions: this._settings.layoutRegions,
482
+ strictRegions: this._settings.strictRegions,
483
+ contentRegions: this._settings.contentRegions,
484
+ floatingRegions: this._settings.floatingRegions &&
485
+ this._settings.floatingRegions.map(floatingRegion => {
486
+ if (utils.types.has(floatingRegion, 'region')) {
487
+ const { maxUpOffset, maxDownOffset, maxLeftOffset, maxRightOffset, ...rest } = floatingRegion;
488
+ return {
489
+ offset: { top: maxUpOffset, bottom: maxDownOffset, left: maxLeftOffset, right: maxRightOffset },
490
+ ...rest,
491
+ };
492
+ }
493
+ return floatingRegion;
494
+ }),
495
+ accessibilityRegions: this._settings.accessibilityRegions,
496
+ disableBrowserFetching: this._settings.disableBrowserFetching,
497
+ layoutBreakpoints: this._settings.layoutBreakpoints,
498
+ ufgOptions: this._settings.visualGridOptions,
499
+ nmgOptions: this._settings.nmgOptions,
500
+ hooks: this._settings.hooks,
501
+ pageId: this._settings.pageId,
502
+ lazyLoad: this._settings.lazyLoad,
503
+ waitBeforeCapture: this._settings.waitBeforeCapture,
504
+ retryTimeout: this._settings.timeout,
505
+ userCommandId: this._settings.variationGroupId,
506
+ densityMetrics: this._settings.densityMetrics,
507
+ }),
508
+ };
509
+ }
510
+ }
511
+ exports.CheckSettingsAutomationFluent = CheckSettingsAutomationFluent;
512
+ exports.TargetImage = {
513
+ image(image) {
514
+ return new CheckSettingsImageFluent().image(image);
515
+ },
516
+ buffer(imageBuffer) {
517
+ return new CheckSettingsImageFluent().image(imageBuffer);
518
+ },
519
+ base64(imageBase64) {
520
+ return new CheckSettingsImageFluent().image(imageBase64);
521
+ },
522
+ path(imagePath) {
523
+ return new CheckSettingsImageFluent().image(imagePath);
524
+ },
525
+ url(imageUrl) {
526
+ return new CheckSettingsImageFluent().image(imageUrl);
527
+ },
528
+ };
529
+ exports.TargetAutomation = {
530
+ spec: null,
531
+ window() {
532
+ return new CheckSettingsAutomationFluent({}, this.spec);
533
+ },
534
+ region(region) {
535
+ return new CheckSettingsAutomationFluent({}, this.spec).region(region);
536
+ },
537
+ frame(contextOrFrame, scrollRootElement) {
538
+ return new CheckSettingsAutomationFluent({}, this.spec).frame(contextOrFrame, scrollRootElement);
539
+ },
540
+ shadow(selector) {
541
+ return new CheckSettingsAutomationFluent({}, this.spec).shadow(selector);
542
+ },
543
+ webview(webview) {
544
+ return new CheckSettingsAutomationFluent({}, this.spec).webview(webview);
545
+ },
546
+ };
547
+ exports.Target = { ...exports.TargetImage, ...exports.TargetAutomation };