@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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { HelloWorld, HelloWorldProps } from './hello-world.mjs';
2
- 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 } from './dialtribe-player-Rc9kfQiX.mjs';
3
- export { DEFAULT_ENCODER_SERVER_URL, DialtribeStreamer, DialtribeStreamerProps, MediaConstraintsOptions, OpenDialtribeStreamerPopupOptions, PopupDimensions, PopupFallbackMode, StreamKeyDisplay, StreamKeyDisplayProps, StreamKeyInput, StreamKeyInputProps, StreamingControlState, StreamingControls, StreamingControlsProps, StreamingPreview, StreamingPreviewProps, UseDialtribeStreamerLauncherOptions, UseDialtribeStreamerLauncherReturn, UseDialtribeStreamerPopupReturn, WebSocketStreamer, WebSocketStreamerOptions, calculatePopupDimensions, checkBrowserCompatibility, getMediaConstraints, getMediaRecorderOptions, openBroadcastPopup, openDialtribeStreamerPopup, useDialtribeStreamerLauncher, useDialtribeStreamerPopup } from './dialtribe-streamer.mjs';
2
+ 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 } from './dialtribe-player-CNriUtNi.mjs';
3
+ 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, l as StreamDiagnostics, 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';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { HelloWorld, HelloWorldProps } from './hello-world.js';
2
- 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 } from './dialtribe-player-Rc9kfQiX.js';
3
- export { DEFAULT_ENCODER_SERVER_URL, DialtribeStreamer, DialtribeStreamerProps, MediaConstraintsOptions, OpenDialtribeStreamerPopupOptions, PopupDimensions, PopupFallbackMode, StreamKeyDisplay, StreamKeyDisplayProps, StreamKeyInput, StreamKeyInputProps, StreamingControlState, StreamingControls, StreamingControlsProps, StreamingPreview, StreamingPreviewProps, UseDialtribeStreamerLauncherOptions, UseDialtribeStreamerLauncherReturn, UseDialtribeStreamerPopupReturn, WebSocketStreamer, WebSocketStreamerOptions, calculatePopupDimensions, checkBrowserCompatibility, getMediaConstraints, getMediaRecorderOptions, openBroadcastPopup, openDialtribeStreamerPopup, useDialtribeStreamerLauncher, useDialtribeStreamerPopup } from './dialtribe-streamer.js';
2
+ 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 } from './dialtribe-player-CNriUtNi.js';
3
+ 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, l as StreamDiagnostics, 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-jgZX44_G.js';
4
4
  import 'react/jsx-runtime';
5
5
  import 'react';
package/dist/index.js CHANGED
@@ -2267,7 +2267,10 @@ var WebSocketStreamer = class {
2267
2267
  this.websocket = null;
2268
2268
  this.mediaRecorder = null;
2269
2269
  this.bytesSent = 0;
2270
+ this.chunksSent = 0;
2270
2271
  this.userStopped = false;
2272
+ // Track if user initiated the stop
2273
+ this.startTime = 0;
2271
2274
  this.streamKey = options.streamKey;
2272
2275
  this.mediaStream = options.mediaStream;
2273
2276
  this.isVideo = options.isVideo;
@@ -2358,10 +2361,12 @@ Please check encoder server logs and DATABASE_URL configuration.`
2358
2361
  console.log("\u2705 WebSocket connected");
2359
2362
  this.setupWebSocketHandlers();
2360
2363
  const recorderOptions = getMediaRecorderOptions(this.isVideo);
2364
+ this.mimeType = recorderOptions.mimeType;
2361
2365
  this.mediaRecorder = new MediaRecorder(this.mediaStream, recorderOptions);
2362
2366
  console.log("\u{1F399}\uFE0F MediaRecorder created with options:", recorderOptions);
2363
2367
  this.setupMediaRecorderHandlers();
2364
2368
  this.mediaRecorder.start(300);
2369
+ this.startTime = Date.now();
2365
2370
  console.log("\u{1F534} Recording started");
2366
2371
  this.onStateChange?.("live");
2367
2372
  } catch (error) {
@@ -2406,6 +2411,19 @@ Please check encoder server logs and DATABASE_URL configuration.`
2406
2411
  getBytesSent() {
2407
2412
  return this.bytesSent;
2408
2413
  }
2414
+ /**
2415
+ * Get current diagnostics
2416
+ */
2417
+ getDiagnostics(closeCode, closeReason) {
2418
+ return {
2419
+ mimeType: this.mimeType,
2420
+ chunksSent: this.chunksSent,
2421
+ bytesSent: this.bytesSent,
2422
+ elapsedMs: this.startTime ? Date.now() - this.startTime : 0,
2423
+ closeCode,
2424
+ closeReason
2425
+ };
2426
+ }
2409
2427
  /**
2410
2428
  * Update the media stream (e.g., when flipping camera)
2411
2429
  * This keeps the WebSocket connection alive while swapping the media source
@@ -2435,9 +2453,22 @@ Please check encoder server logs and DATABASE_URL configuration.`
2435
2453
  this.websocket.addEventListener("close", (event) => {
2436
2454
  console.log("\u{1F50C} WebSocket closed", { code: event.code, reason: event.reason });
2437
2455
  if (!this.userStopped) {
2438
- console.warn("\u26A0\uFE0F Stream was terminated remotely (not user-initiated)");
2456
+ const diagnostics = this.getDiagnostics(event.code, event.reason);
2457
+ console.warn("\u26A0\uFE0F Stream ended unexpectedly", diagnostics);
2458
+ let errorMessage;
2459
+ if (event.code === 1e3) {
2460
+ errorMessage = event.reason || "Stream ended by server";
2461
+ } else if (event.code === 1001) {
2462
+ errorMessage = "Connection closed - server going away";
2463
+ } else if (event.code === 1006) {
2464
+ errorMessage = "Connection lost unexpectedly";
2465
+ } else if (event.code >= 4e3 && event.code < 5e3) {
2466
+ errorMessage = event.reason || "Stream terminated by server";
2467
+ } else {
2468
+ errorMessage = `Connection closed (code: ${event.code})`;
2469
+ }
2439
2470
  this.onStateChange?.("terminated");
2440
- this.onError?.("Your stream was terminated by an administrator");
2471
+ this.onError?.(errorMessage, diagnostics);
2441
2472
  }
2442
2473
  if (this.mediaRecorder && this.mediaRecorder.state !== "inactive") {
2443
2474
  this.mediaRecorder.stop();
@@ -2458,8 +2489,9 @@ Please check encoder server logs and DATABASE_URL configuration.`
2458
2489
  if (event.data.size > 0 && this.websocket?.readyState === WebSocket.OPEN) {
2459
2490
  this.websocket.send(event.data);
2460
2491
  this.bytesSent += event.data.size;
2492
+ this.chunksSent += 1;
2461
2493
  this.onBytesUpdate?.(this.bytesSent);
2462
- console.log(`\u{1F4E4} Sent ${(event.data.size / 1024).toFixed(2)} KB (Total: ${(this.bytesSent / 1024 / 1024).toFixed(2)} MB)`);
2494
+ console.log(`\u{1F4E4} Sent chunk #${this.chunksSent}: ${(event.data.size / 1024).toFixed(2)} KB (Total: ${(this.bytesSent / 1024 / 1024).toFixed(2)} MB)`);
2463
2495
  }
2464
2496
  });
2465
2497
  this.mediaRecorder.addEventListener("error", (event) => {
@@ -3092,6 +3124,7 @@ function DialtribeStreamer({
3092
3124
  }
3093
3125
  }, [initialStreamKey]);
3094
3126
  const [error, setError] = React2.useState(null);
3127
+ const [diagnostics, setDiagnostics] = React2.useState(null);
3095
3128
  const [mediaStream, setMediaStream] = React2.useState(null);
3096
3129
  const [streamer, setStreamer] = React2.useState(null);
3097
3130
  const [bytesSent, setBytesSent] = React2.useState(0);
@@ -3288,9 +3321,11 @@ function DialtribeStreamer({
3288
3321
  setState("error");
3289
3322
  }
3290
3323
  },
3291
- onError: (errorMsg) => {
3324
+ onError: (errorMsg, diag) => {
3292
3325
  setError(errorMsg);
3293
- setState("error");
3326
+ if (diag) {
3327
+ setDiagnostics(diag);
3328
+ }
3294
3329
  }
3295
3330
  });
3296
3331
  await newStreamer.start();
@@ -3575,13 +3610,37 @@ function DialtribeStreamer({
3575
3610
  )
3576
3611
  }
3577
3612
  ) }),
3578
- /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold text-black dark:text-white mb-2", children: "Stream Terminated" }),
3579
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600 dark:text-gray-400 mb-2", children: error || "Your broadcast was terminated by an administrator." }),
3580
- /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-6", children: [
3613
+ /* @__PURE__ */ jsxRuntime.jsx("h2", { className: "text-xl font-bold text-black dark:text-white mb-2", children: "Stream Ended" }),
3614
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-gray-600 dark:text-gray-400 mb-2", children: error || "Connection closed unexpectedly" }),
3615
+ /* @__PURE__ */ jsxRuntime.jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400 mb-2", children: [
3581
3616
  "Total sent: ",
3582
3617
  (bytesSent / 1024 / 1024).toFixed(2),
3583
3618
  " MB"
3584
3619
  ] }),
3620
+ diagnostics && /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-xs text-gray-400 dark:text-gray-500 mb-6 font-mono bg-gray-100 dark:bg-zinc-800 rounded p-2 text-left", children: [
3621
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3622
+ "Codec: ",
3623
+ diagnostics.mimeType || "unknown"
3624
+ ] }),
3625
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3626
+ "Chunks: ",
3627
+ diagnostics.chunksSent,
3628
+ " (",
3629
+ (diagnostics.bytesSent / 1024).toFixed(1),
3630
+ " KB)"
3631
+ ] }),
3632
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3633
+ "Duration: ",
3634
+ (diagnostics.elapsedMs / 1e3).toFixed(1),
3635
+ "s"
3636
+ ] }),
3637
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3638
+ "Close code: ",
3639
+ diagnostics.closeCode ?? "N/A",
3640
+ diagnostics.closeReason ? ` (${diagnostics.closeReason})` : ""
3641
+ ] })
3642
+ ] }),
3643
+ !diagnostics && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mb-6" }),
3585
3644
  /* @__PURE__ */ jsxRuntime.jsx(
3586
3645
  "button",
3587
3646
  {