@webstudio-is/image 0.273.0 → 0.274.1
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/lib/index.js +10 -4
- package/package.json +4 -4
package/lib/index.js
CHANGED
|
@@ -181,6 +181,15 @@ var joinPath = (...segments) => {
|
|
|
181
181
|
var encodePathFragment = (fragment) => {
|
|
182
182
|
return encodeURIComponent(fragment).replace(/%2F/g, "/");
|
|
183
183
|
};
|
|
184
|
+
var getImageSource = (src) => {
|
|
185
|
+
if (src.startsWith("/cgi/asset")) {
|
|
186
|
+
return decodeURIComponent(src.slice("/cgi/asset".length).split("?")[0]);
|
|
187
|
+
}
|
|
188
|
+
if (src.startsWith("/cgi/image")) {
|
|
189
|
+
return decodeURIComponent(src.slice("/cgi/image".length).split("?")[0]);
|
|
190
|
+
}
|
|
191
|
+
return src;
|
|
192
|
+
};
|
|
184
193
|
var wsImageLoader = (props) => {
|
|
185
194
|
const width = props.format === "raw" ? 16 : props.width;
|
|
186
195
|
const quality = props.format === "raw" ? 100 : props.quality;
|
|
@@ -190,10 +199,7 @@ var wsImageLoader = (props) => {
|
|
|
190
199
|
"Width must be only from allowed values"
|
|
191
200
|
);
|
|
192
201
|
}
|
|
193
|
-
|
|
194
|
-
if (src.startsWith("/cgi/asset")) {
|
|
195
|
-
src = src.slice("/cgi/asset".length);
|
|
196
|
-
}
|
|
202
|
+
const src = getImageSource(props.src);
|
|
197
203
|
const resultUrl = new URL("/cgi/image/", NON_EXISTING_DOMAIN);
|
|
198
204
|
if (props.format !== "raw") {
|
|
199
205
|
resultUrl.searchParams.set("width", width.toString());
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webstudio-is/image",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.274.1",
|
|
4
4
|
"description": "Image optimization",
|
|
5
5
|
"author": "Webstudio <github@webstudio.is>",
|
|
6
6
|
"homepage": "https://webstudio.is",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
10
10
|
"warn-once": "^0.1.1",
|
|
11
|
-
"@webstudio-is/sdk": "0.
|
|
11
|
+
"@webstudio-is/sdk": "0.274.1"
|
|
12
12
|
},
|
|
13
13
|
"devDependencies": {
|
|
14
14
|
"@types/react": "^18.2.70",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"react": "18.3.0-canary-14898b6a9-20240318",
|
|
17
17
|
"react-dom": "18.3.0-canary-14898b6a9-20240318",
|
|
18
18
|
"vitest": "^3.1.2",
|
|
19
|
-
"@webstudio-is/
|
|
20
|
-
"@webstudio-is/
|
|
19
|
+
"@webstudio-is/design-system": "0.0.0",
|
|
20
|
+
"@webstudio-is/tsconfig": "1.0.7"
|
|
21
21
|
},
|
|
22
22
|
"peerDependencies": {
|
|
23
23
|
"react": "18.3.0-canary-14898b6a9-20240318",
|