pb-sxp-ui 1.0.100 → 1.0.102
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/dist/index.cjs +188 -139
- package/dist/index.cjs.map +1 -1
- package/dist/index.css +10 -3
- package/dist/index.js +189 -139
- package/dist/index.js.map +1 -1
- package/dist/index.min.cjs +3 -3
- package/dist/index.min.cjs.map +1 -1
- package/dist/index.min.js +3 -3
- package/dist/index.min.js.map +1 -1
- package/dist/pb-ui.js +188 -139
- package/dist/pb-ui.js.map +1 -1
- package/dist/pb-ui.min.js +3 -3
- package/dist/pb-ui.min.js.map +1 -1
- package/es/core/components/SxpPageRender/ExpandableText.js +3 -1
- package/es/core/components/SxpPageRender/Nudge/index.d.ts +2 -0
- package/es/core/components/SxpPageRender/Nudge/index.js +5 -2
- package/es/core/components/SxpPageRender/Tagbar.d.ts +1 -0
- package/es/core/components/SxpPageRender/Tagbar.js +2 -2
- package/es/core/components/SxpPageRender/VideoWidget/VideoPlayer.d.ts +1 -0
- package/es/core/components/SxpPageRender/VideoWidget/VideoPlayer.js +22 -0
- package/es/core/components/SxpPageRender/VideoWidget/index.d.ts +0 -1
- package/es/core/components/SxpPageRender/VideoWidget/index.js +93 -85
- package/es/core/components/SxpPageRender/index.js +10 -27
- package/es/materials/sxp/popup/AppointForm/settingRender.js +2 -2
- package/es/materials/sxp/popup/CommodityDetail/index.js +4 -3
- package/es/materials/sxp/popup/CommodityDetailDiroNew/index.js +4 -3
- package/es/materials/sxp/popup/Prompt/index.d.ts +1 -0
- package/es/materials/sxp/popup/Prompt/index.js +4 -2
- package/es/materials/sxp/popup/Prompt/settingRender.d.ts +12 -0
- package/es/materials/sxp/popup/Prompt/settingRender.js +33 -4
- package/lib/core/components/SxpPageRender/ExpandableText.js +3 -1
- package/lib/core/components/SxpPageRender/Nudge/index.d.ts +2 -0
- package/lib/core/components/SxpPageRender/Nudge/index.js +5 -2
- package/lib/core/components/SxpPageRender/Tagbar.d.ts +1 -0
- package/lib/core/components/SxpPageRender/Tagbar.js +2 -2
- package/lib/core/components/SxpPageRender/VideoWidget/VideoPlayer.d.ts +1 -0
- package/lib/core/components/SxpPageRender/VideoWidget/VideoPlayer.js +26 -0
- package/lib/core/components/SxpPageRender/VideoWidget/index.d.ts +0 -1
- package/lib/core/components/SxpPageRender/VideoWidget/index.js +93 -85
- package/lib/core/components/SxpPageRender/index.js +10 -27
- package/lib/materials/sxp/popup/AppointForm/settingRender.js +2 -2
- package/lib/materials/sxp/popup/CommodityDetail/index.js +4 -3
- package/lib/materials/sxp/popup/CommodityDetailDiroNew/index.js +4 -3
- package/lib/materials/sxp/popup/Prompt/index.d.ts +1 -0
- package/lib/materials/sxp/popup/Prompt/index.js +4 -2
- package/lib/materials/sxp/popup/Prompt/settingRender.d.ts +12 -0
- package/lib/materials/sxp/popup/Prompt/settingRender.js +33 -4
- package/package.json +1 -1
@@ -8,7 +8,7 @@ import { useSxpDataSource } from '../../../../core/hooks';
|
|
8
8
|
import { useEventReport } from '../../../../core/hooks/useEventReport';
|
9
9
|
import { setFontForText } from '../../../../core/utils/tool';
|
10
10
|
const Prompt = (_a) => {
|
11
|
-
var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle"]);
|
11
|
+
var { content, btnText, style, icon, isPopup, isExternalLink, onClose, onClick, submitButtonStyle, contentStyle } = _a, props = __rest(_a, ["content", "btnText", "style", "icon", "isPopup", "isExternalLink", "onClose", "onClick", "submitButtonStyle", "contentStyle"]);
|
12
12
|
const { popupDetailData } = useSxpDataSource();
|
13
13
|
const { jumpToWeb } = useEventReport();
|
14
14
|
const iconSrc = typeof icon === 'string' ? icon : getMediaValueByMode(icon);
|
@@ -29,7 +29,9 @@ const Prompt = (_a) => {
|
|
29
29
|
return (React.createElement("div", Object.assign({ className: `pb-prompt ${css(Object.assign({}, style))}` }, props),
|
30
30
|
React.createElement("div", { className: 'pb-prompt-icon' },
|
31
31
|
React.createElement("img", { width: '100%', src: iconSrc !== null && iconSrc !== void 0 ? iconSrc : success, alt: 'success image' })),
|
32
|
-
React.createElement("div", { className: 'pb-prompt-content'
|
32
|
+
React.createElement("div", { className: 'pb-prompt-content', style: contentStyle, dangerouslySetInnerHTML: {
|
33
|
+
__html: setFontForText(content, contentStyle)
|
34
|
+
} }),
|
33
35
|
React.createElement("button", { "aria-label": btnText, className: 'pb-prompt-btn', style: submitButtonStyle, onClick: handleOk, dangerouslySetInnerHTML: {
|
34
36
|
__html: setFontForText(btnText, submitButtonStyle)
|
35
37
|
} })));
|
@@ -6,12 +6,14 @@ declare const _default: {
|
|
6
6
|
name: string[];
|
7
7
|
mediaType: string;
|
8
8
|
child?: undefined;
|
9
|
+
initialValue?: undefined;
|
9
10
|
} | {
|
10
11
|
type: string;
|
11
12
|
label: string;
|
12
13
|
name: string[];
|
13
14
|
mediaType?: undefined;
|
14
15
|
child?: undefined;
|
16
|
+
initialValue?: undefined;
|
15
17
|
} | {
|
16
18
|
type: string;
|
17
19
|
label: string;
|
@@ -22,6 +24,7 @@ declare const _default: {
|
|
22
24
|
}[];
|
23
25
|
name?: undefined;
|
24
26
|
mediaType?: undefined;
|
27
|
+
initialValue?: undefined;
|
25
28
|
} | {
|
26
29
|
type: string;
|
27
30
|
label: string;
|
@@ -38,12 +41,21 @@ declare const _default: {
|
|
38
41
|
})[];
|
39
42
|
name?: undefined;
|
40
43
|
mediaType?: undefined;
|
44
|
+
initialValue?: undefined;
|
41
45
|
} | {
|
42
46
|
type: string;
|
43
47
|
name: string[];
|
44
48
|
label?: undefined;
|
45
49
|
mediaType?: undefined;
|
46
50
|
child?: undefined;
|
51
|
+
initialValue?: undefined;
|
52
|
+
} | {
|
53
|
+
label: string;
|
54
|
+
type: string;
|
55
|
+
name: string[];
|
56
|
+
initialValue: string;
|
57
|
+
mediaType?: undefined;
|
58
|
+
child?: undefined;
|
47
59
|
})[];
|
48
60
|
}[];
|
49
61
|
export default _default;
|
@@ -14,9 +14,37 @@ export default [
|
|
14
14
|
name: ['props', 'content']
|
15
15
|
},
|
16
16
|
{
|
17
|
-
type: '
|
18
|
-
label: '
|
19
|
-
|
17
|
+
type: 'Group',
|
18
|
+
label: '内容字体',
|
19
|
+
child: [
|
20
|
+
{
|
21
|
+
type: 'Select',
|
22
|
+
name: ['props', 'contentStyle', 'fontFamily-cn'],
|
23
|
+
bottomText: '中文字体'
|
24
|
+
},
|
25
|
+
{
|
26
|
+
type: 'Select',
|
27
|
+
name: ['props', 'contentStyle', 'fontFamily-en'],
|
28
|
+
bottomText: '英文/其他字体'
|
29
|
+
}
|
30
|
+
]
|
31
|
+
},
|
32
|
+
{
|
33
|
+
type: 'Group',
|
34
|
+
label: '',
|
35
|
+
child: [
|
36
|
+
{
|
37
|
+
type: 'Color',
|
38
|
+
name: ['props', 'contentStyle', 'color'],
|
39
|
+
initialValue: '#000'
|
40
|
+
},
|
41
|
+
{
|
42
|
+
type: 'Number',
|
43
|
+
name: ['props', 'contentStyle', 'fontSize'],
|
44
|
+
addonAfter: 'px',
|
45
|
+
initialValue: 14
|
46
|
+
}
|
47
|
+
]
|
20
48
|
},
|
21
49
|
{
|
22
50
|
type: 'Group',
|
@@ -62,7 +90,8 @@ export default [
|
|
62
90
|
{
|
63
91
|
label: '提交按钮颜色',
|
64
92
|
type: 'Color',
|
65
|
-
name: ['props', 'submitButtonStyle', 'backgroundColor']
|
93
|
+
name: ['props', 'submitButtonStyle', 'backgroundColor'],
|
94
|
+
initialValue: '#000'
|
66
95
|
}
|
67
96
|
]
|
68
97
|
}
|
@@ -51,6 +51,8 @@ const ExpandableText = ({ text, maxStr = 108, style, className, onClick, foldTex
|
|
51
51
|
wordBreak: 'break-word'
|
52
52
|
}, dangerouslySetInnerHTML: { __html: (0, tool_1.setFontForText)(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), style) } }),
|
53
53
|
react_1.default.createElement("div", { ref: multiRowCopy, dangerouslySetInnerHTML: { __html: (0, tool_1.setFontForText)(text === null || text === void 0 ? void 0 : text.replace(/\n/g, '</br>'), style) } }),
|
54
|
-
text && isPost && isShow && (react_1.default.createElement("span", { style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick
|
54
|
+
text && isPost && isShow && (react_1.default.createElement("span", { style: { textDecoration: 'underline', cursor: 'pointer' }, onClick: onClick !== null && onClick !== void 0 ? onClick : handleClick, dangerouslySetInnerHTML: {
|
55
|
+
__html: (0, tool_1.setFontForText)(isShowMore ? unfoldText || 'show less' : foldText || 'show more', style)
|
56
|
+
} }))));
|
55
57
|
};
|
56
58
|
exports.default = (0, react_1.memo)(ExpandableText);
|
@@ -1,9 +1,10 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
3
|
const tslib_1 = require("tslib");
|
4
|
+
const tool_1 = require("../../../../core/utils/tool");
|
4
5
|
const react_1 = tslib_1.__importDefault(require("react"));
|
5
6
|
const Nudge = ({ nudge }) => {
|
6
|
-
var _a, _b, _c, _d, _e, _f
|
7
|
+
var _a, _b, _c, _d, _e, _f;
|
7
8
|
return (react_1.default.createElement(react_1.default.Fragment, null, (nudge === null || nudge === void 0 ? void 0 : nudge.isOpen) && (react_1.default.createElement("div", { className: 'clc-sxp-bottom-nudge', style: {
|
8
9
|
marginBottom: (_a = nudge === null || nudge === void 0 ? void 0 : nudge.marginBottom) !== null && _a !== void 0 ? _a : 5,
|
9
10
|
width: (_c = (_b = nudge === null || nudge === void 0 ? void 0 : nudge.size) === null || _b === void 0 ? void 0 : _b.width) !== null && _c !== void 0 ? _c : 212,
|
@@ -12,6 +13,8 @@ const Nudge = ({ nudge }) => {
|
|
12
13
|
borderRadius: (_f = nudge === null || nudge === void 0 ? void 0 : nudge.borderRadius) !== null && _f !== void 0 ? _f : 4
|
13
14
|
} },
|
14
15
|
(nudge === null || nudge === void 0 ? void 0 : nudge.icon) ? (react_1.default.createElement("img", { src: nudge.icon, alt: 'nudge icon', style: { height: '100%', objectFit: 'cover', flexShrink: 0 } })) : null,
|
15
|
-
react_1.default.createElement("p", { style: Object.assign(Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle), { textWrap: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', flex: 1, marginBottom: 0 })
|
16
|
+
react_1.default.createElement("p", { style: Object.assign(Object.assign({}, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle), { textWrap: 'nowrap', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap', flex: 1, marginBottom: 0 }), dangerouslySetInnerHTML: {
|
17
|
+
__html: (0, tool_1.setFontForText)(nudge === null || nudge === void 0 ? void 0 : nudge.content, nudge === null || nudge === void 0 ? void 0 : nudge.textStyle)
|
18
|
+
} })))));
|
16
19
|
};
|
17
20
|
exports.default = Nudge;
|
@@ -6,7 +6,7 @@ const hooks_1 = require("../../../core/hooks");
|
|
6
6
|
const event_1 = tslib_1.__importStar(require("../../../core/utils/event"));
|
7
7
|
const useEventReport_1 = require("../../../core/hooks/useEventReport");
|
8
8
|
const SxpDataSourceProvider_1 = require("../../../core/context/SxpDataSourceProvider");
|
9
|
-
const Tagbar = ({ tagList = [], setActiveIndex }) => {
|
9
|
+
const Tagbar = ({ tagList = [], setActiveIndex, style }) => {
|
10
10
|
const { getRecommendVideos, setRtcList, setCacheRtcList, setCacheActiveIndex, setLoading, swiperRef, waterFallData, bffEventReport, selectTag, setSelectTag } = (0, hooks_1.useSxpDataSource)();
|
11
11
|
const { backMainFeed } = (0, useEventReport_1.useEventReport)();
|
12
12
|
const realTagList = (0, react_1.useMemo)(() => {
|
@@ -47,7 +47,7 @@ const Tagbar = ({ tagList = [], setActiveIndex }) => {
|
|
47
47
|
};
|
48
48
|
if (waterFallData || tagList.length <= 0)
|
49
49
|
return null;
|
50
|
-
return (react_1.default.createElement("div", { className: 'clc-sxp-tagbar' },
|
50
|
+
return (react_1.default.createElement("div", { className: 'clc-sxp-tagbar', style: style },
|
51
51
|
react_1.default.createElement("ul", { className: 'clc-sxp-tagbar-list', style: { margin: 'auto', gap: 24 } }, realTagList.map((tag) => {
|
52
52
|
return (react_1.default.createElement("li", { className: `clc-sxp-tagbar-list-item ${tag === selectTag ? 'clc-sxp-tagbar-list-item-active' : ''}`, key: tag, onClick: handleSelectTag(tag) }, tag));
|
53
53
|
}))));
|
@@ -0,0 +1 @@
|
|
1
|
+
export declare const mountVideoPlayerAtNode: ((domNode: any) => Element | null | undefined) | undefined;
|
@@ -0,0 +1,26 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.mountVideoPlayerAtNode = void 0;
|
4
|
+
const tslib_1 = require("tslib");
|
5
|
+
const react_1 = tslib_1.__importDefault(require("react"));
|
6
|
+
const react_dom_1 = tslib_1.__importDefault(require("react-dom"));
|
7
|
+
exports.mountVideoPlayerAtNode = (() => {
|
8
|
+
if (typeof document === 'undefined')
|
9
|
+
return;
|
10
|
+
const playerContainer = document.createElement('div');
|
11
|
+
const dom = react_dom_1.default.render(react_1.default.createElement("video", { id: 'player-container-id', playsInline: true, crossOrigin: 'anonymous', preload: 'auto', controls: false, muted: true, style: {
|
12
|
+
backgroundColor: 'transparent',
|
13
|
+
width: '100%',
|
14
|
+
height: '100%',
|
15
|
+
objectFit: 'cover',
|
16
|
+
pointerEvents: 'none'
|
17
|
+
} }), playerContainer);
|
18
|
+
return (domNode) => {
|
19
|
+
if (!domNode)
|
20
|
+
return;
|
21
|
+
domNode.innerHTML = '';
|
22
|
+
domNode.appendChild(dom);
|
23
|
+
const videoPlayerWrapperNode = document.querySelector(`#player-container-id`);
|
24
|
+
return videoPlayerWrapperNode;
|
25
|
+
};
|
26
|
+
})();
|
@@ -8,7 +8,8 @@ const FormatImage_1 = tslib_1.__importDefault(require("../FormatImage"));
|
|
8
8
|
const hooks_1 = require("../../../../core/hooks");
|
9
9
|
const event_1 = tslib_1.__importStar(require("../../../../core/utils/event"));
|
10
10
|
const loading_gif_1 = tslib_1.__importDefault(require("./loading.gif"));
|
11
|
-
const
|
11
|
+
const VideoPlayer_1 = require("./VideoPlayer");
|
12
|
+
const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostConfig, videoPlayIcon }) => {
|
12
13
|
const [isPauseVideo, setIsPauseVideo] = (0, react_1.useState)(false);
|
13
14
|
const { bffEventReport, sxpParameter, waterFallData, openHashtag, bffFbReport } = (0, hooks_1.useSxpDataSource)();
|
14
15
|
const videoStartTime = (0, react_1.useRef)(0);
|
@@ -18,6 +19,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
18
19
|
const canvasRef = (0, react_1.useRef)(null);
|
19
20
|
const [firstFrameSrc, setFirstFrameSrc] = (0, react_1.useState)('');
|
20
21
|
const [waiting, setWaiting] = (0, react_1.useState)(false);
|
22
|
+
const videoRef = (0, react_1.useRef)();
|
21
23
|
const videoId = `pb-cache-video-${index}`;
|
22
24
|
const videoEleRef = (0, react_1.useRef)(null);
|
23
25
|
const blur = (0, react_1.useMemo)(() => {
|
@@ -48,56 +50,57 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
48
50
|
return isBgColor && (videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.bgColor) ? { backgroundColor: videoPostConfig === null || videoPostConfig === void 0 ? void 0 : videoPostConfig.bgColor } : {};
|
49
51
|
}, [videoPostConfig, isBgColor]);
|
50
52
|
(0, react_1.useEffect)(() => {
|
51
|
-
if (!videoRef)
|
53
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
52
54
|
return;
|
53
|
-
videoRef.muted = muted;
|
54
|
-
}, [muted, videoRef]);
|
55
|
+
videoRef.current.muted = muted;
|
56
|
+
}, [muted, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
55
57
|
const handlePlay = (0, react_1.useCallback)(() => {
|
56
|
-
|
58
|
+
var _a;
|
59
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
57
60
|
return;
|
58
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
59
|
-
}, [videoRef]);
|
61
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
62
|
+
}, [videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
60
63
|
const PAUSE_ICON = (0, useIconLink_1.useIconLink)('/pb_static/06f28a2025c74c1cb49be6767316d827.png');
|
61
64
|
const handlePlaying = (0, react_1.useCallback)(() => {
|
62
|
-
if (!videoRef)
|
65
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
63
66
|
return;
|
64
67
|
setWaiting(false);
|
65
68
|
setIsLoadFinish(true);
|
66
69
|
}, []);
|
67
70
|
const handleStartPlay = (0, react_1.useCallback)(() => {
|
68
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
69
|
-
if (!videoRef)
|
71
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
72
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
70
73
|
return;
|
71
74
|
setIsPauseVideo(false);
|
72
75
|
const item = data[index];
|
73
|
-
if (item && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration)) {
|
74
|
-
videoStartTime.current = (videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime) || 0;
|
75
|
-
const videoDuration = ((
|
76
|
-
const videoCurrentTime = ((
|
76
|
+
if (item && ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration)) {
|
77
|
+
videoStartTime.current = ((_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.currentTime) || 0;
|
78
|
+
const videoDuration = ((_d = (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.duration) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
79
|
+
const videoCurrentTime = ((_f = (_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.currentTime) !== null && _f !== void 0 ? _f : 0).toFixed(2);
|
77
80
|
const playType = isFirstPlay ? '0' : '1';
|
78
81
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
79
82
|
eventInfo: {
|
80
83
|
eventSubject: 'playVideo',
|
81
84
|
eventDescription: 'User played the video',
|
82
|
-
contentId: (
|
83
|
-
contentName: (
|
85
|
+
contentId: (_h = (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
|
86
|
+
contentName: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
|
84
87
|
playType,
|
85
88
|
startTime: videoCurrentTime,
|
86
89
|
videoDuration,
|
87
|
-
contentTags: JSON.stringify((
|
90
|
+
contentTags: JSON.stringify((_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
|
88
91
|
position: index + '',
|
89
92
|
contentFormat: 'video',
|
90
|
-
traceInfo: (
|
93
|
+
traceInfo: (_o = item === null || item === void 0 ? void 0 : item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
|
91
94
|
}
|
92
95
|
});
|
93
96
|
setIsFirstPlay(false);
|
94
97
|
}
|
95
|
-
}, [bffEventReport, data, index, isFirstPlay, videoRef]);
|
98
|
+
}, [bffEventReport, data, index, isFirstPlay, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
96
99
|
const handLoadeddata = (0, react_1.useCallback)(() => {
|
97
100
|
var _a;
|
98
|
-
if (!videoRef || firstFrameSrc || !blur)
|
101
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || firstFrameSrc || !blur)
|
99
102
|
return;
|
100
|
-
videoRef.style.objectFit = 'contain';
|
103
|
+
videoRef.current.style.objectFit = 'contain';
|
101
104
|
if (((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.cover) || !canvasRef || !canvasRef.current || isBgColor)
|
102
105
|
return;
|
103
106
|
const setFrameImg = () => {
|
@@ -107,155 +110,160 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
107
110
|
const targetHeight = window === null || window === void 0 ? void 0 : window.innerHeight;
|
108
111
|
canvas.height = targetHeight;
|
109
112
|
canvas.width = targetWidth;
|
110
|
-
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(videoRef, 0, 0, canvas.width, canvas.height);
|
113
|
+
ctx === null || ctx === void 0 ? void 0 : ctx.drawImage(videoRef.current, 0, 0, canvas.width, canvas.height);
|
111
114
|
setFirstFrameSrc(canvas.toDataURL());
|
112
115
|
};
|
113
116
|
setFrameImg();
|
114
117
|
setTimeout(() => {
|
115
118
|
setFrameImg();
|
116
119
|
}, 500);
|
117
|
-
}, [videoRef, isBgColor, rec, firstFrameSrc, blur]);
|
120
|
+
}, [videoRef.current, isBgColor, rec, firstFrameSrc, blur]);
|
118
121
|
const handleLoadedmetadata = (0, react_1.useCallback)(() => {
|
119
|
-
if (!videoRef)
|
122
|
+
if (!videoRef.current)
|
120
123
|
return;
|
121
124
|
handleStartPlay();
|
122
125
|
handLoadeddata();
|
123
|
-
}, [videoRef, handLoadeddata, handleStartPlay]);
|
126
|
+
}, [videoRef.current, handLoadeddata, handleStartPlay]);
|
124
127
|
const handleClickVideo = (0, react_1.useCallback)((type) => () => {
|
125
|
-
|
128
|
+
var _a, _b, _c, _d, _e;
|
129
|
+
if (!videoRef.current)
|
126
130
|
return;
|
127
131
|
if (!isLoadFinish)
|
128
132
|
return;
|
129
|
-
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused;
|
133
|
+
const isPause = (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
130
134
|
switch (type) {
|
131
135
|
case 'start':
|
132
136
|
if (!isPause)
|
133
137
|
return;
|
134
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
138
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.play();
|
135
139
|
setIsPauseVideo(false);
|
136
140
|
break;
|
137
141
|
case 'pause':
|
138
142
|
if (isPause)
|
139
143
|
return;
|
140
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
144
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.pause();
|
141
145
|
setIsPauseVideo(true);
|
142
146
|
break;
|
143
147
|
default:
|
144
148
|
if (isPause) {
|
145
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
149
|
+
(_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.play();
|
146
150
|
}
|
147
151
|
else {
|
148
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
152
|
+
(_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.pause();
|
149
153
|
}
|
150
154
|
setIsPauseVideo(!isPause);
|
151
155
|
break;
|
152
156
|
}
|
153
|
-
}, [isLoadFinish, videoRef]);
|
157
|
+
}, [isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
154
158
|
const handlePause = (0, react_1.useCallback)(() => {
|
155
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
156
|
-
if (!videoRef)
|
159
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
|
160
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
157
161
|
return;
|
158
162
|
if (activeIndex !== index)
|
159
163
|
return;
|
160
164
|
const item = data[index];
|
161
|
-
const videoDuration = ((_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration) !== null &&
|
162
|
-
const videoCurrentTime = ((
|
163
|
-
if (videoRef === null || videoRef === void 0 ? void 0 : videoRef.duration) {
|
164
|
-
const playDuration = ((videoRef === null || videoRef === void 0 ? void 0 : videoRef.currentTime) - videoStartTime.current).toFixed(2);
|
165
|
+
const videoDuration = ((_b = (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.duration) !== null && _b !== void 0 ? _b : 0).toFixed(2);
|
166
|
+
const videoCurrentTime = ((_d = (_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.currentTime) !== null && _d !== void 0 ? _d : 0).toFixed(2);
|
167
|
+
if ((_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.duration) {
|
168
|
+
const playDuration = (((_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.currentTime) - videoStartTime.current).toFixed(2);
|
165
169
|
bffEventReport === null || bffEventReport === void 0 ? void 0 : bffEventReport({
|
166
170
|
eventInfo: {
|
167
171
|
eventSubject: 'playOverVideo',
|
168
172
|
eventDescription: 'User finished playing the video',
|
169
|
-
contentId: (
|
170
|
-
contentName: (
|
173
|
+
contentId: (_h = (_g = item === null || item === void 0 ? void 0 : item.video) === null || _g === void 0 ? void 0 : _g.itemId) !== null && _h !== void 0 ? _h : '',
|
174
|
+
contentName: (_k = (_j = item === null || item === void 0 ? void 0 : item.video) === null || _j === void 0 ? void 0 : _j.title) !== null && _k !== void 0 ? _k : '',
|
171
175
|
endTime: videoCurrentTime,
|
172
176
|
videoDuration,
|
173
177
|
playDuration,
|
174
|
-
contentTags: JSON.stringify((
|
178
|
+
contentTags: JSON.stringify((_m = (_l = item === null || item === void 0 ? void 0 : item.video) === null || _l === void 0 ? void 0 : _l.tags) !== null && _m !== void 0 ? _m : []),
|
175
179
|
position: index + '',
|
176
180
|
contentFormat: 'video',
|
177
|
-
traceInfo: (
|
181
|
+
traceInfo: (_o = item === null || item === void 0 ? void 0 : item.video) === null || _o === void 0 ? void 0 : _o.traceInfo
|
178
182
|
}
|
179
183
|
});
|
180
184
|
}
|
181
|
-
}, [data, index, bffEventReport, videoRef, activeIndex]);
|
185
|
+
}, [data, index, bffEventReport, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current, activeIndex]);
|
182
186
|
const handleWaiting = (0, react_1.useCallback)(() => {
|
183
187
|
setWaiting(true);
|
184
188
|
}, []);
|
185
189
|
(0, react_1.useEffect)(() => {
|
186
|
-
|
190
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
|
191
|
+
if (!isActive)
|
187
192
|
return;
|
188
193
|
const videoSrc = rec === null || rec === void 0 ? void 0 : rec.video.url;
|
189
194
|
if (!videoSrc)
|
190
195
|
return;
|
196
|
+
const videoPlayerWrapperNode = document.querySelector(`#${videoId}`);
|
197
|
+
if (!videoPlayerWrapperNode)
|
198
|
+
return;
|
199
|
+
videoRef.current = VideoPlayer_1.mountVideoPlayerAtNode === null || VideoPlayer_1.mountVideoPlayerAtNode === void 0 ? void 0 : (0, VideoPlayer_1.mountVideoPlayerAtNode)(videoPlayerWrapperNode);
|
200
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
201
|
+
return;
|
191
202
|
const Hls = window === null || window === void 0 ? void 0 : window.Hls;
|
192
203
|
let hls = null;
|
193
204
|
if (videoSrc.includes('.m3u8') && Hls && Hls.isSupported()) {
|
194
205
|
hls = new Hls();
|
195
206
|
hls.loadSource(videoSrc);
|
196
|
-
hls.attachMedia(videoRef);
|
207
|
+
hls.attachMedia(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current);
|
197
208
|
hls.on(Hls.Events.MANIFEST_PARSED, function () {
|
198
|
-
|
209
|
+
var _a;
|
210
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
199
211
|
});
|
200
212
|
}
|
201
213
|
else {
|
202
|
-
videoRef.src = videoSrc;
|
214
|
+
videoRef.current.src = videoSrc;
|
203
215
|
}
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
videoRef.
|
211
|
-
videoRef.
|
212
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('
|
213
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('
|
214
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('play', handleStartPlay);
|
215
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('playing', handlePlaying);
|
216
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('pause', handlePause);
|
217
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('ended', handlePlay);
|
218
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('canplay', handlePlay);
|
219
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.addEventListener('waiting', handleWaiting);
|
216
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.setAttribute('x5-playsinline', 'true');
|
217
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.setAttribute('webkit-playsinline', 'true');
|
218
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.addEventListener('loadedmetadata', handleLoadedmetadata);
|
219
|
+
(_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.addEventListener('loadeddata', handLoadeddata);
|
220
|
+
(_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.addEventListener('play', handleStartPlay);
|
221
|
+
(_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.addEventListener('playing', handlePlaying);
|
222
|
+
(_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.addEventListener('pause', handlePause);
|
223
|
+
(_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.addEventListener('ended', handlePlay);
|
224
|
+
(_j = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _j === void 0 ? void 0 : _j.addEventListener('canplay', handlePlay);
|
225
|
+
(_k = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _k === void 0 ? void 0 : _k.addEventListener('waiting', handleWaiting);
|
220
226
|
return () => {
|
227
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
221
228
|
if (hls)
|
222
229
|
hls === null || hls === void 0 ? void 0 : hls.destroy();
|
223
230
|
setIsLoadFinish(false);
|
224
|
-
|
225
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
226
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
227
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
228
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
229
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
230
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
231
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('
|
232
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.removeEventListener('waiting', handleWaiting);
|
231
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.removeEventListener('loadedmetadata', handleLoadedmetadata);
|
232
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.removeEventListener('loadeddata', handLoadeddata);
|
233
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.removeEventListener('play', handleStartPlay);
|
234
|
+
(_d = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _d === void 0 ? void 0 : _d.removeEventListener('playing', handlePlaying);
|
235
|
+
(_e = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _e === void 0 ? void 0 : _e.removeEventListener('pause', handlePause);
|
236
|
+
(_f = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _f === void 0 ? void 0 : _f.removeEventListener('ended', handlePlay);
|
237
|
+
(_g = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _g === void 0 ? void 0 : _g.removeEventListener('canplay', handlePlay);
|
238
|
+
(_h = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _h === void 0 ? void 0 : _h.removeEventListener('waiting', handleWaiting);
|
233
239
|
};
|
234
|
-
}, [isActive, videoId, rec
|
240
|
+
}, [isActive, videoId, rec]);
|
235
241
|
(0, react_1.useEffect)(() => {
|
236
|
-
|
242
|
+
var _a, _b;
|
243
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) || !isLoadFinish)
|
237
244
|
return;
|
238
245
|
if (isActive) {
|
239
246
|
bffFbReport === null || bffFbReport === void 0 ? void 0 : bffFbReport({
|
240
247
|
eventName: 'ViewContent'
|
241
248
|
});
|
242
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
249
|
+
(_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.play();
|
243
250
|
}
|
244
251
|
else {
|
245
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
252
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
|
246
253
|
}
|
247
|
-
}, [isActive, isLoadFinish, videoRef]);
|
254
|
+
}, [isActive, isLoadFinish, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
248
255
|
(0, react_1.useEffect)(() => {
|
249
|
-
|
256
|
+
var _a, _b, _c;
|
257
|
+
if (!isActive || !(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
250
258
|
return;
|
251
|
-
const isPause = videoRef === null || videoRef === void 0 ? void 0 : videoRef.paused;
|
259
|
+
const isPause = (_a = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _a === void 0 ? void 0 : _a.paused;
|
252
260
|
if (!isPause && openHashtag) {
|
253
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.pause();
|
261
|
+
(_b = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _b === void 0 ? void 0 : _b.pause();
|
254
262
|
}
|
255
263
|
else if (!openHashtag) {
|
256
|
-
videoRef === null || videoRef === void 0 ? void 0 : videoRef.play();
|
264
|
+
(_c = videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) === null || _c === void 0 ? void 0 : _c.play();
|
257
265
|
}
|
258
|
-
}, [openHashtag, isActive, videoRef]);
|
266
|
+
}, [openHashtag, isActive, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current]);
|
259
267
|
(0, react_1.useEffect)(() => {
|
260
268
|
if (!isActive)
|
261
269
|
return;
|
@@ -302,11 +310,11 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
302
310
|
}, src: loading_gif_1.default, alt: 'placeholder image' }));
|
303
311
|
}, [waiting, isLoadFinish]);
|
304
312
|
(0, react_1.useEffect)(() => {
|
305
|
-
if (!videoRef)
|
313
|
+
if (!(videoRef === null || videoRef === void 0 ? void 0 : videoRef.current))
|
306
314
|
return;
|
307
315
|
const handleBeforeUnload = () => {
|
308
316
|
var _a;
|
309
|
-
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && videoRef && !isPauseVideo) {
|
317
|
+
if (activeIndex === index && ((_a = rec === null || rec === void 0 ? void 0 : rec.video) === null || _a === void 0 ? void 0 : _a.url) && (videoRef === null || videoRef === void 0 ? void 0 : videoRef.current) && !isPauseVideo) {
|
310
318
|
handleClickVideo('pause')();
|
311
319
|
}
|
312
320
|
};
|
@@ -314,7 +322,7 @@ const VideoWidget = ({ rec, index, height, data, muted, activeIndex, videoPostCo
|
|
314
322
|
return () => {
|
315
323
|
window.removeEventListener('beforeunload', handleBeforeUnload);
|
316
324
|
};
|
317
|
-
}, [activeIndex, index, rec, videoRef, handleClickVideo, isPauseVideo]);
|
325
|
+
}, [activeIndex, index, rec, videoRef === null || videoRef === void 0 ? void 0 : videoRef.current, handleClickVideo, isPauseVideo]);
|
318
326
|
if (!(rec === null || rec === void 0 ? void 0 : rec.video)) {
|
319
327
|
return null;
|
320
328
|
}
|