@gravity-ui/page-constructor 5.0.1 → 5.1.1-alpha.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.
Files changed (31) hide show
  1. package/build/cjs/components/BackgroundMedia/BackgroundMedia.js +4 -1
  2. package/build/cjs/components/DefaultVideo/DefaultVideo.d.ts +1 -0
  3. package/build/cjs/components/DefaultVideo/DefaultVideo.js +19 -2
  4. package/build/cjs/components/Media/Media.d.ts +1 -0
  5. package/build/cjs/components/Media/Media.js +12 -1
  6. package/build/cjs/components/Media/Video/Video.d.ts +3 -1
  7. package/build/cjs/components/Media/Video/Video.js +22 -2
  8. package/build/cjs/containers/PageConstructor/Provider.d.ts +1 -0
  9. package/build/cjs/containers/PageConstructor/Provider.js +10 -1
  10. package/build/cjs/context/blockPreloadVideoMetadataContext/blockPreloadVideoMetadataContext.d.ts +2 -0
  11. package/build/cjs/context/blockPreloadVideoMetadataContext/blockPreloadVideoMetadataContext.js +8 -0
  12. package/build/cjs/context/blockPreloadVideoMetadataContext/index.d.ts +1 -0
  13. package/build/cjs/context/blockPreloadVideoMetadataContext/index.js +6 -0
  14. package/build/cjs/models/constructor-items/common.d.ts +1 -2
  15. package/build/esm/components/BackgroundMedia/BackgroundMedia.js +4 -1
  16. package/build/esm/components/DefaultVideo/DefaultVideo.d.ts +1 -0
  17. package/build/esm/components/DefaultVideo/DefaultVideo.js +20 -3
  18. package/build/esm/components/Media/Media.d.ts +1 -0
  19. package/build/esm/components/Media/Media.js +12 -1
  20. package/build/esm/components/Media/Video/Video.d.ts +3 -1
  21. package/build/esm/components/Media/Video/Video.js +21 -3
  22. package/build/esm/containers/PageConstructor/Provider.d.ts +1 -0
  23. package/build/esm/containers/PageConstructor/Provider.js +10 -1
  24. package/build/esm/context/blockPreloadVideoMetadataContext/blockPreloadVideoMetadataContext.d.ts +2 -0
  25. package/build/esm/context/blockPreloadVideoMetadataContext/blockPreloadVideoMetadataContext.js +4 -0
  26. package/build/esm/context/blockPreloadVideoMetadataContext/index.d.ts +1 -0
  27. package/build/esm/context/blockPreloadVideoMetadataContext/index.js +3 -0
  28. package/build/esm/models/constructor-items/common.d.ts +1 -2
  29. package/package.json +4 -4
  30. package/server/models/constructor-items/common.d.ts +1 -2
  31. package/widget/index.js +1 -1
@@ -13,6 +13,9 @@ const BackgroundMedia = (_a) => {
13
13
  const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'media');
14
14
  return (react_1.default.createElement(AnimateBlock_1.default, { className: b(null, className), style: { backgroundColor: color }, animate: animated, qa: qaAttributes.animate },
15
15
  react_1.default.createElement(Media_1.default, Object.assign({ className: b('media', { 'full-width-media': fullWidthMedia }, mediaClassName), imageClassName: b('image'), videoClassName: b('video'), isBackground: true, qa: qaAttributes.media }, Object.assign({ height: 720, color,
16
- parallax, video: isMobile ? undefined : video }, props)))));
16
+ parallax, video: isMobile ? undefined : video }, props), {
17
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
18
+ // temporal solution for Safari 17
19
+ shouldPreload: false }))));
17
20
  };
18
21
  exports.default = BackgroundMedia;
@@ -6,6 +6,7 @@ interface DefaultVideoProps {
6
6
  qa?: string;
7
7
  customBarControlsClassName?: string;
8
8
  className?: string;
9
+ shouldPreload?: boolean;
9
10
  }
10
11
  export declare const DefaultVideo: React.ForwardRefExoticComponent<DefaultVideoProps & React.RefAttributes<DefaultVideoRefType>>;
11
12
  export {};
@@ -3,18 +3,24 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.DefaultVideo = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
7
+ // temporal solution for Safari 17
8
+ const blockPreloadVideoMetadataContext_1 = require("../../context/blockPreloadVideoMetadataContext");
6
9
  const models_1 = require("../../models");
7
10
  const utils_1 = require("../../utils");
8
11
  const utils_2 = require("../Media/Video/utils");
9
12
  const CustomBarControls_1 = tslib_1.__importDefault(require("../ReactPlayer/CustomBarControls"));
10
13
  const b = (0, utils_1.block)('default-video');
11
14
  exports.DefaultVideo = react_1.default.forwardRef((props, ref) => {
12
- const { video, qa, customBarControlsClassName } = props;
15
+ const { video, qa, customBarControlsClassName, shouldPreload = true } = props;
13
16
  const { controls, customControlsOptions, muted: initiallyMuted = true } = video;
14
17
  const { muteButtonShown, positioning, type: customControlsType, } = customControlsOptions || {};
15
18
  const [isPaused, setIsPaused] = (0, react_1.useState)(false);
16
19
  const [isMuted, setIsMuted] = (0, react_1.useState)(initiallyMuted);
17
20
  const videoRef = (0, react_1.useRef)(null);
21
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
22
+ // temporal solution for Safari 17
23
+ const blockPreloadVideoMetadata = (0, react_1.useContext)(blockPreloadVideoMetadataContext_1.BlockPreloadVideoMetadataContext);
18
24
  // one may not use this hook and work with `ref` variable only, but
19
25
  // in this case one should support both function type and object type,
20
26
  // according to ForwardedRef type.
@@ -47,11 +53,22 @@ exports.DefaultVideo = react_1.default.forwardRef((props, ref) => {
47
53
  onPlayToggle();
48
54
  }
49
55
  }, [onPlayToggle, customControlsType]);
56
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
57
+ // temporal solution for Safari 17
58
+ // eslint-disable-next-line no-nested-ternary
59
+ const preload = blockPreloadVideoMetadata
60
+ ? shouldPreload
61
+ ? 'metadata'
62
+ : undefined
63
+ : 'metadata';
50
64
  return (react_1.default.createElement(react_1.Fragment, null,
51
65
  react_1.default.createElement("video", { disablePictureInPicture: true, playsInline: true,
52
66
  // @ts-ignore
53
67
  // eslint-disable-next-line react/no-unknown-property
54
- pip: "false", className: b(), ref: videoRef, preload: "metadata", muted: isMuted, "aria-label": video.ariaLabel, onClick: onClick }, (0, utils_2.getVideoTypesWithPriority)(video.src).map(({ src, type }, index) => (react_1.default.createElement("source", { key: index, src: src, type: type, "data-qa": qa })))),
68
+ pip: "false", className: b(), ref: videoRef,
69
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
70
+ // temporal solution for Safari 17
71
+ preload: preload, muted: isMuted, "aria-label": video.ariaLabel, onClick: onClick }, (0, utils_2.getVideoTypesWithPriority)(video.src).map(({ src, type }, index) => (react_1.default.createElement("source", { key: index, src: src, type: type, "data-qa": qa })))),
55
72
  controls === models_1.MediaVideoControlsType.Custom && (react_1.default.createElement(CustomBarControls_1.default, { className: customBarControlsClassName, type: customControlsType, isPaused: isPaused, onPlayClick: onPlayToggle, muteButtonShown: muteButtonShown, shown: true, positioning: positioning, mute: {
56
73
  isMuted: Boolean(isMuted),
57
74
  changeMute: onMuteToggle,
@@ -6,6 +6,7 @@ export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAddi
6
6
  youtubeClassName?: string;
7
7
  autoplay?: boolean;
8
8
  onImageLoad?: () => void;
9
+ shouldPreload?: boolean;
9
10
  }
10
11
  export declare const Media: (props: MediaAllProps) => JSX.Element;
11
12
  export default Media;
@@ -12,7 +12,10 @@ const Image_1 = tslib_1.__importDefault(require("./Image/Image"));
12
12
  const Video_1 = tslib_1.__importDefault(require("./Video/Video"));
13
13
  const b = (0, utils_1.block)('Media');
14
14
  const Media = (props) => {
15
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins, } = props;
15
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins,
16
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
17
+ // temporal solution for Safari 17
18
+ shouldPreload, } = props;
16
19
  const [hasVideoFallback, setHasVideoFallback] = (0, react_1.useState)(false);
17
20
  const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'video');
18
21
  const content = (0, react_1.useMemo)(() => {
@@ -34,11 +37,16 @@ const Media = (props) => {
34
37
  hasVideoFallback,
35
38
  setHasVideoFallback,
36
39
  ratio,
40
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
41
+ // temporal solution for Safari 17
42
+ shouldPreload,
37
43
  };
38
44
  if (fullscreen) {
39
45
  result.push(react_1.default.createElement(FullscreenVideo_1.default, Object.assign({}, videoProps, { qa: qaAttributes.video })));
40
46
  }
41
47
  else {
48
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
49
+ // temporal solution for Safari 17
42
50
  result.push(react_1.default.createElement(Video_1.default, Object.assign({}, videoProps, { qa: qaAttributes.video })));
43
51
  }
44
52
  }
@@ -74,6 +82,9 @@ const Media = (props) => {
74
82
  playButton,
75
83
  customBarControlsClassName,
76
84
  ratio,
85
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
86
+ // temporal solution for Safari 17
87
+ shouldPreload,
77
88
  youtubeClassName,
78
89
  autoplay,
79
90
  margins,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { MediaComponentVideoProps, PlayButtonProps, QAProps } from '../../../models';
2
+ import { LoopProps, MediaComponentVideoProps, PlayButtonProps, QAProps } from '../../../models';
3
3
  export interface VideoAdditionProps {
4
4
  playButton?: PlayButtonProps;
5
5
  customBarControlsClassName?: string;
@@ -9,7 +9,9 @@ export interface VideoAdditionProps {
9
9
  interface InnerVideoProps {
10
10
  setHasVideoFallback: React.Dispatch<boolean>;
11
11
  hasVideoFallback: boolean;
12
+ shouldPreload?: boolean;
12
13
  }
13
14
  export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps & QAProps;
15
+ export declare const getShouldPreloadMetadata: (loop: boolean | LoopProps | undefined) => boolean;
14
16
  declare const Video: (props: VideoAllProps) => JSX.Element | null;
15
17
  export default Video;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getShouldPreloadMetadata = void 0;
3
4
  const tslib_1 = require("tslib");
4
5
  const react_1 = tslib_1.__importStar(require("react"));
5
6
  const models_1 = require("../../../models");
@@ -7,8 +8,18 @@ const utils_1 = require("../../../utils");
7
8
  const DefaultVideo_1 = require("../../DefaultVideo/DefaultVideo");
8
9
  const ReactPlayer_1 = tslib_1.__importDefault(require("../../ReactPlayer/ReactPlayer"));
9
10
  const b = (0, utils_1.block)('media-component-video');
11
+ const getShouldPreloadMetadata = (loop) => {
12
+ if (loop === undefined) {
13
+ return true;
14
+ }
15
+ if (typeof loop === 'boolean') {
16
+ return !loop;
17
+ }
18
+ return false;
19
+ };
20
+ exports.getShouldPreloadMetadata = getShouldPreloadMetadata;
10
21
  const Video = (props) => {
11
- const { video, height, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, qa, ratio, } = props;
22
+ const { video, height, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, qa, ratio, shouldPreload, } = props;
12
23
  const qaAttributes = (0, utils_1.getQaAttrubutes)(qa, 'source');
13
24
  const ref = (0, react_1.useRef)(null);
14
25
  (0, react_1.useEffect)(() => {
@@ -45,8 +56,14 @@ const Video = (props) => {
45
56
  ratio,
46
57
  ]);
47
58
  const defaultVideoBlock = (0, react_1.useMemo)(() => {
59
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
60
+ // temporal solution for Safari 17
61
+ const shouldPreloadLocal = (0, exports.getShouldPreloadMetadata)(video.loop);
48
62
  return video.src.length && !hasVideoFallback ? (react_1.default.createElement("div", { className: b('wrap', videoClassName), style: { height }, "data-qa": qaAttributes.default },
49
- react_1.default.createElement(DefaultVideo_1.DefaultVideo, { ref: ref, video: video, qa: qaAttributes.source }))) : null;
63
+ react_1.default.createElement(DefaultVideo_1.DefaultVideo, { ref: ref, video: video, qa: qaAttributes.source,
64
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
65
+ // temporal solution for Safari 17
66
+ shouldPreload: shouldPreload ? shouldPreloadLocal : shouldPreload }))) : null;
50
67
  }, [
51
68
  video,
52
69
  hasVideoFallback,
@@ -54,6 +71,9 @@ const Video = (props) => {
54
71
  height,
55
72
  qaAttributes.default,
56
73
  qaAttributes.source,
74
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
75
+ // temporal solution for Safari 17
76
+ shouldPreload,
57
77
  ]);
58
78
  switch (video.type) {
59
79
  case models_1.MediaVideoType.Player:
@@ -16,5 +16,6 @@ export interface PageConstructorProviderProps {
16
16
  projectSettings?: ProjectSettingsContextProps;
17
17
  analytics?: AnalyticsContextProps;
18
18
  image?: ImageContextProps;
19
+ blockPreloadVideoMetadata?: boolean;
19
20
  }
20
21
  export declare const PageConstructorProvider: (props: WithChildren<PageConstructorProviderProps>) => JSX.Element;
@@ -5,6 +5,9 @@ const tslib_1 = require("tslib");
5
5
  const react_1 = tslib_1.__importStar(require("react"));
6
6
  const constants_1 = require("../../components/constants");
7
7
  const analyticsContext_1 = require("../../context/analyticsContext");
8
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
9
+ // temporal solution for Safari 17
10
+ const blockPreloadVideoMetadataContext_1 = require("../../context/blockPreloadVideoMetadataContext");
8
11
  const imageContext_1 = require("../../context/imageContext");
9
12
  const localeContext_1 = require("../../context/localeContext");
10
13
  const locationContext_1 = require("../../context/locationContext");
@@ -14,7 +17,10 @@ const projectSettingsContext_1 = require("../../context/projectSettingsContext")
14
17
  const ssrContext_1 = require("../../context/ssrContext");
15
18
  const theme_1 = require("../../context/theme");
16
19
  const PageConstructorProvider = (props) => {
17
- const { isMobile, mapsContext = mapsContext_1.initialMapValue, locale = {}, location = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = constants_1.DEFAULT_THEME, children, image = {}, } = props;
20
+ const { isMobile, mapsContext = mapsContext_1.initialMapValue, locale = {}, location = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = constants_1.DEFAULT_THEME, children, image = {},
21
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
22
+ // temporal solution for Safari 17
23
+ blockPreloadVideoMetadata, } = props;
18
24
  /* eslint-disable react/jsx-key */
19
25
  const context = [
20
26
  react_1.default.createElement(theme_1.ThemeContext.Provider, { value: { theme } }),
@@ -23,6 +29,9 @@ const PageConstructorProvider = (props) => {
23
29
  react_1.default.createElement(imageContext_1.ImageContext.Provider, { value: image }),
24
30
  react_1.default.createElement(locationContext_1.LocationContext.Provider, { value: location }),
25
31
  react_1.default.createElement(mobileContext_1.MobileContext.Provider, { value: Boolean(isMobile) }),
32
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
33
+ // temporal solution for Safari 17
34
+ react_1.default.createElement(blockPreloadVideoMetadataContext_1.BlockPreloadVideoMetadataContext.Provider, { value: Boolean(blockPreloadVideoMetadata) }),
26
35
  react_1.default.createElement(mapsContext_1.MapsContext.Provider, { value: mapsContext }),
27
36
  react_1.default.createElement(analyticsContext_1.AnalyticsContext.Provider, { value: analytics }),
28
37
  react_1.default.createElement(ssrContext_1.SSRContext.Provider, { value: { isServer: ssrConfig === null || ssrConfig === void 0 ? void 0 : ssrConfig.isServer } }),
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const BlockPreloadVideoMetadataContext: React.Context<boolean>;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
3
+ // temporal solution for Safari 17
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.BlockPreloadVideoMetadataContext = void 0;
6
+ const tslib_1 = require("tslib");
7
+ const react_1 = tslib_1.__importDefault(require("react"));
8
+ exports.BlockPreloadVideoMetadataContext = react_1.default.createContext(false);
@@ -0,0 +1 @@
1
+ export * from './blockPreloadVideoMetadataContext';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
3
+ // temporal solution for Safari 17
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ const tslib_1 = require("tslib");
6
+ tslib_1.__exportStar(require("./blockPreloadVideoMetadataContext"), exports);
@@ -92,7 +92,7 @@ export interface AnchorProps {
92
92
  /**
93
93
  * @deprecated Component VideoBlock will be deleted, which uses this logic
94
94
  */
95
- interface LoopProps {
95
+ export interface LoopProps {
96
96
  start: number;
97
97
  end?: number;
98
98
  }
@@ -358,4 +358,3 @@ export interface WithBorder {
358
358
  */
359
359
  disableShadow?: boolean;
360
360
  }
361
- export {};
@@ -12,6 +12,9 @@ const BackgroundMedia = (_a) => {
12
12
  const qaAttributes = getQaAttrubutes(qa, 'media');
13
13
  return (React.createElement(AnimateBlock, { className: b(null, className), style: { backgroundColor: color }, animate: animated, qa: qaAttributes.animate },
14
14
  React.createElement(Media, Object.assign({ className: b('media', { 'full-width-media': fullWidthMedia }, mediaClassName), imageClassName: b('image'), videoClassName: b('video'), isBackground: true, qa: qaAttributes.media }, Object.assign({ height: 720, color,
15
- parallax, video: isMobile ? undefined : video }, props)))));
15
+ parallax, video: isMobile ? undefined : video }, props), {
16
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
17
+ // temporal solution for Safari 17
18
+ shouldPreload: false }))));
16
19
  };
17
20
  export default BackgroundMedia;
@@ -7,6 +7,7 @@ interface DefaultVideoProps {
7
7
  qa?: string;
8
8
  customBarControlsClassName?: string;
9
9
  className?: string;
10
+ shouldPreload?: boolean;
10
11
  }
11
12
  export declare const DefaultVideo: React.ForwardRefExoticComponent<DefaultVideoProps & React.RefAttributes<DefaultVideoRefType>>;
12
13
  export {};
@@ -1,4 +1,7 @@
1
- import React, { Fragment, useCallback, useImperativeHandle, useRef, useState } from 'react';
1
+ import React, { Fragment, useCallback, useContext, useImperativeHandle, useRef, useState, } from 'react';
2
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
3
+ // temporal solution for Safari 17
4
+ import { BlockPreloadVideoMetadataContext } from '../../context/blockPreloadVideoMetadataContext';
2
5
  import { CustomControlsType, MediaVideoControlsType } from '../../models';
3
6
  import { block } from '../../utils';
4
7
  import { getVideoTypesWithPriority } from '../Media/Video/utils';
@@ -6,12 +9,15 @@ import CustomBarControls from '../ReactPlayer/CustomBarControls';
6
9
  import './DefaultVideo.css';
7
10
  const b = block('default-video');
8
11
  export const DefaultVideo = React.forwardRef((props, ref) => {
9
- const { video, qa, customBarControlsClassName } = props;
12
+ const { video, qa, customBarControlsClassName, shouldPreload = true } = props;
10
13
  const { controls, customControlsOptions, muted: initiallyMuted = true } = video;
11
14
  const { muteButtonShown, positioning, type: customControlsType, } = customControlsOptions || {};
12
15
  const [isPaused, setIsPaused] = useState(false);
13
16
  const [isMuted, setIsMuted] = useState(initiallyMuted);
14
17
  const videoRef = useRef(null);
18
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
19
+ // temporal solution for Safari 17
20
+ const blockPreloadVideoMetadata = useContext(BlockPreloadVideoMetadataContext);
15
21
  // one may not use this hook and work with `ref` variable only, but
16
22
  // in this case one should support both function type and object type,
17
23
  // according to ForwardedRef type.
@@ -44,11 +50,22 @@ export const DefaultVideo = React.forwardRef((props, ref) => {
44
50
  onPlayToggle();
45
51
  }
46
52
  }, [onPlayToggle, customControlsType]);
53
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
54
+ // temporal solution for Safari 17
55
+ // eslint-disable-next-line no-nested-ternary
56
+ const preload = blockPreloadVideoMetadata
57
+ ? shouldPreload
58
+ ? 'metadata'
59
+ : undefined
60
+ : 'metadata';
47
61
  return (React.createElement(Fragment, null,
48
62
  React.createElement("video", { disablePictureInPicture: true, playsInline: true,
49
63
  // @ts-ignore
50
64
  // eslint-disable-next-line react/no-unknown-property
51
- pip: "false", className: b(), ref: videoRef, preload: "metadata", muted: isMuted, "aria-label": video.ariaLabel, onClick: onClick }, getVideoTypesWithPriority(video.src).map(({ src, type }, index) => (React.createElement("source", { key: index, src: src, type: type, "data-qa": qa })))),
65
+ pip: "false", className: b(), ref: videoRef,
66
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
67
+ // temporal solution for Safari 17
68
+ preload: preload, muted: isMuted, "aria-label": video.ariaLabel, onClick: onClick }, getVideoTypesWithPriority(video.src).map(({ src, type }, index) => (React.createElement("source", { key: index, src: src, type: type, "data-qa": qa })))),
52
69
  controls === MediaVideoControlsType.Custom && (React.createElement(CustomBarControls, { className: customBarControlsClassName, type: customControlsType, isPaused: isPaused, onPlayClick: onPlayToggle, muteButtonShown: muteButtonShown, shown: true, positioning: positioning, mute: {
53
70
  isMuted: Boolean(isMuted),
54
71
  changeMute: onMuteToggle,
@@ -7,6 +7,7 @@ export interface MediaAllProps extends MediaProps, VideoAdditionProps, ImageAddi
7
7
  youtubeClassName?: string;
8
8
  autoplay?: boolean;
9
9
  onImageLoad?: () => void;
10
+ shouldPreload?: boolean;
10
11
  }
11
12
  export declare const Media: (props: MediaAllProps) => JSX.Element;
12
13
  export default Media;
@@ -9,7 +9,10 @@ import Video from './Video/Video';
9
9
  import './Media.css';
10
10
  const b = block('Media');
11
11
  export const Media = (props) => {
12
- const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins, } = props;
12
+ const { image, video, youtube, dataLens, color, height, previewImg, parallax = false, fullscreen, analyticsEvents, className, imageClassName, videoClassName, youtubeClassName, playVideo = true, isBackground, playButton, customBarControlsClassName, qa, ratio, autoplay, onImageLoad, iframe, margins,
13
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
14
+ // temporal solution for Safari 17
15
+ shouldPreload, } = props;
13
16
  const [hasVideoFallback, setHasVideoFallback] = useState(false);
14
17
  const qaAttributes = getQaAttrubutes(qa, 'video');
15
18
  const content = useMemo(() => {
@@ -31,11 +34,16 @@ export const Media = (props) => {
31
34
  hasVideoFallback,
32
35
  setHasVideoFallback,
33
36
  ratio,
37
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
38
+ // temporal solution for Safari 17
39
+ shouldPreload,
34
40
  };
35
41
  if (fullscreen) {
36
42
  result.push(React.createElement(FullscreenVideo, Object.assign({}, videoProps, { qa: qaAttributes.video })));
37
43
  }
38
44
  else {
45
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
46
+ // temporal solution for Safari 17
39
47
  result.push(React.createElement(Video, Object.assign({}, videoProps, { qa: qaAttributes.video })));
40
48
  }
41
49
  }
@@ -71,6 +79,9 @@ export const Media = (props) => {
71
79
  playButton,
72
80
  customBarControlsClassName,
73
81
  ratio,
82
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
83
+ // temporal solution for Safari 17
84
+ shouldPreload,
74
85
  youtubeClassName,
75
86
  autoplay,
76
87
  margins,
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { MediaComponentVideoProps, PlayButtonProps, QAProps } from '../../../models';
2
+ import { LoopProps, MediaComponentVideoProps, PlayButtonProps, QAProps } from '../../../models';
3
3
  import './Video.css';
4
4
  export interface VideoAdditionProps {
5
5
  playButton?: PlayButtonProps;
@@ -10,7 +10,9 @@ export interface VideoAdditionProps {
10
10
  interface InnerVideoProps {
11
11
  setHasVideoFallback: React.Dispatch<boolean>;
12
12
  hasVideoFallback: boolean;
13
+ shouldPreload?: boolean;
13
14
  }
14
15
  export type VideoAllProps = VideoAdditionProps & MediaComponentVideoProps & InnerVideoProps & QAProps;
16
+ export declare const getShouldPreloadMetadata: (loop: boolean | LoopProps | undefined) => boolean;
15
17
  declare const Video: (props: VideoAllProps) => JSX.Element | null;
16
18
  export default Video;
@@ -1,12 +1,21 @@
1
1
  import React, { useEffect, useMemo, useRef } from 'react';
2
- import { MediaVideoType } from '../../../models';
2
+ import { MediaVideoType, } from '../../../models';
3
3
  import { block, getQaAttrubutes } from '../../../utils';
4
4
  import { DefaultVideo } from '../../DefaultVideo/DefaultVideo';
5
5
  import ReactPlayerBlock from '../../ReactPlayer/ReactPlayer';
6
6
  import './Video.css';
7
7
  const b = block('media-component-video');
8
+ export const getShouldPreloadMetadata = (loop) => {
9
+ if (loop === undefined) {
10
+ return true;
11
+ }
12
+ if (typeof loop === 'boolean') {
13
+ return !loop;
14
+ }
15
+ return false;
16
+ };
8
17
  const Video = (props) => {
9
- const { video, height, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, qa, ratio, } = props;
18
+ const { video, height, analyticsEvents, previewImg, playButton: commonPlayButton, customBarControlsClassName, videoClassName, playVideo, setHasVideoFallback, hasVideoFallback, qa, ratio, shouldPreload, } = props;
10
19
  const qaAttributes = getQaAttrubutes(qa, 'source');
11
20
  const ref = useRef(null);
12
21
  useEffect(() => {
@@ -43,8 +52,14 @@ const Video = (props) => {
43
52
  ratio,
44
53
  ]);
45
54
  const defaultVideoBlock = useMemo(() => {
55
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
56
+ // temporal solution for Safari 17
57
+ const shouldPreloadLocal = getShouldPreloadMetadata(video.loop);
46
58
  return video.src.length && !hasVideoFallback ? (React.createElement("div", { className: b('wrap', videoClassName), style: { height }, "data-qa": qaAttributes.default },
47
- React.createElement(DefaultVideo, { ref: ref, video: video, qa: qaAttributes.source }))) : null;
59
+ React.createElement(DefaultVideo, { ref: ref, video: video, qa: qaAttributes.source,
60
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
61
+ // temporal solution for Safari 17
62
+ shouldPreload: shouldPreload ? shouldPreloadLocal : shouldPreload }))) : null;
48
63
  }, [
49
64
  video,
50
65
  hasVideoFallback,
@@ -52,6 +67,9 @@ const Video = (props) => {
52
67
  height,
53
68
  qaAttributes.default,
54
69
  qaAttributes.source,
70
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
71
+ // temporal solution for Safari 17
72
+ shouldPreload,
55
73
  ]);
56
74
  switch (video.type) {
57
75
  case MediaVideoType.Player:
@@ -16,5 +16,6 @@ export interface PageConstructorProviderProps {
16
16
  projectSettings?: ProjectSettingsContextProps;
17
17
  analytics?: AnalyticsContextProps;
18
18
  image?: ImageContextProps;
19
+ blockPreloadVideoMetadata?: boolean;
19
20
  }
20
21
  export declare const PageConstructorProvider: (props: WithChildren<PageConstructorProviderProps>) => JSX.Element;
@@ -1,6 +1,9 @@
1
1
  import React, { Fragment } from 'react';
2
2
  import { DEFAULT_THEME } from '../../components/constants';
3
3
  import { AnalyticsContext } from '../../context/analyticsContext';
4
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
5
+ // temporal solution for Safari 17
6
+ import { BlockPreloadVideoMetadataContext } from '../../context/blockPreloadVideoMetadataContext';
4
7
  import { ImageContext } from '../../context/imageContext';
5
8
  import { LocaleContext } from '../../context/localeContext';
6
9
  import { LocationContext } from '../../context/locationContext';
@@ -10,7 +13,10 @@ import { ProjectSettingsContext, } from '../../context/projectSettingsContext';
10
13
  import { SSRContext } from '../../context/ssrContext';
11
14
  import { ThemeContext } from '../../context/theme';
12
15
  export const PageConstructorProvider = (props) => {
13
- const { isMobile, mapsContext = initialMapValue, locale = {}, location = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, image = {}, } = props;
16
+ const { isMobile, mapsContext = initialMapValue, locale = {}, location = {}, analytics = {}, ssrConfig = {}, projectSettings = {}, theme = DEFAULT_THEME, children, image = {},
17
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
18
+ // temporal solution for Safari 17
19
+ blockPreloadVideoMetadata, } = props;
14
20
  /* eslint-disable react/jsx-key */
15
21
  const context = [
16
22
  React.createElement(ThemeContext.Provider, { value: { theme } }),
@@ -19,6 +25,9 @@ export const PageConstructorProvider = (props) => {
19
25
  React.createElement(ImageContext.Provider, { value: image }),
20
26
  React.createElement(LocationContext.Provider, { value: location }),
21
27
  React.createElement(MobileContext.Provider, { value: Boolean(isMobile) }),
28
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
29
+ // temporal solution for Safari 17
30
+ React.createElement(BlockPreloadVideoMetadataContext.Provider, { value: Boolean(blockPreloadVideoMetadata) }),
22
31
  React.createElement(MapsContext.Provider, { value: mapsContext }),
23
32
  React.createElement(AnalyticsContext.Provider, { value: analytics }),
24
33
  React.createElement(SSRContext.Provider, { value: { isServer: ssrConfig === null || ssrConfig === void 0 ? void 0 : ssrConfig.isServer } }),
@@ -0,0 +1,2 @@
1
+ import React from 'react';
2
+ export declare const BlockPreloadVideoMetadataContext: React.Context<boolean>;
@@ -0,0 +1,4 @@
1
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
2
+ // temporal solution for Safari 17
3
+ import React from 'react';
4
+ export const BlockPreloadVideoMetadataContext = React.createContext(false);
@@ -0,0 +1 @@
1
+ export * from './blockPreloadVideoMetadataContext';
@@ -0,0 +1,3 @@
1
+ // ISSUE-853 https://github.com/gravity-ui/page-constructor/issues/853
2
+ // temporal solution for Safari 17
3
+ export * from './blockPreloadVideoMetadataContext';
@@ -92,7 +92,7 @@ export interface AnchorProps {
92
92
  /**
93
93
  * @deprecated Component VideoBlock will be deleted, which uses this logic
94
94
  */
95
- interface LoopProps {
95
+ export interface LoopProps {
96
96
  start: number;
97
97
  end?: number;
98
98
  }
@@ -358,4 +358,3 @@ export interface WithBorder {
358
358
  */
359
359
  disableShadow?: boolean;
360
360
  }
361
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/page-constructor",
3
- "version": "5.0.1",
3
+ "version": "5.1.1-alpha.0",
4
4
  "description": "Gravity UI Page Constructor",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -83,7 +83,7 @@
83
83
  "@bem-react/classname": "^1.6.0",
84
84
  "@gravity-ui/components": "^3.0.0",
85
85
  "@gravity-ui/dynamic-forms": "^4.0.0",
86
- "@gravity-ui/i18n": "^1.2.0",
86
+ "@gravity-ui/i18n": "^1.3.0",
87
87
  "@react-spring/web": "^9.7.3",
88
88
  "ajv": "^8.12.0",
89
89
  "ajv-keywords": "^5.1.0",
@@ -116,13 +116,13 @@
116
116
  "@babel/preset-typescript": "^7.22.5",
117
117
  "@commitlint/cli": "^17.1.2",
118
118
  "@commitlint/config-conventional": "^17.1.0",
119
- "@diplodoc/transform": "^4.10.4",
119
+ "@diplodoc/transform": "^4.10.8",
120
120
  "@gravity-ui/eslint-config": "^2.0.0",
121
121
  "@gravity-ui/icons": "^2.8.1",
122
122
  "@gravity-ui/prettier-config": "^1.0.1",
123
123
  "@gravity-ui/stylelint-config": "^1.0.0",
124
124
  "@gravity-ui/tsconfig": "^1.0.0",
125
- "@gravity-ui/uikit": "^6.0.0",
125
+ "@gravity-ui/uikit": "^6.2.0",
126
126
  "@storybook/addon-actions": "^7.6.17",
127
127
  "@storybook/addon-essentials": "^7.6.17",
128
128
  "@storybook/addon-knobs": "^7.0.2",
@@ -92,7 +92,7 @@ export interface AnchorProps {
92
92
  /**
93
93
  * @deprecated Component VideoBlock will be deleted, which uses this logic
94
94
  */
95
- interface LoopProps {
95
+ export interface LoopProps {
96
96
  start: number;
97
97
  end?: number;
98
98
  }
@@ -358,4 +358,3 @@ export interface WithBorder {
358
358
  */
359
359
  disableShadow?: boolean;
360
360
  }
361
- export {};