@gravity-ui/page-constructor 2.2.1 → 2.3.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 +7 -0
- package/README.md +1 -1
- package/build/cjs/components/Image/Image.js +2 -2
- package/build/cjs/utils/imageCompress.d.ts +6 -0
- package/build/cjs/utils/imageCompress.js +11 -0
- package/build/esm/components/Image/Image.js +2 -2
- package/build/esm/utils/imageCompress.d.ts +6 -0
- package/build/esm/utils/imageCompress.js +7 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [2.3.0](https://github.com/gravity-ui/page-constructor/compare/v2.2.1...v2.3.0) (2023-04-03)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add whitelist of image extenstions which can be compressed ([#215](https://github.com/gravity-ui/page-constructor/issues/215)) ([136034b](https://github.com/gravity-ui/page-constructor/commit/136034b642f7c044c00402cf2e0527ae8a099aeb))
|
|
9
|
+
|
|
3
10
|
## [2.2.1](https://github.com/gravity-ui/page-constructor/compare/v2.2.0...v2.2.1) (2023-03-30)
|
|
4
11
|
|
|
5
12
|
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @gravity-ui/page-constructor · [](https://www.npmjs.com/package/@gravity-ui/page-constructor) [](https://www.npmjs.com/package/@gravity-ui/page-constructor) [](https://github.com/gravity-ui/page-constructor/actions/workflows/ci.yml?query=branch:main) [](https://github.com/gravity-ui/page-constructor/actions/workflows/release.yml?query=branch:main) [](https://preview.yandexcloud.dev/page-constructor/)
|
|
2
2
|
|
|
3
3
|
## Install
|
|
4
4
|
|
|
@@ -4,6 +4,7 @@ const tslib_1 = require("tslib");
|
|
|
4
4
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
5
5
|
const projectSettingsContext_1 = require("../../context/projectSettingsContext");
|
|
6
6
|
const constants_1 = require("../../constants");
|
|
7
|
+
const imageCompress_1 = require("../../utils/imageCompress");
|
|
7
8
|
const checkWebP = (src) => {
|
|
8
9
|
return src.endsWith('.webp') ? src : src + '.webp';
|
|
9
10
|
};
|
|
@@ -15,10 +16,9 @@ const Image = (props) => {
|
|
|
15
16
|
if (!imageSrc) {
|
|
16
17
|
return null;
|
|
17
18
|
}
|
|
18
|
-
// TODO: Temporary solution for .svg images
|
|
19
19
|
const disableWebp = projectSettings.disableCompress ||
|
|
20
20
|
disableCompress ||
|
|
21
|
-
|
|
21
|
+
!(0, imageCompress_1.isCompressible)(imageSrc) ||
|
|
22
22
|
imgLoadingError;
|
|
23
23
|
return (react_1.default.createElement("picture", { className: containerClassName },
|
|
24
24
|
mobile && (react_1.default.createElement(react_1.Fragment, null,
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCompressible = exports.AvailableForCompressExtension = void 0;
|
|
4
|
+
var AvailableForCompressExtension;
|
|
5
|
+
(function (AvailableForCompressExtension) {
|
|
6
|
+
AvailableForCompressExtension["PNG"] = "png";
|
|
7
|
+
AvailableForCompressExtension["JPG"] = "jpg";
|
|
8
|
+
AvailableForCompressExtension["JPEG"] = "jpeg";
|
|
9
|
+
})(AvailableForCompressExtension = exports.AvailableForCompressExtension || (exports.AvailableForCompressExtension = {}));
|
|
10
|
+
const isCompressible = (fileName) => Object.keys(AvailableForCompressExtension).some((ext) => fileName.endsWith(`.${ext}`));
|
|
11
|
+
exports.isCompressible = isCompressible;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useState, Fragment } from 'react';
|
|
2
2
|
import { ProjectSettingsContext } from '../../context/projectSettingsContext';
|
|
3
3
|
import { BREAKPOINTS } from '../../constants';
|
|
4
|
+
import { isCompressible } from '../../utils/imageCompress';
|
|
4
5
|
const checkWebP = (src) => {
|
|
5
6
|
return src.endsWith('.webp') ? src : src + '.webp';
|
|
6
7
|
};
|
|
@@ -12,10 +13,9 @@ const Image = (props) => {
|
|
|
12
13
|
if (!imageSrc) {
|
|
13
14
|
return null;
|
|
14
15
|
}
|
|
15
|
-
// TODO: Temporary solution for .svg images
|
|
16
16
|
const disableWebp = projectSettings.disableCompress ||
|
|
17
17
|
disableCompress ||
|
|
18
|
-
imageSrc
|
|
18
|
+
!isCompressible(imageSrc) ||
|
|
19
19
|
imgLoadingError;
|
|
20
20
|
return (React.createElement("picture", { className: containerClassName },
|
|
21
21
|
mobile && (React.createElement(Fragment, null,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export var AvailableForCompressExtension;
|
|
2
|
+
(function (AvailableForCompressExtension) {
|
|
3
|
+
AvailableForCompressExtension["PNG"] = "png";
|
|
4
|
+
AvailableForCompressExtension["JPG"] = "jpg";
|
|
5
|
+
AvailableForCompressExtension["JPEG"] = "jpeg";
|
|
6
|
+
})(AvailableForCompressExtension || (AvailableForCompressExtension = {}));
|
|
7
|
+
export const isCompressible = (fileName) => Object.keys(AvailableForCompressExtension).some((ext) => fileName.endsWith(`.${ext}`));
|