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.
package/lib/index.js CHANGED
@@ -1583,6 +1583,41 @@ function createHlsAdPlayer(contentVideo, options) {
1583
1583
  }
1584
1584
  };
1585
1585
  }
1586
+ // src/utils/devUrl.ts
1587
+ var PRIVATE_HOST_PATTERNS = [
1588
+ /^localhost$/i,
1589
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1590
+ /^0\.0\.0\.0$/,
1591
+ /^::1$/,
1592
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1593
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
1594
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
1595
+ ];
1596
+ function isLocalDevHost(hostname) {
1597
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
1598
+ if (!host) return false;
1599
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
1600
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
1601
+ return pattern.test(host);
1602
+ });
1603
+ }
1604
+ function toDevSafeUrl(rawUrl) {
1605
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
1606
+ var url;
1607
+ try {
1608
+ url = new URL(rawUrl);
1609
+ } catch (unused) {
1610
+ return rawUrl;
1611
+ }
1612
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1613
+ return rawUrl;
1614
+ }
1615
+ if (!isLocalDevHost(url.hostname)) {
1616
+ return rawUrl;
1617
+ }
1618
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
1619
+ return "file://".concat(cleanPath);
1620
+ }
1586
1621
  // src/sdk/pal.ts
1587
1622
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
1588
1623
  var _nonceLoader;
@@ -1669,17 +1704,17 @@ function createPalNonceManager() {
1669
1704
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
1670
1705
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
1671
1706
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
1672
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1707
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1673
1708
  request.iconsSupported = true;
1674
1709
  request.playerType = "StormcloudVideoPlayer";
1675
1710
  request.playerVersion = "1.0";
1676
1711
  request.supportedApiFrameworks = "2,7,9";
1677
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1712
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1678
1713
  request.videoWidth = options.videoWidth || 640;
1679
1714
  request.videoHeight = options.videoHeight || 480;
1680
1715
  if (options.ppid) request.ppid = options.ppid;
1681
1716
  if (options.sessionId) request.sessionId = options.sessionId;
1682
- console.log("[PAL] NonceRequest before generateNonce:", {
1717
+ console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
1683
1718
  adWillAutoPlay: request.adWillAutoPlay,
1684
1719
  adWillPlayMuted: request.adWillPlayMuted,
1685
1720
  playerVolume: request.playerVolume,
@@ -1694,7 +1729,7 @@ function createPalNonceManager() {
1694
1729
  videoHeight: request.videoHeight,
1695
1730
  ppid: request.ppid,
1696
1731
  sessionId: request.sessionId
1697
- });
1732
+ }, null, 2));
1698
1733
  return [
1699
1734
  4,
1700
1735
  loader.loadNonceManager(request)
@@ -5345,7 +5380,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5345
5380
  podMaxDurationMs: podParams.maxDurationMs,
5346
5381
  isCtv: envSignals.isCtv,
5347
5382
  contentUrl: envSignals.contentUrl,
5348
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5383
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
5349
5384
  adWillPlayMuted: adWillPlayMuted,
5350
5385
  adWillAutoPlay: !!this.config.autoplay,
5351
5386
  appId: envSignals.appId,