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
@@ -1296,6 +1296,308 @@ function normalizeBoolean(value) {
1296
1296
  }
1297
1297
  return void 0;
1298
1298
  }
1299
+ // src/utils/contentMetadata.ts
1300
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1301
+ var BRIDGE_KEYS = {
1302
+ channelName: [
1303
+ "channelName",
1304
+ "ct_ch"
1305
+ ],
1306
+ programTitle: [
1307
+ "programTitle",
1308
+ "ct_ti"
1309
+ ],
1310
+ contentNetwork: [
1311
+ "contentNetwork",
1312
+ "ct_ne"
1313
+ ],
1314
+ contentType: [
1315
+ "contentType",
1316
+ "ctt"
1317
+ ],
1318
+ contentCategory: [
1319
+ "contentCategory",
1320
+ "ctc"
1321
+ ],
1322
+ contentGenre: [
1323
+ "contentGenre",
1324
+ "ctgr"
1325
+ ],
1326
+ contentLanguage: [
1327
+ "contentLanguage",
1328
+ "ctlg"
1329
+ ],
1330
+ contentDuration: [
1331
+ "contentDuration",
1332
+ "ctd"
1333
+ ],
1334
+ contentSeason: [
1335
+ "contentSeason",
1336
+ "cts"
1337
+ ],
1338
+ contentEpisode: [
1339
+ "contentEpisode",
1340
+ "cte"
1341
+ ],
1342
+ contentRating: [
1343
+ "contentRating",
1344
+ "ctr"
1345
+ ],
1346
+ contentId: [
1347
+ "contentId",
1348
+ "ctid"
1349
+ ]
1350
+ };
1351
+ function sanitizeContentValue(value) {
1352
+ if (typeof value !== "string") return void 0;
1353
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1354
+ if (!cleaned) return void 0;
1355
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1356
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1357
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1358
+ }
1359
+ function sanitizeContentScalar(value) {
1360
+ if (typeof value === "number") {
1361
+ return Number.isFinite(value) ? String(value) : void 0;
1362
+ }
1363
+ return sanitizeContentValue(value);
1364
+ }
1365
+ function normalizeContentLanguage(value) {
1366
+ var cleaned = sanitizeContentValue(value);
1367
+ if (!cleaned) return void 0;
1368
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1369
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1370
+ }
1371
+ function normalizeContentDuration(value) {
1372
+ var raw = sanitizeContentScalar(value);
1373
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1374
+ var seconds = Number(raw);
1375
+ if (seconds === -1) return -1;
1376
+ return seconds > 0 ? Math.round(seconds) : void 0;
1377
+ }
1378
+ function bridgeSources() {
1379
+ if (typeof window === "undefined") return [];
1380
+ var w = window;
1381
+ return [
1382
+ w.__STORMCLOUD_CTV__,
1383
+ w.__STORMCLOUD_CTV_AD_INFO__,
1384
+ w.stormcloudCtv
1385
+ ].filter(Boolean);
1386
+ }
1387
+ function readBridgeValue2(keys, sanitize) {
1388
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1389
+ try {
1390
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1391
+ var source = _step.value;
1392
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1393
+ try {
1394
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1395
+ var key = _step1.value;
1396
+ var value = void 0;
1397
+ try {
1398
+ value = source === null || source === void 0 ? void 0 : source[key];
1399
+ if (typeof value === "function") value = value.call(source);
1400
+ } catch (unused) {
1401
+ value = void 0;
1402
+ }
1403
+ var sanitized = sanitize(value);
1404
+ if (sanitized != null) return sanitized;
1405
+ }
1406
+ } catch (err) {
1407
+ _didIteratorError1 = true;
1408
+ _iteratorError1 = err;
1409
+ } finally{
1410
+ try {
1411
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1412
+ _iterator1.return();
1413
+ }
1414
+ } finally{
1415
+ if (_didIteratorError1) {
1416
+ throw _iteratorError1;
1417
+ }
1418
+ }
1419
+ }
1420
+ }
1421
+ } catch (err) {
1422
+ _didIteratorError = true;
1423
+ _iteratorError = err;
1424
+ } finally{
1425
+ try {
1426
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1427
+ _iterator.return();
1428
+ }
1429
+ } finally{
1430
+ if (_didIteratorError) {
1431
+ throw _iteratorError;
1432
+ }
1433
+ }
1434
+ }
1435
+ return void 0;
1436
+ }
1437
+ function readBridgeContentValue(keys) {
1438
+ return readBridgeValue2(keys, sanitizeContentValue);
1439
+ }
1440
+ function resolveContentMetadata(config) {
1441
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1442
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1443
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1444
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1445
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1446
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1447
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1448
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1449
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1450
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1451
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1452
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1453
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1454
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1455
+ return _object_spread({}, channelName ? {
1456
+ channelName: channelName
1457
+ } : {}, programTitle ? {
1458
+ programTitle: programTitle
1459
+ } : {}, contentNetwork ? {
1460
+ contentNetwork: contentNetwork
1461
+ } : {}, contentType ? {
1462
+ contentType: contentType
1463
+ } : {}, contentCategory ? {
1464
+ contentCategory: contentCategory
1465
+ } : {}, contentGenre ? {
1466
+ contentGenre: contentGenre
1467
+ } : {}, contentLanguage ? {
1468
+ contentLanguage: contentLanguage
1469
+ } : {}, contentDurationSeconds != null ? {
1470
+ contentDurationSeconds: contentDurationSeconds
1471
+ } : {}, contentSeason ? {
1472
+ contentSeason: contentSeason
1473
+ } : {}, contentEpisode ? {
1474
+ contentEpisode: contentEpisode
1475
+ } : {}, contentRating ? {
1476
+ contentRating: contentRating
1477
+ } : {}, contentId ? {
1478
+ contentId: contentId
1479
+ } : {});
1480
+ }
1481
+ function applyContentMetadataUpdate(target, meta) {
1482
+ var apply = function apply(key, value) {
1483
+ if (value === void 0) return;
1484
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1485
+ if (clean) target[key] = clean;
1486
+ else delete target[key];
1487
+ };
1488
+ apply("channelName", meta.channelName);
1489
+ apply("programTitle", meta.programTitle);
1490
+ apply("contentNetwork", meta.contentNetwork);
1491
+ if (meta.details === void 0) return;
1492
+ if (meta.details === null) delete target.contentDetails;
1493
+ else target.contentDetails = _object_spread({}, meta.details);
1494
+ }
1495
+ function appendMissingContentParams(url, meta) {
1496
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1497
+ try {
1498
+ var parsed = new URL(url);
1499
+ var add = function add(key, value) {
1500
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1501
+ };
1502
+ add("ct_ch", meta.channelName);
1503
+ add("ct_ti", meta.programTitle);
1504
+ add("ct_ne", meta.contentNetwork);
1505
+ return parsed.toString();
1506
+ } catch (unused) {
1507
+ return url;
1508
+ }
1509
+ }
1510
+ // src/utils/partnerSignals.ts
1511
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1512
+ "aaid",
1513
+ "adid",
1514
+ "afai",
1515
+ "idfa",
1516
+ "lgudid",
1517
+ "msai",
1518
+ "rida",
1519
+ "tifa",
1520
+ "tvos",
1521
+ "vaid",
1522
+ "vida"
1523
+ ]);
1524
+ function toIabIfaType(deviceIdType, source) {
1525
+ if (!deviceIdType) return void 0;
1526
+ var type = deviceIdType.trim().toLowerCase();
1527
+ if (source === "generated") return "sessionid";
1528
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1529
+ if (source === "platform") return "dpid";
1530
+ return "ppid";
1531
+ }
1532
+ function playbackMethodCode(autoPlay, muted) {
1533
+ if (autoPlay === false) return 3;
1534
+ if (autoPlay !== true || muted == null) return void 0;
1535
+ return muted ? 2 : 1;
1536
+ }
1537
+ function resolvePlayerSize(video) {
1538
+ var width = video ? video.clientWidth : 0;
1539
+ var height = video ? video.clientHeight : 0;
1540
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1541
+ width = window.innerWidth;
1542
+ height = window.innerHeight;
1543
+ }
1544
+ if (!(width > 0 && height > 0)) return {};
1545
+ return {
1546
+ width: Math.round(width),
1547
+ height: Math.round(height)
1548
+ };
1549
+ }
1550
+ function sanitizeUserId(value) {
1551
+ var cleaned = sanitizeContentValue(value);
1552
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1553
+ return cleaned;
1554
+ }
1555
+ function isPublicIpv4(ip) {
1556
+ var parts = ip.split(".");
1557
+ if (parts.length !== 4) return false;
1558
+ var nums = parts.map(function(p) {
1559
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1560
+ });
1561
+ if (nums.some(function(n) {
1562
+ return !(n >= 0 && n <= 255);
1563
+ })) return false;
1564
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1565
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1566
+ if (a === 100 && b >= 64 && b <= 127) return false;
1567
+ if (a === 169 && b === 254) return false;
1568
+ if (a === 172 && b >= 16 && b <= 31) return false;
1569
+ if (a === 192 && b === 168) return false;
1570
+ return true;
1571
+ }
1572
+ function isPublicIpv6(ip) {
1573
+ var lower = ip.toLowerCase();
1574
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1575
+ if (lower === "::" || lower === "::1") return false;
1576
+ if (/^fe[89ab]/.test(lower)) return false;
1577
+ if (/^f[cd]/.test(lower)) return false;
1578
+ return true;
1579
+ }
1580
+ function sanitizePublicIp(value) {
1581
+ var cleaned = sanitizeContentValue(value);
1582
+ if (!cleaned) return void 0;
1583
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1584
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1585
+ }
1586
+ function resolveUserId(configValue) {
1587
+ var _sanitizeUserId;
1588
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1589
+ "userId",
1590
+ "uid"
1591
+ ], sanitizeUserId);
1592
+ }
1593
+ function resolveClientIp(configValue) {
1594
+ var _sanitizePublicIp;
1595
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1596
+ "ipAddress",
1597
+ "clientIp",
1598
+ "ip"
1599
+ ], sanitizePublicIp);
1600
+ }
1299
1601
  // src/utils/vastMacros.ts
1300
1602
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1301
1603
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1613,7 +1915,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1613
1915
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1614
1916
  "PMND",
1615
1917
  "PMXD",
1616
- "PMAD"
1918
+ "PMAD",
1919
+ "MABD"
1617
1920
  ]);
1618
1921
  function hasScvpMacros(url) {
1619
1922
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1658,6 +1961,8 @@ function resolveScvpMacroValues(ctx) {
1658
1961
  set("RDID", deviceId);
1659
1962
  set("IDTYPE", deviceIdType);
1660
1963
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1964
+ set("IFA", deviceId);
1965
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1661
1966
  }
1662
1967
  set("SID", ctx.sessionId);
1663
1968
  set("DTH", ctx.deviceTypeHint);
@@ -1675,6 +1980,26 @@ function resolveScvpMacroValues(ctx) {
1675
1980
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1676
1981
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1677
1982
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1983
+ set("PLAYER-WIDTH", ctx.playerWidth);
1984
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1985
+ set("TIMESTAMP", ctx.timestamp);
1986
+ set("LIVE", toFlag(ctx.isLive));
1987
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1988
+ set("DEVICE-MAKE", ctx.deviceMake);
1989
+ set("DEVICE-MODEL", ctx.deviceModel);
1990
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1991
+ set("UA", ctx.userAgent);
1992
+ set("IP", ctx.ipAddress);
1993
+ set("UID", ctx.userId);
1994
+ set("CT-TYPE", ctx.contentType);
1995
+ set("CT-CATEGORY", ctx.contentCategory);
1996
+ set("CT-GENRE", ctx.contentGenre);
1997
+ set("CT-LANGUAGE", ctx.contentLanguage);
1998
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1999
+ set("CT-SEASON", ctx.contentSeason);
2000
+ set("CT-EPISODE", ctx.contentEpisode);
2001
+ set("CT-RATING", ctx.contentRating);
2002
+ set("CT-ID", ctx.contentId);
1678
2003
  return values;
1679
2004
  }
1680
2005
  var keepNone = function keepNone() {
@@ -2890,15 +3215,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2890
3215
  values.set("PMND", String(pod.pmnd));
2891
3216
  values.set("PMXD", String(pod.pmxd));
2892
3217
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3218
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2893
3219
  }
2894
3220
  var substituted = substituteScvpMacros(rawUrl, values);
2895
3221
  var finalUrl;
2896
3222
  try {
2897
3223
  var url = new URL(normalizeVastTagUrl(substituted.url));
3224
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3225
+ var setPodParam = function setPodParam(key, value) {
3226
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3227
+ };
2898
3228
  if (pod) {
2899
- url.searchParams.set("pmnd", String(pod.pmnd));
2900
- url.searchParams.set("pmxd", String(pod.pmxd));
2901
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3229
+ setPodParam("pmnd", pod.pmnd);
3230
+ setPodParam("pmxd", pod.pmxd);
3231
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2902
3232
  else url.searchParams.delete("pmad");
2903
3233
  } else {
2904
3234
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2964,7 +3294,9 @@ function validateGamRequestUrl(url, expect) {
2964
3294
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2965
3295
  var params;
2966
3296
  try {
2967
- params = new URL(url).searchParams;
3297
+ var parsed = new URL(url);
3298
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3299
+ params = parsed.searchParams;
2968
3300
  } catch (unused) {
2969
3301
  return problems.concat("URL could not be parsed");
2970
3302
  }
@@ -6385,7 +6717,7 @@ function safeCall2(fn, thisArg) {
6385
6717
  function userAgent() {
6386
6718
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6387
6719
  }
6388
- function bridgeSources() {
6720
+ function bridgeSources2() {
6389
6721
  if (typeof window === "undefined") return [];
6390
6722
  var w = window;
6391
6723
  return [
@@ -6397,7 +6729,7 @@ function bridgeSources() {
6397
6729
  function readBridge(keys) {
6398
6730
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6399
6731
  try {
6400
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6732
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6401
6733
  var source = _step.value;
6402
6734
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6403
6735
  try {
@@ -6444,6 +6776,11 @@ function readBridge(keys) {
6444
6776
  }
6445
6777
  return void 0;
6446
6778
  }
6779
+ function makeForCategory(category) {
6780
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6781
+ if (category === "Samsung TV") return "Samsung";
6782
+ return void 0;
6783
+ }
6447
6784
  function normalizeCategory(value) {
6448
6785
  var v = cleanString(value);
6449
6786
  if (!v) return void 0;
@@ -6591,7 +6928,7 @@ function primeDeviceInfo() {
6591
6928
  return primePromise;
6592
6929
  }
6593
6930
  function getDeviceInfo() {
6594
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6931
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6595
6932
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6596
6933
  if (primePromise && !platformCache) {} else {
6597
6934
  platformCache = platform;
@@ -6614,7 +6951,14 @@ function getDeviceInfo() {
6614
6951
  ]),
6615
6952
  category: normalizeCategory(readBridge([
6616
6953
  "deviceCategory"
6617
- ]))
6954
+ ])),
6955
+ make: readBridge([
6956
+ "deviceMake"
6957
+ ]),
6958
+ hardwareVersion: readBridge([
6959
+ "deviceHardwareVersion",
6960
+ "hardwareVersion"
6961
+ ])
6618
6962
  };
6619
6963
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6620
6964
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6627,7 +6971,9 @@ function getDeviceInfo() {
6627
6971
  bridge.internalDeviceId,
6628
6972
  bridge.model,
6629
6973
  bridge.firmware,
6630
- bridge.category
6974
+ bridge.category,
6975
+ bridge.make,
6976
+ bridge.hardwareVersion
6631
6977
  ];
6632
6978
  if (bridgeValues.some(function(v) {
6633
6979
  return v !== void 0;
@@ -6635,12 +6981,18 @@ function getDeviceInfo() {
6635
6981
  if (hostDeviceInfo) sources.unshift("host");
6636
6982
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6637
6983
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6984
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6985
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6638
6986
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6639
6987
  return _object_spread_props(_object_spread({
6640
6988
  category: category,
6641
6989
  categoryCode: CATEGORY_CODES[category]
6642
- }, model ? {
6990
+ }, make ? {
6991
+ make: make
6992
+ } : {}, model ? {
6643
6993
  model: model
6994
+ } : {}, hardwareVersion ? {
6995
+ hardwareVersion: hardwareVersion
6644
6996
  } : {}, sonifiModel ? {
6645
6997
  sonifiModel: sonifiModel
6646
6998
  } : {}, firmware ? {
@@ -6731,117 +7083,6 @@ function deviceInfoAnalyticsFields(info) {
6731
7083
  terminal_id: info.terminalId
6732
7084
  } : {});
6733
7085
  }
6734
- // src/utils/contentMetadata.ts
6735
- var MAX_CONTENT_VALUE_LENGTH = 128;
6736
- var BRIDGE_KEYS = {
6737
- channelName: [
6738
- "channelName",
6739
- "ct_ch"
6740
- ],
6741
- programTitle: [
6742
- "programTitle",
6743
- "ct_ti"
6744
- ],
6745
- contentNetwork: [
6746
- "contentNetwork",
6747
- "ct_ne"
6748
- ]
6749
- };
6750
- function sanitizeContentValue(value) {
6751
- if (typeof value !== "string") return void 0;
6752
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6753
- if (!cleaned) return void 0;
6754
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6755
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6756
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6757
- }
6758
- function bridgeSources2() {
6759
- if (typeof window === "undefined") return [];
6760
- var w = window;
6761
- return [
6762
- w.__STORMCLOUD_CTV__,
6763
- w.__STORMCLOUD_CTV_AD_INFO__,
6764
- w.stormcloudCtv
6765
- ].filter(Boolean);
6766
- }
6767
- function readBridgeContentValue(keys) {
6768
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6769
- try {
6770
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6771
- var source = _step.value;
6772
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6773
- try {
6774
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6775
- var key = _step1.value;
6776
- var value = void 0;
6777
- try {
6778
- value = source === null || source === void 0 ? void 0 : source[key];
6779
- if (typeof value === "function") value = value.call(source);
6780
- } catch (unused) {
6781
- value = void 0;
6782
- }
6783
- var sanitized = sanitizeContentValue(value);
6784
- if (sanitized) return sanitized;
6785
- }
6786
- } catch (err) {
6787
- _didIteratorError1 = true;
6788
- _iteratorError1 = err;
6789
- } finally{
6790
- try {
6791
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6792
- _iterator1.return();
6793
- }
6794
- } finally{
6795
- if (_didIteratorError1) {
6796
- throw _iteratorError1;
6797
- }
6798
- }
6799
- }
6800
- }
6801
- } catch (err) {
6802
- _didIteratorError = true;
6803
- _iteratorError = err;
6804
- } finally{
6805
- try {
6806
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6807
- _iterator.return();
6808
- }
6809
- } finally{
6810
- if (_didIteratorError) {
6811
- throw _iteratorError;
6812
- }
6813
- }
6814
- }
6815
- return void 0;
6816
- }
6817
- function resolveContentMetadata(config) {
6818
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6819
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6820
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6821
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6822
- return _object_spread({}, channelName ? {
6823
- channelName: channelName
6824
- } : {}, programTitle ? {
6825
- programTitle: programTitle
6826
- } : {}, contentNetwork ? {
6827
- contentNetwork: contentNetwork
6828
- } : {});
6829
- }
6830
- function appendMissingContentParams(url, meta) {
6831
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6832
- try {
6833
- var parsed = new URL(url);
6834
- var add = function add(key, value) {
6835
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6836
- };
6837
- add("ct_ch", meta.channelName);
6838
- add("ct_ti", meta.programTitle);
6839
- add("ct_ne", meta.contentNetwork);
6840
- return parsed.toString();
6841
- } catch (unused) {
6842
- return url;
6843
- }
6844
- }
6845
7086
  // src/utils/screenActivity.ts
6846
7087
  var hostStandby = false;
6847
7088
  function setHostStandby(standby) {
@@ -8843,6 +9084,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8843
9084
  return Scte35CueManager;
8844
9085
  }();
8845
9086
  // src/player/AdConfigManager.ts
9087
+ function isGamAdUrl(rawUrl) {
9088
+ try {
9089
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9090
+ } catch (unused) {
9091
+ return false;
9092
+ }
9093
+ }
8846
9094
  function withDeferredPodParams(rawUrl, deferNonce) {
8847
9095
  try {
8848
9096
  var url = new URL(rawUrl);
@@ -8860,11 +9108,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8860
9108
  }
8861
9109
  var AdConfigManager = /*#__PURE__*/ function() {
8862
9110
  function AdConfigManager(config, video) {
9111
+ var _this = this;
8863
9112
  _class_call_check(this, AdConfigManager);
8864
9113
  this.vmapBreaks = [];
8865
9114
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8866
9115
  this.streamCorrelator = generateCorrelator();
8867
9116
  this.consentSignals = {};
9117
+ this.isLiveStream = function() {
9118
+ return !!_this.config.isLiveStream;
9119
+ };
8868
9120
  this.podCounter = 0;
8869
9121
  this.podAssignedByPrefetch = false;
8870
9122
  this.lastHeartbeatTime = 0;
@@ -9315,13 +9567,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9315
9567
  {
9316
9568
  key: "generatePodVastUrl",
9317
9569
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9570
+ var _content_contentDurationSeconds;
9318
9571
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9319
9572
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9320
9573
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9321
9574
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9322
9575
  });
9323
9576
  var content = resolveContentMetadata(this.config);
9324
- var macroContext = _object_spread_props(_object_spread({
9577
+ var isLive = this.isLiveStream();
9578
+ var device = getDeviceInfo();
9579
+ var playerSize = resolvePlayerSize(this.video);
9580
+ var videoDuration = this.video.duration;
9581
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9582
+ var userId = resolveUserId(this.config.adUserId);
9583
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9584
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9585
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9325
9586
  correlator: this.viewCorrelator,
9326
9587
  streamCorrelator: this.streamCorrelator,
9327
9588
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9343,8 +9604,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9343
9604
  contentNetwork: content.contentNetwork
9344
9605
  } : {}), {
9345
9606
  consent: this.consentSignals,
9346
- palNonce: palNonce.getCurrentNonce() || void 0
9347
- });
9607
+ palNonce: palNonce.getCurrentNonce() || void 0,
9608
+ deviceIdSource: envSignals.deviceIdSource,
9609
+ isLive: isLive
9610
+ }), playerSize.width ? {
9611
+ playerWidth: playerSize.width
9612
+ } : {}, playerSize.height ? {
9613
+ playerHeight: playerSize.height
9614
+ } : {}), {
9615
+ timestamp: String(Date.now())
9616
+ }), device.make ? {
9617
+ deviceMake: device.make
9618
+ } : {}, device.model ? {
9619
+ deviceModel: device.model
9620
+ } : {}, device.hardwareVersion ? {
9621
+ deviceHardwareVersion: device.hardwareVersion
9622
+ } : {}, userAgent2 ? {
9623
+ userAgent: userAgent2
9624
+ } : {}, ipAddress ? {
9625
+ ipAddress: ipAddress
9626
+ } : {}, userId ? {
9627
+ userId: userId
9628
+ } : {}, content.contentType ? {
9629
+ contentType: content.contentType
9630
+ } : {}, content.contentCategory ? {
9631
+ contentCategory: content.contentCategory
9632
+ } : {}, content.contentGenre ? {
9633
+ contentGenre: content.contentGenre
9634
+ } : {}, content.contentLanguage ? {
9635
+ contentLanguage: content.contentLanguage
9636
+ } : {}, contentDurationSeconds != null ? {
9637
+ contentDurationSeconds: contentDurationSeconds
9638
+ } : {}, content.contentSeason ? {
9639
+ contentSeason: content.contentSeason
9640
+ } : {}, content.contentEpisode ? {
9641
+ contentEpisode: content.contentEpisode
9642
+ } : {}, content.contentRating ? {
9643
+ contentRating: content.contentRating
9644
+ } : {}, content.contentId ? {
9645
+ contentId: content.contentId
9646
+ } : {});
9348
9647
  var nonceReady = !!macroContext.palNonce;
9349
9648
  var finalUrl;
9350
9649
  if (hasScvpMacros(baseUrl)) {
@@ -9358,9 +9657,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9358
9657
  } else {
9359
9658
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9360
9659
  }
9361
- finalUrl = appendMissingContentParams(finalUrl, content);
9362
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9363
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9660
+ if (isGamAdUrl(finalUrl)) {
9661
+ finalUrl = appendMissingContentParams(finalUrl, content);
9662
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9663
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9664
+ }
9364
9665
  }
9365
9666
  if (this.debug) {
9366
9667
  var id = envSignals.deviceId;
@@ -9373,7 +9674,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
9373
9674
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9374
9675
  ct_ch: content.channelName,
9375
9676
  ct_ti: content.programTitle,
9376
- ct_ne: content.contentNetwork
9677
+ ct_ne: content.contentNetwork,
9678
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9679
+ live: isLive,
9680
+ player: playerSize,
9681
+ make: device.make,
9682
+ model: device.model
9377
9683
  });
9378
9684
  }
9379
9685
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -13544,6 +13850,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13544
13850
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13545
13851
  }
13546
13852
  });
13853
+ this.adConfig.isLiveStream = function() {
13854
+ return _this.hlsEngine.isLiveStream;
13855
+ };
13547
13856
  this.adBreak = new AdBreakOrchestrator({
13548
13857
  config: this.config,
13549
13858
  video: this.video,
@@ -13905,16 +14214,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13905
14214
  {
13906
14215
  key: "setContentMetadata",
13907
14216
  value: function setContentMetadata(meta) {
13908
- var _this = this;
13909
- var apply = function apply(key, value) {
13910
- if (value === void 0) return;
13911
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13912
- if (clean) _this.config[key] = clean;
13913
- else delete _this.config[key];
13914
- };
13915
- apply("channelName", meta.channelName);
13916
- apply("programTitle", meta.programTitle);
13917
- apply("contentNetwork", meta.contentNetwork);
14217
+ applyContentMetadataUpdate(this.config, meta);
14218
+ }
14219
+ },
14220
+ {
14221
+ key: "setRequestSignals",
14222
+ value: function setRequestSignals(signals) {
14223
+ if (signals.userId !== void 0) {
14224
+ if (signals.userId) this.config.adUserId = signals.userId;
14225
+ else delete this.config.adUserId;
14226
+ }
14227
+ if (signals.ipAddress !== void 0) {
14228
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14229
+ else delete this.config.clientIpAddress;
14230
+ }
13918
14231
  }
13919
14232
  },
13920
14233
  {