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