@dialtribe/react-sdk 0.1.0-alpha.12 → 0.1.0-alpha.15

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.
@@ -1,501 +1,4 @@
1
- export { A as ApiClientConfig, h as AudioWaveform, B as Broadcast, C as CDN_DOMAIN, d as DIALTRIBE_API_BASE, c as DialtribeClient, a as DialtribeContextValue, i as DialtribeOverlay, k as DialtribeOverlayMode, j as DialtribeOverlayProps, e as DialtribePlayer, g as DialtribePlayerErrorBoundary, f as DialtribePlayerProps, D as DialtribeProvider, b as DialtribeProviderProps, E as ENDPOINTS, H as HTTP_STATUS, q as HttpStatusCode, L as LoadingSpinner, m as TranscriptData, l as TranscriptSegment, T as TranscriptWord, o as buildBroadcastCdnUrl, p as buildBroadcastS3KeyPrefix, n as formatTime, u as useDialtribe, r as useDialtribeOptional } from './dialtribe-player-Rc9kfQiX.mjs';
2
- import * as react_jsx_runtime from 'react/jsx-runtime';
3
- import React$1, { RefObject } from 'react';
4
-
5
- /**
6
- * Props for the DialtribeStreamer component.
7
- *
8
- * @example
9
- * ```tsx
10
- * // Inside DialtribeProvider (recommended)
11
- * <DialtribeProvider sessionToken={token}>
12
- * <DialtribeStreamer
13
- * streamKey={keyFromBackend}
14
- * onDone={() => window.close()}
15
- * />
16
- * </DialtribeProvider>
17
- *
18
- * // Standalone (e.g., popup window)
19
- * <DialtribeStreamer
20
- * sessionToken={token}
21
- * streamKey={keyFromBackend}
22
- * onDone={() => window.close()}
23
- * />
24
- * ```
25
- */
26
- interface DialtribeStreamerProps {
27
- /**
28
- * Session token for API authentication.
29
- *
30
- * Required for permission checks. Can be provided via:
31
- * 1. DialtribeProvider context (recommended for main app)
32
- * 2. This prop (required for popup windows)
33
- *
34
- * Must include `broadcasts:stream` permission.
35
- */
36
- sessionToken?: string;
37
- /**
38
- * Stream key for broadcasting.
39
- *
40
- * **Production apps should always provide this from their backend.**
41
- * The stream key authenticates the broadcaster with the encoder server.
42
- *
43
- * If omitted, a manual input form is shown. This is intended for
44
- * development/testing only - end users should never see or handle stream keys.
45
- *
46
- * @example "w1_abc123def456..."
47
- */
48
- streamKey?: string;
49
- /**
50
- * Called when streaming ends (user stops, terminates, or clicks Done).
51
- * Use this to close the popup or navigate away.
52
- *
53
- * @example () => window.close()
54
- */
55
- onDone?: () => void;
56
- /**
57
- * Called when the stream key changes (e.g., user edits it in preview mode).
58
- * Useful for persisting the key or updating parent state.
59
- */
60
- onStreamKeyChange?: (key: string) => void;
61
- /**
62
- * Custom encoder server URL. Defaults to Dialtribe's production encoder.
63
- * Only change this for self-hosted encoder deployments.
64
- *
65
- * @default "https://broadcastapi.dialtribe.com"
66
- */
67
- encoderServerUrl?: string;
68
- /**
69
- * Custom API base URL for broadcast availability checks.
70
- * Only change this for self-hosted API deployments.
71
- *
72
- * @default "https://dialtribe.com/api/public/v1"
73
- */
74
- apiBaseUrl?: string;
75
- /**
76
- * When true, the streamer fills its parent container instead of the viewport.
77
- * Use this when embedding the streamer inline within a page.
78
- *
79
- * @default false
80
- */
81
- inline?: boolean;
82
- }
83
- declare function DialtribeStreamer({ sessionToken: propSessionToken, streamKey: initialStreamKey, onDone, onStreamKeyChange, encoderServerUrl, apiBaseUrl, inline, }: DialtribeStreamerProps): react_jsx_runtime.JSX.Element;
84
-
85
- interface StreamingPreviewProps {
86
- videoRef: RefObject<HTMLVideoElement>;
87
- isVideoKey: boolean;
88
- isVideoEnabled: boolean;
89
- mediaStream: MediaStream | null;
90
- facingMode: "user" | "environment";
91
- }
92
- declare function StreamingPreview({ videoRef, isVideoKey, isVideoEnabled, mediaStream, facingMode, }: StreamingPreviewProps): react_jsx_runtime.JSX.Element;
93
-
94
- type StreamingControlState = "previewing" | "connecting" | "live" | "stopping";
95
- interface MediaDeviceInfo {
96
- deviceId: string;
97
- label: string;
98
- }
99
- interface StreamingControlsProps {
100
- state: StreamingControlState;
101
- isVideoKey: boolean;
102
- isMuted: boolean;
103
- isVideoEnabled: boolean;
104
- facingMode: "user" | "environment";
105
- hasMultipleCameras: boolean;
106
- startTime: Date | null;
107
- bytesSent: number;
108
- showStopConfirm: boolean;
109
- streamKey: string;
110
- onStreamKeyChange?: (newKey: string) => void;
111
- onStart: () => void;
112
- onStop: () => void;
113
- onConfirmStop: () => void;
114
- onCancelStop: () => void;
115
- onToggleMute: () => void;
116
- onToggleVideo: () => void;
117
- onFlipCamera: () => void;
118
- onClose?: () => void;
119
- showCloseConfirm?: boolean;
120
- onConfirmClose?: () => void;
121
- onCancelClose?: () => void;
122
- videoDevices?: MediaDeviceInfo[];
123
- audioDevices?: MediaDeviceInfo[];
124
- selectedVideoDeviceId?: string;
125
- selectedAudioDeviceId?: string;
126
- onVideoDeviceChange?: (deviceId: string) => void;
127
- onAudioDeviceChange?: (deviceId: string) => void;
128
- mediaStream?: MediaStream | null;
129
- }
130
- declare function StreamingControls({ state, isVideoKey, isMuted, isVideoEnabled, facingMode: _facingMode, // Reserved for future use (e.g., showing camera direction)
131
- hasMultipleCameras, startTime, bytesSent, showStopConfirm, streamKey, onStreamKeyChange, onStart, onStop, onConfirmStop, onCancelStop, onToggleMute, onToggleVideo, onFlipCamera, onClose, showCloseConfirm, onConfirmClose, onCancelClose, videoDevices, audioDevices, selectedVideoDeviceId, selectedAudioDeviceId, onVideoDeviceChange, onAudioDeviceChange, mediaStream, }: StreamingControlsProps): react_jsx_runtime.JSX.Element;
132
-
133
- interface StreamKeyDisplayProps {
134
- streamKey: string;
135
- className?: string;
136
- showLabel?: boolean;
137
- showCopy?: boolean;
138
- editable?: boolean;
139
- onChange?: (newKey: string) => void;
140
- size?: 'sm' | 'md' | 'lg';
141
- layout?: 'vertical' | 'horizontal';
142
- darkMode?: boolean;
143
- }
144
- /**
145
- * Shared component for displaying stream keys with reveal/copy functionality
146
- * Obscures the stream key by default, showing only first 6 and last 6 characters
147
- * When revealed and editable, becomes an input field for editing
148
- */
149
- declare function StreamKeyDisplay({ streamKey, className, showLabel, showCopy, editable, onChange, size, layout, darkMode, }: StreamKeyDisplayProps): react_jsx_runtime.JSX.Element;
150
-
151
- interface StreamKeyInputProps {
152
- onSubmit: (key: string) => void;
153
- /**
154
- * When true, the input fills its parent container instead of the viewport.
155
- * Use this when embedding inline within a page.
156
- */
157
- inline?: boolean;
158
- }
159
- /**
160
- * Stream key input form for manual entry
161
- * Validates stream key format before submission
162
- */
163
- declare function StreamKeyInput({ onSubmit, inline }: StreamKeyInputProps): react_jsx_runtime.JSX.Element;
164
-
165
- /**
166
- * WebSocket streaming client for sending media chunks to encoder server
167
- * Based on prankcast reference implementation
168
- */
169
- /** Default encoder server URL */
170
- declare const DEFAULT_ENCODER_SERVER_URL = "https://broadcastapi.dialtribe.com";
171
- interface WebSocketStreamerOptions {
172
- streamKey: string;
173
- mediaStream: MediaStream;
174
- isVideo: boolean;
175
- /** Optional custom encoder server URL (defaults to DEFAULT_ENCODER_SERVER_URL) */
176
- encoderServerUrl?: string;
177
- onBytesUpdate?: (bytes: number) => void;
178
- onStateChange?: (state: "connecting" | "live" | "stopped" | "terminated" | "error") => void;
179
- onError?: (error: string) => void;
180
- }
181
- declare class WebSocketStreamer {
182
- private streamKey;
183
- private mediaStream;
184
- private isVideo;
185
- private encoderServerUrl;
186
- private websocket;
187
- private mediaRecorder;
188
- private bytesSent;
189
- private userStopped;
190
- private onBytesUpdate?;
191
- private onStateChange?;
192
- private onError?;
193
- constructor(options: WebSocketStreamerOptions);
194
- /**
195
- * Validate stream key format
196
- * Stream keys must follow format: {tierCode}{foreignId}_{randomKey}
197
- * Tier codes: a (audio shared), b (audio VIP), v (video shared), w (video VIP)
198
- */
199
- private validateStreamKeyFormat;
200
- /**
201
- * Build WebSocket URL from stream key
202
- */
203
- private buildWebSocketUrl;
204
- /**
205
- * Start streaming
206
- */
207
- start(): Promise<void>;
208
- /**
209
- * Stop streaming
210
- */
211
- stop(): void;
212
- /**
213
- * Get total bytes sent
214
- */
215
- getBytesSent(): number;
216
- /**
217
- * Update the media stream (e.g., when flipping camera)
218
- * This keeps the WebSocket connection alive while swapping the media source
219
- *
220
- * Note: Errors are thrown to the caller, not sent to onError callback
221
- * This allows the caller to handle camera flip failures gracefully
222
- */
223
- updateMediaStream(newMediaStream: MediaStream): Promise<void>;
224
- /**
225
- * Set up WebSocket event handlers
226
- */
227
- private setupWebSocketHandlers;
228
- /**
229
- * Set up MediaRecorder event handlers
230
- */
231
- private setupMediaRecorderHandlers;
232
- }
233
-
234
- /**
235
- * Media constraints for browser streaming
236
- * Based on prankcast reference implementation
237
- */
238
- interface MediaConstraintsOptions {
239
- isVideo: boolean;
240
- facingMode?: "user" | "environment";
241
- }
242
- declare function getMediaConstraints(options: MediaConstraintsOptions): MediaStreamConstraints;
243
- /**
244
- * MediaRecorder options for encoding
245
- */
246
- declare function getMediaRecorderOptions(isVideo: boolean): MediaRecorderOptions;
247
- /**
248
- * Check browser compatibility
249
- */
250
- declare function checkBrowserCompatibility(): {
251
- compatible: boolean;
252
- error?: string;
253
- };
254
-
255
- /**
256
- * Utility functions for opening broadcast streamer popup windows
257
- */
258
- interface PopupDimensions {
259
- width: number;
260
- height: number;
261
- left: number;
262
- top: number;
263
- }
264
- /**
265
- * Calculate optimal popup dimensions based on screen size
266
- * - Desktop/wider screens: 16:9 landscape ratio (e.g., 1280x720) to match modern webcams
267
- * - Mobile/narrower screens: 9:16 portrait ratio (e.g., 720x1280) for vertical video
268
- */
269
- declare function calculatePopupDimensions(): PopupDimensions;
270
- /**
271
- * Options for opening a broadcast streamer popup window.
272
- */
273
- interface OpenDialtribeStreamerPopupOptions {
274
- /**
275
- * Session token for API authentication. **Required.**
276
- * The token must include `broadcasts:stream` permission.
277
- * Sent securely via postMessage (not in the URL).
278
- */
279
- sessionToken: string;
280
- /**
281
- * Stream key for broadcasting. **Required for production use.**
282
- * Fetch this from your backend and pass it here.
283
- * The key is sent securely via postMessage (not in the URL).
284
- *
285
- * @example "w1_abc123def456..."
286
- */
287
- streamKey: string;
288
- /**
289
- * URL path for the streamer page. **Required.**
290
- * This is the route in your app where the popup page is hosted.
291
- *
292
- * @example "/broadcasts/new"
293
- * @example "/stream/live"
294
- */
295
- streamerUrl: string;
296
- /** Optional app ID to include in the postMessage payload */
297
- appId?: number;
298
- /** Additional URL parameters to pass to the popup page */
299
- additionalParams?: Record<string, string>;
300
- }
301
- /**
302
- * Open broadcast streamer popup window with credentials sent via postMessage
303
- * This is more secure than passing sensitive data in the URL
304
- *
305
- * @example
306
- * ```tsx
307
- * import { openDialtribeStreamerPopup } from '@dialtribe/react-sdk/dialtribe-streamer';
308
- *
309
- * // Open popup for live streaming
310
- * openDialtribeStreamerPopup({
311
- * sessionToken: 'sess_xxx...',
312
- * streamKey: 'w1_abc123...',
313
- * streamerUrl: '/broadcasts/new',
314
- * });
315
- * ```
316
- *
317
- * @returns The popup window reference, or null if popup was blocked
318
- */
319
- declare function openDialtribeStreamerPopup(options: OpenDialtribeStreamerPopupOptions): Window | null;
320
- /**
321
- * Legacy function name for backwards compatibility
322
- * @deprecated Use openDialtribeStreamerPopup instead
323
- */
324
- declare const openBroadcastPopup: typeof openDialtribeStreamerPopup;
325
-
326
- /**
327
- * Return value from useDialtribeStreamerPopup hook.
328
- */
329
- interface UseDialtribeStreamerPopupReturn {
330
- /**
331
- * Session token received from parent window.
332
- * Will be null until credentials are received via postMessage.
333
- */
334
- sessionToken: string | null;
335
- /**
336
- * Stream key received from parent window.
337
- * Will be null until credentials are received via postMessage.
338
- */
339
- streamKey: string | null;
340
- /**
341
- * API base URL received from parent window.
342
- * Defaults to empty string (uses SDK default).
343
- */
344
- apiBaseUrl: string;
345
- /**
346
- * Function to update the stream key.
347
- * Pass this to DialtribeStreamer's onStreamKeyChange prop.
348
- */
349
- setStreamKey: React.Dispatch<React.SetStateAction<string | null>>;
350
- /**
351
- * True if credentials have been received from the parent window.
352
- */
353
- isReady: boolean;
354
- }
355
- /**
356
- * Hook for popup pages that receive streaming credentials via postMessage.
357
- *
358
- * Use this in your popup page component to handle the postMessage communication
359
- * with the parent window that opened the popup via `openDialtribeStreamerPopup()`.
360
- *
361
- * @example
362
- * ```tsx
363
- * import { DialtribeStreamer, useDialtribeStreamerPopup } from '@dialtribe/react-sdk/dialtribe-streamer';
364
- *
365
- * export default function BroadcastPopupPage() {
366
- * const { sessionToken, streamKey, apiBaseUrl, setStreamKey } = useDialtribeStreamerPopup();
367
- *
368
- * return (
369
- * <DialtribeStreamer
370
- * sessionToken={sessionToken}
371
- * streamKey={streamKey}
372
- * apiBaseUrl={apiBaseUrl}
373
- * onDone={() => window.close()}
374
- * onStreamKeyChange={setStreamKey}
375
- * />
376
- * );
377
- * }
378
- * ```
379
- */
380
- declare function useDialtribeStreamerPopup(): UseDialtribeStreamerPopupReturn;
381
-
382
- /**
383
- * Fallback behavior when popup is blocked by the browser.
384
- */
385
- type PopupFallbackMode = 'fullscreen' | 'newTab' | 'none';
386
- /**
387
- * Options for the useDialtribeStreamerLauncher hook.
388
- */
389
- interface UseDialtribeStreamerLauncherOptions {
390
- /**
391
- * Session token for API authentication.
392
- */
393
- sessionToken: string | null;
394
- /**
395
- * Stream key for broadcasting.
396
- */
397
- streamKey: string;
398
- /**
399
- * URL path for the streamer page (e.g., '/broadcasts/new').
400
- */
401
- streamerUrl: string;
402
- /**
403
- * API base URL for the streamer.
404
- */
405
- apiBaseUrl?: string;
406
- /**
407
- * What to do if the popup is blocked by the browser.
408
- * - 'fullscreen': Show a fullscreen overlay in the current page
409
- * - 'newTab': Open in a new browser tab (less likely to be blocked)
410
- * - 'none': Do nothing, let the caller handle it
411
- *
412
- * @default 'fullscreen'
413
- */
414
- fallback?: PopupFallbackMode;
415
- /**
416
- * Callback when popup is blocked (called regardless of fallback mode).
417
- */
418
- onPopupBlocked?: () => void;
419
- /**
420
- * Callback when streaming ends (from fullscreen fallback mode).
421
- */
422
- onDone?: () => void;
423
- /**
424
- * Callback when stream key changes (from fallback streamer).
425
- */
426
- onStreamKeyChange?: (key: string) => void;
427
- }
428
- /**
429
- * Return value from useDialtribeStreamerLauncher hook.
430
- */
431
- interface UseDialtribeStreamerLauncherReturn {
432
- /**
433
- * Launch the streamer. Tries popup first, falls back if blocked.
434
- */
435
- launch: () => void;
436
- /**
437
- * Portal component that renders the fallback overlay.
438
- * Include this once in your JSX - it renders via portal to document.body.
439
- *
440
- * @example
441
- * ```tsx
442
- * const { launch, Fallback } = useDialtribeStreamerLauncher({...});
443
- * return (
444
- * <>
445
- * <button onClick={launch}>Start</button>
446
- * <Fallback />
447
- * </>
448
- * );
449
- * ```
450
- */
451
- Fallback: React$1.FC;
452
- /**
453
- * Whether the fallback fullscreen overlay is currently shown.
454
- * Use this for custom fallback rendering.
455
- */
456
- showFallback: boolean;
457
- /**
458
- * Close the fallback overlay.
459
- * Use this for custom fallback rendering.
460
- */
461
- closeFallback: () => void;
462
- /**
463
- * Reference to the popup window (if successfully opened).
464
- */
465
- popupRef: Window | null;
466
- /**
467
- * Whether the last launch attempt was blocked.
468
- */
469
- wasBlocked: boolean;
470
- }
471
- /**
472
- * Hook for launching the DialtribeStreamer with automatic popup fallback.
473
- *
474
- * This hook tries to open the streamer in a popup window first. If the popup
475
- * is blocked by the browser, it automatically falls back to a fullscreen
476
- * overlay or new tab (configurable).
477
- *
478
- * @example
479
- * ```tsx
480
- * import { useDialtribeStreamerLauncher } from '@dialtribe/react-sdk/dialtribe-streamer';
481
- *
482
- * function StreamButton({ sessionToken, streamKey }: Props) {
483
- * const { launch, Fallback } = useDialtribeStreamerLauncher({
484
- * sessionToken,
485
- * streamKey,
486
- * streamerUrl: '/broadcasts/new',
487
- * fallback: 'fullscreen',
488
- * });
489
- *
490
- * return (
491
- * <>
492
- * <button onClick={launch}>Start Streaming</button>
493
- * <Fallback />
494
- * </>
495
- * );
496
- * }
497
- * ```
498
- */
499
- declare function useDialtribeStreamerLauncher(options: UseDialtribeStreamerLauncherOptions): UseDialtribeStreamerLauncherReturn;
500
-
501
- export { DEFAULT_ENCODER_SERVER_URL, DialtribeStreamer, type DialtribeStreamerProps, type MediaConstraintsOptions, type OpenDialtribeStreamerPopupOptions, type PopupDimensions, type PopupFallbackMode, StreamKeyDisplay, type StreamKeyDisplayProps, StreamKeyInput, type StreamKeyInputProps, type StreamingControlState, StreamingControls, type StreamingControlsProps, StreamingPreview, type StreamingPreviewProps, type UseDialtribeStreamerLauncherOptions, type UseDialtribeStreamerLauncherReturn, type UseDialtribeStreamerPopupReturn, WebSocketStreamer, type WebSocketStreamerOptions, calculatePopupDimensions, checkBrowserCompatibility, getMediaConstraints, getMediaRecorderOptions, openBroadcastPopup, openDialtribeStreamerPopup, useDialtribeStreamerLauncher, useDialtribeStreamerPopup };
1
+ export { A as ApiClientConfig, h as AudioWaveform, B as Broadcast, C as CDN_DOMAIN, d as DIALTRIBE_API_BASE, c as DialtribeClient, a as DialtribeContextValue, i as DialtribeOverlay, k as DialtribeOverlayMode, j as DialtribeOverlayProps, e as DialtribePlayer, g as DialtribePlayerErrorBoundary, f as DialtribePlayerProps, D as DialtribeProvider, b as DialtribeProviderProps, E as ENDPOINTS, H as HTTP_STATUS, q as HttpStatusCode, L as LoadingSpinner, m as TranscriptData, l as TranscriptSegment, T as TranscriptWord, o as buildBroadcastCdnUrl, p as buildBroadcastS3KeyPrefix, n as formatTime, u as useDialtribe, r as useDialtribeOptional } from './dialtribe-player-CNriUtNi.mjs';
2
+ export { j as DEFAULT_ENCODER_SERVER_URL, D as DialtribeStreamer, a as DialtribeStreamerProps, M as MediaConstraintsOptions, O as OpenDialtribeStreamerPopupOptions, P as PopupDimensions, w as PopupFallbackMode, f as StreamKeyDisplay, g as StreamKeyDisplayProps, h as StreamKeyInput, i as StreamKeyInputProps, e as StreamingControlState, c as StreamingControls, d as StreamingControlsProps, S as StreamingPreview, b as StreamingPreviewProps, t as UseDialtribeStreamerLauncherOptions, v as UseDialtribeStreamerLauncherReturn, U as UseDialtribeStreamerPopupReturn, W as WebSocketStreamer, k as WebSocketStreamerOptions, r as calculatePopupDimensions, o as checkBrowserCompatibility, m as getMediaConstraints, n as getMediaRecorderOptions, q as openBroadcastPopup, p as openDialtribeStreamerPopup, s as useDialtribeStreamerLauncher, u as useDialtribeStreamerPopup } from './dialtribe-streamer-Bc17hH6o.mjs';
3
+ import 'react/jsx-runtime';
4
+ import 'react';