stormcloud-video-player 0.8.33 → 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.
package/lib/index.cjs CHANGED
@@ -1800,6 +1800,41 @@ function createHlsAdPlayer(contentVideo, options) {
1800
1800
  }
1801
1801
  };
1802
1802
  }
1803
+ // src/utils/devUrl.ts
1804
+ var PRIVATE_HOST_PATTERNS = [
1805
+ /^localhost$/i,
1806
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1807
+ /^0\.0\.0\.0$/,
1808
+ /^::1$/,
1809
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1810
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
1811
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
1812
+ ];
1813
+ function isLocalDevHost(hostname) {
1814
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
1815
+ if (!host) return false;
1816
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
1817
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
1818
+ return pattern.test(host);
1819
+ });
1820
+ }
1821
+ function toDevSafeUrl(rawUrl) {
1822
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
1823
+ var url;
1824
+ try {
1825
+ url = new URL(rawUrl);
1826
+ } catch (unused) {
1827
+ return rawUrl;
1828
+ }
1829
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1830
+ return rawUrl;
1831
+ }
1832
+ if (!isLocalDevHost(url.hostname)) {
1833
+ return rawUrl;
1834
+ }
1835
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
1836
+ return "file://".concat(cleanPath);
1837
+ }
1803
1838
  // src/sdk/pal.ts
1804
1839
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
1805
1840
  var _nonceLoader;
@@ -1886,12 +1921,12 @@ function createPalNonceManager() {
1886
1921
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
1887
1922
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
1888
1923
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
1889
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1924
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1890
1925
  request.iconsSupported = true;
1891
1926
  request.playerType = "StormcloudVideoPlayer";
1892
1927
  request.playerVersion = "1.0";
1893
1928
  request.supportedApiFrameworks = "2,7,9";
1894
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1929
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1895
1930
  request.videoWidth = options.videoWidth || 640;
1896
1931
  request.videoHeight = options.videoHeight || 480;
1897
1932
  if (options.ppid) request.ppid = options.ppid;
@@ -5557,7 +5592,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5557
5592
  podMaxDurationMs: podParams.maxDurationMs,
5558
5593
  isCtv: envSignals.isCtv,
5559
5594
  contentUrl: envSignals.contentUrl,
5560
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5595
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
5561
5596
  adWillPlayMuted: adWillPlayMuted,
5562
5597
  adWillAutoPlay: !!this.config.autoplay,
5563
5598
  appId: envSignals.appId,