@websolutespa/bom-mixer-image 1.8.4 → 2.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.
- package/CHANGELOG.md +110 -104
- package/dist/index.js +6 -1
- package/dist/index.mjs +6 -1
- package/package.json +6 -6
- package/src/image/image.handler.ts +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,104 +1,110 @@
|
|
|
1
|
-
# @websolutespa/bom-mixer-image
|
|
2
|
-
|
|
3
|
-
##
|
|
4
|
-
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
-
|
|
8
|
-
|
|
9
|
-
## 1.8.
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
## 1.8.
|
|
24
|
-
|
|
25
|
-
### Patch Changes
|
|
26
|
-
|
|
27
|
-
- Modified: imageHandler
|
|
28
|
-
|
|
29
|
-
## 1.8.
|
|
30
|
-
|
|
31
|
-
### Patch Changes
|
|
32
|
-
|
|
33
|
-
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
-
|
|
49
|
-
|
|
50
|
-
## 1.0.
|
|
51
|
-
|
|
52
|
-
### Patch Changes
|
|
53
|
-
|
|
54
|
-
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
-
|
|
63
|
-
|
|
64
|
-
## 1.0.
|
|
65
|
-
|
|
66
|
-
### Patch Changes
|
|
67
|
-
|
|
68
|
-
- Modified: imageHandler
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
-
|
|
93
|
-
|
|
94
|
-
## 1.0.
|
|
95
|
-
|
|
96
|
-
### Patch Changes
|
|
97
|
-
|
|
98
|
-
-
|
|
99
|
-
|
|
100
|
-
## 1.0.
|
|
101
|
-
|
|
102
|
-
### Patch Changes
|
|
103
|
-
|
|
104
|
-
-
|
|
1
|
+
# @websolutespa/bom-mixer-image
|
|
2
|
+
|
|
3
|
+
## 2.0.0
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- Release: Bom 2.0
|
|
8
|
+
|
|
9
|
+
## 1.8.4
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- Fixing: handling latin1 src
|
|
14
|
+
|
|
15
|
+
## 1.8.3
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Added: ImageStrategy.Token
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- @websolutespa/bom-core@1.8.4
|
|
22
|
+
|
|
23
|
+
## 1.8.2
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- Modified: imageHandler
|
|
28
|
+
|
|
29
|
+
## 1.8.1
|
|
30
|
+
|
|
31
|
+
### Patch Changes
|
|
32
|
+
|
|
33
|
+
- Modified: imageHandler
|
|
34
|
+
|
|
35
|
+
## 1.8.0
|
|
36
|
+
|
|
37
|
+
### Patch Changes
|
|
38
|
+
|
|
39
|
+
- Updated dependencies [f8a1d97]
|
|
40
|
+
- @websolutespa/bom-core@1.8.0
|
|
41
|
+
|
|
42
|
+
## 1.0.9
|
|
43
|
+
|
|
44
|
+
### Patch Changes
|
|
45
|
+
|
|
46
|
+
- Fixing: downgrading eslint to v8.56.0
|
|
47
|
+
- Updated dependencies
|
|
48
|
+
- @websolutespa/bom-core@1.7.8
|
|
49
|
+
|
|
50
|
+
## 1.0.8
|
|
51
|
+
|
|
52
|
+
### Patch Changes
|
|
53
|
+
|
|
54
|
+
- Added: Cache-Control
|
|
55
|
+
|
|
56
|
+
## 1.0.7
|
|
57
|
+
|
|
58
|
+
### Patch Changes
|
|
59
|
+
|
|
60
|
+
- Fixing: imageHandler Vercel support
|
|
61
|
+
- Updated dependencies
|
|
62
|
+
- @websolutespa/bom-core@1.7.7
|
|
63
|
+
|
|
64
|
+
## 1.0.6
|
|
65
|
+
|
|
66
|
+
### Patch Changes
|
|
67
|
+
|
|
68
|
+
- Modified: imageHandler, re-route not found to origin
|
|
69
|
+
|
|
70
|
+
## 1.0.5
|
|
71
|
+
|
|
72
|
+
### Patch Changes
|
|
73
|
+
|
|
74
|
+
- Modified: imageHandler
|
|
75
|
+
- Updated dependencies
|
|
76
|
+
- @websolutespa/bom-core@1.7.6
|
|
77
|
+
|
|
78
|
+
## 1.0.4
|
|
79
|
+
|
|
80
|
+
### Patch Changes
|
|
81
|
+
|
|
82
|
+
- Modified: imageHandler getOriginalImage
|
|
83
|
+
- Updated dependencies
|
|
84
|
+
- @websolutespa/bom-core@1.7.5
|
|
85
|
+
|
|
86
|
+
## 1.0.3
|
|
87
|
+
|
|
88
|
+
### Patch Changes
|
|
89
|
+
|
|
90
|
+
- 43957d4: Fixing: production local asset public path
|
|
91
|
+
- Updated dependencies
|
|
92
|
+
- @websolutespa/bom-core@1.7.4
|
|
93
|
+
|
|
94
|
+
## 1.0.2
|
|
95
|
+
|
|
96
|
+
### Patch Changes
|
|
97
|
+
|
|
98
|
+
- 75b1311: Fixing: relative paths
|
|
99
|
+
|
|
100
|
+
## 1.0.1
|
|
101
|
+
|
|
102
|
+
### Patch Changes
|
|
103
|
+
|
|
104
|
+
- Updating: dependencies
|
|
105
|
+
|
|
106
|
+
## 1.0.0
|
|
107
|
+
|
|
108
|
+
### Patch Changes
|
|
109
|
+
|
|
110
|
+
- Added: first release
|
package/dist/index.js
CHANGED
|
@@ -108,7 +108,9 @@ function imageHandler({
|
|
|
108
108
|
}
|
|
109
109
|
const originalImageBuffer = await getOriginalImage(imageOptions.url, domains, request.headers);
|
|
110
110
|
if (originalImageBuffer) {
|
|
111
|
-
const originalImage = (0, import_sharp.default)(originalImageBuffer
|
|
111
|
+
const originalImage = (0, import_sharp.default)(originalImageBuffer, {
|
|
112
|
+
animated: isGIF(imageOptions.url)
|
|
113
|
+
});
|
|
112
114
|
const resizedImage = await resizeImage(originalImage, imageOptions);
|
|
113
115
|
const compressedImage = resizedImage.webp({
|
|
114
116
|
quality: imageOptions.q
|
|
@@ -132,6 +134,9 @@ function imageHandler({
|
|
|
132
134
|
}
|
|
133
135
|
});
|
|
134
136
|
}
|
|
137
|
+
function isGIF(src) {
|
|
138
|
+
return src.indexOf(".gif") !== -1;
|
|
139
|
+
}
|
|
135
140
|
function isInvalidReferer(request) {
|
|
136
141
|
const { headers } = request;
|
|
137
142
|
const referer = headers.referer;
|
package/dist/index.mjs
CHANGED
|
@@ -72,7 +72,9 @@ function imageHandler({
|
|
|
72
72
|
}
|
|
73
73
|
const originalImageBuffer = await getOriginalImage(imageOptions.url, domains, request.headers);
|
|
74
74
|
if (originalImageBuffer) {
|
|
75
|
-
const originalImage = sharp(originalImageBuffer
|
|
75
|
+
const originalImage = sharp(originalImageBuffer, {
|
|
76
|
+
animated: isGIF(imageOptions.url)
|
|
77
|
+
});
|
|
76
78
|
const resizedImage = await resizeImage(originalImage, imageOptions);
|
|
77
79
|
const compressedImage = resizedImage.webp({
|
|
78
80
|
quality: imageOptions.q
|
|
@@ -96,6 +98,9 @@ function imageHandler({
|
|
|
96
98
|
}
|
|
97
99
|
});
|
|
98
100
|
}
|
|
101
|
+
function isGIF(src) {
|
|
102
|
+
return src.indexOf(".gif") !== -1;
|
|
103
|
+
}
|
|
99
104
|
function isInvalidReferer(request) {
|
|
100
105
|
const { headers } = request;
|
|
101
106
|
const referer = headers.referer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@websolutespa/bom-mixer-image",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Mixer Image module of the BOM Repository",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"bom",
|
|
@@ -24,17 +24,17 @@
|
|
|
24
24
|
},
|
|
25
25
|
"dependencies": {},
|
|
26
26
|
"peerDependencies": {
|
|
27
|
-
"@websolutespa/bom-core": "
|
|
27
|
+
"@websolutespa/bom-core": "^2.0.0",
|
|
28
28
|
"next": ">= 14.1.4",
|
|
29
29
|
"sharp": ">= 0.30.4"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
32
|
"@types/sharp": "^0.30.4",
|
|
33
|
-
"@websolutespa/bom-cli": "
|
|
34
|
-
"@websolutespa/test": "
|
|
35
|
-
"@websolutespa/tsconfig": "
|
|
33
|
+
"@websolutespa/bom-cli": "^2.0.0",
|
|
34
|
+
"@websolutespa/test": "^2.0.0",
|
|
35
|
+
"@websolutespa/tsconfig": "^2.0.0",
|
|
36
36
|
"eslint": "^8.56.0",
|
|
37
|
-
"eslint-config-websolute": "
|
|
37
|
+
"eslint-config-websolute": "^2.0.0",
|
|
38
38
|
"npm-run-all": "^4.1.5",
|
|
39
39
|
"sharp": "0.30.4",
|
|
40
40
|
"ts-node": "^10.9.1",
|
|
@@ -84,7 +84,9 @@ export function imageHandler({
|
|
|
84
84
|
// Checking if the original image exists
|
|
85
85
|
if (originalImageBuffer) {
|
|
86
86
|
// Original image
|
|
87
|
-
const originalImage = sharp(originalImageBuffer
|
|
87
|
+
const originalImage = sharp(originalImageBuffer, {
|
|
88
|
+
animated: isGIF(imageOptions.url),
|
|
89
|
+
});
|
|
88
90
|
// Resizing the original image and converting it to WebP format
|
|
89
91
|
const resizedImage = await resizeImage(originalImage, imageOptions);
|
|
90
92
|
// Converting resized image to WebP format
|
|
@@ -121,6 +123,10 @@ export function imageHandler({
|
|
|
121
123
|
});
|
|
122
124
|
}
|
|
123
125
|
|
|
126
|
+
function isGIF(src: string): boolean {
|
|
127
|
+
return src.indexOf('.gif') !== -1;
|
|
128
|
+
}
|
|
129
|
+
|
|
124
130
|
function isInvalidReferer(request: NextApiRequest): boolean {
|
|
125
131
|
const { headers } = request;
|
|
126
132
|
const referer = headers.referer;
|