@djangocfg/ui-nextjs 2.1.65 → 2.1.66
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/package.json +9 -6
- package/src/blocks/SplitHero/SplitHeroMedia.tsx +2 -1
- package/src/tools/AudioPlayer/AudioEqualizer.tsx +235 -0
- package/src/tools/AudioPlayer/AudioPlayer.tsx +223 -0
- package/src/tools/AudioPlayer/AudioReactiveCover.tsx +389 -0
- package/src/tools/AudioPlayer/AudioShortcutsPopover.tsx +95 -0
- package/src/tools/AudioPlayer/README.md +301 -0
- package/src/tools/AudioPlayer/SimpleAudioPlayer.tsx +275 -0
- package/src/tools/AudioPlayer/VisualizationToggle.tsx +68 -0
- package/src/tools/AudioPlayer/context.tsx +426 -0
- package/src/tools/AudioPlayer/effects/index.ts +412 -0
- package/src/tools/AudioPlayer/index.ts +84 -0
- package/src/tools/AudioPlayer/types.ts +162 -0
- package/src/tools/AudioPlayer/useAudioHotkeys.ts +142 -0
- package/src/tools/AudioPlayer/useAudioVisualization.tsx +195 -0
- package/src/tools/ImageViewer/ImageViewer.tsx +416 -0
- package/src/tools/ImageViewer/README.md +161 -0
- package/src/tools/ImageViewer/index.ts +16 -0
- package/src/tools/VideoPlayer/README.md +196 -187
- package/src/tools/VideoPlayer/VideoErrorFallback.tsx +174 -0
- package/src/tools/VideoPlayer/VideoPlayer.tsx +189 -218
- package/src/tools/VideoPlayer/VideoPlayerContext.tsx +125 -0
- package/src/tools/VideoPlayer/index.ts +59 -7
- package/src/tools/VideoPlayer/providers/NativeProvider.tsx +206 -0
- package/src/tools/VideoPlayer/providers/StreamProvider.tsx +311 -0
- package/src/tools/VideoPlayer/providers/VidstackProvider.tsx +254 -0
- package/src/tools/VideoPlayer/providers/index.ts +8 -0
- package/src/tools/VideoPlayer/types.ts +320 -71
- package/src/tools/index.ts +82 -4
- package/src/tools/VideoPlayer/NativePlayer.tsx +0 -141
package/src/tools/index.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
* - JsonForm: ~300KB (JSON Schema form generator)
|
|
10
10
|
* - OpenapiViewer: ~400KB (OpenAPI schema viewer & playground)
|
|
11
11
|
* - VideoPlayer: ~150KB (Professional video player with Vidstack)
|
|
12
|
+
* - AudioPlayer: ~200KB (Audio player with WaveSurfer.js)
|
|
13
|
+
* - ImageViewer: ~50KB (Image viewer with zoom/pan/rotate)
|
|
12
14
|
*/
|
|
13
15
|
|
|
14
16
|
// Export tools as named exports (all use dynamic imports internally)
|
|
@@ -39,11 +41,87 @@ export { default as OpenapiViewer } from './OpenapiViewer';
|
|
|
39
41
|
export type { PlaygroundConfig, SchemaSource, PlaygroundProps } from './OpenapiViewer';
|
|
40
42
|
|
|
41
43
|
// Export VideoPlayer
|
|
42
|
-
export {
|
|
44
|
+
export {
|
|
45
|
+
VideoPlayer,
|
|
46
|
+
VideoControls,
|
|
47
|
+
VidstackProvider,
|
|
48
|
+
NativeProvider,
|
|
49
|
+
StreamProvider,
|
|
50
|
+
VideoPlayerProvider,
|
|
51
|
+
useVideoPlayerContext,
|
|
52
|
+
VideoErrorFallback,
|
|
53
|
+
createVideoErrorFallback,
|
|
54
|
+
resolvePlayerMode,
|
|
55
|
+
resolveFileSource,
|
|
56
|
+
isSimpleStreamSource,
|
|
57
|
+
resolveStreamSource,
|
|
58
|
+
} from './VideoPlayer';
|
|
43
59
|
export type {
|
|
44
|
-
|
|
60
|
+
VideoSourceUnion,
|
|
61
|
+
UrlSource,
|
|
62
|
+
YouTubeSource,
|
|
63
|
+
VimeoSource,
|
|
64
|
+
HLSSource,
|
|
65
|
+
DASHSource,
|
|
66
|
+
StreamSource,
|
|
67
|
+
BlobSource,
|
|
68
|
+
DataUrlSource,
|
|
69
|
+
PlayerMode,
|
|
70
|
+
AspectRatioValue,
|
|
45
71
|
VideoPlayerProps,
|
|
46
72
|
VideoPlayerRef,
|
|
47
|
-
|
|
48
|
-
|
|
73
|
+
ErrorFallbackProps,
|
|
74
|
+
ResolveFileSourceOptions,
|
|
75
|
+
VideoPlayerContextValue,
|
|
76
|
+
VideoPlayerProviderProps,
|
|
77
|
+
SimpleStreamSource,
|
|
78
|
+
VideoErrorFallbackProps,
|
|
79
|
+
CreateVideoErrorFallbackOptions,
|
|
49
80
|
} from './VideoPlayer';
|
|
81
|
+
|
|
82
|
+
// Export AudioPlayer
|
|
83
|
+
export {
|
|
84
|
+
// Simple wrapper (recommended)
|
|
85
|
+
SimpleAudioPlayer,
|
|
86
|
+
// Core components
|
|
87
|
+
AudioPlayer,
|
|
88
|
+
AudioEqualizer,
|
|
89
|
+
AudioReactiveCover,
|
|
90
|
+
AudioShortcutsPopover,
|
|
91
|
+
VisualizationToggle,
|
|
92
|
+
AudioProvider,
|
|
93
|
+
useAudio,
|
|
94
|
+
useAudioControls,
|
|
95
|
+
useAudioState,
|
|
96
|
+
useAudioElement,
|
|
97
|
+
useAudioHotkeys,
|
|
98
|
+
AUDIO_SHORTCUTS,
|
|
99
|
+
useAudioVisualization,
|
|
100
|
+
VisualizationProvider,
|
|
101
|
+
VARIANT_INFO,
|
|
102
|
+
INTENSITY_INFO,
|
|
103
|
+
COLOR_SCHEME_INFO,
|
|
104
|
+
} from './AudioPlayer';
|
|
105
|
+
export type {
|
|
106
|
+
SimpleAudioPlayerProps,
|
|
107
|
+
AudioSource,
|
|
108
|
+
PlaybackStatus,
|
|
109
|
+
WaveformOptions,
|
|
110
|
+
EqualizerOptions,
|
|
111
|
+
AudioContextState,
|
|
112
|
+
AudioPlayerProps,
|
|
113
|
+
AudioEqualizerProps,
|
|
114
|
+
AudioReactiveCoverProps,
|
|
115
|
+
AudioViewerProps,
|
|
116
|
+
VisualizationSettings,
|
|
117
|
+
VisualizationVariant,
|
|
118
|
+
VisualizationIntensity,
|
|
119
|
+
VisualizationColorScheme,
|
|
120
|
+
AudioHotkeyOptions,
|
|
121
|
+
ShortcutItem,
|
|
122
|
+
ShortcutGroup,
|
|
123
|
+
} from './AudioPlayer';
|
|
124
|
+
|
|
125
|
+
// Export ImageViewer
|
|
126
|
+
export { ImageViewer } from './ImageViewer';
|
|
127
|
+
export type { ImageViewerProps, ImageFile } from './ImageViewer';
|
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* NativePlayer - Lightweight native HTML5 video player
|
|
3
|
-
* For demo videos, background videos, autoplay loop muted scenarios
|
|
4
|
-
* Use VideoPlayer (Vidstack) for full-featured player with controls
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
'use client';
|
|
8
|
-
|
|
9
|
-
import React, { useState, useRef, useEffect, forwardRef, useImperativeHandle } from 'react';
|
|
10
|
-
|
|
11
|
-
import { cn } from '@djangocfg/ui-core/lib';
|
|
12
|
-
import { Preloader, AspectRatio } from '@djangocfg/ui-core';
|
|
13
|
-
|
|
14
|
-
import type { NativePlayerProps, NativePlayerRef } from './types';
|
|
15
|
-
|
|
16
|
-
export const NativePlayer = forwardRef<NativePlayerRef, NativePlayerProps>(
|
|
17
|
-
(
|
|
18
|
-
{
|
|
19
|
-
src,
|
|
20
|
-
poster,
|
|
21
|
-
aspectRatio = 16 / 9,
|
|
22
|
-
autoPlay = true,
|
|
23
|
-
muted = true,
|
|
24
|
-
loop = true,
|
|
25
|
-
playsInline = true,
|
|
26
|
-
preload = 'auto',
|
|
27
|
-
controls = false,
|
|
28
|
-
disableContextMenu = true,
|
|
29
|
-
showPreloader = true,
|
|
30
|
-
preloaderTimeout = 5000,
|
|
31
|
-
className,
|
|
32
|
-
videoClassName,
|
|
33
|
-
preloaderClassName,
|
|
34
|
-
onLoadStart,
|
|
35
|
-
onCanPlay,
|
|
36
|
-
onPlaying,
|
|
37
|
-
onEnded,
|
|
38
|
-
onError,
|
|
39
|
-
},
|
|
40
|
-
ref
|
|
41
|
-
) => {
|
|
42
|
-
const [isLoading, setIsLoading] = useState(showPreloader);
|
|
43
|
-
const videoRef = useRef<HTMLVideoElement>(null);
|
|
44
|
-
|
|
45
|
-
// Expose video element methods via ref
|
|
46
|
-
useImperativeHandle(ref, () => ({
|
|
47
|
-
play: () => videoRef.current?.play(),
|
|
48
|
-
pause: () => videoRef.current?.pause(),
|
|
49
|
-
get currentTime() {
|
|
50
|
-
return videoRef.current?.currentTime ?? 0;
|
|
51
|
-
},
|
|
52
|
-
set currentTime(time: number) {
|
|
53
|
-
if (videoRef.current) videoRef.current.currentTime = time;
|
|
54
|
-
},
|
|
55
|
-
get paused() {
|
|
56
|
-
return videoRef.current?.paused ?? true;
|
|
57
|
-
},
|
|
58
|
-
get element() {
|
|
59
|
-
return videoRef.current;
|
|
60
|
-
},
|
|
61
|
-
}));
|
|
62
|
-
|
|
63
|
-
useEffect(() => {
|
|
64
|
-
if (!showPreloader) return;
|
|
65
|
-
|
|
66
|
-
const video = videoRef.current;
|
|
67
|
-
if (!video) return;
|
|
68
|
-
|
|
69
|
-
// Check if video is already loaded (readyState >= HAVE_FUTURE_DATA)
|
|
70
|
-
if (video.readyState >= 3) {
|
|
71
|
-
setIsLoading(false);
|
|
72
|
-
return;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const hideLoader = () => setIsLoading(false);
|
|
76
|
-
|
|
77
|
-
// Listen to multiple events for better browser support
|
|
78
|
-
video.addEventListener('canplay', hideLoader);
|
|
79
|
-
video.addEventListener('loadeddata', hideLoader);
|
|
80
|
-
video.addEventListener('playing', hideLoader);
|
|
81
|
-
|
|
82
|
-
// Fallback: hide loader after timeout even if video fails (shows poster instead)
|
|
83
|
-
const timeout = setTimeout(hideLoader, preloaderTimeout);
|
|
84
|
-
|
|
85
|
-
return () => {
|
|
86
|
-
video.removeEventListener('canplay', hideLoader);
|
|
87
|
-
video.removeEventListener('loadeddata', hideLoader);
|
|
88
|
-
video.removeEventListener('playing', hideLoader);
|
|
89
|
-
clearTimeout(timeout);
|
|
90
|
-
};
|
|
91
|
-
}, [showPreloader, preloaderTimeout]);
|
|
92
|
-
|
|
93
|
-
const handleContextMenu = (e: React.MouseEvent) => {
|
|
94
|
-
if (disableContextMenu) {
|
|
95
|
-
e.preventDefault();
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<div className={cn('relative overflow-hidden', className)}>
|
|
101
|
-
<AspectRatio ratio={aspectRatio}>
|
|
102
|
-
{/* Preloader */}
|
|
103
|
-
{showPreloader && isLoading && (
|
|
104
|
-
<div
|
|
105
|
-
className={cn(
|
|
106
|
-
'absolute inset-0 flex items-center justify-center bg-muted/30 backdrop-blur-sm z-10',
|
|
107
|
-
preloaderClassName
|
|
108
|
-
)}
|
|
109
|
-
>
|
|
110
|
-
<Preloader size="lg" spinnerClassName="text-white" />
|
|
111
|
-
</div>
|
|
112
|
-
)}
|
|
113
|
-
|
|
114
|
-
{/* Video */}
|
|
115
|
-
<video
|
|
116
|
-
ref={videoRef}
|
|
117
|
-
className={cn('w-full h-full object-cover', videoClassName)}
|
|
118
|
-
autoPlay={autoPlay}
|
|
119
|
-
muted={muted}
|
|
120
|
-
loop={loop}
|
|
121
|
-
playsInline={playsInline}
|
|
122
|
-
preload={preload}
|
|
123
|
-
controls={controls}
|
|
124
|
-
poster={poster}
|
|
125
|
-
onContextMenu={handleContextMenu}
|
|
126
|
-
onLoadStart={onLoadStart}
|
|
127
|
-
onCanPlay={onCanPlay}
|
|
128
|
-
onPlaying={onPlaying}
|
|
129
|
-
onEnded={onEnded}
|
|
130
|
-
onError={onError}
|
|
131
|
-
>
|
|
132
|
-
<source src={src} type="video/mp4" />
|
|
133
|
-
Your browser does not support the video tag.
|
|
134
|
-
</video>
|
|
135
|
-
</AspectRatio>
|
|
136
|
-
</div>
|
|
137
|
-
);
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
|
|
141
|
-
NativePlayer.displayName = 'NativePlayer';
|