stormcloud-video-player 0.8.80 → 0.8.81

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.
Files changed (59) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.d.cts +2 -1
  3. package/lib/StormcloudPlayer.cjs +452 -139
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/StormcloudPlayer.d.cts +1 -0
  6. package/lib/index.cjs +478 -140
  7. package/lib/index.cjs.map +1 -1
  8. package/lib/index.d.cts +1 -0
  9. package/lib/index.d.ts +30 -5
  10. package/lib/index.js +478 -140
  11. package/lib/index.js.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.cjs +37 -9
  13. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  15. package/lib/player/AdConfigManager.cjs +408 -123
  16. package/lib/player/AdConfigManager.cjs.map +1 -1
  17. package/lib/player/AdConfigManager.d.cts +2 -0
  18. package/lib/player/AdTimingService.d.cts +1 -0
  19. package/lib/player/EdgePodRequest.d.cts +1 -0
  20. package/lib/player/FloorLadder.d.cts +1 -0
  21. package/lib/player/HlsEngine.d.cts +1 -0
  22. package/lib/player/OptimizedPodRequest.cjs +17 -5
  23. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  24. package/lib/player/PlayerControls.d.cts +1 -0
  25. package/lib/player/Scte35CueManager.d.cts +1 -0
  26. package/lib/player/Scte35Parser.d.cts +1 -0
  27. package/lib/player/StormcloudVideoPlayer.cjs +452 -139
  28. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  29. package/lib/player/StormcloudVideoPlayer.d.cts +5 -4
  30. package/lib/player/playerTypes.d.cts +1 -0
  31. package/lib/players/HlsPlayer.cjs +452 -139
  32. package/lib/players/HlsPlayer.cjs.map +1 -1
  33. package/lib/players/HlsPlayer.d.cts +1 -0
  34. package/lib/players/index.cjs +452 -139
  35. package/lib/players/index.cjs.map +1 -1
  36. package/lib/props.d.cts +1 -0
  37. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  38. package/lib/types.d.cts +7 -1
  39. package/lib/ui/StormcloudVideoPlayer.cjs +478 -140
  40. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  41. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  42. package/lib/utils/__tests__/adSignals.test.cjs +169 -14
  43. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  44. package/lib/utils/contentMetadata.cjs +120 -4
  45. package/lib/utils/contentMetadata.cjs.map +1 -1
  46. package/lib/utils/contentMetadata.d.cts +37 -1
  47. package/lib/utils/deviceInfo.cjs +24 -4
  48. package/lib/utils/deviceInfo.cjs.map +1 -1
  49. package/lib/utils/deviceInfo.d.cts +3 -0
  50. package/lib/utils/partnerSignals.cjs +294 -0
  51. package/lib/utils/partnerSignals.cjs.map +1 -0
  52. package/lib/utils/partnerSignals.d.cts +12 -0
  53. package/lib/utils/tracking.cjs +24 -4
  54. package/lib/utils/tracking.cjs.map +1 -1
  55. package/lib/utils/tracking.d.cts +1 -0
  56. package/lib/utils/vastMacros.cjs +51 -1
  57. package/lib/utils/vastMacros.cjs.map +1 -1
  58. package/lib/utils/vastMacros.d.cts +20 -0
  59. package/package.json +1 -1
@@ -1329,6 +1329,308 @@ function normalizeBoolean(value) {
1329
1329
  }
1330
1330
  return void 0;
1331
1331
  }
1332
+ // src/utils/contentMetadata.ts
1333
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1334
+ var BRIDGE_KEYS = {
1335
+ channelName: [
1336
+ "channelName",
1337
+ "ct_ch"
1338
+ ],
1339
+ programTitle: [
1340
+ "programTitle",
1341
+ "ct_ti"
1342
+ ],
1343
+ contentNetwork: [
1344
+ "contentNetwork",
1345
+ "ct_ne"
1346
+ ],
1347
+ contentType: [
1348
+ "contentType",
1349
+ "ctt"
1350
+ ],
1351
+ contentCategory: [
1352
+ "contentCategory",
1353
+ "ctc"
1354
+ ],
1355
+ contentGenre: [
1356
+ "contentGenre",
1357
+ "ctgr"
1358
+ ],
1359
+ contentLanguage: [
1360
+ "contentLanguage",
1361
+ "ctlg"
1362
+ ],
1363
+ contentDuration: [
1364
+ "contentDuration",
1365
+ "ctd"
1366
+ ],
1367
+ contentSeason: [
1368
+ "contentSeason",
1369
+ "cts"
1370
+ ],
1371
+ contentEpisode: [
1372
+ "contentEpisode",
1373
+ "cte"
1374
+ ],
1375
+ contentRating: [
1376
+ "contentRating",
1377
+ "ctr"
1378
+ ],
1379
+ contentId: [
1380
+ "contentId",
1381
+ "ctid"
1382
+ ]
1383
+ };
1384
+ function sanitizeContentValue(value) {
1385
+ if (typeof value !== "string") return void 0;
1386
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1387
+ if (!cleaned) return void 0;
1388
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1389
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1390
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1391
+ }
1392
+ function sanitizeContentScalar(value) {
1393
+ if (typeof value === "number") {
1394
+ return Number.isFinite(value) ? String(value) : void 0;
1395
+ }
1396
+ return sanitizeContentValue(value);
1397
+ }
1398
+ function normalizeContentLanguage(value) {
1399
+ var cleaned = sanitizeContentValue(value);
1400
+ if (!cleaned) return void 0;
1401
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1402
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1403
+ }
1404
+ function normalizeContentDuration(value) {
1405
+ var raw = sanitizeContentScalar(value);
1406
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1407
+ var seconds = Number(raw);
1408
+ if (seconds === -1) return -1;
1409
+ return seconds > 0 ? Math.round(seconds) : void 0;
1410
+ }
1411
+ function bridgeSources() {
1412
+ if (typeof window === "undefined") return [];
1413
+ var w = window;
1414
+ return [
1415
+ w.__STORMCLOUD_CTV__,
1416
+ w.__STORMCLOUD_CTV_AD_INFO__,
1417
+ w.stormcloudCtv
1418
+ ].filter(Boolean);
1419
+ }
1420
+ function readBridgeValue2(keys, sanitize) {
1421
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1422
+ try {
1423
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1424
+ var source = _step.value;
1425
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1426
+ try {
1427
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1428
+ var key = _step1.value;
1429
+ var value = void 0;
1430
+ try {
1431
+ value = source === null || source === void 0 ? void 0 : source[key];
1432
+ if (typeof value === "function") value = value.call(source);
1433
+ } catch (unused) {
1434
+ value = void 0;
1435
+ }
1436
+ var sanitized = sanitize(value);
1437
+ if (sanitized != null) return sanitized;
1438
+ }
1439
+ } catch (err) {
1440
+ _didIteratorError1 = true;
1441
+ _iteratorError1 = err;
1442
+ } finally{
1443
+ try {
1444
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1445
+ _iterator1.return();
1446
+ }
1447
+ } finally{
1448
+ if (_didIteratorError1) {
1449
+ throw _iteratorError1;
1450
+ }
1451
+ }
1452
+ }
1453
+ }
1454
+ } catch (err) {
1455
+ _didIteratorError = true;
1456
+ _iteratorError = err;
1457
+ } finally{
1458
+ try {
1459
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1460
+ _iterator.return();
1461
+ }
1462
+ } finally{
1463
+ if (_didIteratorError) {
1464
+ throw _iteratorError;
1465
+ }
1466
+ }
1467
+ }
1468
+ return void 0;
1469
+ }
1470
+ function readBridgeContentValue(keys) {
1471
+ return readBridgeValue2(keys, sanitizeContentValue);
1472
+ }
1473
+ function resolveContentMetadata(config) {
1474
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1475
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1476
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1477
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1478
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1479
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1480
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1481
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1482
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1483
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1484
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1485
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1486
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1487
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1488
+ return _object_spread({}, channelName ? {
1489
+ channelName: channelName
1490
+ } : {}, programTitle ? {
1491
+ programTitle: programTitle
1492
+ } : {}, contentNetwork ? {
1493
+ contentNetwork: contentNetwork
1494
+ } : {}, contentType ? {
1495
+ contentType: contentType
1496
+ } : {}, contentCategory ? {
1497
+ contentCategory: contentCategory
1498
+ } : {}, contentGenre ? {
1499
+ contentGenre: contentGenre
1500
+ } : {}, contentLanguage ? {
1501
+ contentLanguage: contentLanguage
1502
+ } : {}, contentDurationSeconds != null ? {
1503
+ contentDurationSeconds: contentDurationSeconds
1504
+ } : {}, contentSeason ? {
1505
+ contentSeason: contentSeason
1506
+ } : {}, contentEpisode ? {
1507
+ contentEpisode: contentEpisode
1508
+ } : {}, contentRating ? {
1509
+ contentRating: contentRating
1510
+ } : {}, contentId ? {
1511
+ contentId: contentId
1512
+ } : {});
1513
+ }
1514
+ function applyContentMetadataUpdate(target, meta) {
1515
+ var apply = function apply(key, value) {
1516
+ if (value === void 0) return;
1517
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1518
+ if (clean) target[key] = clean;
1519
+ else delete target[key];
1520
+ };
1521
+ apply("channelName", meta.channelName);
1522
+ apply("programTitle", meta.programTitle);
1523
+ apply("contentNetwork", meta.contentNetwork);
1524
+ if (meta.details === void 0) return;
1525
+ if (meta.details === null) delete target.contentDetails;
1526
+ else target.contentDetails = _object_spread({}, meta.details);
1527
+ }
1528
+ function appendMissingContentParams(url, meta) {
1529
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1530
+ try {
1531
+ var parsed = new URL(url);
1532
+ var add = function add(key, value) {
1533
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1534
+ };
1535
+ add("ct_ch", meta.channelName);
1536
+ add("ct_ti", meta.programTitle);
1537
+ add("ct_ne", meta.contentNetwork);
1538
+ return parsed.toString();
1539
+ } catch (unused) {
1540
+ return url;
1541
+ }
1542
+ }
1543
+ // src/utils/partnerSignals.ts
1544
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1545
+ "aaid",
1546
+ "adid",
1547
+ "afai",
1548
+ "idfa",
1549
+ "lgudid",
1550
+ "msai",
1551
+ "rida",
1552
+ "tifa",
1553
+ "tvos",
1554
+ "vaid",
1555
+ "vida"
1556
+ ]);
1557
+ function toIabIfaType(deviceIdType, source) {
1558
+ if (!deviceIdType) return void 0;
1559
+ var type = deviceIdType.trim().toLowerCase();
1560
+ if (source === "generated") return "sessionid";
1561
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1562
+ if (source === "platform") return "dpid";
1563
+ return "ppid";
1564
+ }
1565
+ function playbackMethodCode(autoPlay, muted) {
1566
+ if (autoPlay === false) return 3;
1567
+ if (autoPlay !== true || muted == null) return void 0;
1568
+ return muted ? 2 : 1;
1569
+ }
1570
+ function resolvePlayerSize(video) {
1571
+ var width = video ? video.clientWidth : 0;
1572
+ var height = video ? video.clientHeight : 0;
1573
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1574
+ width = window.innerWidth;
1575
+ height = window.innerHeight;
1576
+ }
1577
+ if (!(width > 0 && height > 0)) return {};
1578
+ return {
1579
+ width: Math.round(width),
1580
+ height: Math.round(height)
1581
+ };
1582
+ }
1583
+ function sanitizeUserId(value) {
1584
+ var cleaned = sanitizeContentValue(value);
1585
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1586
+ return cleaned;
1587
+ }
1588
+ function isPublicIpv4(ip) {
1589
+ var parts = ip.split(".");
1590
+ if (parts.length !== 4) return false;
1591
+ var nums = parts.map(function(p) {
1592
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1593
+ });
1594
+ if (nums.some(function(n) {
1595
+ return !(n >= 0 && n <= 255);
1596
+ })) return false;
1597
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1598
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1599
+ if (a === 100 && b >= 64 && b <= 127) return false;
1600
+ if (a === 169 && b === 254) return false;
1601
+ if (a === 172 && b >= 16 && b <= 31) return false;
1602
+ if (a === 192 && b === 168) return false;
1603
+ return true;
1604
+ }
1605
+ function isPublicIpv6(ip) {
1606
+ var lower = ip.toLowerCase();
1607
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1608
+ if (lower === "::" || lower === "::1") return false;
1609
+ if (/^fe[89ab]/.test(lower)) return false;
1610
+ if (/^f[cd]/.test(lower)) return false;
1611
+ return true;
1612
+ }
1613
+ function sanitizePublicIp(value) {
1614
+ var cleaned = sanitizeContentValue(value);
1615
+ if (!cleaned) return void 0;
1616
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1617
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1618
+ }
1619
+ function resolveUserId(configValue) {
1620
+ var _sanitizeUserId;
1621
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1622
+ "userId",
1623
+ "uid"
1624
+ ], sanitizeUserId);
1625
+ }
1626
+ function resolveClientIp(configValue) {
1627
+ var _sanitizePublicIp;
1628
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1629
+ "ipAddress",
1630
+ "clientIp",
1631
+ "ip"
1632
+ ], sanitizePublicIp);
1633
+ }
1332
1634
  // src/utils/vastMacros.ts
1333
1635
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1334
1636
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1646,7 +1948,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1646
1948
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1647
1949
  "PMND",
1648
1950
  "PMXD",
1649
- "PMAD"
1951
+ "PMAD",
1952
+ "MABD"
1650
1953
  ]);
1651
1954
  function hasScvpMacros(url) {
1652
1955
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1691,6 +1994,8 @@ function resolveScvpMacroValues(ctx) {
1691
1994
  set("RDID", deviceId);
1692
1995
  set("IDTYPE", deviceIdType);
1693
1996
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1997
+ set("IFA", deviceId);
1998
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1694
1999
  }
1695
2000
  set("SID", ctx.sessionId);
1696
2001
  set("DTH", ctx.deviceTypeHint);
@@ -1708,6 +2013,26 @@ function resolveScvpMacroValues(ctx) {
1708
2013
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1709
2014
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1710
2015
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
2016
+ set("PLAYER-WIDTH", ctx.playerWidth);
2017
+ set("PLAYER-HEIGHT", ctx.playerHeight);
2018
+ set("TIMESTAMP", ctx.timestamp);
2019
+ set("LIVE", toFlag(ctx.isLive));
2020
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
2021
+ set("DEVICE-MAKE", ctx.deviceMake);
2022
+ set("DEVICE-MODEL", ctx.deviceModel);
2023
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
2024
+ set("UA", ctx.userAgent);
2025
+ set("IP", ctx.ipAddress);
2026
+ set("UID", ctx.userId);
2027
+ set("CT-TYPE", ctx.contentType);
2028
+ set("CT-CATEGORY", ctx.contentCategory);
2029
+ set("CT-GENRE", ctx.contentGenre);
2030
+ set("CT-LANGUAGE", ctx.contentLanguage);
2031
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
2032
+ set("CT-SEASON", ctx.contentSeason);
2033
+ set("CT-EPISODE", ctx.contentEpisode);
2034
+ set("CT-RATING", ctx.contentRating);
2035
+ set("CT-ID", ctx.contentId);
1711
2036
  return values;
1712
2037
  }
1713
2038
  var keepNone = function keepNone() {
@@ -2923,15 +3248,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2923
3248
  values.set("PMND", String(pod.pmnd));
2924
3249
  values.set("PMXD", String(pod.pmxd));
2925
3250
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3251
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2926
3252
  }
2927
3253
  var substituted = substituteScvpMacros(rawUrl, values);
2928
3254
  var finalUrl;
2929
3255
  try {
2930
3256
  var url = new URL(normalizeVastTagUrl(substituted.url));
3257
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3258
+ var setPodParam = function setPodParam(key, value) {
3259
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3260
+ };
2931
3261
  if (pod) {
2932
- url.searchParams.set("pmnd", String(pod.pmnd));
2933
- url.searchParams.set("pmxd", String(pod.pmxd));
2934
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3262
+ setPodParam("pmnd", pod.pmnd);
3263
+ setPodParam("pmxd", pod.pmxd);
3264
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2935
3265
  else url.searchParams.delete("pmad");
2936
3266
  } else {
2937
3267
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2997,7 +3327,9 @@ function validateGamRequestUrl(url, expect) {
2997
3327
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2998
3328
  var params;
2999
3329
  try {
3000
- params = new URL(url).searchParams;
3330
+ var parsed = new URL(url);
3331
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3332
+ params = parsed.searchParams;
3001
3333
  } catch (unused) {
3002
3334
  return problems.concat("URL could not be parsed");
3003
3335
  }
@@ -6418,7 +6750,7 @@ function safeCall2(fn, thisArg) {
6418
6750
  function userAgent() {
6419
6751
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6420
6752
  }
6421
- function bridgeSources() {
6753
+ function bridgeSources2() {
6422
6754
  if (typeof window === "undefined") return [];
6423
6755
  var w = window;
6424
6756
  return [
@@ -6430,7 +6762,7 @@ function bridgeSources() {
6430
6762
  function readBridge(keys) {
6431
6763
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6432
6764
  try {
6433
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6765
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6434
6766
  var source = _step.value;
6435
6767
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6436
6768
  try {
@@ -6477,6 +6809,11 @@ function readBridge(keys) {
6477
6809
  }
6478
6810
  return void 0;
6479
6811
  }
6812
+ function makeForCategory(category) {
6813
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6814
+ if (category === "Samsung TV") return "Samsung";
6815
+ return void 0;
6816
+ }
6480
6817
  function normalizeCategory(value) {
6481
6818
  var v = cleanString(value);
6482
6819
  if (!v) return void 0;
@@ -6624,7 +6961,7 @@ function primeDeviceInfo() {
6624
6961
  return primePromise;
6625
6962
  }
6626
6963
  function getDeviceInfo() {
6627
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6964
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6628
6965
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6629
6966
  if (primePromise && !platformCache) {} else {
6630
6967
  platformCache = platform;
@@ -6647,7 +6984,14 @@ function getDeviceInfo() {
6647
6984
  ]),
6648
6985
  category: normalizeCategory(readBridge([
6649
6986
  "deviceCategory"
6650
- ]))
6987
+ ])),
6988
+ make: readBridge([
6989
+ "deviceMake"
6990
+ ]),
6991
+ hardwareVersion: readBridge([
6992
+ "deviceHardwareVersion",
6993
+ "hardwareVersion"
6994
+ ])
6651
6995
  };
6652
6996
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6653
6997
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6660,7 +7004,9 @@ function getDeviceInfo() {
6660
7004
  bridge.internalDeviceId,
6661
7005
  bridge.model,
6662
7006
  bridge.firmware,
6663
- bridge.category
7007
+ bridge.category,
7008
+ bridge.make,
7009
+ bridge.hardwareVersion
6664
7010
  ];
6665
7011
  if (bridgeValues.some(function(v) {
6666
7012
  return v !== void 0;
@@ -6668,12 +7014,18 @@ function getDeviceInfo() {
6668
7014
  if (hostDeviceInfo) sources.unshift("host");
6669
7015
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6670
7016
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
7017
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
7018
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6671
7019
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6672
7020
  return _object_spread_props(_object_spread({
6673
7021
  category: category,
6674
7022
  categoryCode: CATEGORY_CODES[category]
6675
- }, model ? {
7023
+ }, make ? {
7024
+ make: make
7025
+ } : {}, model ? {
6676
7026
  model: model
7027
+ } : {}, hardwareVersion ? {
7028
+ hardwareVersion: hardwareVersion
6677
7029
  } : {}, sonifiModel ? {
6678
7030
  sonifiModel: sonifiModel
6679
7031
  } : {}, firmware ? {
@@ -6764,117 +7116,6 @@ function deviceInfoAnalyticsFields(info) {
6764
7116
  terminal_id: info.terminalId
6765
7117
  } : {});
6766
7118
  }
6767
- // src/utils/contentMetadata.ts
6768
- var MAX_CONTENT_VALUE_LENGTH = 128;
6769
- var BRIDGE_KEYS = {
6770
- channelName: [
6771
- "channelName",
6772
- "ct_ch"
6773
- ],
6774
- programTitle: [
6775
- "programTitle",
6776
- "ct_ti"
6777
- ],
6778
- contentNetwork: [
6779
- "contentNetwork",
6780
- "ct_ne"
6781
- ]
6782
- };
6783
- function sanitizeContentValue(value) {
6784
- if (typeof value !== "string") return void 0;
6785
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6786
- if (!cleaned) return void 0;
6787
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6788
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6789
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6790
- }
6791
- function bridgeSources2() {
6792
- if (typeof window === "undefined") return [];
6793
- var w = window;
6794
- return [
6795
- w.__STORMCLOUD_CTV__,
6796
- w.__STORMCLOUD_CTV_AD_INFO__,
6797
- w.stormcloudCtv
6798
- ].filter(Boolean);
6799
- }
6800
- function readBridgeContentValue(keys) {
6801
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6802
- try {
6803
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6804
- var source = _step.value;
6805
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6806
- try {
6807
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6808
- var key = _step1.value;
6809
- var value = void 0;
6810
- try {
6811
- value = source === null || source === void 0 ? void 0 : source[key];
6812
- if (typeof value === "function") value = value.call(source);
6813
- } catch (unused) {
6814
- value = void 0;
6815
- }
6816
- var sanitized = sanitizeContentValue(value);
6817
- if (sanitized) return sanitized;
6818
- }
6819
- } catch (err) {
6820
- _didIteratorError1 = true;
6821
- _iteratorError1 = err;
6822
- } finally{
6823
- try {
6824
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6825
- _iterator1.return();
6826
- }
6827
- } finally{
6828
- if (_didIteratorError1) {
6829
- throw _iteratorError1;
6830
- }
6831
- }
6832
- }
6833
- }
6834
- } catch (err) {
6835
- _didIteratorError = true;
6836
- _iteratorError = err;
6837
- } finally{
6838
- try {
6839
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6840
- _iterator.return();
6841
- }
6842
- } finally{
6843
- if (_didIteratorError) {
6844
- throw _iteratorError;
6845
- }
6846
- }
6847
- }
6848
- return void 0;
6849
- }
6850
- function resolveContentMetadata(config) {
6851
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6852
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6853
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6854
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6855
- return _object_spread({}, channelName ? {
6856
- channelName: channelName
6857
- } : {}, programTitle ? {
6858
- programTitle: programTitle
6859
- } : {}, contentNetwork ? {
6860
- contentNetwork: contentNetwork
6861
- } : {});
6862
- }
6863
- function appendMissingContentParams(url, meta) {
6864
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6865
- try {
6866
- var parsed = new URL(url);
6867
- var add = function add(key, value) {
6868
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6869
- };
6870
- add("ct_ch", meta.channelName);
6871
- add("ct_ti", meta.programTitle);
6872
- add("ct_ne", meta.contentNetwork);
6873
- return parsed.toString();
6874
- } catch (unused) {
6875
- return url;
6876
- }
6877
- }
6878
7119
  // src/utils/screenActivity.ts
6879
7120
  var hostStandby = false;
6880
7121
  function setHostStandby(standby) {
@@ -8876,6 +9117,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8876
9117
  return Scte35CueManager;
8877
9118
  }();
8878
9119
  // src/player/AdConfigManager.ts
9120
+ function isGamAdUrl(rawUrl) {
9121
+ try {
9122
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9123
+ } catch (unused) {
9124
+ return false;
9125
+ }
9126
+ }
8879
9127
  function withDeferredPodParams(rawUrl, deferNonce) {
8880
9128
  try {
8881
9129
  var url = new URL(rawUrl);
@@ -8893,11 +9141,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8893
9141
  }
8894
9142
  var AdConfigManager = /*#__PURE__*/ function() {
8895
9143
  function AdConfigManager(config, video) {
9144
+ var _this = this;
8896
9145
  _class_call_check(this, AdConfigManager);
8897
9146
  this.vmapBreaks = [];
8898
9147
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8899
9148
  this.streamCorrelator = generateCorrelator();
8900
9149
  this.consentSignals = {};
9150
+ this.isLiveStream = function() {
9151
+ return !!_this.config.isLiveStream;
9152
+ };
8901
9153
  this.podCounter = 0;
8902
9154
  this.podAssignedByPrefetch = false;
8903
9155
  this.lastHeartbeatTime = 0;
@@ -9348,13 +9600,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9348
9600
  {
9349
9601
  key: "generatePodVastUrl",
9350
9602
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9603
+ var _content_contentDurationSeconds;
9351
9604
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9352
9605
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9353
9606
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9354
9607
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9355
9608
  });
9356
9609
  var content = resolveContentMetadata(this.config);
9357
- var macroContext = _object_spread_props(_object_spread({
9610
+ var isLive = this.isLiveStream();
9611
+ var device = getDeviceInfo();
9612
+ var playerSize = resolvePlayerSize(this.video);
9613
+ var videoDuration = this.video.duration;
9614
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9615
+ var userId = resolveUserId(this.config.adUserId);
9616
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9617
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9618
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9358
9619
  correlator: this.viewCorrelator,
9359
9620
  streamCorrelator: this.streamCorrelator,
9360
9621
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9376,8 +9637,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9376
9637
  contentNetwork: content.contentNetwork
9377
9638
  } : {}), {
9378
9639
  consent: this.consentSignals,
9379
- palNonce: palNonce.getCurrentNonce() || void 0
9380
- });
9640
+ palNonce: palNonce.getCurrentNonce() || void 0,
9641
+ deviceIdSource: envSignals.deviceIdSource,
9642
+ isLive: isLive
9643
+ }), playerSize.width ? {
9644
+ playerWidth: playerSize.width
9645
+ } : {}, playerSize.height ? {
9646
+ playerHeight: playerSize.height
9647
+ } : {}), {
9648
+ timestamp: String(Date.now())
9649
+ }), device.make ? {
9650
+ deviceMake: device.make
9651
+ } : {}, device.model ? {
9652
+ deviceModel: device.model
9653
+ } : {}, device.hardwareVersion ? {
9654
+ deviceHardwareVersion: device.hardwareVersion
9655
+ } : {}, userAgent2 ? {
9656
+ userAgent: userAgent2
9657
+ } : {}, ipAddress ? {
9658
+ ipAddress: ipAddress
9659
+ } : {}, userId ? {
9660
+ userId: userId
9661
+ } : {}, content.contentType ? {
9662
+ contentType: content.contentType
9663
+ } : {}, content.contentCategory ? {
9664
+ contentCategory: content.contentCategory
9665
+ } : {}, content.contentGenre ? {
9666
+ contentGenre: content.contentGenre
9667
+ } : {}, content.contentLanguage ? {
9668
+ contentLanguage: content.contentLanguage
9669
+ } : {}, contentDurationSeconds != null ? {
9670
+ contentDurationSeconds: contentDurationSeconds
9671
+ } : {}, content.contentSeason ? {
9672
+ contentSeason: content.contentSeason
9673
+ } : {}, content.contentEpisode ? {
9674
+ contentEpisode: content.contentEpisode
9675
+ } : {}, content.contentRating ? {
9676
+ contentRating: content.contentRating
9677
+ } : {}, content.contentId ? {
9678
+ contentId: content.contentId
9679
+ } : {});
9381
9680
  var nonceReady = !!macroContext.palNonce;
9382
9681
  var finalUrl;
9383
9682
  if (hasScvpMacros(baseUrl)) {
@@ -9391,9 +9690,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9391
9690
  } else {
9392
9691
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9393
9692
  }
9394
- finalUrl = appendMissingContentParams(finalUrl, content);
9395
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9396
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9693
+ if (isGamAdUrl(finalUrl)) {
9694
+ finalUrl = appendMissingContentParams(finalUrl, content);
9695
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9696
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9697
+ }
9397
9698
  }
9398
9699
  if (this.debug) {
9399
9700
  var id = envSignals.deviceId;
@@ -9406,7 +9707,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
9406
9707
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9407
9708
  ct_ch: content.channelName,
9408
9709
  ct_ti: content.programTitle,
9409
- ct_ne: content.contentNetwork
9710
+ ct_ne: content.contentNetwork,
9711
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9712
+ live: isLive,
9713
+ player: playerSize,
9714
+ make: device.make,
9715
+ model: device.model
9410
9716
  });
9411
9717
  }
9412
9718
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -13577,6 +13883,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13577
13883
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13578
13884
  }
13579
13885
  });
13886
+ this.adConfig.isLiveStream = function() {
13887
+ return _this.hlsEngine.isLiveStream;
13888
+ };
13580
13889
  this.adBreak = new AdBreakOrchestrator({
13581
13890
  config: this.config,
13582
13891
  video: this.video,
@@ -13938,16 +14247,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13938
14247
  {
13939
14248
  key: "setContentMetadata",
13940
14249
  value: function setContentMetadata(meta) {
13941
- var _this = this;
13942
- var apply = function apply(key, value) {
13943
- if (value === void 0) return;
13944
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13945
- if (clean) _this.config[key] = clean;
13946
- else delete _this.config[key];
13947
- };
13948
- apply("channelName", meta.channelName);
13949
- apply("programTitle", meta.programTitle);
13950
- apply("contentNetwork", meta.contentNetwork);
14250
+ applyContentMetadataUpdate(this.config, meta);
14251
+ }
14252
+ },
14253
+ {
14254
+ key: "setRequestSignals",
14255
+ value: function setRequestSignals(signals) {
14256
+ if (signals.userId !== void 0) {
14257
+ if (signals.userId) this.config.adUserId = signals.userId;
14258
+ else delete this.config.adUserId;
14259
+ }
14260
+ if (signals.ipAddress !== void 0) {
14261
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14262
+ else delete this.config.clientIpAddress;
14263
+ }
13951
14264
  }
13952
14265
  },
13953
14266
  {