@mottosports/motto-video-player 1.0.1-rc.12 → 1.0.1-rc.2

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/README.md CHANGED
@@ -20,6 +20,108 @@ React video player component for the Motto platform, powered by Shaka Player wit
20
20
  npm install @motto-ui-components/motto-video-player @tanstack/react-query
21
21
  ```
22
22
 
23
+ ## Next.js SSR Compatibility
24
+
25
+ This component is now fully compatible with Next.js Server-Side Rendering (SSR). The component automatically detects when it's running in a server environment and gracefully handles browser-only APIs.
26
+
27
+ ### Basic Usage in Next.js
28
+
29
+ For SSR compatibility, use the `ClientSideEvent` component which only renders on the client side:
30
+
31
+ ```tsx
32
+ import { ClientSideEvent } from '@mottosports/motto-video-player';
33
+
34
+ export default function MyPage() {
35
+ return (
36
+ <ClientSideEvent
37
+ publicKey="your-public-key"
38
+ eventId="your-event-id"
39
+ locale="en"
40
+ />
41
+ );
42
+ }
43
+ ```
44
+
45
+ Alternatively, if you prefer to use the regular `Event` component, wrap it with SSR checks:
46
+
47
+ ```tsx
48
+ import { Event } from '@mottosports/motto-video-player';
49
+
50
+ export default function MyPage() {
51
+ return (
52
+ <Event
53
+ publicKey="your-public-key"
54
+ eventId="your-event-id"
55
+ locale="en"
56
+ />
57
+ );
58
+ }
59
+ ```
60
+
61
+ ### Dynamic Imports (Alternative Approach)
62
+
63
+ You can also use Next.js dynamic imports with the regular Event component:
64
+
65
+ ```tsx
66
+ import dynamic from 'next/dynamic';
67
+
68
+ const Event = dynamic(
69
+ () => import('@mottosports/motto-video-player').then(mod => ({ default: mod.Event })),
70
+ {
71
+ ssr: false,
72
+ loading: () => <div>Loading video player...</div>
73
+ }
74
+ );
75
+
76
+ export default function MyPage() {
77
+ return (
78
+ <Event
79
+ publicKey="your-public-key"
80
+ eventId="your-event-id"
81
+ locale="en"
82
+ />
83
+ );
84
+ }
85
+ ```
86
+
87
+ **Recommended Approach**: Use `ClientSideEvent` for simpler SSR handling without dynamic imports.
88
+
89
+ ### App Router Usage (Next.js 13+)
90
+
91
+ With App Router, you can use `ClientSideEvent` directly without 'use client' directive:
92
+
93
+ ```tsx
94
+ import { ClientSideEvent } from '@mottosports/motto-video-player';
95
+
96
+ export default function VideoPlayer() {
97
+ return (
98
+ <ClientSideEvent
99
+ publicKey="your-public-key"
100
+ eventId="your-event-id"
101
+ locale="en"
102
+ />
103
+ );
104
+ }
105
+ ```
106
+
107
+ Or use the regular Event component with 'use client':
108
+
109
+ ```tsx
110
+ 'use client';
111
+
112
+ import { Event } from '@mottosports/motto-video-player';
113
+
114
+ export default function VideoPlayer() {
115
+ return (
116
+ <Event
117
+ publicKey="your-public-key"
118
+ eventId="your-event-id"
119
+ locale="en"
120
+ />
121
+ );
122
+ }
123
+ ```
124
+
23
125
  ## Quick Start
24
126
 
25
127
  ### Setup QueryClient (Required for Video wrapper)
package/dist/index.d.mts CHANGED
@@ -225,7 +225,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
225
225
  * Event callbacks
226
226
  */
227
227
  events?: PlayerEvents;
228
+ /**
229
+ * CSS class name for the container element
230
+ */
228
231
  containerClassName?: string;
232
+ /**
233
+ * Optional manual override for stream start time
234
+ * If not provided, the player will attempt to auto-detect the stream start time
235
+ * from the manifest for live streams. When provided, shows elapsed time since
236
+ * stream started instead of the current playback position.
237
+ */
238
+ streamStartDate?: Date;
229
239
  }
230
240
  /**
231
241
  * Mux Analytics type definitions
@@ -442,6 +452,13 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
442
452
  }
443
453
  declare const Event: React.FC<EventProps>;
444
454
 
455
+ /**
456
+ * Client-side wrapper for the Event component that prevents SSR issues.
457
+ * This component only renders the Event component after the client has mounted,
458
+ * preventing any browser API calls during server-side rendering.
459
+ */
460
+ declare const ClientSideEvent: React.FC<EventProps>;
461
+
445
462
  interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
446
463
  publicKey: string;
447
464
  creativeWorkId: string;
@@ -486,4 +503,4 @@ interface QueryProviderProps {
486
503
  }
487
504
  declare const QueryProvider: React.FC<QueryProviderProps>;
488
505
 
489
- export { CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
506
+ export { ClientSideEvent, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
package/dist/index.d.ts CHANGED
@@ -225,7 +225,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
225
225
  * Event callbacks
226
226
  */
227
227
  events?: PlayerEvents;
228
+ /**
229
+ * CSS class name for the container element
230
+ */
228
231
  containerClassName?: string;
232
+ /**
233
+ * Optional manual override for stream start time
234
+ * If not provided, the player will attempt to auto-detect the stream start time
235
+ * from the manifest for live streams. When provided, shows elapsed time since
236
+ * stream started instead of the current playback position.
237
+ */
238
+ streamStartDate?: Date;
229
239
  }
230
240
  /**
231
241
  * Mux Analytics type definitions
@@ -442,6 +452,13 @@ interface EventProps extends Omit<PlayerProps, 'src'> {
442
452
  }
443
453
  declare const Event: React.FC<EventProps>;
444
454
 
455
+ /**
456
+ * Client-side wrapper for the Event component that prevents SSR issues.
457
+ * This component only renders the Event component after the client has mounted,
458
+ * preventing any browser API calls during server-side rendering.
459
+ */
460
+ declare const ClientSideEvent: React.FC<EventProps>;
461
+
445
462
  interface CreativeWorkProps extends Omit<PlayerProps, 'src'> {
446
463
  publicKey: string;
447
464
  creativeWorkId: string;
@@ -486,4 +503,4 @@ interface QueryProviderProps {
486
503
  }
487
504
  declare const QueryProvider: React.FC<QueryProviderProps>;
488
505
 
489
- export { CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };
506
+ export { ClientSideEvent, CreativeWork, type CreativeWorkData, type CreativeWorkProps, CreativeWorksSortDirection, Event, type EventData, type EventProps, EventsSortDirection, Player, type PlayerEvents, type PlayerProps, QueryProvider, Video, type VideoData, type VideoListItem, type VideoProps, queryClient };