@xiping/react-components 1.0.55 → 1.0.58
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/cjs/components/blur-text/BlurText.d.ts +16 -0
- package/dist/cjs/components/blur-text/BlurText.js +1 -0
- package/dist/cjs/components/blur-text/index.d.ts +2 -0
- package/dist/cjs/components/button/Button.css +1 -0
- package/dist/cjs/components/button/Button.js +1 -1
- package/dist/cjs/components/comic-text/ComicText.css +1 -0
- package/dist/cjs/components/comic-text/ComicText.js +2 -2
- package/dist/cjs/components/dock/Duck.css +1 -0
- package/dist/cjs/components/dock/Duck.d.ts +2 -4
- package/dist/cjs/components/dock/Duck.js +1 -1
- package/dist/cjs/components/flip-text/FlipText.css +1 -0
- package/dist/cjs/components/flip-text/FlipText.js +1 -1
- package/dist/cjs/components/gradient-text/index.css +1 -0
- package/dist/cjs/components/gradient-text/index.js +1 -1
- package/dist/cjs/components/hyper-text/HyperText.css +1 -0
- package/dist/cjs/components/hyper-text/index.js +1 -1
- package/dist/cjs/components/image-compare/ImageCompare.css +1 -0
- package/dist/cjs/components/image-compare/ImageCompare.d.ts +4 -2
- package/dist/cjs/components/image-compare/ImageCompare.js +1 -1
- package/dist/cjs/components/image-viewer/ImageThumbnails.css +1 -0
- package/dist/cjs/components/image-viewer/ImageThumbnails.js +1 -1
- package/dist/cjs/components/image-viewer/ImageViewer.css +1 -0
- package/dist/cjs/components/image-viewer/ImageViewer.js +1 -1
- package/dist/cjs/components/message/Message.css +1 -0
- package/dist/cjs/components/message/Message.js +1 -1
- package/dist/cjs/components/pointer/Pointer.css +1 -0
- package/dist/cjs/components/pointer/Pointer.js +1 -1
- package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.css +1 -0
- package/dist/cjs/components/scratch-to-reveal/ScratchToReveal.js +1 -1
- package/dist/cjs/components/shimmer-button/ShimmerButton.css +1 -0
- package/dist/cjs/components/shimmer-button/ShimmerButton.js +1 -1
- package/dist/cjs/components/shiny-button/ShinyButton.css +1 -0
- package/dist/cjs/components/shiny-button/ShinyButton.js +1 -1
- package/dist/cjs/components/shiny-text/ShinyText.css +1 -0
- package/dist/cjs/components/shiny-text/ShinyText.d.ts +16 -0
- package/dist/cjs/components/shiny-text/ShinyText.js +1 -0
- package/dist/cjs/components/shiny-text/index.d.ts +2 -0
- package/dist/cjs/components/sparkles-text/SparklesText.css +1 -0
- package/dist/cjs/components/sparkles-text/SparklesText.js +1 -1
- package/dist/cjs/components/split-text/SplitText.css +1 -0
- package/dist/cjs/components/split-text/SplitText.js +1 -1
- package/dist/cjs/components/subtitle-player/CurrentMode.css +1 -0
- package/dist/cjs/components/subtitle-player/CurrentMode.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/CurrentMode.js +2 -2
- package/dist/cjs/components/subtitle-player/LyricsMode.css +1 -0
- package/dist/cjs/components/subtitle-player/LyricsMode.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/LyricsMode.js +2 -2
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.css +1 -0
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
- package/dist/cjs/components/subtitle-player/SubtitlePlayer.js +1 -1
- package/dist/cjs/components/text-animate/TextAnimate.css +1 -0
- package/dist/cjs/components/text-animate/TextAnimate.js +2 -2
- package/dist/cjs/components/text-type/TextType.css +1 -0
- package/dist/cjs/components/text-type/TextType.js +1 -1
- package/dist/cjs/components/txt-reader/index.module.css +1 -0
- package/dist/cjs/components/txt-reader/index.module.css.js +1 -1
- package/dist/cjs/components/typing-animation/index.css +1 -0
- package/dist/cjs/components/typing-animation/index.js +1 -1
- package/dist/cjs/components/variable-proximity/index.css +1 -0
- package/dist/cjs/components/variable-proximity/index.js +1 -1
- package/dist/cjs/components/video-dialog/VideoDialog.css +1 -0
- package/dist/cjs/components/video-dialog/VideoDialog.js +1 -1
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.d.ts +3 -3
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.js +1 -1
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.mobile.css +1 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayer.pc.css +1 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayerMobile.d.ts +20 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayerMobile.js +1 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayerPC.d.ts +23 -0
- package/dist/cjs/components/video-subtitle-player/VideoSubtitlePlayerPC.js +1 -0
- package/dist/cjs/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutMobile.d.ts +8 -0
- package/dist/cjs/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutMobile.js +1 -0
- package/dist/cjs/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutPC.d.ts +6 -0
- package/dist/cjs/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutPC.js +1 -0
- package/dist/cjs/components/video-subtitle-player/layouts/index.d.ts +3 -0
- package/dist/cjs/components/video-subtitle-player/layouts/types.d.ts +17 -0
- package/dist/cjs/components/video-subtitle-player/useXGPlayer.d.ts +10 -0
- package/dist/cjs/components/video-subtitle-player/useXGPlayer.js +1 -0
- package/dist/cjs/index.d.ts +2 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/llms.txt +2 -13
- package/dist/cjs/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
- package/dist/cjs/react-components.css +114 -1
- package/dist/es/components/blur-text/BlurText.d.ts +16 -0
- package/dist/es/components/blur-text/BlurText.js +77 -0
- package/dist/es/components/blur-text/index.d.ts +2 -0
- package/dist/es/components/button/Button.css +1 -0
- package/dist/es/components/button/Button.js +35 -46
- package/dist/es/components/comic-text/ComicText.css +1 -0
- package/dist/es/components/comic-text/ComicText.js +13 -12
- package/dist/es/components/dock/Duck.css +1 -0
- package/dist/es/components/dock/Duck.d.ts +2 -4
- package/dist/es/components/dock/Duck.js +60 -64
- package/dist/es/components/flip-text/FlipText.css +1 -0
- package/dist/es/components/flip-text/FlipText.js +8 -8
- package/dist/es/components/gradient-text/index.css +1 -0
- package/dist/es/components/gradient-text/index.js +9 -8
- package/dist/es/components/hyper-text/HyperText.css +1 -0
- package/dist/es/components/hyper-text/index.js +16 -13
- package/dist/es/components/image-compare/ImageCompare.css +1 -0
- package/dist/es/components/image-compare/ImageCompare.d.ts +4 -2
- package/dist/es/components/image-compare/ImageCompare.js +55 -48
- package/dist/es/components/image-viewer/ImageThumbnails.css +1 -0
- package/dist/es/components/image-viewer/ImageThumbnails.js +41 -42
- package/dist/es/components/image-viewer/ImageViewer.css +1 -0
- package/dist/es/components/image-viewer/ImageViewer.js +34 -35
- package/dist/es/components/message/Message.css +1 -0
- package/dist/es/components/message/Message.js +65 -54
- package/dist/es/components/pointer/Pointer.css +1 -0
- package/dist/es/components/pointer/Pointer.js +23 -25
- package/dist/es/components/scratch-to-reveal/ScratchToReveal.css +1 -0
- package/dist/es/components/scratch-to-reveal/ScratchToReveal.js +17 -16
- package/dist/es/components/shimmer-button/ShimmerButton.css +1 -0
- package/dist/es/components/shimmer-button/ShimmerButton.js +8 -8
- package/dist/es/components/shiny-button/ShinyButton.css +1 -0
- package/dist/es/components/shiny-button/ShinyButton.js +13 -13
- package/dist/es/components/shiny-text/ShinyText.css +1 -0
- package/dist/es/components/shiny-text/ShinyText.d.ts +16 -0
- package/dist/es/components/shiny-text/ShinyText.js +76 -0
- package/dist/es/components/shiny-text/index.d.ts +2 -0
- package/dist/es/components/sparkles-text/SparklesText.css +1 -0
- package/dist/es/components/sparkles-text/SparklesText.js +14 -14
- package/dist/es/components/split-text/SplitText.css +1 -0
- package/dist/es/components/split-text/SplitText.js +1 -1
- package/dist/es/components/subtitle-player/CurrentMode.css +1 -0
- package/dist/es/components/subtitle-player/CurrentMode.d.ts +2 -0
- package/dist/es/components/subtitle-player/CurrentMode.js +75 -40
- package/dist/es/components/subtitle-player/LyricsMode.css +1 -0
- package/dist/es/components/subtitle-player/LyricsMode.d.ts +2 -0
- package/dist/es/components/subtitle-player/LyricsMode.js +139 -68
- package/dist/es/components/subtitle-player/SubtitlePlayer.css +1 -0
- package/dist/es/components/subtitle-player/SubtitlePlayer.d.ts +2 -0
- package/dist/es/components/subtitle-player/SubtitlePlayer.js +63 -60
- package/dist/es/components/text-animate/TextAnimate.css +1 -0
- package/dist/es/components/text-animate/TextAnimate.js +57 -55
- package/dist/es/components/text-type/TextType.css +1 -0
- package/dist/es/components/text-type/TextType.js +24 -19
- package/dist/es/components/txt-reader/index.module.css +1 -0
- package/dist/es/components/txt-reader/index.module.css.js +1 -1
- package/dist/es/components/typing-animation/index.css +1 -0
- package/dist/es/components/typing-animation/index.js +12 -12
- package/dist/es/components/variable-proximity/index.css +1 -0
- package/dist/es/components/variable-proximity/index.js +19 -18
- package/dist/es/components/video-dialog/VideoDialog.css +1 -0
- package/dist/es/components/video-dialog/VideoDialog.js +1 -1
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.css +1 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.d.ts +3 -3
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.js +69 -122
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.mobile.css +1 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayer.pc.css +1 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayerMobile.d.ts +20 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayerMobile.js +47 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayerPC.d.ts +23 -0
- package/dist/es/components/video-subtitle-player/VideoSubtitlePlayerPC.js +75 -0
- package/dist/es/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutMobile.d.ts +8 -0
- package/dist/es/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutMobile.js +21 -0
- package/dist/es/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutPC.d.ts +6 -0
- package/dist/es/components/video-subtitle-player/layouts/VideoSubtitlePlayerLayoutPC.js +50 -0
- package/dist/es/components/video-subtitle-player/layouts/index.d.ts +3 -0
- package/dist/es/components/video-subtitle-player/layouts/types.d.ts +17 -0
- package/dist/es/components/video-subtitle-player/useXGPlayer.d.ts +10 -0
- package/dist/es/components/video-subtitle-player/useXGPlayer.js +36 -0
- package/dist/es/index.d.ts +2 -1
- package/dist/es/index.js +59 -60
- package/dist/es/llms.txt +2 -13
- package/dist/es/node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css +1 -0
- package/dist/es/react-components.css +114 -1
- package/package.json +20 -15
- package/dist/cjs/components/animated-list/AnimatedList.d.ts +0 -9
- package/dist/cjs/components/animated-list/AnimatedList.js +0 -1
- package/dist/cjs/components/animated-list/index.d.ts +0 -1
- package/dist/cjs/utils/utils.js +0 -1
- package/dist/es/components/animated-list/AnimatedList.d.ts +0 -9
- package/dist/es/components/animated-list/AnimatedList.js +0 -44
- package/dist/es/components/animated-list/index.d.ts +0 -1
- package/dist/es/utils/utils.js +0 -8
|
@@ -1,128 +1,75 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useRef as
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
const
|
|
10
|
-
videoUrl:
|
|
11
|
-
subtitles:
|
|
12
|
-
poster:
|
|
13
|
-
className:
|
|
14
|
-
style:
|
|
15
|
-
onFetchDetail:
|
|
1
|
+
import { jsx as u } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as v, useEffect as w, useCallback as d } from "react";
|
|
3
|
+
import { isMobile as V, isTablet as g } from "react-device-detect";
|
|
4
|
+
import { useVideoSubtitleStore as k } from "./useVideoSubtitleStore.js";
|
|
5
|
+
import { useXGPlayer as H } from "./useXGPlayer.js";
|
|
6
|
+
import { VideoSubtitlePlayerPC as M } from "./VideoSubtitlePlayerPC.js";
|
|
7
|
+
import { VideoSubtitlePlayerMobile as T } from "./VideoSubtitlePlayerMobile.js";
|
|
8
|
+
import './VideoSubtitlePlayer.css';/* empty css */
|
|
9
|
+
const X = ({
|
|
10
|
+
videoUrl: p,
|
|
11
|
+
subtitles: r,
|
|
12
|
+
poster: b,
|
|
13
|
+
className: l = "",
|
|
14
|
+
style: n,
|
|
15
|
+
onFetchDetail: e,
|
|
16
|
+
forceLayout: m
|
|
16
17
|
}) => {
|
|
17
|
-
const
|
|
18
|
-
currentTime:
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
d.current = i;
|
|
44
|
-
const f = () => {
|
|
45
|
-
const R = i.currentTime || 0;
|
|
46
|
-
_(R);
|
|
47
|
-
}, x = () => {
|
|
48
|
-
s(!0);
|
|
49
|
-
}, g = () => {
|
|
50
|
-
s(!1);
|
|
51
|
-
}, b = () => {
|
|
52
|
-
s(!1);
|
|
53
|
-
};
|
|
54
|
-
return i.on("timeupdate", f), i.on("play", x), i.on("pause", g), i.on("ended", b), () => {
|
|
55
|
-
i.off("timeupdate", f), i.off("play", x), i.off("pause", g), i.off("ended", b), i.destroy(), d.current = null;
|
|
56
|
-
};
|
|
57
|
-
}, [m, v, _, s]), u(() => {
|
|
58
|
-
if (d.current) {
|
|
59
|
-
const a = d.current;
|
|
60
|
-
Math.abs(a.currentTime - r) > 0.5 && (a.currentTime = r);
|
|
61
|
-
}
|
|
62
|
-
}, [r]);
|
|
63
|
-
const C = H(
|
|
64
|
-
async (a) => {
|
|
65
|
-
c ? await c(a) : await y(a);
|
|
18
|
+
const t = v(null), c = m !== void 0 ? m === "mobile" : V || g, {
|
|
19
|
+
currentTime: a,
|
|
20
|
+
setCurrentTime: C,
|
|
21
|
+
setIsPlaying: y,
|
|
22
|
+
setSubtitles: s,
|
|
23
|
+
currentDetail: P,
|
|
24
|
+
isLoadingDetail: S,
|
|
25
|
+
fetchDetail: i
|
|
26
|
+
} = k();
|
|
27
|
+
w(() => {
|
|
28
|
+
s(r);
|
|
29
|
+
}, [r, s]), H(
|
|
30
|
+
t,
|
|
31
|
+
p,
|
|
32
|
+
b,
|
|
33
|
+
{ setCurrentTime: C, setIsPlaying: y },
|
|
34
|
+
a
|
|
35
|
+
);
|
|
36
|
+
const f = d(
|
|
37
|
+
async (o) => {
|
|
38
|
+
e ? await e(o) : await i(o);
|
|
39
|
+
},
|
|
40
|
+
[e, i]
|
|
41
|
+
), W = d(
|
|
42
|
+
async (o) => {
|
|
43
|
+
e ? await e(o) : await i(o);
|
|
66
44
|
},
|
|
67
|
-
[
|
|
45
|
+
[e, i]
|
|
46
|
+
);
|
|
47
|
+
return c ? /* @__PURE__ */ u(
|
|
48
|
+
T,
|
|
49
|
+
{
|
|
50
|
+
playerRef: t,
|
|
51
|
+
subtitles: r,
|
|
52
|
+
currentTime: a,
|
|
53
|
+
onWordHoverChange: f,
|
|
54
|
+
onWordClick: W,
|
|
55
|
+
className: l,
|
|
56
|
+
style: n
|
|
57
|
+
}
|
|
58
|
+
) : /* @__PURE__ */ u(
|
|
59
|
+
M,
|
|
60
|
+
{
|
|
61
|
+
playerRef: t,
|
|
62
|
+
subtitles: r,
|
|
63
|
+
currentTime: a,
|
|
64
|
+
currentDetail: P,
|
|
65
|
+
isLoadingDetail: S,
|
|
66
|
+
onWordHoverChange: f,
|
|
67
|
+
className: l,
|
|
68
|
+
style: n
|
|
69
|
+
}
|
|
68
70
|
);
|
|
69
|
-
return /* @__PURE__ */ e("div", { className: `xiping-video-subtitle-player ${P}`, style: w, children: /* @__PURE__ */ t(z, { direction: "horizontal", children: [
|
|
70
|
-
/* @__PURE__ */ e(o, { defaultSize: 65, minSize: 40, children: /* @__PURE__ */ t(z, { direction: "vertical", children: [
|
|
71
|
-
/* @__PURE__ */ e(o, { defaultSize: 60, minSize: 30, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__video-wrapper", children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__video-container", children: /* @__PURE__ */ e(
|
|
72
|
-
"div",
|
|
73
|
-
{
|
|
74
|
-
ref: n,
|
|
75
|
-
className: "xiping-video-subtitle-player__video"
|
|
76
|
-
}
|
|
77
|
-
) }) }) }),
|
|
78
|
-
/* @__PURE__ */ e(S, { className: "xiping-video-subtitle-player__resize-handle xiping-video-subtitle-player__resize-handle--vertical" }),
|
|
79
|
-
/* @__PURE__ */ e(o, { defaultSize: 40, minSize: 20, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__subtitle-container", children: /* @__PURE__ */ e(
|
|
80
|
-
j,
|
|
81
|
-
{
|
|
82
|
-
subtitles: p,
|
|
83
|
-
currentTime: r,
|
|
84
|
-
mode: "current",
|
|
85
|
-
onWordHoverChange: C
|
|
86
|
-
}
|
|
87
|
-
) }) })
|
|
88
|
-
] }) }),
|
|
89
|
-
/* @__PURE__ */ e(S, { className: "xiping-video-subtitle-player__resize-handle xiping-video-subtitle-player__resize-handle--horizontal" }),
|
|
90
|
-
/* @__PURE__ */ e(o, { defaultSize: 35, minSize: 25, maxSize: 50, children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__right", children: /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail", children: T ? /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-loading", children: [
|
|
91
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-loading-spinner" }),
|
|
92
|
-
/* @__PURE__ */ e("span", { children: "加载中..." })
|
|
93
|
-
] }) : l ? /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-content", children: [
|
|
94
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-word", children: l.word }),
|
|
95
|
-
l.pronunciation && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pronunciation", children: l.pronunciation }),
|
|
96
|
-
l.partOfSpeech && /* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-pos", children: l.partOfSpeech }),
|
|
97
|
-
l.translation && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-translation", children: [
|
|
98
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "中文翻译" }),
|
|
99
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.translation })
|
|
100
|
-
] }),
|
|
101
|
-
l.definition && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-definition", children: [
|
|
102
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "英文解释" }),
|
|
103
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-text", children: l.definition })
|
|
104
|
-
] }),
|
|
105
|
-
l.examples && l.examples.length > 0 && /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-examples", children: [
|
|
106
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-label", children: "例句" }),
|
|
107
|
-
l.examples.map((a, i) => /* @__PURE__ */ t(
|
|
108
|
-
"div",
|
|
109
|
-
{
|
|
110
|
-
className: "xiping-video-subtitle-player__detail-example",
|
|
111
|
-
children: [
|
|
112
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-en", children: a.sentence }),
|
|
113
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-example-zh", children: a.translation })
|
|
114
|
-
]
|
|
115
|
-
},
|
|
116
|
-
i
|
|
117
|
-
))
|
|
118
|
-
] })
|
|
119
|
-
] }) : /* @__PURE__ */ t("div", { className: "xiping-video-subtitle-player__detail-empty", children: [
|
|
120
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-icon", children: "📖" }),
|
|
121
|
-
/* @__PURE__ */ e("div", { className: "xiping-video-subtitle-player__detail-empty-text", children: "将鼠标悬停在字幕单词上查看详情" })
|
|
122
|
-
] }) }) }) })
|
|
123
|
-
] }) });
|
|
124
71
|
};
|
|
125
72
|
export {
|
|
126
|
-
|
|
127
|
-
|
|
73
|
+
X as VideoSubtitlePlayer,
|
|
74
|
+
X as default
|
|
128
75
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-video-subtitle-player--mobile{display:flex;flex-direction:column;min-height:0;height:100%}.xiping-video-subtitle-player__mobile-video{flex:0 0 auto;width:100%;aspect-ratio:16 / 9;background:#000}.xiping-video-subtitle-player__mobile-video-wrapper{width:100%;height:100%;background:#000;overflow:hidden}.xiping-video-subtitle-player__mobile-video-container{position:relative;width:100%;height:100%;background-color:#a62c2c;overflow:hidden}.xiping-video-subtitle-player__mobile-video-container .xgplayer{width:100%!important;height:100%!important}.xiping-video-subtitle-player__mobile-video-container .xgplayer video{-o-object-fit:fill!important;object-fit:fill!important}.xiping-video-subtitle-player__mobile-subtitle{flex:1;min-height:0;padding:12px 16px;overflow-y:auto;background:#0000004d;-webkit-overflow-scrolling:touch}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.xiping-video-subtitle-player--pc .xiping-video-subtitle-player__panel-group,.xiping-video-subtitle-player--pc .xiping-video-subtitle-player__panel-group-inner{width:100%;height:100%}.xiping-video-subtitle-player--pc .xiping-video-subtitle-player__right{border-left:1px solid rgba(255,255,255,.1)}.xiping-video-subtitle-player__resize-handle--horizontal{position:relative;width:2px;background:#ffffff1a;cursor:col-resize;transition:background .2s ease;flex-shrink:0}.xiping-video-subtitle-player__resize-handle--horizontal:hover{background:#fbbf2480}.xiping-video-subtitle-player__resize-handle--horizontal:active{background:#fbbf24cc}.xiping-video-subtitle-player__resize-handle--horizontal:before{content:"";position:absolute;inset:0 -4px;cursor:col-resize}.xiping-video-subtitle-player__resize-handle--vertical{position:relative;height:2px;background:#ffffff1a;cursor:row-resize;transition:background .2s ease;flex-shrink:0}.xiping-video-subtitle-player__resize-handle--vertical:hover{background:#fbbf2480}.xiping-video-subtitle-player__resize-handle--vertical:active{background:#fbbf24cc}.xiping-video-subtitle-player__resize-handle--vertical:before{content:"";position:absolute;inset:-4px 0;cursor:row-resize}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { default as React, RefObject } from 'react';
|
|
2
|
+
import { SubtitleData, HoverTarget, WordClickTarget } from '../subtitle-player/SubtitlePlayer';
|
|
3
|
+
export interface VideoSubtitlePlayerMobileProps {
|
|
4
|
+
/** 播放器挂载的容器 ref */
|
|
5
|
+
playerRef: RefObject<HTMLDivElement | null>;
|
|
6
|
+
/** 字幕数据 */
|
|
7
|
+
subtitles: SubtitleData[];
|
|
8
|
+
/** 当前播放时间(秒) */
|
|
9
|
+
currentTime: number;
|
|
10
|
+
/** 单词 hover 变化时拉取/展示详情(可为弹窗等) */
|
|
11
|
+
onWordHoverChange: (target: HoverTarget | null) => void | Promise<void>;
|
|
12
|
+
/** 单词点击时拉取/展示详情(移动端主要交互) */
|
|
13
|
+
onWordClick: (target: WordClickTarget) => void | Promise<void>;
|
|
14
|
+
className?: string;
|
|
15
|
+
style?: React.CSSProperties;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 移动端视图:上下两栏(视频 + 字幕),无右侧详情区,详情后续以弹窗等形式实现
|
|
19
|
+
*/
|
|
20
|
+
export declare const VideoSubtitlePlayerMobile: React.FC<VideoSubtitlePlayerMobileProps>;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { jsx as e } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as l } from "react";
|
|
3
|
+
import u from "clsx";
|
|
4
|
+
import { SubtitlePlayer as y } from "../subtitle-player/SubtitlePlayer.js";
|
|
5
|
+
import { VideoSubtitlePlayerLayoutMobile as f } from "./layouts/VideoSubtitlePlayerLayoutMobile.js";
|
|
6
|
+
const P = ({
|
|
7
|
+
playerRef: r,
|
|
8
|
+
subtitles: a,
|
|
9
|
+
currentTime: s,
|
|
10
|
+
onWordHoverChange: t,
|
|
11
|
+
onWordClick: i,
|
|
12
|
+
className: c = "",
|
|
13
|
+
style: m
|
|
14
|
+
}) => {
|
|
15
|
+
const n = l(
|
|
16
|
+
async (o) => {
|
|
17
|
+
await t(o);
|
|
18
|
+
},
|
|
19
|
+
[t]
|
|
20
|
+
), d = l(
|
|
21
|
+
async (o) => {
|
|
22
|
+
await i(o);
|
|
23
|
+
},
|
|
24
|
+
[i]
|
|
25
|
+
), b = /* @__PURE__ */ e("div", { ref: r, className: "xiping-video-subtitle-player__video" }), p = /* @__PURE__ */ e(
|
|
26
|
+
y,
|
|
27
|
+
{
|
|
28
|
+
subtitles: a,
|
|
29
|
+
currentTime: s,
|
|
30
|
+
mode: "lyrics",
|
|
31
|
+
onWordHoverChange: n,
|
|
32
|
+
onWordClick: d
|
|
33
|
+
}
|
|
34
|
+
);
|
|
35
|
+
return /* @__PURE__ */ e(
|
|
36
|
+
f,
|
|
37
|
+
{
|
|
38
|
+
className: u(c),
|
|
39
|
+
style: m,
|
|
40
|
+
videoSlot: b,
|
|
41
|
+
subtitleSlot: p
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
P as VideoSubtitlePlayerMobile
|
|
47
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { default as React, RefObject } from 'react';
|
|
2
|
+
import { SubtitleData, HoverTarget } from '../subtitle-player/SubtitlePlayer';
|
|
3
|
+
import { SubtitleDetail } from './useVideoSubtitleStore';
|
|
4
|
+
export interface VideoSubtitlePlayerPCProps {
|
|
5
|
+
/** 播放器挂载的容器 ref */
|
|
6
|
+
playerRef: RefObject<HTMLDivElement | null>;
|
|
7
|
+
/** 字幕数据 */
|
|
8
|
+
subtitles: SubtitleData[];
|
|
9
|
+
/** 当前播放时间(秒) */
|
|
10
|
+
currentTime: number;
|
|
11
|
+
/** 当前悬停单词的详情 */
|
|
12
|
+
currentDetail: SubtitleDetail | null;
|
|
13
|
+
/** 是否正在加载详情 */
|
|
14
|
+
isLoadingDetail: boolean;
|
|
15
|
+
/** 单词 hover 变化时拉取/展示详情 */
|
|
16
|
+
onWordHoverChange: (target: HoverTarget | null) => void | Promise<void>;
|
|
17
|
+
className?: string;
|
|
18
|
+
style?: React.CSSProperties;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* PC 端视图:可拖拽分栏 + 右侧详情区,所有 PC 专属 UI 集中在此
|
|
22
|
+
*/
|
|
23
|
+
export declare const VideoSubtitlePlayerPC: React.FC<VideoSubtitlePlayerPCProps>;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { jsx as i, jsxs as l } from "react/jsx-runtime";
|
|
2
|
+
import { useCallback as y } from "react";
|
|
3
|
+
import b from "clsx";
|
|
4
|
+
import { SubtitlePlayer as h } from "../subtitle-player/SubtitlePlayer.js";
|
|
5
|
+
import { VideoSubtitlePlayerLayoutPC as g } from "./layouts/VideoSubtitlePlayerLayoutPC.js";
|
|
6
|
+
const C = ({
|
|
7
|
+
playerRef: t,
|
|
8
|
+
subtitles: s,
|
|
9
|
+
currentTime: n,
|
|
10
|
+
currentDetail: e,
|
|
11
|
+
isLoadingDetail: p,
|
|
12
|
+
onWordHoverChange: d,
|
|
13
|
+
className: o = "",
|
|
14
|
+
style: r
|
|
15
|
+
}) => {
|
|
16
|
+
const c = y(
|
|
17
|
+
async (a) => {
|
|
18
|
+
await d(a);
|
|
19
|
+
},
|
|
20
|
+
[d]
|
|
21
|
+
), v = /* @__PURE__ */ i("div", { ref: t, className: "xiping-video-subtitle-player__video" }), m = /* @__PURE__ */ i(
|
|
22
|
+
h,
|
|
23
|
+
{
|
|
24
|
+
subtitles: s,
|
|
25
|
+
currentTime: n,
|
|
26
|
+
mode: "lyrics",
|
|
27
|
+
onWordHoverChange: c
|
|
28
|
+
}
|
|
29
|
+
), _ = /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail", children: p ? /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-loading", children: [
|
|
30
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-loading-spinner" }),
|
|
31
|
+
/* @__PURE__ */ i("span", { children: "加载中..." })
|
|
32
|
+
] }) : e ? /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-content", children: [
|
|
33
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-word", children: e.word }),
|
|
34
|
+
e.pronunciation && /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-pronunciation", children: e.pronunciation }),
|
|
35
|
+
e.partOfSpeech && /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-pos", children: e.partOfSpeech }),
|
|
36
|
+
e.translation && /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-translation", children: [
|
|
37
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-label", children: "中文翻译" }),
|
|
38
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-text", children: e.translation })
|
|
39
|
+
] }),
|
|
40
|
+
e.definition && /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-definition", children: [
|
|
41
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-label", children: "英文解释" }),
|
|
42
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-text", children: e.definition })
|
|
43
|
+
] }),
|
|
44
|
+
e.examples && e.examples.length > 0 && /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-examples", children: [
|
|
45
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-label", children: "例句" }),
|
|
46
|
+
e.examples.map((a, x) => /* @__PURE__ */ l(
|
|
47
|
+
"div",
|
|
48
|
+
{
|
|
49
|
+
className: "xiping-video-subtitle-player__detail-example",
|
|
50
|
+
children: [
|
|
51
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-example-en", children: a.sentence }),
|
|
52
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-example-zh", children: a.translation })
|
|
53
|
+
]
|
|
54
|
+
},
|
|
55
|
+
x
|
|
56
|
+
))
|
|
57
|
+
] })
|
|
58
|
+
] }) : /* @__PURE__ */ l("div", { className: "xiping-video-subtitle-player__detail-empty", children: [
|
|
59
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-empty-icon", children: "📖" }),
|
|
60
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__detail-empty-text", children: "将鼠标悬停在字幕单词上查看详情" })
|
|
61
|
+
] }) });
|
|
62
|
+
return /* @__PURE__ */ i(
|
|
63
|
+
g,
|
|
64
|
+
{
|
|
65
|
+
className: b(o),
|
|
66
|
+
style: r,
|
|
67
|
+
videoSlot: v,
|
|
68
|
+
subtitleSlot: m,
|
|
69
|
+
detailSlot: _
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
C as VideoSubtitlePlayerPC
|
|
75
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { VideoSubtitlePlayerLayoutMobileProps } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* 移动端布局:上下两栏,无拖拽
|
|
5
|
+
* - 上:视频区域(100vw 宽,16:9 占位)
|
|
6
|
+
* - 下:仅字幕区域(单词详情后续以弹窗等形式实现,此处不展示)
|
|
7
|
+
*/
|
|
8
|
+
export declare const VideoSubtitlePlayerLayoutMobile: React.FC<VideoSubtitlePlayerLayoutMobileProps>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { jsxs as r, jsx as i } from "react/jsx-runtime";
|
|
2
|
+
import s from "clsx";
|
|
3
|
+
import '../VideoSubtitlePlayer.mobile.css';/* empty css */
|
|
4
|
+
const m = ({ className: e = "", style: l, videoSlot: o, subtitleSlot: t }) => /* @__PURE__ */ r(
|
|
5
|
+
"div",
|
|
6
|
+
{
|
|
7
|
+
className: s(
|
|
8
|
+
"xiping-video-subtitle-player",
|
|
9
|
+
"xiping-video-subtitle-player--mobile",
|
|
10
|
+
e
|
|
11
|
+
),
|
|
12
|
+
style: l,
|
|
13
|
+
children: [
|
|
14
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__mobile-video", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__mobile-video-wrapper", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__mobile-video-container", children: o }) }) }),
|
|
15
|
+
/* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__mobile-subtitle", children: t })
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
export {
|
|
20
|
+
m as VideoSubtitlePlayerLayoutMobile
|
|
21
|
+
};
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { jsx as i, jsxs as a } from "react/jsx-runtime";
|
|
2
|
+
import { Group as r, Panel as e, Separator as t } from "react-resizable-panels";
|
|
3
|
+
import l from "clsx";
|
|
4
|
+
import '../VideoSubtitlePlayer.pc.css';/* empty css */
|
|
5
|
+
const _ = ({ className: n = "", style: s, videoSlot: d, subtitleSlot: o, detailSlot: p }) => /* @__PURE__ */ i(
|
|
6
|
+
"div",
|
|
7
|
+
{
|
|
8
|
+
className: l(
|
|
9
|
+
"xiping-video-subtitle-player",
|
|
10
|
+
"xiping-video-subtitle-player--pc",
|
|
11
|
+
n
|
|
12
|
+
),
|
|
13
|
+
style: s,
|
|
14
|
+
children: /* @__PURE__ */ a(
|
|
15
|
+
r,
|
|
16
|
+
{
|
|
17
|
+
orientation: "horizontal",
|
|
18
|
+
className: "xiping-video-subtitle-player__panel-group",
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ i(e, { defaultSize: "65", minSize: "40", children: /* @__PURE__ */ a(r, { orientation: "vertical", className: "xiping-video-subtitle-player__panel-group-inner", children: [
|
|
21
|
+
/* @__PURE__ */ i(e, { defaultSize: "60", minSize: "30", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__video-wrapper", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__video-container", children: d }) }) }),
|
|
22
|
+
/* @__PURE__ */ i(
|
|
23
|
+
t,
|
|
24
|
+
{
|
|
25
|
+
className: l(
|
|
26
|
+
"xiping-video-subtitle-player__resize-handle",
|
|
27
|
+
"xiping-video-subtitle-player__resize-handle--vertical"
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
),
|
|
31
|
+
/* @__PURE__ */ i(e, { defaultSize: "40", minSize: "20", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__subtitle-container", children: o }) })
|
|
32
|
+
] }) }),
|
|
33
|
+
/* @__PURE__ */ i(
|
|
34
|
+
t,
|
|
35
|
+
{
|
|
36
|
+
className: l(
|
|
37
|
+
"xiping-video-subtitle-player__resize-handle",
|
|
38
|
+
"xiping-video-subtitle-player__resize-handle--horizontal"
|
|
39
|
+
)
|
|
40
|
+
}
|
|
41
|
+
),
|
|
42
|
+
/* @__PURE__ */ i(e, { defaultSize: "35", minSize: "25", maxSize: "50", children: /* @__PURE__ */ i("div", { className: "xiping-video-subtitle-player__right", children: p }) })
|
|
43
|
+
]
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
);
|
|
48
|
+
export {
|
|
49
|
+
_ as VideoSubtitlePlayerLayoutPC
|
|
50
|
+
};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
/** 移动端布局 props:仅视频 + 字幕,无详情区(详情后续弹窗等单独实现) */
|
|
3
|
+
export interface VideoSubtitlePlayerLayoutMobileProps {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: React.CSSProperties;
|
|
6
|
+
videoSlot: ReactNode;
|
|
7
|
+
subtitleSlot: ReactNode;
|
|
8
|
+
}
|
|
9
|
+
/** PC 端布局 props:视频 + 字幕 + 右侧详情区 */
|
|
10
|
+
export interface VideoSubtitlePlayerLayoutPCProps {
|
|
11
|
+
className?: string;
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
videoSlot: ReactNode;
|
|
14
|
+
subtitleSlot: ReactNode;
|
|
15
|
+
/** 右侧详情区域 */
|
|
16
|
+
detailSlot: ReactNode;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { RefObject } from 'react';
|
|
2
|
+
export interface UseXGPlayerCallbacks {
|
|
3
|
+
setCurrentTime: (time: number) => void;
|
|
4
|
+
setIsPlaying: (playing: boolean) => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* 封装 xgplayer 的创建、事件绑定与销毁,以及外部 currentTime 同步
|
|
8
|
+
* 调用方需渲染一个 div 并传入其 ref,播放器会挂载到该节点
|
|
9
|
+
*/
|
|
10
|
+
export declare function useXGPlayer(containerRef: RefObject<HTMLDivElement | null>, videoUrl: string, poster: string | undefined, callbacks: UseXGPlayerCallbacks, currentTime: number): void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { useRef as h, useEffect as p } from "react";
|
|
2
|
+
import P from "xgplayer";
|
|
3
|
+
import '../../node_modules/.pnpm/xgplayer@3.0.23_core-js@3.47.0/node_modules/xgplayer/dist/index.min.css';/* empty css */
|
|
4
|
+
function T(o, s, u, y, r) {
|
|
5
|
+
const a = h(null), { setCurrentTime: l, setIsPlaying: n } = y;
|
|
6
|
+
p(() => {
|
|
7
|
+
if (!o.current) return;
|
|
8
|
+
const t = `xiping-video-subtitle-player-${Date.now()}`;
|
|
9
|
+
o.current.id = t;
|
|
10
|
+
const e = new P({
|
|
11
|
+
id: t,
|
|
12
|
+
url: s,
|
|
13
|
+
poster: u,
|
|
14
|
+
autoplay: !1,
|
|
15
|
+
fluid: !1,
|
|
16
|
+
width: "100%",
|
|
17
|
+
height: "100%",
|
|
18
|
+
controls: !0
|
|
19
|
+
});
|
|
20
|
+
a.current = e;
|
|
21
|
+
const f = () => {
|
|
22
|
+
const m = e.currentTime ?? 0;
|
|
23
|
+
l(m);
|
|
24
|
+
}, i = () => n(!0), c = () => n(!1), d = () => n(!1);
|
|
25
|
+
return e.on("timeupdate", f), e.on("play", i), e.on("pause", c), e.on("ended", d), () => {
|
|
26
|
+
e.off("timeupdate", f), e.off("play", i), e.off("pause", c), e.off("ended", d), e.destroy(), a.current = null;
|
|
27
|
+
};
|
|
28
|
+
}, [s, u, l, n]), p(() => {
|
|
29
|
+
const t = a.current;
|
|
30
|
+
if (!t) return;
|
|
31
|
+
Math.abs(t.currentTime - r) > 0.5 && (t.currentTime = r);
|
|
32
|
+
}, [r]);
|
|
33
|
+
}
|
|
34
|
+
export {
|
|
35
|
+
T as useXGPlayer
|
|
36
|
+
};
|
package/dist/es/index.d.ts
CHANGED
|
@@ -18,13 +18,14 @@ export * from './components/blur-fade';
|
|
|
18
18
|
export * from './components/video-dialog';
|
|
19
19
|
export * from './components/comic-text';
|
|
20
20
|
export * from './components/flip-text';
|
|
21
|
-
export * from './components/animated-list';
|
|
22
21
|
export * from './components/shiny-button';
|
|
22
|
+
export * from './components/shiny-text';
|
|
23
23
|
export * from './components/scratch-to-reveal';
|
|
24
24
|
export * from './components/split-text';
|
|
25
25
|
export * from './components/dome-gallery';
|
|
26
26
|
export * from './components/text-type';
|
|
27
27
|
export * from './components/gradient-text';
|
|
28
|
+
export * from './components/blur-text';
|
|
28
29
|
export * from './components/variable-proximity';
|
|
29
30
|
export * from './components/subtitle-player';
|
|
30
31
|
export * from './components/video-subtitle-player';
|