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,4 +1,4 @@
1
- import { A as AdController } from '../types-e6QV7SBp.cjs';
1
+ import { A as AdController } from '../types-CSHvCbhZ.cjs';
2
2
  import Hls from 'hls.js';
3
3
 
4
4
  declare function createHlsAdPlayer(contentVideo: HTMLVideoElement, options?: {
package/lib/sdk/pal.cjs CHANGED
@@ -185,6 +185,42 @@ __export(pal_exports, {
185
185
  }
186
186
  });
187
187
  module.exports = __toCommonJS(pal_exports);
188
+ // src/utils/devUrl.ts
189
+ var PRIVATE_HOST_PATTERNS = [
190
+ /^localhost$/i,
191
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
192
+ /^0\.0\.0\.0$/,
193
+ /^::1$/,
194
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
195
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
196
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
197
+ ];
198
+ function isLocalDevHost(hostname) {
199
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
200
+ if (!host) return false;
201
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
202
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
203
+ return pattern.test(host);
204
+ });
205
+ }
206
+ function toDevSafeUrl(rawUrl) {
207
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
208
+ var url;
209
+ try {
210
+ url = new URL(rawUrl);
211
+ } catch (unused) {
212
+ return rawUrl;
213
+ }
214
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
215
+ return rawUrl;
216
+ }
217
+ if (!isLocalDevHost(url.hostname)) {
218
+ return rawUrl;
219
+ }
220
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
221
+ return "file://".concat(cleanPath);
222
+ }
223
+ // src/sdk/pal.ts
188
224
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
189
225
  var _nonceLoader;
190
226
  var _palLoadPromise;
@@ -270,17 +306,17 @@ function createPalNonceManager() {
270
306
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
271
307
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
272
308
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
273
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
309
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
274
310
  request.iconsSupported = true;
275
311
  request.playerType = "StormcloudVideoPlayer";
276
312
  request.playerVersion = "1.0";
277
313
  request.supportedApiFrameworks = "2,7,9";
278
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
314
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
279
315
  request.videoWidth = options.videoWidth || 640;
280
316
  request.videoHeight = options.videoHeight || 480;
281
317
  if (options.ppid) request.ppid = options.ppid;
282
318
  if (options.sessionId) request.sessionId = options.sessionId;
283
- console.log("[PAL] NonceRequest before generateNonce:", {
319
+ console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
284
320
  adWillAutoPlay: request.adWillAutoPlay,
285
321
  adWillPlayMuted: request.adWillPlayMuted,
286
322
  playerVolume: request.playerVolume,
@@ -295,7 +331,7 @@ function createPalNonceManager() {
295
331
  videoHeight: request.videoHeight,
296
332
  ppid: request.ppid,
297
333
  sessionId: request.sessionId
298
- });
334
+ }, null, 2));
299
335
  return [
300
336
  4,
301
337
  loader.loadNonceManager(request)
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/sdk/pal.cjs"],"names":["__defProp","Object","defineProperty","__getOwnPropDesc","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBACIA,IAAAA,IAAYC,OAAOC,CAAAA,CAAAA,MAAAA,CAAAA,KAAc;gBACjCC,IAAAA,WAAmBF,CAAAA,CAAAA,GAAAA,CAAAA,CAAOG,OAAAA,iBAAwB;gBAClDC,OAAAA,IAAAA,KAAoBJ,GAAAA,IAAOK,mBAAmB;YAC9CC,EAAAA,eAAAA,KAAeN,OAAOO,SAAS,CAACC,cAAc;gBAC9CC,IAAAA,GAAW,IAAA,WAAA,GAACC,IAAAA,CAAAA,GAAQC,kBAAAA,IAAAA,OAAAA,CAAAA,SAAAA;gBACjB,IAAIC,MAAQD,IACfZ,CAAAA,QAAAA,CAAUW,OAAAA,CAAQE,KAAAA,CAAM;gBAAEC,KAAKF,EAAAA,AAAG,CAACC,EAAK,OAALA,IAAK,EAAA,OAAA,KAAA,SAAA,OAAA,mBAAA;cAAEE,YAAY;QAAK;QAC/D,mBAAA,SAAA;YACIC,IAAAA,QAAc,qBAACC,IAAIC,MAAMC,QAAQC;0FAC/BF,QAAQ,CAAA,OAAOA,IAAAA,iBAAAA,eAAP,SAAOA,KAAG,MAAM,YAAY,OAAOA,SAAS,YAAY;kBAC7D,WAAA,gCAAA,2BAAA;;8CAAA,IAAIG,MAAJ;sBACH,IAAI,CAACd,aAAae,IAAI,CAACL,IAAII,QAAQA,QAAQF,QACzCnB,UAAUiB,IAAII,KAAK;4BAAEP,KAAK,6EAAA,KAALA,UAAAA;8CAAWI,IAAI,CAACG,IAAI;wBAAEN,YAAY,CAAEK,CAAAA,OAAOjB,iBAAiBe,MAAMG,IAAG,KAAMD,KAAKL,UAAU;0CAAC;;8FAFpH,QAAK,QAAA,GAAWV,QAAAA,UAAkBa,0BAA7B,SAAA,6BAAA,QAAA,yBAAA;oCAAA;gBAAA;;;uGAAA,OAAA,WAAA,CAAA,SAAA;mCAAA;;wCAAA;gCAAA;;;;IAGP;IACA,OAAOD,kDAAAA;AACT,KAAA,CAAA,OAAA,OAAA,GAAA;IACA,uBAAA,EAAIM,eAAe,sBAACC;YAAQR,YAAYhB,UAAU,CAAC,GAAG,cAAc","sourcesContent":["\"use strict\";\nvar __defProp = Object.defineProperty;\nvar __getOwnPropDesc = Object.getOwnPropertyDescriptor;\nvar __getOwnPropNames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/sdk/pal.ts\nvar pal_exports = {};\n__export(pal_exports, {\n createPalNonceManager: () => createPalNonceManager\n});\nmodule.exports = __toCommonJS(pal_exports);\nvar PAL_SDK_URL = \"https://imasdk.googleapis.com/pal/sdkloader/pal.js\";\nvar _nonceLoader;\nvar _palLoadPromise;\nfunction loadPalSdk() {\n if (typeof window !== \"undefined\" && window.goog?.pal) {\n return Promise.resolve();\n }\n if (_palLoadPromise) return _palLoadPromise;\n _palLoadPromise = new Promise((resolve, reject) => {\n const existing = document.querySelector(\n 'script[data-pal=\"true\"]'\n );\n if (existing) {\n if (window.goog?.pal) {\n resolve();\n return;\n }\n const timeout = setTimeout(\n () => reject(new Error(\"PAL SDK load timeout\")),\n 1e4\n );\n existing.addEventListener(\"load\", () => {\n clearTimeout(timeout);\n resolve();\n });\n existing.addEventListener(\"error\", () => {\n clearTimeout(timeout);\n reject(new Error(\"PAL SDK load failed\"));\n });\n return;\n }\n const script = document.createElement(\"script\");\n script.src = PAL_SDK_URL;\n script.async = true;\n script.setAttribute(\"data-pal\", \"true\");\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"PAL SDK load failed\"));\n document.head.appendChild(script);\n });\n return _palLoadPromise;\n}\nfunction getOrCreateNonceLoader() {\n if (_nonceLoader) return _nonceLoader;\n const goog = window.goog;\n const consentSettings = new goog.pal.ConsentSettings();\n consentSettings.allowStorage = true;\n _nonceLoader = new goog.pal.NonceLoader(consentSettings);\n return _nonceLoader;\n}\nfunction createPalNonceManager() {\n let currentNonce = \"\";\n let currentNonceManager;\n return {\n async generateNonce(options = {}) {\n try {\n await loadPalSdk();\n const loader = getOrCreateNonceLoader();\n const goog = window.goog;\n const request = new goog.pal.NonceRequest();\n request.adWillAutoPlay = options.adWillAutoPlay ?? true;\n request.adWillPlayMuted = options.adWillPlayMuted ?? false;\n request.playerVolume = options.playerVolume ?? (request.adWillPlayMuted ? 0 : 1);\n request.continuousPlayback = options.continuousPlayback ?? true;\n request.descriptionUrl = options.descriptionUrl || (typeof window !== \"undefined\" ? window.location.href : \"\");\n request.iconsSupported = true;\n request.playerType = \"StormcloudVideoPlayer\";\n request.playerVersion = \"1.0\";\n request.supportedApiFrameworks = \"2,7,9\";\n request.url = options.descriptionUrl || (typeof window !== \"undefined\" ? window.location.href : \"\");\n request.videoWidth = options.videoWidth || 640;\n request.videoHeight = options.videoHeight || 480;\n if (options.ppid) request.ppid = options.ppid;\n if (options.sessionId) request.sessionId = options.sessionId;\n console.log(\"[PAL] NonceRequest before generateNonce:\", {\n adWillAutoPlay: request.adWillAutoPlay,\n adWillPlayMuted: request.adWillPlayMuted,\n playerVolume: request.playerVolume,\n continuousPlayback: request.continuousPlayback,\n descriptionUrl: request.descriptionUrl,\n iconsSupported: request.iconsSupported,\n playerType: request.playerType,\n playerVersion: request.playerVersion,\n supportedApiFrameworks: request.supportedApiFrameworks,\n url: request.url,\n videoWidth: request.videoWidth,\n videoHeight: request.videoHeight,\n ppid: request.ppid,\n sessionId: request.sessionId\n });\n const manager = await loader.loadNonceManager(request);\n currentNonceManager = manager;\n currentNonce = manager.getNonce();\n console.log(\"[PAL] Nonce generated successfully\");\n return currentNonce;\n } catch (error) {\n console.warn(\"[PAL] Failed to generate nonce:\", error);\n currentNonce = \"\";\n currentNonceManager = void 0;\n return \"\";\n }\n },\n getCurrentNonce() {\n return currentNonce;\n },\n injectNonce(vastTagUrl) {\n if (!currentNonce || !vastTagUrl) return vastTagUrl;\n try {\n const url = new URL(vastTagUrl);\n url.searchParams.delete(\"paln\");\n url.searchParams.set(\"givn\", currentNonce);\n return url.toString();\n } catch {\n let base = vastTagUrl.replace(/([?&])paln=[^&]*/g, \"\").replace(/[?&]$/, \"\");\n const sep = base.includes(\"?\") ? \"&\" : \"?\";\n return `${base}${sep}givn=${encodeURIComponent(currentNonce)}`;\n }\n },\n sendPlaybackStart() {\n try {\n currentNonceManager?.sendPlaybackStart();\n } catch {\n }\n },\n sendPlaybackEnd() {\n try {\n currentNonceManager?.sendPlaybackEnd();\n } catch {\n }\n },\n sendAdClick() {\n try {\n currentNonceManager?.sendAdClick();\n } catch {\n }\n },\n sendAdTouch(event) {\n try {\n currentNonceManager?.sendAdTouch(event);\n } catch {\n }\n },\n reset() {\n currentNonce = \"\";\n currentNonceManager = void 0;\n }\n };\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n createPalNonceManager\n});\n"]}
1
+ {"version":3,"sources":["/home/ubuntu24-new/Dev/stormcloud-vp/lib/sdk/pal.cjs","../../src/sdk/pal.ts","../../src/utils/devUrl.ts"],"names":["__getOwnPropDesc","Object","getOwnPropertyDescriptor","__getOwnPropNames","getOwnPropertyNames","__hasOwnProp","prototype","hasOwnProperty","__export","target","all","name","get","__defProp","enumerable","__copyProps","to","from","except","desc","key","call","__toCommonJS","mod","value","pal_exports","createPalNonceManager","module","exports","PRIVATE_HOST_PATTERNS","isLocalDevHost","hostname","host","replace","toLowerCase","endsWith","some","pattern","test","toDevSafeUrl","rawUrl","url","URL","protocol"],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0KAWS,6BAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BATLA,QAAAA,OAAmBC,GAAAA,GAAAA,CAAOC,OAAAA,UAAAA,IAAAA,GAAwB;4BAClDC,QAAAA,QAAoBF,GAAAA,GAAAA,CAAOG,OAAAA,WAAAA,CAAmB,GAAA;4BAC9CC,IAAAA,OAAeJ,CAAAA,IAAAA,EAAOK,QAAAA,CAAS,CAACC,EAAAA,GAAAA,QAAAA,CAAc,GAAA;4BAC9CC,IAAAA,GAAW,KAAA,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ames = Object.getOwnPropertyNames;\nvar __hasOwnProp = Object.prototype.hasOwnProperty;\nvar __export = (target, all) => {\n for (var name in all)\n __defProp(target, name, { get: all[name], enumerable: true });\n};\nvar __copyProps = (to, from, except, desc) => {\n if (from && typeof from === \"object\" || typeof from === \"function\") {\n for (let key of __getOwnPropNames(from))\n if (!__hasOwnProp.call(to, key) && key !== except)\n __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });\n }\n return to;\n};\nvar __toCommonJS = (mod) => __copyProps(__defProp({}, \"__esModule\", { value: true }), mod);\n\n// src/sdk/pal.ts\nvar pal_exports = {};\n__export(pal_exports, {\n createPalNonceManager: () => createPalNonceManager\n});\nmodule.exports = __toCommonJS(pal_exports);\n\n// src/utils/devUrl.ts\nvar PRIVATE_HOST_PATTERNS = [\n /^localhost$/i,\n /^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/,\n /^0\\.0\\.0\\.0$/,\n /^::1$/,\n /^10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/,\n /^192\\.168\\.\\d{1,3}\\.\\d{1,3}$/,\n /^172\\.(1[6-9]|2\\d|3[0-1])\\.\\d{1,3}\\.\\d{1,3}$/\n];\nfunction isLocalDevHost(hostname) {\n const host = hostname.replace(/^\\[/, \"\").replace(/\\]$/, \"\").toLowerCase();\n if (!host) return false;\n if (host.endsWith(\".local\") || host.endsWith(\".localhost\")) return true;\n return PRIVATE_HOST_PATTERNS.some((pattern) => pattern.test(host));\n}\nfunction toDevSafeUrl(rawUrl) {\n if (!rawUrl) return rawUrl ?? \"\";\n let url;\n try {\n url = new URL(rawUrl);\n } catch {\n return rawUrl;\n }\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n return rawUrl;\n }\n if (!isLocalDevHost(url.hostname)) {\n return rawUrl;\n }\n const cleanPath = url.pathname.replace(/\\/{2,}/g, \"/\") || \"/index.html\";\n return `file://${cleanPath}`;\n}\n\n// src/sdk/pal.ts\nvar PAL_SDK_URL = \"https://imasdk.googleapis.com/pal/sdkloader/pal.js\";\nvar _nonceLoader;\nvar _palLoadPromise;\nfunction loadPalSdk() {\n if (typeof window !== \"undefined\" && window.goog?.pal) {\n return Promise.resolve();\n }\n if (_palLoadPromise) return _palLoadPromise;\n _palLoadPromise = new Promise((resolve, reject) => {\n const existing = document.querySelector(\n 'script[data-pal=\"true\"]'\n );\n if (existing) {\n if (window.goog?.pal) {\n resolve();\n return;\n }\n const timeout = setTimeout(\n () => reject(new Error(\"PAL SDK load timeout\")),\n 1e4\n );\n existing.addEventListener(\"load\", () => {\n clearTimeout(timeout);\n resolve();\n });\n existing.addEventListener(\"error\", () => {\n clearTimeout(timeout);\n reject(new Error(\"PAL SDK load failed\"));\n });\n return;\n }\n const script = document.createElement(\"script\");\n script.src = PAL_SDK_URL;\n script.async = true;\n script.setAttribute(\"data-pal\", \"true\");\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"PAL SDK load failed\"));\n document.head.appendChild(script);\n });\n return _palLoadPromise;\n}\nfunction getOrCreateNonceLoader() {\n if (_nonceLoader) return _nonceLoader;\n const goog = window.goog;\n const consentSettings = new goog.pal.ConsentSettings();\n consentSettings.allowStorage = true;\n _nonceLoader = new goog.pal.NonceLoader(consentSettings);\n return _nonceLoader;\n}\nfunction createPalNonceManager() {\n let currentNonce = \"\";\n let currentNonceManager;\n return {\n async generateNonce(options = {}) {\n try {\n await loadPalSdk();\n const loader = getOrCreateNonceLoader();\n const goog = window.goog;\n const request = new goog.pal.NonceRequest();\n request.adWillAutoPlay = options.adWillAutoPlay ?? true;\n request.adWillPlayMuted = options.adWillPlayMuted ?? false;\n request.playerVolume = options.playerVolume ?? (request.adWillPlayMuted ? 0 : 1);\n request.continuousPlayback = options.continuousPlayback ?? true;\n request.descriptionUrl = toDevSafeUrl(\n options.descriptionUrl || (typeof window !== \"undefined\" ? window.location.href : \"\")\n );\n request.iconsSupported = true;\n request.playerType = \"StormcloudVideoPlayer\";\n request.playerVersion = \"1.0\";\n request.supportedApiFrameworks = \"2,7,9\";\n request.url = toDevSafeUrl(\n options.descriptionUrl || (typeof window !== \"undefined\" ? window.location.href : \"\")\n );\n request.videoWidth = options.videoWidth || 640;\n request.videoHeight = options.videoHeight || 480;\n if (options.ppid) request.ppid = options.ppid;\n if (options.sessionId) request.sessionId = options.sessionId;\n console.log(\n \"[PAL] NonceRequest before generateNonce:\",\n JSON.stringify({\n adWillAutoPlay: request.adWillAutoPlay,\n adWillPlayMuted: request.adWillPlayMuted,\n playerVolume: request.playerVolume,\n continuousPlayback: request.continuousPlayback,\n descriptionUrl: request.descriptionUrl,\n iconsSupported: request.iconsSupported,\n playerType: request.playerType,\n playerVersion: request.playerVersion,\n supportedApiFrameworks: request.supportedApiFrameworks,\n url: request.url,\n videoWidth: request.videoWidth,\n videoHeight: request.videoHeight,\n ppid: request.ppid,\n sessionId: request.sessionId\n }, null, 2)\n );\n const manager = await loader.loadNonceManager(request);\n currentNonceManager = manager;\n currentNonce = manager.getNonce();\n console.log(\"[PAL] Nonce generated successfully\");\n return currentNonce;\n } catch (error) {\n console.warn(\"[PAL] Failed to generate nonce:\", error);\n currentNonce = \"\";\n currentNonceManager = void 0;\n return \"\";\n }\n },\n getCurrentNonce() {\n return currentNonce;\n },\n injectNonce(vastTagUrl) {\n if (!currentNonce || !vastTagUrl) return vastTagUrl;\n try {\n const url = new URL(vastTagUrl);\n url.searchParams.delete(\"paln\");\n url.searchParams.set(\"givn\", currentNonce);\n return url.toString();\n } catch {\n let base = vastTagUrl.replace(/([?&])paln=[^&]*/g, \"\").replace(/[?&]$/, \"\");\n const sep = base.includes(\"?\") ? \"&\" : \"?\";\n return `${base}${sep}givn=${encodeURIComponent(currentNonce)}`;\n }\n },\n sendPlaybackStart() {\n try {\n currentNonceManager?.sendPlaybackStart();\n } catch {\n }\n },\n sendPlaybackEnd() {\n try {\n currentNonceManager?.sendPlaybackEnd();\n } catch {\n }\n },\n sendAdClick() {\n try {\n currentNonceManager?.sendAdClick();\n } catch {\n }\n },\n sendAdTouch(event) {\n try {\n currentNonceManager?.sendAdTouch(event);\n } catch {\n }\n },\n reset() {\n currentNonce = \"\";\n currentNonceManager = void 0;\n }\n };\n}\n// Annotate the CommonJS export names for ESM import in node:\n0 && (module.exports = {\n createPalNonceManager\n});\n","import { toDevSafeUrl } from \"../utils/devUrl\";\n\ndeclare global {\n interface Window {\n goog?: any;\n }\n}\n\nconst PAL_SDK_URL =\n \"https://imasdk.googleapis.com/pal/sdkloader/pal.js\";\n\nlet _nonceLoader: any | undefined;\nlet _palLoadPromise: Promise<void> | undefined;\n\nfunction loadPalSdk(): Promise<void> {\n if (typeof window !== \"undefined\" && window.goog?.pal) {\n return Promise.resolve();\n }\n\n if (_palLoadPromise) return _palLoadPromise;\n\n _palLoadPromise = new Promise<void>((resolve, reject) => {\n const existing = document.querySelector(\n 'script[data-pal=\"true\"]'\n ) as HTMLScriptElement | null;\n\n if (existing) {\n if (window.goog?.pal) {\n resolve();\n return;\n }\n const timeout = setTimeout(\n () => reject(new Error(\"PAL SDK load timeout\")),\n 10000\n );\n existing.addEventListener(\"load\", () => {\n clearTimeout(timeout);\n resolve();\n });\n existing.addEventListener(\"error\", () => {\n clearTimeout(timeout);\n reject(new Error(\"PAL SDK load failed\"));\n });\n return;\n }\n\n const script = document.createElement(\"script\");\n script.src = PAL_SDK_URL;\n script.async = true;\n script.setAttribute(\"data-pal\", \"true\");\n script.onload = () => resolve();\n script.onerror = () => reject(new Error(\"PAL SDK load failed\"));\n document.head.appendChild(script);\n });\n\n return _palLoadPromise;\n}\n\nfunction getOrCreateNonceLoader(): any {\n if (_nonceLoader) return _nonceLoader;\n const goog = window.goog;\n const consentSettings = new goog.pal.ConsentSettings();\n consentSettings.allowStorage = true;\n _nonceLoader = new goog.pal.NonceLoader(consentSettings);\n return _nonceLoader;\n}\n\nexport interface PalNonceOptions {\n videoWidth?: number;\n videoHeight?: number;\n descriptionUrl?: string;\n ppid?: string;\n sessionId?: string;\n adWillAutoPlay?: boolean;\n adWillPlayMuted?: boolean;\n playerVolume?: number;\n continuousPlayback?: boolean;\n}\n\nexport interface PalNonceManager {\n generateNonce(options?: PalNonceOptions): Promise<string>;\n\n getCurrentNonce(): string;\n\n injectNonce(vastTagUrl: string): string;\n\n sendPlaybackStart(): void;\n\n sendPlaybackEnd(): void;\n\n sendAdClick(): void;\n\n sendAdTouch(event: MouseEvent | TouchEvent): void;\n\n reset(): void;\n}\n\nexport function createPalNonceManager(): PalNonceManager {\n let currentNonce = \"\";\n let currentNonceManager: any | undefined;\n\n return {\n async generateNonce(options: PalNonceOptions = {}): Promise<string> {\n try {\n await loadPalSdk();\n\n const loader = getOrCreateNonceLoader();\n const goog = window.goog;\n\n const request = new goog.pal.NonceRequest();\n request.adWillAutoPlay = options.adWillAutoPlay ?? true;\n request.adWillPlayMuted = options.adWillPlayMuted ?? false;\n request.playerVolume =\n options.playerVolume ?? (request.adWillPlayMuted ? 0 : 1);\n request.continuousPlayback = options.continuousPlayback ?? true;\n request.descriptionUrl = toDevSafeUrl(\n options.descriptionUrl ||\n (typeof window !== \"undefined\" ? window.location.href : \"\")\n );\n request.iconsSupported = true;\n request.playerType = \"StormcloudVideoPlayer\";\n request.playerVersion = \"1.0\";\n request.supportedApiFrameworks = \"2,7,9\";\n request.url = toDevSafeUrl(\n options.descriptionUrl ||\n (typeof window !== \"undefined\" ? window.location.href : \"\")\n );\n request.videoWidth = options.videoWidth || 640;\n request.videoHeight = options.videoHeight || 480;\n\n if (options.ppid) request.ppid = options.ppid;\n if (options.sessionId) request.sessionId = options.sessionId;\n\n console.log(\n \"[PAL] NonceRequest before generateNonce:\",\n JSON.stringify({\n adWillAutoPlay: request.adWillAutoPlay,\n adWillPlayMuted: request.adWillPlayMuted,\n playerVolume: request.playerVolume,\n continuousPlayback: request.continuousPlayback,\n descriptionUrl: request.descriptionUrl,\n iconsSupported: request.iconsSupported,\n playerType: request.playerType,\n playerVersion: request.playerVersion,\n supportedApiFrameworks: request.supportedApiFrameworks,\n url: request.url,\n videoWidth: request.videoWidth,\n videoHeight: request.videoHeight,\n ppid: request.ppid,\n sessionId: request.sessionId,\n }, null, 2)\n );\n\n const manager = await loader.loadNonceManager(request);\n currentNonceManager = manager;\n currentNonce = manager.getNonce() as string;\n\n console.log(\"[PAL] Nonce generated successfully\");\n return currentNonce;\n } catch (error) {\n console.warn(\"[PAL] Failed to generate nonce:\", error);\n currentNonce = \"\";\n currentNonceManager = undefined;\n return \"\";\n }\n },\n\n getCurrentNonce(): string {\n return currentNonce;\n },\n\n injectNonce(vastTagUrl: string): string {\n if (!currentNonce || !vastTagUrl) return vastTagUrl;\n\n try {\n const url = new URL(vastTagUrl);\n url.searchParams.delete(\"paln\");\n url.searchParams.set(\"givn\", currentNonce);\n return url.toString();\n } catch {\n let base = vastTagUrl\n .replace(/([?&])paln=[^&]*/g, \"\")\n .replace(/[?&]$/, \"\");\n const sep = base.includes(\"?\") ? \"&\" : \"?\";\n return `${base}${sep}givn=${encodeURIComponent(currentNonce)}`;\n }\n },\n\n sendPlaybackStart(): void {\n try {\n currentNonceManager?.sendPlaybackStart();\n } catch {}\n },\n\n sendPlaybackEnd(): void {\n try {\n currentNonceManager?.sendPlaybackEnd();\n } catch {}\n },\n\n sendAdClick(): void {\n try {\n currentNonceManager?.sendAdClick();\n } catch {}\n },\n\n sendAdTouch(event: MouseEvent | TouchEvent): void {\n try {\n currentNonceManager?.sendAdTouch(event);\n } catch {}\n },\n\n reset(): void {\n currentNonce = \"\";\n currentNonceManager = undefined;\n },\n };\n}\n","const PRIVATE_HOST_PATTERNS: RegExp[] = [\n /^localhost$/i,\n /^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/,\n /^0\\.0\\.0\\.0$/,\n /^::1$/,\n /^10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/,\n /^192\\.168\\.\\d{1,3}\\.\\d{1,3}$/,\n /^172\\.(1[6-9]|2\\d|3[0-1])\\.\\d{1,3}\\.\\d{1,3}$/,\n];\n\nexport function isLocalDevHost(hostname: string): boolean {\n const host = hostname.replace(/^\\[/, \"\").replace(/\\]$/, \"\").toLowerCase();\n if (!host) return false;\n if (host.endsWith(\".local\") || host.endsWith(\".localhost\")) return true;\n return PRIVATE_HOST_PATTERNS.some((pattern) => pattern.test(host));\n}\n\nexport function toDevSafeUrl(rawUrl: string | undefined): string {\n if (!rawUrl) return rawUrl ?? \"\";\n\n let url: URL;\n try {\n url = new URL(rawUrl);\n } catch {\n return rawUrl;\n }\n\n if (url.protocol !== \"http:\" && url.protocol !== \"https:\") {\n return rawUrl;\n }\n\n if (!isLocalDevHost(url.hostname)) {\n return rawUrl;\n }\n\n const cleanPath = url.pathname.replace(/\\/{2,}/g, \"/\") || \"/index.html\";\n return `file://${cleanPath}`;\n}\n"]}
@@ -1599,6 +1599,41 @@ function createHlsAdPlayer(contentVideo, options) {
1599
1599
  }
1600
1600
  };
1601
1601
  }
1602
+ // src/utils/devUrl.ts
1603
+ var PRIVATE_HOST_PATTERNS = [
1604
+ /^localhost$/i,
1605
+ /^127\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1606
+ /^0\.0\.0\.0$/,
1607
+ /^::1$/,
1608
+ /^10\.\d{1,3}\.\d{1,3}\.\d{1,3}$/,
1609
+ /^192\.168\.\d{1,3}\.\d{1,3}$/,
1610
+ /^172\.(1[6-9]|2\d|3[0-1])\.\d{1,3}\.\d{1,3}$/
1611
+ ];
1612
+ function isLocalDevHost(hostname) {
1613
+ var host = hostname.replace(/^\[/, "").replace(/\]$/, "").toLowerCase();
1614
+ if (!host) return false;
1615
+ if (host.endsWith(".local") || host.endsWith(".localhost")) return true;
1616
+ return PRIVATE_HOST_PATTERNS.some(function(pattern) {
1617
+ return pattern.test(host);
1618
+ });
1619
+ }
1620
+ function toDevSafeUrl(rawUrl) {
1621
+ if (!rawUrl) return rawUrl !== null && rawUrl !== void 0 ? rawUrl : "";
1622
+ var url;
1623
+ try {
1624
+ url = new URL(rawUrl);
1625
+ } catch (unused) {
1626
+ return rawUrl;
1627
+ }
1628
+ if (url.protocol !== "http:" && url.protocol !== "https:") {
1629
+ return rawUrl;
1630
+ }
1631
+ if (!isLocalDevHost(url.hostname)) {
1632
+ return rawUrl;
1633
+ }
1634
+ var cleanPath = url.pathname.replace(/\/{2,}/g, "/") || "/index.html";
1635
+ return "file://".concat(cleanPath);
1636
+ }
1602
1637
  // src/sdk/pal.ts
1603
1638
  var PAL_SDK_URL = "https://imasdk.googleapis.com/pal/sdkloader/pal.js";
1604
1639
  var _nonceLoader;
@@ -1685,17 +1720,17 @@ function createPalNonceManager() {
1685
1720
  request.adWillPlayMuted = (_options_adWillPlayMuted = options.adWillPlayMuted) !== null && _options_adWillPlayMuted !== void 0 ? _options_adWillPlayMuted : false;
1686
1721
  request.playerVolume = (_options_playerVolume = options.playerVolume) !== null && _options_playerVolume !== void 0 ? _options_playerVolume : request.adWillPlayMuted ? 0 : 1;
1687
1722
  request.continuousPlayback = (_options_continuousPlayback = options.continuousPlayback) !== null && _options_continuousPlayback !== void 0 ? _options_continuousPlayback : true;
1688
- request.descriptionUrl = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1723
+ request.descriptionUrl = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1689
1724
  request.iconsSupported = true;
1690
1725
  request.playerType = "StormcloudVideoPlayer";
1691
1726
  request.playerVersion = "1.0";
1692
1727
  request.supportedApiFrameworks = "2,7,9";
1693
- request.url = options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : "");
1728
+ request.url = toDevSafeUrl(options.descriptionUrl || (typeof window !== "undefined" ? window.location.href : ""));
1694
1729
  request.videoWidth = options.videoWidth || 640;
1695
1730
  request.videoHeight = options.videoHeight || 480;
1696
1731
  if (options.ppid) request.ppid = options.ppid;
1697
1732
  if (options.sessionId) request.sessionId = options.sessionId;
1698
- console.log("[PAL] NonceRequest before generateNonce:", {
1733
+ console.log("[PAL] NonceRequest before generateNonce:", JSON.stringify({
1699
1734
  adWillAutoPlay: request.adWillAutoPlay,
1700
1735
  adWillPlayMuted: request.adWillPlayMuted,
1701
1736
  playerVolume: request.playerVolume,
@@ -1710,7 +1745,7 @@ function createPalNonceManager() {
1710
1745
  videoHeight: request.videoHeight,
1711
1746
  ppid: request.ppid,
1712
1747
  sessionId: request.sessionId
1713
- });
1748
+ }, null, 2));
1714
1749
  return [
1715
1750
  4,
1716
1751
  loader.loadNonceManager(request)
@@ -5309,7 +5344,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
5309
5344
  podMaxDurationMs: podParams.maxDurationMs,
5310
5345
  isCtv: envSignals.isCtv,
5311
5346
  contentUrl: envSignals.contentUrl,
5312
- pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? window.location.href : void 0,
5347
+ pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
5313
5348
  adWillPlayMuted: adWillPlayMuted,
5314
5349
  adWillAutoPlay: !!this.config.autoplay,
5315
5350
  appId: envSignals.appId,