@mottosports/motto-video-player 1.0.1-rc.63 → 1.0.1-rc.65

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
@@ -314,6 +314,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
314
314
  */
315
315
  locale?: string;
316
316
  containerClassName?: string;
317
+ /**
318
+ * Motto public key used for authenticated requests
319
+ */
320
+ publicKey?: string;
321
+ /**
322
+ * Authentication context for player operations
323
+ */
324
+ auth?: {
325
+ mottoToken?: string;
326
+ userId?: string;
327
+ };
317
328
  }
318
329
  /**
319
330
  * Mux Analytics type definitions
package/dist/index.d.ts CHANGED
@@ -314,6 +314,17 @@ interface PlayerProps extends Omit<HTMLAttributes<HTMLVideoElement>, 'src' | 'on
314
314
  */
315
315
  locale?: string;
316
316
  containerClassName?: string;
317
+ /**
318
+ * Motto public key used for authenticated requests
319
+ */
320
+ publicKey?: string;
321
+ /**
322
+ * Authentication context for player operations
323
+ */
324
+ auth?: {
325
+ mottoToken?: string;
326
+ userId?: string;
327
+ };
317
328
  }
318
329
  /**
319
330
  * Mux Analytics type definitions
package/dist/index.js CHANGED
@@ -1201,6 +1201,7 @@ var isPlayReadySupported = () => {
1201
1201
  return isXbox || (isEdge || isIE) && isWindows;
1202
1202
  };
1203
1203
  var supportsWidevinePersistentLicenses = () => {
1204
+ return false;
1204
1205
  if (typeof navigator === "undefined") {
1205
1206
  return false;
1206
1207
  }
@@ -1225,7 +1226,7 @@ var supportsWidevinePersistentLicenses = () => {
1225
1226
  var import_mux_data_shakaplayer = __toESM(require("@mux/mux-data-shakaplayer"));
1226
1227
 
1227
1228
  // package.json
1228
- var version = "1.0.1-rc.63";
1229
+ var version = "1.0.1-rc.65";
1229
1230
 
1230
1231
  // src/utils/licenseCache.ts
1231
1232
  var PERSISTENT_LICENSE_PREFIX = "motto_lic_";
@@ -1386,7 +1387,9 @@ var useShakaPlayer = ({
1386
1387
  onPlayerReady,
1387
1388
  muxConfig,
1388
1389
  onMuxReady,
1389
- onMuxDataUpdate
1390
+ onMuxDataUpdate,
1391
+ publicKey,
1392
+ mottoToken
1390
1393
  }) => {
1391
1394
  const playerRef = (0, import_react.useRef)(null);
1392
1395
  const [isRetrying, setIsRetrying] = (0, import_react.useState)(false);
@@ -1527,7 +1530,12 @@ var useShakaPlayer = ({
1527
1530
  if (netEngine) {
1528
1531
  netEngine.registerRequestFilter((type, request) => {
1529
1532
  if (type === import_shaka_player.default.net.NetworkingEngine.RequestType.LICENSE) {
1530
- request.headers["x-dt-auth-token"] = src.drm.token;
1533
+ if (publicKey) {
1534
+ request.headers["authorization"] = `Bearer ${publicKey}`;
1535
+ }
1536
+ if (mottoToken) {
1537
+ request.headers["x-motto-token"] = mottoToken;
1538
+ }
1531
1539
  }
1532
1540
  });
1533
1541
  netEngine.registerResponseFilter((type, response) => {
@@ -1649,7 +1657,8 @@ var useShakaPlayer = ({
1649
1657
  return initializePlayerInternal(video);
1650
1658
  }, [initializePlayerInternal]);
1651
1659
  const destroyPlayer = (0, import_react.useCallback)(async () => {
1652
- if (playerRef.current) {
1660
+ const playerInstance = playerRef.current;
1661
+ if (playerInstance) {
1653
1662
  try {
1654
1663
  if (videoElementRef.current) {
1655
1664
  try {
@@ -1670,19 +1679,21 @@ var useShakaPlayer = ({
1670
1679
  waitingForKeyTimerRef.current = null;
1671
1680
  }
1672
1681
  try {
1673
- if (drmExpirationHandlerRef.current && playerRef.current?.removeEventListener) {
1674
- playerRef.current.removeEventListener("drmsessionupdate", drmExpirationHandlerRef.current);
1682
+ if (drmExpirationHandlerRef.current && playerInstance.removeEventListener) {
1683
+ playerInstance.removeEventListener("drmsessionupdate", drmExpirationHandlerRef.current);
1675
1684
  }
1676
1685
  } catch (e) {
1677
1686
  console.warn("Error removing DRM expiration listener:", e);
1678
1687
  } finally {
1679
1688
  drmExpirationHandlerRef.current = null;
1680
1689
  }
1681
- await playerRef.current.destroy();
1690
+ await playerInstance.destroy();
1682
1691
  } catch (error) {
1683
1692
  console.warn("Error destroying Shaka Player:", error);
1684
1693
  } finally {
1685
- playerRef.current = null;
1694
+ if (playerRef.current === playerInstance) {
1695
+ playerRef.current = null;
1696
+ }
1686
1697
  storedPersistentThisLoadRef.current = false;
1687
1698
  }
1688
1699
  }
@@ -2189,14 +2200,18 @@ var useShakaUI = (playerRef, containerRef, videoRef, controls, chromecastConfig,
2189
2200
  }
2190
2201
  return ui;
2191
2202
  }, [controls, containerRef, playerRef, videoRef, chromecastConfig, seekbarColors, onSkipBack, onSkipForward, iconSizes, locale]);
2192
- const destroyUI = (0, import_react6.useCallback)(() => {
2193
- if (uiRef.current) {
2203
+ const destroyUI = (0, import_react6.useCallback)(async () => {
2204
+ const uiInstance = uiRef.current;
2205
+ if (uiInstance) {
2194
2206
  try {
2195
- uiRef.current.destroy();
2207
+ await uiInstance.destroy();
2196
2208
  } catch (error) {
2197
2209
  console.error("Error destroying UI:", error);
2210
+ } finally {
2211
+ if (uiRef.current === uiInstance) {
2212
+ uiRef.current = null;
2213
+ }
2198
2214
  }
2199
- uiRef.current = null;
2200
2215
  }
2201
2216
  }, []);
2202
2217
  return {
@@ -3822,6 +3837,8 @@ var Player = (0, import_react12.forwardRef)(
3822
3837
  events,
3823
3838
  locale = "en",
3824
3839
  containerClassName,
3840
+ publicKey,
3841
+ auth,
3825
3842
  ...videoProps
3826
3843
  }, ref) => {
3827
3844
  const videoRef = (0, import_react12.useRef)(null);
@@ -3838,7 +3855,9 @@ var Player = (0, import_react12.forwardRef)(
3838
3855
  onPlayerReady: events?.onPlayerReady,
3839
3856
  muxConfig,
3840
3857
  onMuxReady: events?.onMuxReady,
3841
- onMuxDataUpdate: events?.onMuxDataUpdate
3858
+ onMuxDataUpdate: events?.onMuxDataUpdate,
3859
+ publicKey,
3860
+ mottoToken: auth?.mottoToken
3842
3861
  });
3843
3862
  const {
3844
3863
  initializeMux,
@@ -4685,6 +4704,8 @@ var Video = ({
4685
4704
  events,
4686
4705
  locale,
4687
4706
  containerClassName: "w-full h-full",
4707
+ publicKey,
4708
+ auth,
4688
4709
  children
4689
4710
  }
4690
4711
  ) }) });
@@ -4853,7 +4874,9 @@ var Event = ({
4853
4874
  className: (0, import_tailwind_merge4.twMerge)(className, "peer aspect-video"),
4854
4875
  events,
4855
4876
  locale,
4856
- containerClassName: "w-full h-full"
4877
+ containerClassName: "w-full h-full",
4878
+ publicKey,
4879
+ auth
4857
4880
  }
4858
4881
  ) }),
4859
4882
  !hideTitle && eventData && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -5209,7 +5232,9 @@ var CreativeWork = ({
5209
5232
  },
5210
5233
  src: activePlaylist,
5211
5234
  locale,
5212
- containerClassName: "w-full h-full"
5235
+ containerClassName: "w-full h-full",
5236
+ publicKey,
5237
+ auth
5213
5238
  }
5214
5239
  ),
5215
5240
  !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(