@gravity-ui/page-constructor 2.1.0 → 2.2.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.2.0](https://github.com/gravity-ui/page-constructor/compare/v2.1.1...v2.2.0) (2023-03-29)
4
+
5
+
6
+ ### Features
7
+
8
+ * dropdown a ReactPlayer version ([#254](https://github.com/gravity-ui/page-constructor/issues/254)) ([fec1c3f](https://github.com/gravity-ui/page-constructor/commit/fec1c3fee50dcd86d08c0501f80d7aca0795e026))
9
+
10
+ ## [2.1.1](https://github.com/gravity-ui/page-constructor/compare/v2.1.0...v2.1.1) (2023-03-28)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * quotes validator schema ([#247](https://github.com/gravity-ui/page-constructor/issues/247)) ([87b8587](https://github.com/gravity-ui/page-constructor/commit/87b8587bcd5fe2bb96b5d70aae9eb6ca9e189f33))
16
+
3
17
  ## [2.1.0](https://github.com/gravity-ui/page-constructor/compare/v2.0.3...v2.1.0) (2023-03-27)
4
18
 
5
19
 
package/README.md CHANGED
@@ -306,6 +306,13 @@ In usual cases we use two types of commits:
306
306
  1. fix: a commit of the type fix patches a bug in your codebase (this correlates with PATCH in Semantic Versioning).
307
307
  2. feat: a commit of the type feat introduces a new feature to the codebase (this correlates with MINOR in Semantic Versioning).
308
308
  3. BREAKING CHANGE: a commit that has a footer BREAKING CHANGE:, or appends a ! after the type/scope, introduces a breaking API change (correlating with MAJOR in Semantic Versioning). A BREAKING CHANGE can be part of commits of any type.
309
+ 4. To set release package version manually you need to add `Release-As: <version>` to your commit message e.g.
310
+
311
+ ```bash
312
+ git commit -m 'chore: bump release
313
+
314
+ Release-As: 1.2.3'
315
+ ```
309
316
 
310
317
  You can see all information [here](https://www.conventionalcommits.org/en/v1.0.0/).
311
318
 
@@ -14,6 +14,7 @@ const metrikaContext_1 = require("../../context/metrikaContext");
14
14
  const mobileContext_1 = require("../../context/mobileContext");
15
15
  const hooks_1 = require("../../hooks");
16
16
  const icons_1 = require("../../icons");
17
+ const utils_2 = require("./utils");
17
18
  const b = (0, utils_1.block)('ReactPlayer');
18
19
  const FPS = 60;
19
20
  // eslint-disable-next-line react/display-name
@@ -35,6 +36,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
35
36
  const [started, setStarted] = (0, react_1.useState)(autoPlay);
36
37
  const [paused, setPaused] = (0, react_1.useState)(false);
37
38
  const [ended, setEnded] = (0, react_1.useState)(false);
39
+ const videoSrc = (0, react_1.useMemo)(() => (0, utils_2.checkYoutubeVideos)(src), [src]);
38
40
  const eventsArray = (0, react_1.useMemo)(() => {
39
41
  if (analyticsEvents) {
40
42
  return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
@@ -193,7 +195,7 @@ exports.ReactPlayerBlock = react_1.default.forwardRef((props, originRef) => {
193
195
  }, elapsedTimePercent: elapsedTimePercent }));
194
196
  }, [controls, isPlaying, customBarControlsClassName, changeMute]);
195
197
  return (react_1.default.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
196
- react_1.default.createElement(react_player_1.default, { className: b('player'), url: src, muted: muted, controls: controls === models_1.MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
198
+ react_1.default.createElement(react_player_1.default, { className: b('player'), url: videoSrc, muted: muted, controls: controls === models_1.MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
197
199
  renderCustomBarControls(muted, playedPercent)));
198
200
  });
199
201
  function getHeight(width) {
@@ -0,0 +1 @@
1
+ export declare const checkYoutubeVideos: (src: string | string[]) => string | string[];
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkYoutubeVideos = void 0;
4
+ // the file serves to support live video with react-player@2.9
5
+ const LIVE_YUOTUBE_VIDEO_REGEX = /(?:youtu\.be\/live\/|youtube(?:-nocookie)?\.com\/(?:live\/))((\w|-){11})/;
6
+ const YOUTUBE_VIDEO_TEMPLATE = 'https://www.youtube.com/watch?v=';
7
+ const checkYoutubeVideos = (src) => {
8
+ if (Array.isArray(src)) {
9
+ return src.map((videoUrl) => {
10
+ var _a;
11
+ if (LIVE_YUOTUBE_VIDEO_REGEX.test(videoUrl)) {
12
+ const youtubeLiveId = (_a = videoUrl.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
13
+ if (!youtubeLiveId) {
14
+ return videoUrl;
15
+ }
16
+ return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
17
+ }
18
+ return videoUrl;
19
+ });
20
+ }
21
+ return src;
22
+ };
23
+ exports.checkYoutubeVideos = checkYoutubeVideos;
@@ -38,6 +38,9 @@ export declare const Quote: {
38
38
  type: string;
39
39
  pattern: string;
40
40
  };
41
+ buttonText: {
42
+ type: string;
43
+ };
41
44
  theme: {
42
45
  type: string;
43
46
  enum: string[];
@@ -18,6 +18,8 @@ exports.Quote = {
18
18
  }, url: {
19
19
  type: 'string',
20
20
  pattern: schema_1.urlPattern,
21
+ }, buttonText: {
22
+ type: 'string',
21
23
  }, theme: common_1.ThemeProps, author: common_1.authorItem }),
22
24
  },
23
25
  };
@@ -10,6 +10,7 @@ import { MetrikaContext } from '../../context/metrikaContext';
10
10
  import { MobileContext } from '../../context/mobileContext';
11
11
  import { useAnalytics } from '../../hooks';
12
12
  import { PlayVideo } from '../../icons';
13
+ import { checkYoutubeVideos } from './utils';
13
14
  import './ReactPlayer.css';
14
15
  const b = block('ReactPlayer');
15
16
  const FPS = 60;
@@ -32,6 +33,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
32
33
  const [started, setStarted] = useState(autoPlay);
33
34
  const [paused, setPaused] = useState(false);
34
35
  const [ended, setEnded] = useState(false);
36
+ const videoSrc = useMemo(() => checkYoutubeVideos(src), [src]);
35
37
  const eventsArray = useMemo(() => {
36
38
  if (analyticsEvents) {
37
39
  return Array.isArray(analyticsEvents) ? analyticsEvents : [analyticsEvents];
@@ -190,7 +192,7 @@ export const ReactPlayerBlock = React.forwardRef((props, originRef) => {
190
192
  }, elapsedTimePercent: elapsedTimePercent }));
191
193
  }, [controls, isPlaying, customBarControlsClassName, changeMute]);
192
194
  return (React.createElement("div", { className: b({ wrapper: !currentHeight }, className), ref: ref, onClick: handleClick },
193
- React.createElement(ReactPlayer, { className: b('player'), url: src, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
195
+ React.createElement(ReactPlayer, { className: b('player'), url: videoSrc, muted: muted, controls: controls === MediaVideoControlsType.Default, height: currentHeight || '100%', width: width || '100%', light: previewImgUrl, playing: isPlaying, playIcon: playIcon, progressInterval: FPS, onClickPreview: handleClickPreview, onStart: onStart, onReady: setPlayerRef, onPlay: onPlay, onPause: onPause, onProgress: onProgress, onEnded: onEnded }),
194
196
  renderCustomBarControls(muted, playedPercent)));
195
197
  });
196
198
  function getHeight(width) {
@@ -0,0 +1 @@
1
+ export declare const checkYoutubeVideos: (src: string | string[]) => string | string[];
@@ -0,0 +1,19 @@
1
+ // the file serves to support live video with react-player@2.9
2
+ const LIVE_YUOTUBE_VIDEO_REGEX = /(?:youtu\.be\/live\/|youtube(?:-nocookie)?\.com\/(?:live\/))((\w|-){11})/;
3
+ const YOUTUBE_VIDEO_TEMPLATE = 'https://www.youtube.com/watch?v=';
4
+ export const checkYoutubeVideos = (src) => {
5
+ if (Array.isArray(src)) {
6
+ return src.map((videoUrl) => {
7
+ var _a;
8
+ if (LIVE_YUOTUBE_VIDEO_REGEX.test(videoUrl)) {
9
+ const youtubeLiveId = (_a = videoUrl.match(LIVE_YUOTUBE_VIDEO_REGEX)) === null || _a === void 0 ? void 0 : _a[1];
10
+ if (!youtubeLiveId) {
11
+ return videoUrl;
12
+ }
13
+ return `${YOUTUBE_VIDEO_TEMPLATE}${youtubeLiveId}`;
14
+ }
15
+ return videoUrl;
16
+ });
17
+ }
18
+ return src;
19
+ };
@@ -38,6 +38,9 @@ export declare const Quote: {
38
38
  type: string;
39
39
  pattern: string;
40
40
  };
41
+ buttonText: {
42
+ type: string;
43
+ };
41
44
  theme: {
42
45
  type: string;
43
46
  enum: string[];
@@ -15,6 +15,8 @@ export const Quote = {
15
15
  }, url: {
16
16
  type: 'string',
17
17
  pattern: urlPattern,
18
+ }, buttonText: {
19
+ type: 'string',
18
20
  }, theme: ThemeProps, author: authorItem }),
19
21
  },
20
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -50,7 +50,7 @@
50
50
  "bem-cn-lite": "^4.0.0",
51
51
  "github-buttons": "2.23.0",
52
52
  "lodash": "^4.17.21",
53
- "react-player": "^2.12.0",
53
+ "react-player": "^2.9.0",
54
54
  "react-slick": "^0.28.1",
55
55
  "react-spring": "^9.3.0",
56
56
  "react-transition-group": "^4.4.2",