stormcloud-video-player 0.8.32 → 0.8.34

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,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { S as StormcloudVideoPlayerConfig } from '../types-e6QV7SBp.cjs';
2
+ import { a as StormcloudVideoPlayerConfig } from '../types-CSHvCbhZ.cjs';
3
3
 
4
4
  interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
5
5
  onMount?: (player: any) => void;
@@ -1649,6 +1649,41 @@ function createHlsAdPlayer(contentVideo, options) {
1649
1649
  }
1650
1650
  };
1651
1651
  }
1652
+ // src/utils/devUrl.ts
1653
+ var PRIVATE_HOST_PATTERNS = [
1654
+ /^localhost$/i,
1655
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1656
+ /^0\.0\.0\.0$/,
1657
+ /^::1$/,
1658
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1659
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
1660
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
1661
+ ];
1662
+ function isLocalDevHost(hostname) {
1663
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
1664
+ if (!host) return false;
1665
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
1666
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
1667
+ return pattern.test(host);
1668
+ });
1669
+ }
1670
+ function toDevSafeUrl(rawUrl) {
1671
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
1672
+ var url;
1673
+ try {
1674
+ url = new URL(rawUrl);
1675
+ } catch (unused) {
1676
+ return rawUrl;
1677
+ }
1678
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1679
+ return rawUrl;
1680
+ }
1681
+ if (!isLocalDevHost(url.hostname)) {
1682
+ return rawUrl;
1683
+ }
1684
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
1685
+ return "file://".concat(cleanPath);
1686
+ }
1652
1687
  // src/sdk/pal.ts
1653
1688
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
1654
1689
  var _nonceLoader;
@@ -1735,17 +1770,17 @@ function createPalNonceManager() {
1735
1770
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
1736
1771
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
1737
1772
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
1738
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1773
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1739
1774
  request.iconsSupported = true;
1740
1775
  request.playerType = "StormcloudVideoPlayer";
1741
1776
  request.playerVersion = "1.0";
1742
1777
  request.supportedApiFrameworks = "2,7,9";
1743
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1778
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1744
1779
  request.videoWidth = options.videoWidth || 640;
1745
1780
  request.videoHeight = options.videoHeight || 480;
1746
1781
  if (options.ppid) request.ppid = options.ppid;
1747
1782
  if (options.sessionId) request.sessionId = options.sessionId;
1748
- console.log("[PAL] NonceRequest before generateNonce:", {
1783
+ console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
1749
1784
  adWillAutoPlay: request.adWillAutoPlay,
1750
1785
  adWillPlayMuted: request.adWillPlayMuted,
1751
1786
  playerVolume: request.playerVolume,
@@ -1760,7 +1795,7 @@ function createPalNonceManager() {
1760
1795
  videoHeight: request.videoHeight,
1761
1796
  ppid: request.ppid,
1762
1797
  sessionId: request.sessionId
1763
- });
1798
+ }, null, 2));
1764
1799
  return [
1765
1800
  4,
1766
1801
  loader.loadNonceManager(request)
@@ -5359,7 +5394,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5359
5394
  podMaxDurationMs: podParams.maxDurationMs,
5360
5395
  isCtv: envSignals.isCtv,
5361
5396
  contentUrl: envSignals.contentUrl,
5362
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5397
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
5363
5398
  adWillPlayMuted: adWillPlayMuted,
5364
5399
  adWillAutoPlay: !!this.config.autoplay,
5365
5400
  appId: envSignals.appId,