@applitools/eyes-images 4.20.0 → 4.22.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.
@@ -1,217 +0,0 @@
1
- 'use strict'
2
-
3
- const {CheckSettings, Location, RectangleSize} = require('@applitools/eyes-sdk-core')
4
-
5
- class ImagesCheckSettings extends CheckSettings {
6
- /**
7
- * @param {MutableImage} [image]
8
- * @param {Buffer} [buffer]
9
- * @param {string} [base64]
10
- * @param {string} [path]
11
- * @param {string} [url]
12
- */
13
- constructor(image, buffer, base64, path, url) {
14
- super()
15
-
16
- this._image = image
17
- this._imageBuffer = buffer
18
- this._imageBase64 = base64
19
- this._imagePath = path
20
- this._imageUrl = url
21
- this._imageProvider = null
22
-
23
- /** @type {RectangleSize} */
24
- this._imageSize = undefined
25
- /** @type {string} */
26
- this._domString = undefined
27
- /** @type {Location} */
28
- this._imageLocation = undefined
29
- /** @type {boolean} */
30
- this._ignoreMismatch = false
31
- /** @type {string} */
32
- this._variantId = undefined
33
- }
34
-
35
- /**
36
- * @package
37
- * @return {MutableImage}
38
- */
39
- getMutableImage() {
40
- return this._image
41
- }
42
-
43
- /**
44
- * @package
45
- * @return {Buffer}
46
- */
47
- getImageBuffer() {
48
- return this._imageBuffer
49
- }
50
-
51
- /**
52
- * @package
53
- * @param {Buffer} imageBuffer
54
- */
55
- setImageBuffer(imageBuffer) {
56
- this._imageBuffer = imageBuffer
57
- }
58
-
59
- /**
60
- * @package
61
- * @return {string}
62
- */
63
- getImageString() {
64
- return this._imageBase64
65
- }
66
-
67
- /**
68
- * @package
69
- * @param {string} base64String
70
- */
71
- setImageString(base64String) {
72
- this._imageBase64 = base64String
73
- }
74
-
75
- /**
76
- * @package
77
- * @return {string}
78
- */
79
- getImagePath() {
80
- return this._imagePath
81
- }
82
-
83
- /**
84
- * @package
85
- * @param {string} imagePath
86
- */
87
- setImagePath(imagePath) {
88
- this._imagePath = imagePath
89
- }
90
-
91
- /**
92
- * @package
93
- * @return {string}
94
- */
95
- getImageUrl() {
96
- return this._imageUrl
97
- }
98
-
99
- /**
100
- * @package
101
- * @param {string} imageUrl
102
- * @param {RectangleSize|RectangleSizeObject} [imageSize]
103
- */
104
- setImageUrl(imageUrl, imageSize) {
105
- this._imageUrl = imageUrl
106
-
107
- if (imageSize) {
108
- this.imageSize(imageSize)
109
- }
110
- }
111
-
112
- /**
113
- * @package
114
- * @return {ImageProvider}
115
- */
116
- getImageProvider() {
117
- return this._imageProvider
118
- }
119
-
120
- /**
121
- * @package
122
- * @param {ImageProvider} imageProvider
123
- */
124
- setImageProvider(imageProvider) {
125
- this._imageProvider = imageProvider
126
- }
127
-
128
- /**
129
- * @param {RectangleSize} imageSize
130
- * @return {this} - This instance of the settings object.
131
- */
132
- imageSize(imageSize) {
133
- this._imageSize = new RectangleSize(imageSize)
134
- return this
135
- }
136
-
137
- /**
138
- * @package
139
- * @return {RectangleSize}
140
- */
141
- getImageSize() {
142
- return this._imageSize
143
- }
144
-
145
- /**
146
- * @param {string} domString
147
- * @return {this} - This instance of the settings object.
148
- */
149
- withDom(domString) {
150
- this._sendDom = true
151
- this._domString = domString
152
- return this
153
- }
154
-
155
- /**
156
- * @package
157
- * @return {string}
158
- */
159
- getDomString() {
160
- return this._domString
161
- }
162
-
163
- /**
164
- * @param {Location|LocationObject} location
165
- * @return {this} - This instance of the settings object.
166
- */
167
- withLocation(location) {
168
- this._imageLocation = new Location(location)
169
- return this
170
- }
171
-
172
- /**
173
- * @package
174
- * @return {Location}
175
- */
176
- getImageLocation() {
177
- return this._imageLocation
178
- }
179
-
180
- /**
181
- * @param {boolean} [ignoreMismatch=true] - True if the server should ignore a negative result for the visual validation.
182
- * Default value is `false`, but if you call to .ignoreMismatch() without arguments it will set value to `true`.
183
- * @return {this}
184
- */
185
- ignoreMismatch(ignoreMismatch = true) {
186
- this._ignoreMismatch = ignoreMismatch
187
- return this
188
- }
189
-
190
- /**
191
- * @package
192
- * @return {boolean}
193
- */
194
- getIgnoreMismatch() {
195
- return this._ignoreMismatch
196
- }
197
-
198
- /**
199
- * @param {Region|RegionObject} region - The region to validate.
200
- * @return {this}
201
- */
202
- region(region) {
203
- super.updateTargetRegion(region)
204
- return this
205
- }
206
-
207
- variantId(variantId) {
208
- this._variantId = variantId
209
- return this
210
- }
211
-
212
- getVariantId() {
213
- return this._variantId
214
- }
215
- }
216
-
217
- exports.ImagesCheckSettings = ImagesCheckSettings
@@ -1,158 +0,0 @@
1
- 'use strict'
2
-
3
- const {ImageProvider, MutableImage, TypeUtils, ArgumentGuard} = require('@applitools/eyes-sdk-core')
4
-
5
- const {ImagesCheckSettings} = require('./ImagesCheckSettings')
6
-
7
- class Target {
8
- /**
9
- * @signature `image(base64String)`
10
- * @sigparam {string} base64String - A base64 encoded image to use as the checkpoint image
11
- *
12
- * @signature `image(url)`
13
- * @sigparam {string} url - A URL of the PNG image to download and use as the checkpoint image
14
- *
15
- * @signature `image(filePath)`
16
- * @sigparam {string} filePath - Path to a local PNG file to use as the checkpoint image
17
- *
18
- * @signature `image(imageBuffer)`
19
- * @sigparam {Buffer} imageBuffer - A Buffer object that contains an image to use as checkpoint image
20
- *
21
- * @signature `image(mutableImage)`
22
- * @sigparam {MutableImage} mutableImage - An in memory image to use as the checkpoint image
23
- *
24
- * @signature `image(imageProvider)`
25
- * @sigparam {ImageProvider} imageProvider - An instance of class (object) which implements {@link ImageProvider}
26
- * (has a method called {@code getImage} which returns {@code Promise<MutableImage>})
27
- *
28
- * @param {string|Buffer|ImageProvider|MutableImage} varArg
29
- * @return {ImagesCheckSettings}
30
- */
31
- static image(varArg) {
32
- if (varArg instanceof MutableImage) {
33
- return new ImagesCheckSettings(varArg)
34
- }
35
-
36
- if (varArg instanceof ImageProvider) {
37
- return Target.imageProvider(varArg)
38
- }
39
-
40
- if (TypeUtils.isBuffer(varArg)) {
41
- return Target.buffer(varArg)
42
- }
43
-
44
- if (TypeUtils.isBase64(varArg)) {
45
- return Target.base64(varArg)
46
- }
47
-
48
- if (TypeUtils.isUrl(varArg)) {
49
- return Target.url(varArg)
50
- }
51
-
52
- if (TypeUtils.isString(varArg)) {
53
- return Target.path(varArg)
54
- }
55
-
56
- throw new TypeError('IllegalType: unsupported type of image!')
57
- }
58
-
59
- /**
60
- * @param {Buffer} imageBuffer
61
- * @return {ImagesCheckSettings}
62
- */
63
- static buffer(imageBuffer) {
64
- ArgumentGuard.isBuffer(imageBuffer, 'buffer')
65
-
66
- const checkSettings = new ImagesCheckSettings()
67
- checkSettings.setImageBuffer(imageBuffer)
68
- return checkSettings
69
- }
70
-
71
- /**
72
- * @param {string} imageBase64
73
- * @return {ImagesCheckSettings}
74
- */
75
- static base64(imageBase64) {
76
- ArgumentGuard.isBase64(imageBase64)
77
-
78
- const checkSettings = new ImagesCheckSettings()
79
- checkSettings.setImageString(imageBase64)
80
- return checkSettings
81
- }
82
-
83
- /**
84
- * @param {string} imagePath
85
- * @return {ImagesCheckSettings}
86
- */
87
- static path(imagePath) {
88
- ArgumentGuard.isString(imagePath, 'path')
89
-
90
- const checkSettings = new ImagesCheckSettings()
91
- checkSettings.setImagePath(imagePath)
92
- return checkSettings
93
- }
94
-
95
- /**
96
- * @param {string} imageUrl
97
- * @param {RectangleSize} [imageSize]
98
- * @return {ImagesCheckSettings}
99
- */
100
- static url(imageUrl, imageSize) {
101
- ArgumentGuard.isString(imageUrl, 'url')
102
-
103
- const checkSettings = new ImagesCheckSettings()
104
- checkSettings.setImageUrl(imageUrl, imageSize)
105
- return checkSettings
106
- }
107
-
108
- /**
109
- * @param {ImageProvider} imageProvider
110
- * @return {ImagesCheckSettings}
111
- */
112
- static imageProvider(imageProvider) {
113
- ArgumentGuard.isValidType(imageProvider, ImageProvider)
114
-
115
- const checkSettings = new ImagesCheckSettings()
116
- checkSettings.setImageProvider(imageProvider)
117
- return checkSettings
118
- }
119
-
120
- /**
121
- * @signature `region(base64String, rect)`
122
- * @sigparam {string} base64String - A base64 encoded image to use as the checkpoint image
123
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
124
- *
125
- * @signature `region(url, rect)`
126
- * @sigparam {string} url - A URL of the PNG image to download and use as the checkpoint image
127
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
128
- *
129
- * @signature `region(filePath, rect)`
130
- * @sigparam {string} filePath - Path to a local PNG file to use as the checkpoint image
131
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
132
- *
133
- * @signature `region(imageBuffer, rect)`
134
- * @sigparam {Buffer} imageBuffer - A Buffer object that contains an image to use as checkpoint image
135
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
136
- *
137
- * @signature `region(mutableImage, rect)`
138
- * @sigparam {MutableImage} mutableImage - An in memory image to use as the checkpoint image
139
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
140
- *
141
- * @signature `region(imageProvider, rect)`
142
- * @sigparam {ImageProvider} imageProvider - An instance of class (object) which implements {@link ImageProvider}
143
- * (has a method called {@code getImage} which returns {@code Promise<MutableImage>})
144
- * @sigparam {Region|RegionObject} rect - A region within the image to be checked
145
- *
146
- * @param {string|Buffer|MutableImage} image
147
- * @param {Region|RegionObject} rect
148
- * @return {ImagesCheckSettings}
149
- */
150
- static region(image, rect) {
151
- const checkSettings = Target.image(image)
152
-
153
- checkSettings.region(rect)
154
- return checkSettings
155
- }
156
- }
157
-
158
- exports.Target = Target