@djangocfg/ui-nextjs 2.1.89 → 2.1.91

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 (161) hide show
  1. package/README.md +6 -15
  2. package/package.json +6 -25
  3. package/src/blocks/SplitHero/SplitHeroMedia.tsx +1 -1
  4. package/src/components/index.ts +0 -40
  5. package/src/hooks/index.ts +0 -6
  6. package/src/index.ts +2 -11
  7. package/src/components/button-download.tsx +0 -277
  8. package/src/components/markdown/MarkdownMessage.tsx +0 -340
  9. package/src/components/markdown/index.ts +0 -5
  10. package/src/components/menubar.tsx +0 -275
  11. package/src/components/multi-select-pro/async.tsx +0 -598
  12. package/src/components/multi-select-pro/helpers.tsx +0 -84
  13. package/src/components/multi-select-pro/index.tsx +0 -612
  14. package/src/components/navigation-menu.tsx +0 -154
  15. package/src/components/otp/index.tsx +0 -197
  16. package/src/components/otp/types.ts +0 -133
  17. package/src/components/otp/use-otp-input.ts +0 -225
  18. package/src/components/phone-input.tsx +0 -277
  19. package/src/components/sonner.tsx +0 -32
  20. package/src/hooks/useLocalStorage.ts +0 -300
  21. package/src/hooks/useSessionStorage.ts +0 -290
  22. package/src/lib/index.ts +0 -5
  23. package/src/lib/logger/index.ts +0 -10
  24. package/src/lib/logger/logStore.ts +0 -122
  25. package/src/lib/logger/logger.ts +0 -175
  26. package/src/lib/logger/types.ts +0 -82
  27. package/src/stores/index.ts +0 -8
  28. package/src/stores/mediaCache.ts +0 -534
  29. package/src/tools/AudioPlayer/README.md +0 -206
  30. package/src/tools/AudioPlayer/components/HybridAudioPlayer.tsx +0 -216
  31. package/src/tools/AudioPlayer/components/HybridSimplePlayer.tsx +0 -280
  32. package/src/tools/AudioPlayer/components/HybridWaveform.tsx +0 -279
  33. package/src/tools/AudioPlayer/components/ReactiveCover/AudioReactiveCover.tsx +0 -149
  34. package/src/tools/AudioPlayer/components/ReactiveCover/effects/GlowEffect.tsx +0 -110
  35. package/src/tools/AudioPlayer/components/ReactiveCover/effects/MeshEffect.tsx +0 -58
  36. package/src/tools/AudioPlayer/components/ReactiveCover/effects/OrbsEffect.tsx +0 -45
  37. package/src/tools/AudioPlayer/components/ReactiveCover/effects/SpotlightEffect.tsx +0 -82
  38. package/src/tools/AudioPlayer/components/ReactiveCover/effects/index.ts +0 -8
  39. package/src/tools/AudioPlayer/components/ReactiveCover/index.ts +0 -6
  40. package/src/tools/AudioPlayer/components/index.ts +0 -22
  41. package/src/tools/AudioPlayer/context/HybridAudioProvider.tsx +0 -158
  42. package/src/tools/AudioPlayer/context/index.ts +0 -16
  43. package/src/tools/AudioPlayer/effects/index.ts +0 -412
  44. package/src/tools/AudioPlayer/hooks/index.ts +0 -35
  45. package/src/tools/AudioPlayer/hooks/useHybridAudio.ts +0 -387
  46. package/src/tools/AudioPlayer/hooks/useHybridAudioAnalysis.ts +0 -95
  47. package/src/tools/AudioPlayer/hooks/useVisualization.tsx +0 -207
  48. package/src/tools/AudioPlayer/index.ts +0 -133
  49. package/src/tools/AudioPlayer/types/effects.ts +0 -73
  50. package/src/tools/AudioPlayer/types/index.ts +0 -27
  51. package/src/tools/AudioPlayer/utils/debug.ts +0 -14
  52. package/src/tools/AudioPlayer/utils/formatTime.ts +0 -10
  53. package/src/tools/AudioPlayer/utils/index.ts +0 -6
  54. package/src/tools/ImageViewer/@refactoring/00-PLAN.md +0 -71
  55. package/src/tools/ImageViewer/@refactoring/01-TYPES.md +0 -121
  56. package/src/tools/ImageViewer/@refactoring/02-UTILS.md +0 -143
  57. package/src/tools/ImageViewer/@refactoring/03-HOOKS.md +0 -261
  58. package/src/tools/ImageViewer/@refactoring/04-COMPONENTS.md +0 -427
  59. package/src/tools/ImageViewer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -126
  60. package/src/tools/ImageViewer/README.md +0 -200
  61. package/src/tools/ImageViewer/components/ImageInfo.tsx +0 -44
  62. package/src/tools/ImageViewer/components/ImageToolbar.tsx +0 -150
  63. package/src/tools/ImageViewer/components/ImageViewer.tsx +0 -241
  64. package/src/tools/ImageViewer/components/index.ts +0 -7
  65. package/src/tools/ImageViewer/hooks/index.ts +0 -9
  66. package/src/tools/ImageViewer/hooks/useImageLoading.ts +0 -204
  67. package/src/tools/ImageViewer/hooks/useImageTransform.ts +0 -101
  68. package/src/tools/ImageViewer/index.ts +0 -60
  69. package/src/tools/ImageViewer/types.ts +0 -81
  70. package/src/tools/ImageViewer/utils/constants.ts +0 -59
  71. package/src/tools/ImageViewer/utils/debug.ts +0 -14
  72. package/src/tools/ImageViewer/utils/index.ts +0 -17
  73. package/src/tools/ImageViewer/utils/lqip.ts +0 -47
  74. package/src/tools/JsonForm/JsonSchemaForm.tsx +0 -197
  75. package/src/tools/JsonForm/examples/BotConfigExample.tsx +0 -249
  76. package/src/tools/JsonForm/examples/RealBotConfigExample.tsx +0 -161
  77. package/src/tools/JsonForm/index.ts +0 -46
  78. package/src/tools/JsonForm/templates/ArrayFieldItemTemplate.tsx +0 -47
  79. package/src/tools/JsonForm/templates/ArrayFieldTemplate.tsx +0 -74
  80. package/src/tools/JsonForm/templates/BaseInputTemplate.tsx +0 -107
  81. package/src/tools/JsonForm/templates/ErrorListTemplate.tsx +0 -35
  82. package/src/tools/JsonForm/templates/FieldTemplate.tsx +0 -62
  83. package/src/tools/JsonForm/templates/ObjectFieldTemplate.tsx +0 -116
  84. package/src/tools/JsonForm/templates/index.ts +0 -12
  85. package/src/tools/JsonForm/types.ts +0 -83
  86. package/src/tools/JsonForm/utils.ts +0 -213
  87. package/src/tools/JsonForm/widgets/CheckboxWidget.tsx +0 -37
  88. package/src/tools/JsonForm/widgets/ColorWidget.tsx +0 -219
  89. package/src/tools/JsonForm/widgets/NumberWidget.tsx +0 -89
  90. package/src/tools/JsonForm/widgets/SelectWidget.tsx +0 -97
  91. package/src/tools/JsonForm/widgets/SliderWidget.tsx +0 -148
  92. package/src/tools/JsonForm/widgets/SwitchWidget.tsx +0 -35
  93. package/src/tools/JsonForm/widgets/TextWidget.tsx +0 -96
  94. package/src/tools/JsonForm/widgets/index.ts +0 -14
  95. package/src/tools/JsonTree/index.tsx +0 -243
  96. package/src/tools/LottiePlayer/LottiePlayer.client.tsx +0 -213
  97. package/src/tools/LottiePlayer/index.tsx +0 -55
  98. package/src/tools/LottiePlayer/types.ts +0 -108
  99. package/src/tools/LottiePlayer/useLottie.ts +0 -164
  100. package/src/tools/Mermaid/Mermaid.client.tsx +0 -82
  101. package/src/tools/Mermaid/components/MermaidCodeViewer.tsx +0 -95
  102. package/src/tools/Mermaid/components/MermaidFullscreenModal.tsx +0 -103
  103. package/src/tools/Mermaid/hooks/index.ts +0 -4
  104. package/src/tools/Mermaid/hooks/useMermaidCleanup.ts +0 -73
  105. package/src/tools/Mermaid/hooks/useMermaidFullscreen.ts +0 -46
  106. package/src/tools/Mermaid/hooks/useMermaidRenderer.ts +0 -226
  107. package/src/tools/Mermaid/hooks/useMermaidValidation.ts +0 -29
  108. package/src/tools/Mermaid/index.tsx +0 -41
  109. package/src/tools/Mermaid/utils/mermaid-helpers.ts +0 -33
  110. package/src/tools/OpenapiViewer/components/EndpointInfo.tsx +0 -149
  111. package/src/tools/OpenapiViewer/components/EndpointsLibrary.tsx +0 -263
  112. package/src/tools/OpenapiViewer/components/PlaygroundLayout.tsx +0 -125
  113. package/src/tools/OpenapiViewer/components/PlaygroundStepper.tsx +0 -100
  114. package/src/tools/OpenapiViewer/components/RequestBuilder.tsx +0 -157
  115. package/src/tools/OpenapiViewer/components/RequestParametersForm.tsx +0 -253
  116. package/src/tools/OpenapiViewer/components/ResponseViewer.tsx +0 -173
  117. package/src/tools/OpenapiViewer/components/VersionSelector.tsx +0 -68
  118. package/src/tools/OpenapiViewer/components/index.ts +0 -14
  119. package/src/tools/OpenapiViewer/constants.ts +0 -39
  120. package/src/tools/OpenapiViewer/context/PlaygroundContext.tsx +0 -337
  121. package/src/tools/OpenapiViewer/hooks/index.ts +0 -8
  122. package/src/tools/OpenapiViewer/hooks/useMobile.ts +0 -10
  123. package/src/tools/OpenapiViewer/hooks/useOpenApiSchema.ts +0 -199
  124. package/src/tools/OpenapiViewer/index.tsx +0 -38
  125. package/src/tools/OpenapiViewer/types.ts +0 -151
  126. package/src/tools/OpenapiViewer/utils/apiKeyManager.ts +0 -149
  127. package/src/tools/OpenapiViewer/utils/formatters.ts +0 -71
  128. package/src/tools/OpenapiViewer/utils/index.ts +0 -9
  129. package/src/tools/OpenapiViewer/utils/versionManager.ts +0 -161
  130. package/src/tools/PrettyCode/PrettyCode.client.tsx +0 -208
  131. package/src/tools/PrettyCode/index.tsx +0 -45
  132. package/src/tools/VideoPlayer/@refactoring/00-PLAN.md +0 -91
  133. package/src/tools/VideoPlayer/@refactoring/01-TYPES.md +0 -284
  134. package/src/tools/VideoPlayer/@refactoring/02-UTILS.md +0 -141
  135. package/src/tools/VideoPlayer/@refactoring/03-HOOKS.md +0 -178
  136. package/src/tools/VideoPlayer/@refactoring/04-COMPONENTS.md +0 -95
  137. package/src/tools/VideoPlayer/@refactoring/05-EXECUTION-CHECKLIST.md +0 -139
  138. package/src/tools/VideoPlayer/README.md +0 -264
  139. package/src/tools/VideoPlayer/components/VideoControls.tsx +0 -138
  140. package/src/tools/VideoPlayer/components/VideoErrorFallback.tsx +0 -174
  141. package/src/tools/VideoPlayer/components/VideoPlayer.tsx +0 -201
  142. package/src/tools/VideoPlayer/components/index.ts +0 -14
  143. package/src/tools/VideoPlayer/context/VideoPlayerContext.tsx +0 -52
  144. package/src/tools/VideoPlayer/context/index.ts +0 -8
  145. package/src/tools/VideoPlayer/hooks/index.ts +0 -12
  146. package/src/tools/VideoPlayer/hooks/useVideoPlayerSettings.ts +0 -70
  147. package/src/tools/VideoPlayer/hooks/useVideoPositionCache.ts +0 -116
  148. package/src/tools/VideoPlayer/index.ts +0 -77
  149. package/src/tools/VideoPlayer/providers/NativeProvider.tsx +0 -284
  150. package/src/tools/VideoPlayer/providers/StreamProvider.tsx +0 -505
  151. package/src/tools/VideoPlayer/providers/VidstackProvider.tsx +0 -400
  152. package/src/tools/VideoPlayer/providers/index.ts +0 -8
  153. package/src/tools/VideoPlayer/types/index.ts +0 -38
  154. package/src/tools/VideoPlayer/types/player.ts +0 -116
  155. package/src/tools/VideoPlayer/types/provider.ts +0 -93
  156. package/src/tools/VideoPlayer/types/sources.ts +0 -97
  157. package/src/tools/VideoPlayer/utils/debug.ts +0 -14
  158. package/src/tools/VideoPlayer/utils/fileSource.ts +0 -78
  159. package/src/tools/VideoPlayer/utils/index.ts +0 -12
  160. package/src/tools/VideoPlayer/utils/resolvers.ts +0 -75
  161. package/src/tools/index.ts +0 -170
@@ -1,201 +0,0 @@
1
- /**
2
- * VideoPlayer - Unified Video Player Component
3
- *
4
- * Supports multiple modes:
5
- * - vidstack: Full-featured player (YouTube, Vimeo, HLS, DASH)
6
- * - native: Lightweight HTML5 player
7
- * - streaming: HTTP Range streaming with auth / Blob sources
8
- *
9
- * @example
10
- * // YouTube video
11
- * <VideoPlayer source={{ type: 'youtube', id: 'dQw4w9WgXcQ' }} />
12
- *
13
- * @example
14
- * // HLS stream
15
- * <VideoPlayer source={{ type: 'hls', url: 'https://example.com/video.m3u8' }} />
16
- *
17
- * @example
18
- * // HTTP Range streaming with auth (full source)
19
- * <VideoPlayer
20
- * source={{
21
- * type: 'stream',
22
- * sessionId: 'abc123',
23
- * path: '/videos/movie.mp4',
24
- * getStreamUrl: (id, path) => `/api/stream/${id}?path=${path}&token=${token}`
25
- * }}
26
- * />
27
- *
28
- * @example
29
- * // HTTP Range streaming (simplified, using VideoPlayerProvider context)
30
- * <VideoPlayerProvider sessionId={sessionId} getStreamUrl={getStreamUrl}>
31
- * <VideoPlayer source={{ type: 'stream', path: '/videos/movie.mp4' }} />
32
- * </VideoPlayerProvider>
33
- *
34
- * @example
35
- * // Blob/ArrayBuffer
36
- * <VideoPlayer source={{ type: 'blob', data: arrayBuffer, mimeType: 'video/mp4' }} />
37
- */
38
-
39
- 'use client';
40
-
41
- import React, { forwardRef, useMemo } from 'react';
42
-
43
- import { VidstackProvider, NativeProvider, StreamProvider } from '../providers';
44
- import { useVideoPlayerContext } from '../context';
45
- import { resolvePlayerMode, isSimpleStreamSource, resolveStreamSource } from '../utils';
46
-
47
- import type { VideoPlayerProps, VideoPlayerRef, VideoSourceUnion, VidstackProviderProps, NativeProviderProps, StreamProviderProps, SimpleStreamSource } from '../types';
48
-
49
- export const VideoPlayer = forwardRef<VideoPlayerRef, VideoPlayerProps & { source: VideoSourceUnion | SimpleStreamSource }>(
50
- (
51
- {
52
- source: rawSource,
53
- mode = 'auto',
54
- aspectRatio = 16 / 9,
55
- autoPlay = false,
56
- muted = false,
57
- loop = false,
58
- playsInline = true,
59
- controls = true,
60
- preload = 'metadata',
61
- theme = 'default',
62
- showInfo = false,
63
- className,
64
- videoClassName,
65
- disableContextMenu = false,
66
- showPreloader = true,
67
- preloaderTimeout = 5000,
68
- errorFallback,
69
- onPlay,
70
- onPause,
71
- onEnded,
72
- onError,
73
- onLoadStart,
74
- onCanPlay,
75
- onTimeUpdate,
76
- },
77
- ref
78
- ) => {
79
- // Get context for simplified stream sources
80
- const context = useVideoPlayerContext();
81
-
82
- // Resolve simplified stream source to full source using context
83
- const source = useMemo(() => {
84
- if (isSimpleStreamSource(rawSource)) {
85
- const resolved = resolveStreamSource(rawSource, context);
86
- if (!resolved) {
87
- // Return a special error source that will trigger error fallback
88
- return null;
89
- }
90
- return resolved;
91
- }
92
- return rawSource;
93
- }, [rawSource, context]);
94
-
95
- // Handle unresolved source
96
- if (!source) {
97
- // Render error state
98
- const errorMessage = 'Stream source requires VideoPlayerProvider with getStreamUrl and sessionId';
99
-
100
- if (typeof errorFallback === 'function') {
101
- return (
102
- <div className={className} style={{ aspectRatio: aspectRatio === 'fill' ? undefined : aspectRatio }}>
103
- {errorFallback({ error: errorMessage })}
104
- </div>
105
- );
106
- }
107
-
108
- if (errorFallback) {
109
- return (
110
- <div className={className} style={{ aspectRatio: aspectRatio === 'fill' ? undefined : aspectRatio }}>
111
- {errorFallback}
112
- </div>
113
- );
114
- }
115
-
116
- // Default error UI
117
- return (
118
- <div
119
- className={className}
120
- style={{
121
- aspectRatio: aspectRatio === 'fill' ? undefined : aspectRatio,
122
- display: 'flex',
123
- alignItems: 'center',
124
- justifyContent: 'center',
125
- backgroundColor: 'black',
126
- color: 'white',
127
- }}
128
- >
129
- <p>{errorMessage}</p>
130
- </div>
131
- );
132
- }
133
-
134
- // Determine which provider to use
135
- const resolvedMode = resolvePlayerMode(source, mode);
136
-
137
- // Common props for all providers
138
- const commonProps = {
139
- aspectRatio,
140
- autoPlay,
141
- muted,
142
- loop,
143
- playsInline,
144
- controls,
145
- preload,
146
- className,
147
- onPlay,
148
- onPause,
149
- onEnded,
150
- onError,
151
- onLoadStart,
152
- onCanPlay,
153
- onTimeUpdate,
154
- };
155
-
156
- // Render appropriate provider
157
- switch (resolvedMode) {
158
- case 'vidstack':
159
- return (
160
- <VidstackProvider
161
- ref={ref}
162
- source={source as VidstackProviderProps['source']}
163
- theme={theme}
164
- showInfo={showInfo}
165
- errorFallback={errorFallback}
166
- {...commonProps}
167
- />
168
- );
169
-
170
- case 'streaming':
171
- return (
172
- <StreamProvider
173
- ref={ref}
174
- source={source as StreamProviderProps['source']}
175
- videoClassName={videoClassName}
176
- disableContextMenu={disableContextMenu}
177
- showPreloader={showPreloader}
178
- preloaderTimeout={preloaderTimeout}
179
- errorFallback={errorFallback}
180
- {...commonProps}
181
- />
182
- );
183
-
184
- case 'native':
185
- default:
186
- return (
187
- <NativeProvider
188
- ref={ref}
189
- source={source as NativeProviderProps['source']}
190
- videoClassName={videoClassName}
191
- disableContextMenu={disableContextMenu}
192
- showPreloader={showPreloader}
193
- preloaderTimeout={preloaderTimeout}
194
- {...commonProps}
195
- />
196
- );
197
- }
198
- }
199
- );
200
-
201
- VideoPlayer.displayName = 'VideoPlayer';
@@ -1,14 +0,0 @@
1
- /**
2
- * VideoPlayer components - Public API
3
- */
4
-
5
- export { VideoPlayer } from './VideoPlayer';
6
- export { VideoControls } from './VideoControls';
7
- export {
8
- VideoErrorFallback,
9
- createVideoErrorFallback,
10
- } from './VideoErrorFallback';
11
- export type {
12
- VideoErrorFallbackProps,
13
- CreateVideoErrorFallbackOptions,
14
- } from './VideoErrorFallback';
@@ -1,52 +0,0 @@
1
- /**
2
- * VideoPlayerContext - Context for streaming configuration
3
- * Simplifies streaming API by providing getStreamUrl globally
4
- */
5
-
6
- 'use client';
7
-
8
- import React, { createContext, useContext, useMemo } from 'react';
9
-
10
- import type { VideoPlayerContextValue, VideoPlayerProviderProps } from '../types';
11
-
12
- // =============================================================================
13
- // Context
14
- // =============================================================================
15
-
16
- const VideoPlayerContext = createContext<VideoPlayerContextValue | null>(null);
17
-
18
- /**
19
- * Provider for VideoPlayer streaming configuration
20
- *
21
- * @example
22
- * // In your app layout or FileWorkspace
23
- * <VideoPlayerProvider
24
- * sessionId={sessionId}
25
- * getStreamUrl={terminalClient.terminal_media.streamStreamRetrieveUrl}
26
- * >
27
- * <VideoPlayer source={{ type: 'stream', path: '/video.mp4' }} />
28
- * </VideoPlayerProvider>
29
- */
30
- export function VideoPlayerProvider({
31
- children,
32
- getStreamUrl,
33
- sessionId,
34
- }: VideoPlayerProviderProps) {
35
- const value = useMemo(
36
- () => ({ getStreamUrl, sessionId }),
37
- [getStreamUrl, sessionId]
38
- );
39
-
40
- return (
41
- <VideoPlayerContext.Provider value={value}>
42
- {children}
43
- </VideoPlayerContext.Provider>
44
- );
45
- }
46
-
47
- /**
48
- * Hook to access VideoPlayer context
49
- */
50
- export function useVideoPlayerContext(): VideoPlayerContextValue | null {
51
- return useContext(VideoPlayerContext);
52
- }
@@ -1,8 +0,0 @@
1
- /**
2
- * VideoPlayer context - Public API
3
- */
4
-
5
- export {
6
- VideoPlayerProvider,
7
- useVideoPlayerContext,
8
- } from './VideoPlayerContext';
@@ -1,12 +0,0 @@
1
- /**
2
- * VideoPlayer hooks - Public API
3
- */
4
-
5
- export { useVideoPositionCache } from './useVideoPositionCache';
6
- export type {
7
- UseVideoPositionCacheOptions,
8
- UseVideoPositionCacheReturn,
9
- } from './useVideoPositionCache';
10
-
11
- export { useVideoPlayerSettings } from './useVideoPlayerSettings';
12
- export type { VideoPlayerSettingsReturn } from './useVideoPlayerSettings';
@@ -1,70 +0,0 @@
1
- 'use client';
2
-
3
- /**
4
- * useVideoPlayerSettings - Hook for persisted video player settings
5
- *
6
- * Provides volume and loop settings that persist in localStorage.
7
- * Use this hook in video player providers to apply saved settings.
8
- *
9
- * @example
10
- * const { settings, updateVolume, updateLoop } = useVideoPlayerSettings();
11
- *
12
- * // Apply to video element
13
- * videoRef.current.volume = settings.volume;
14
- * videoRef.current.loop = settings.isLooping;
15
- *
16
- * // Save when user changes
17
- * const handleVolumeChange = (vol: number) => {
18
- * videoRef.current.volume = vol;
19
- * updateVolume(vol);
20
- * };
21
- */
22
-
23
- import { useCallback } from 'react';
24
- import { useVideoPlayerSettings as useSettings } from '../../../stores/mediaCache';
25
-
26
- export interface VideoPlayerSettingsReturn {
27
- /** Current settings */
28
- settings: {
29
- volume: number;
30
- isLooping: boolean;
31
- };
32
- /** Update volume (0-1) */
33
- updateVolume: (volume: number) => void;
34
- /** Update loop setting */
35
- updateLoop: (isLooping: boolean) => void;
36
- /** Update multiple settings at once */
37
- updateSettings: (settings: { volume?: number; isLooping?: boolean }) => void;
38
- }
39
-
40
- export function useVideoPlayerSettings(): VideoPlayerSettingsReturn {
41
- const { settings, saveSettings } = useSettings();
42
-
43
- const updateVolume = useCallback(
44
- (volume: number) => {
45
- saveSettings({ volume: Math.max(0, Math.min(1, volume)) });
46
- },
47
- [saveSettings]
48
- );
49
-
50
- const updateLoop = useCallback(
51
- (isLooping: boolean) => {
52
- saveSettings({ isLooping });
53
- },
54
- [saveSettings]
55
- );
56
-
57
- const updateSettings = useCallback(
58
- (newSettings: { volume?: number; isLooping?: boolean }) => {
59
- saveSettings(newSettings);
60
- },
61
- [saveSettings]
62
- );
63
-
64
- return {
65
- settings,
66
- updateVolume,
67
- updateLoop,
68
- updateSettings,
69
- };
70
- }
@@ -1,116 +0,0 @@
1
- 'use client';
2
-
3
- /**
4
- * useVideoPositionCache - Manages video playback position caching
5
- *
6
- * Saves position periodically during playback and restores on load.
7
- */
8
-
9
- import { useRef, useEffect, useCallback } from 'react';
10
- import { useMediaCacheStore } from '../../../stores/mediaCache';
11
-
12
- // =============================================================================
13
- // TYPES
14
- // =============================================================================
15
-
16
- export interface UseVideoPositionCacheOptions {
17
- /** Unique key for caching (e.g., video URL or stream key) */
18
- cacheKey: string | null;
19
- /** Current playback time in seconds */
20
- currentTime: number;
21
- /** Video duration in seconds */
22
- duration: number;
23
- /** Whether video is currently playing */
24
- isPlaying: boolean;
25
- /** Whether video is ready to play */
26
- isReady: boolean;
27
- /** Callback to seek to a specific time */
28
- onSeek: (time: number) => void;
29
- }
30
-
31
- export interface UseVideoPositionCacheReturn {
32
- /** Manually save current position */
33
- savePosition: () => void;
34
- /** Clear saved position */
35
- clearPosition: () => void;
36
- }
37
-
38
- // =============================================================================
39
- // CONSTANTS
40
- // =============================================================================
41
-
42
- /** Save interval in seconds */
43
- const SAVE_INTERVAL = 5;
44
-
45
- /** Minimum offset from end to restore (avoid restoring at the very end) */
46
- const END_BUFFER = 1;
47
-
48
- // =============================================================================
49
- // HOOK
50
- // =============================================================================
51
-
52
- export function useVideoPositionCache(
53
- options: UseVideoPositionCacheOptions
54
- ): UseVideoPositionCacheReturn {
55
- const { cacheKey, currentTime, duration, isPlaying, isReady, onSeek } = options;
56
-
57
- // Get stable function references from store
58
- const saveVideoPosition = useMediaCacheStore.getState().saveVideoPosition;
59
- const getVideoPosition = useMediaCacheStore.getState().getVideoPosition;
60
-
61
- const lastSavedTimeRef = useRef<number>(0);
62
- const hasRestoredRef = useRef<boolean>(false);
63
-
64
- // Restore position when ready
65
- useEffect(() => {
66
- if (!isReady || !cacheKey || hasRestoredRef.current) return;
67
-
68
- const savedPosition = getVideoPosition(cacheKey);
69
- if (savedPosition && savedPosition > 0 && duration > 0) {
70
- // Only restore if position is valid (not at the end)
71
- if (savedPosition < duration - END_BUFFER) {
72
- onSeek(savedPosition);
73
- }
74
- }
75
- hasRestoredRef.current = true;
76
- // eslint-disable-next-line react-hooks/exhaustive-deps
77
- }, [isReady, cacheKey, duration, onSeek]);
78
-
79
- // Reset restored flag when cache key changes
80
- useEffect(() => {
81
- hasRestoredRef.current = false;
82
- lastSavedTimeRef.current = 0;
83
- }, [cacheKey]);
84
-
85
- // Save position periodically during playback
86
- useEffect(() => {
87
- if (!cacheKey || !isPlaying || currentTime <= 0) return;
88
-
89
- const timeSinceLastSave = currentTime - lastSavedTimeRef.current;
90
- if (timeSinceLastSave >= SAVE_INTERVAL || timeSinceLastSave < 0) {
91
- saveVideoPosition(cacheKey, currentTime);
92
- lastSavedTimeRef.current = currentTime;
93
- }
94
- // eslint-disable-next-line react-hooks/exhaustive-deps
95
- }, [cacheKey, isPlaying, currentTime]);
96
-
97
- const savePosition = useCallback(() => {
98
- if (cacheKey && currentTime > 0) {
99
- saveVideoPosition(cacheKey, currentTime);
100
- lastSavedTimeRef.current = currentTime;
101
- }
102
- // eslint-disable-next-line react-hooks/exhaustive-deps
103
- }, [cacheKey, currentTime]);
104
-
105
- const clearPosition = useCallback(() => {
106
- if (cacheKey) {
107
- saveVideoPosition(cacheKey, 0);
108
- }
109
- // eslint-disable-next-line react-hooks/exhaustive-deps
110
- }, [cacheKey]);
111
-
112
- return {
113
- savePosition,
114
- clearPosition,
115
- };
116
- }
@@ -1,77 +0,0 @@
1
- /**
2
- * VideoPlayer - Unified Video Player
3
- * Supports Vidstack (YouTube, Vimeo, HLS, DASH), Native HTML5, and HTTP Streaming
4
- */
5
-
6
- // Main component
7
- export { VideoPlayer } from './components';
8
-
9
- // Controls (can be used standalone with Vidstack)
10
- export { VideoControls } from './components';
11
-
12
- // Error Fallback
13
- export {
14
- VideoErrorFallback,
15
- createVideoErrorFallback,
16
- } from './components';
17
- export type {
18
- VideoErrorFallbackProps,
19
- CreateVideoErrorFallbackOptions,
20
- } from './components';
21
-
22
- // Providers (for advanced usage)
23
- export { VidstackProvider, NativeProvider, StreamProvider } from './providers';
24
-
25
- // Context (for streaming configuration)
26
- export {
27
- VideoPlayerProvider,
28
- useVideoPlayerContext,
29
- } from './context';
30
-
31
- // Hooks
32
- export { useVideoPositionCache } from './hooks';
33
- export type {
34
- UseVideoPositionCacheOptions,
35
- UseVideoPositionCacheReturn,
36
- } from './hooks';
37
-
38
- // Utils
39
- export {
40
- resolvePlayerMode,
41
- resolveFileSource,
42
- isSimpleStreamSource,
43
- resolveStreamSource,
44
- } from './utils';
45
-
46
- // Types
47
- export type {
48
- // Source types
49
- VideoSourceUnion,
50
- UrlSource,
51
- YouTubeSource,
52
- VimeoSource,
53
- HLSSource,
54
- DASHSource,
55
- StreamSource,
56
- BlobSource,
57
- DataUrlSource,
58
- // Player types
59
- PlayerMode,
60
- AspectRatioValue,
61
- VideoPlayerProps,
62
- VideoPlayerRef,
63
- ErrorFallbackProps,
64
- // Provider props (internal)
65
- VidstackProviderProps,
66
- NativeProviderProps,
67
- StreamProviderProps,
68
- // Common types
69
- CommonPlayerSettings,
70
- CommonPlayerEvents,
71
- // File source helper types
72
- ResolveFileSourceOptions,
73
- // Context types
74
- VideoPlayerContextValue,
75
- VideoPlayerProviderProps,
76
- SimpleStreamSource,
77
- } from './types';