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
@@ -1246,6 +1246,308 @@ function normalizeBoolean(value) {
1246
1246
  }
1247
1247
  return void 0;
1248
1248
  }
1249
+ // src/utils/contentMetadata.ts
1250
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1251
+ var BRIDGE_KEYS = {
1252
+ channelName: [
1253
+ "channelName",
1254
+ "ct_ch"
1255
+ ],
1256
+ programTitle: [
1257
+ "programTitle",
1258
+ "ct_ti"
1259
+ ],
1260
+ contentNetwork: [
1261
+ "contentNetwork",
1262
+ "ct_ne"
1263
+ ],
1264
+ contentType: [
1265
+ "contentType",
1266
+ "ctt"
1267
+ ],
1268
+ contentCategory: [
1269
+ "contentCategory",
1270
+ "ctc"
1271
+ ],
1272
+ contentGenre: [
1273
+ "contentGenre",
1274
+ "ctgr"
1275
+ ],
1276
+ contentLanguage: [
1277
+ "contentLanguage",
1278
+ "ctlg"
1279
+ ],
1280
+ contentDuration: [
1281
+ "contentDuration",
1282
+ "ctd"
1283
+ ],
1284
+ contentSeason: [
1285
+ "contentSeason",
1286
+ "cts"
1287
+ ],
1288
+ contentEpisode: [
1289
+ "contentEpisode",
1290
+ "cte"
1291
+ ],
1292
+ contentRating: [
1293
+ "contentRating",
1294
+ "ctr"
1295
+ ],
1296
+ contentId: [
1297
+ "contentId",
1298
+ "ctid"
1299
+ ]
1300
+ };
1301
+ function sanitizeContentValue(value) {
1302
+ if (typeof value !== "string") return void 0;
1303
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1304
+ if (!cleaned) return void 0;
1305
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1306
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1307
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1308
+ }
1309
+ function sanitizeContentScalar(value) {
1310
+ if (typeof value === "number") {
1311
+ return Number.isFinite(value) ? String(value) : void 0;
1312
+ }
1313
+ return sanitizeContentValue(value);
1314
+ }
1315
+ function normalizeContentLanguage(value) {
1316
+ var cleaned = sanitizeContentValue(value);
1317
+ if (!cleaned) return void 0;
1318
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1319
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1320
+ }
1321
+ function normalizeContentDuration(value) {
1322
+ var raw = sanitizeContentScalar(value);
1323
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1324
+ var seconds = Number(raw);
1325
+ if (seconds === -1) return -1;
1326
+ return seconds > 0 ? Math.round(seconds) : void 0;
1327
+ }
1328
+ function bridgeSources() {
1329
+ if (typeof window === "undefined") return [];
1330
+ var w = window;
1331
+ return [
1332
+ w.__STORMCLOUD_CTV__,
1333
+ w.__STORMCLOUD_CTV_AD_INFO__,
1334
+ w.stormcloudCtv
1335
+ ].filter(Boolean);
1336
+ }
1337
+ function readBridgeValue2(keys, sanitize) {
1338
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1339
+ try {
1340
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1341
+ var source = _step.value;
1342
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1343
+ try {
1344
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1345
+ var key = _step1.value;
1346
+ var value = void 0;
1347
+ try {
1348
+ value = source === null || source === void 0 ? void 0 : source[key];
1349
+ if (typeof value === "function") value = value.call(source);
1350
+ } catch (unused) {
1351
+ value = void 0;
1352
+ }
1353
+ var sanitized = sanitize(value);
1354
+ if (sanitized != null) return sanitized;
1355
+ }
1356
+ } catch (err) {
1357
+ _didIteratorError1 = true;
1358
+ _iteratorError1 = err;
1359
+ } finally{
1360
+ try {
1361
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1362
+ _iterator1.return();
1363
+ }
1364
+ } finally{
1365
+ if (_didIteratorError1) {
1366
+ throw _iteratorError1;
1367
+ }
1368
+ }
1369
+ }
1370
+ }
1371
+ } catch (err) {
1372
+ _didIteratorError = true;
1373
+ _iteratorError = err;
1374
+ } finally{
1375
+ try {
1376
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1377
+ _iterator.return();
1378
+ }
1379
+ } finally{
1380
+ if (_didIteratorError) {
1381
+ throw _iteratorError;
1382
+ }
1383
+ }
1384
+ }
1385
+ return void 0;
1386
+ }
1387
+ function readBridgeContentValue(keys) {
1388
+ return readBridgeValue2(keys, sanitizeContentValue);
1389
+ }
1390
+ function resolveContentMetadata(config) {
1391
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1392
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1393
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1394
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1395
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1396
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1397
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1398
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1399
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1400
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1401
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1402
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1403
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1404
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1405
+ return _object_spread({}, channelName ? {
1406
+ channelName: channelName
1407
+ } : {}, programTitle ? {
1408
+ programTitle: programTitle
1409
+ } : {}, contentNetwork ? {
1410
+ contentNetwork: contentNetwork
1411
+ } : {}, contentType ? {
1412
+ contentType: contentType
1413
+ } : {}, contentCategory ? {
1414
+ contentCategory: contentCategory
1415
+ } : {}, contentGenre ? {
1416
+ contentGenre: contentGenre
1417
+ } : {}, contentLanguage ? {
1418
+ contentLanguage: contentLanguage
1419
+ } : {}, contentDurationSeconds != null ? {
1420
+ contentDurationSeconds: contentDurationSeconds
1421
+ } : {}, contentSeason ? {
1422
+ contentSeason: contentSeason
1423
+ } : {}, contentEpisode ? {
1424
+ contentEpisode: contentEpisode
1425
+ } : {}, contentRating ? {
1426
+ contentRating: contentRating
1427
+ } : {}, contentId ? {
1428
+ contentId: contentId
1429
+ } : {});
1430
+ }
1431
+ function applyContentMetadataUpdate(target, meta) {
1432
+ var apply = function apply(key, value) {
1433
+ if (value === void 0) return;
1434
+ var clean = value === null ? void 0 : sanitizeContentValue(value);
1435
+ if (clean) target[key] = clean;
1436
+ else delete target[key];
1437
+ };
1438
+ apply("channelName", meta.channelName);
1439
+ apply("programTitle", meta.programTitle);
1440
+ apply("contentNetwork", meta.contentNetwork);
1441
+ if (meta.details === void 0) return;
1442
+ if (meta.details === null) delete target.contentDetails;
1443
+ else target.contentDetails = _object_spread({}, meta.details);
1444
+ }
1445
+ function appendMissingContentParams(url, meta) {
1446
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1447
+ try {
1448
+ var parsed = new URL(url);
1449
+ var add = function add(key, value) {
1450
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1451
+ };
1452
+ add("ct_ch", meta.channelName);
1453
+ add("ct_ti", meta.programTitle);
1454
+ add("ct_ne", meta.contentNetwork);
1455
+ return parsed.toString();
1456
+ } catch (unused) {
1457
+ return url;
1458
+ }
1459
+ }
1460
+ // src/utils/partnerSignals.ts
1461
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1462
+ "aaid",
1463
+ "adid",
1464
+ "afai",
1465
+ "idfa",
1466
+ "lgudid",
1467
+ "msai",
1468
+ "rida",
1469
+ "tifa",
1470
+ "tvos",
1471
+ "vaid",
1472
+ "vida"
1473
+ ]);
1474
+ function toIabIfaType(deviceIdType, source) {
1475
+ if (!deviceIdType) return void 0;
1476
+ var type = deviceIdType.trim().toLowerCase();
1477
+ if (source === "generated") return "sessionid";
1478
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1479
+ if (source === "platform") return "dpid";
1480
+ return "ppid";
1481
+ }
1482
+ function playbackMethodCode(autoPlay, muted) {
1483
+ if (autoPlay === false) return 3;
1484
+ if (autoPlay !== true || muted == null) return void 0;
1485
+ return muted ? 2 : 1;
1486
+ }
1487
+ function resolvePlayerSize(video) {
1488
+ var width = video ? video.clientWidth : 0;
1489
+ var height = video ? video.clientHeight : 0;
1490
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1491
+ width = window.innerWidth;
1492
+ height = window.innerHeight;
1493
+ }
1494
+ if (!(width > 0 && height > 0)) return {};
1495
+ return {
1496
+ width: Math.round(width),
1497
+ height: Math.round(height)
1498
+ };
1499
+ }
1500
+ function sanitizeUserId(value) {
1501
+ var cleaned = sanitizeContentValue(value);
1502
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1503
+ return cleaned;
1504
+ }
1505
+ function isPublicIpv4(ip) {
1506
+ var parts = ip.split(".");
1507
+ if (parts.length !== 4) return false;
1508
+ var nums = parts.map(function(p) {
1509
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1510
+ });
1511
+ if (nums.some(function(n) {
1512
+ return !(n >= 0 && n <= 255);
1513
+ })) return false;
1514
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1515
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1516
+ if (a === 100 && b >= 64 && b <= 127) return false;
1517
+ if (a === 169 && b === 254) return false;
1518
+ if (a === 172 && b >= 16 && b <= 31) return false;
1519
+ if (a === 192 && b === 168) return false;
1520
+ return true;
1521
+ }
1522
+ function isPublicIpv6(ip) {
1523
+ var lower = ip.toLowerCase();
1524
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1525
+ if (lower === "::" || lower === "::1") return false;
1526
+ if (/^fe[89ab]/.test(lower)) return false;
1527
+ if (/^f[cd]/.test(lower)) return false;
1528
+ return true;
1529
+ }
1530
+ function sanitizePublicIp(value) {
1531
+ var cleaned = sanitizeContentValue(value);
1532
+ if (!cleaned) return void 0;
1533
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1534
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1535
+ }
1536
+ function resolveUserId(configValue) {
1537
+ var _sanitizeUserId;
1538
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1539
+ "userId",
1540
+ "uid"
1541
+ ], sanitizeUserId);
1542
+ }
1543
+ function resolveClientIp(configValue) {
1544
+ var _sanitizePublicIp;
1545
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1546
+ "ipAddress",
1547
+ "clientIp",
1548
+ "ip"
1549
+ ], sanitizePublicIp);
1550
+ }
1249
1551
  // src/utils/vastMacros.ts
1250
1552
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1251
1553
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1563,7 +1865,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1563
1865
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1564
1866
  "PMND",
1565
1867
  "PMXD",
1566
- "PMAD"
1868
+ "PMAD",
1869
+ "MABD"
1567
1870
  ]);
1568
1871
  function hasScvpMacros(url) {
1569
1872
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1608,6 +1911,8 @@ function resolveScvpMacroValues(ctx) {
1608
1911
  set("RDID", deviceId);
1609
1912
  set("IDTYPE", deviceIdType);
1610
1913
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1914
+ set("IFA", deviceId);
1915
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1611
1916
  }
1612
1917
  set("SID", ctx.sessionId);
1613
1918
  set("DTH", ctx.deviceTypeHint);
@@ -1625,6 +1930,26 @@ function resolveScvpMacroValues(ctx) {
1625
1930
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1626
1931
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1627
1932
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1933
+ set("PLAYER-WIDTH", ctx.playerWidth);
1934
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1935
+ set("TIMESTAMP", ctx.timestamp);
1936
+ set("LIVE", toFlag(ctx.isLive));
1937
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1938
+ set("DEVICE-MAKE", ctx.deviceMake);
1939
+ set("DEVICE-MODEL", ctx.deviceModel);
1940
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1941
+ set("UA", ctx.userAgent);
1942
+ set("IP", ctx.ipAddress);
1943
+ set("UID", ctx.userId);
1944
+ set("CT-TYPE", ctx.contentType);
1945
+ set("CT-CATEGORY", ctx.contentCategory);
1946
+ set("CT-GENRE", ctx.contentGenre);
1947
+ set("CT-LANGUAGE", ctx.contentLanguage);
1948
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1949
+ set("CT-SEASON", ctx.contentSeason);
1950
+ set("CT-EPISODE", ctx.contentEpisode);
1951
+ set("CT-RATING", ctx.contentRating);
1952
+ set("CT-ID", ctx.contentId);
1628
1953
  return values;
1629
1954
  }
1630
1955
  var keepNone = function keepNone() {
@@ -2840,15 +3165,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2840
3165
  values.set("PMND", String(pod.pmnd));
2841
3166
  values.set("PMXD", String(pod.pmxd));
2842
3167
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
3168
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2843
3169
  }
2844
3170
  var substituted = substituteScvpMacros(rawUrl, values);
2845
3171
  var finalUrl;
2846
3172
  try {
2847
3173
  var url = new URL(normalizeVastTagUrl(substituted.url));
3174
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
3175
+ var setPodParam = function setPodParam(key, value) {
3176
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
3177
+ };
2848
3178
  if (pod) {
2849
- url.searchParams.set("pmnd", String(pod.pmnd));
2850
- url.searchParams.set("pmxd", String(pod.pmxd));
2851
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
3179
+ setPodParam("pmnd", pod.pmnd);
3180
+ setPodParam("pmxd", pod.pmxd);
3181
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
2852
3182
  else url.searchParams.delete("pmad");
2853
3183
  } else {
2854
3184
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2914,7 +3244,9 @@ function validateGamRequestUrl(url, expect) {
2914
3244
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2915
3245
  var params;
2916
3246
  try {
2917
- params = new URL(url).searchParams;
3247
+ var parsed = new URL(url);
3248
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
3249
+ params = parsed.searchParams;
2918
3250
  } catch (unused) {
2919
3251
  return problems.concat("URL could not be parsed");
2920
3252
  }
@@ -6335,7 +6667,7 @@ function safeCall2(fn, thisArg) {
6335
6667
  function userAgent() {
6336
6668
  return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
6337
6669
  }
6338
- function bridgeSources() {
6670
+ function bridgeSources2() {
6339
6671
  if (typeof window === "undefined") return [];
6340
6672
  var w = window;
6341
6673
  return [
@@ -6347,7 +6679,7 @@ function bridgeSources() {
6347
6679
  function readBridge(keys) {
6348
6680
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6349
6681
  try {
6350
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6682
+ for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6351
6683
  var source = _step.value;
6352
6684
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6353
6685
  try {
@@ -6394,6 +6726,11 @@ function readBridge(keys) {
6394
6726
  }
6395
6727
  return void 0;
6396
6728
  }
6729
+ function makeForCategory(category) {
6730
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
6731
+ if (category === "Samsung TV") return "Samsung";
6732
+ return void 0;
6733
+ }
6397
6734
  function normalizeCategory(value) {
6398
6735
  var v = cleanString(value);
6399
6736
  if (!v) return void 0;
@@ -6541,7 +6878,7 @@ function primeDeviceInfo() {
6541
6878
  return primePromise;
6542
6879
  }
6543
6880
  function getDeviceInfo() {
6544
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
6881
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
6545
6882
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
6546
6883
  if (primePromise && !platformCache) {} else {
6547
6884
  platformCache = platform;
@@ -6564,7 +6901,14 @@ function getDeviceInfo() {
6564
6901
  ]),
6565
6902
  category: normalizeCategory(readBridge([
6566
6903
  "deviceCategory"
6567
- ]))
6904
+ ])),
6905
+ make: readBridge([
6906
+ "deviceMake"
6907
+ ]),
6908
+ hardwareVersion: readBridge([
6909
+ "deviceHardwareVersion",
6910
+ "hardwareVersion"
6911
+ ])
6568
6912
  };
6569
6913
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
6570
6914
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -6577,7 +6921,9 @@ function getDeviceInfo() {
6577
6921
  bridge.internalDeviceId,
6578
6922
  bridge.model,
6579
6923
  bridge.firmware,
6580
- bridge.category
6924
+ bridge.category,
6925
+ bridge.make,
6926
+ bridge.hardwareVersion
6581
6927
  ];
6582
6928
  if (bridgeValues.some(function(v) {
6583
6929
  return v !== void 0;
@@ -6585,12 +6931,18 @@ function getDeviceInfo() {
6585
6931
  if (hostDeviceInfo) sources.unshift("host");
6586
6932
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
6587
6933
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
6934
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
6935
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
6588
6936
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
6589
6937
  return _object_spread_props(_object_spread({
6590
6938
  category: category,
6591
6939
  categoryCode: CATEGORY_CODES[category]
6592
- }, model ? {
6940
+ }, make ? {
6941
+ make: make
6942
+ } : {}, model ? {
6593
6943
  model: model
6944
+ } : {}, hardwareVersion ? {
6945
+ hardwareVersion: hardwareVersion
6594
6946
  } : {}, sonifiModel ? {
6595
6947
  sonifiModel: sonifiModel
6596
6948
  } : {}, firmware ? {
@@ -6681,117 +7033,6 @@ function deviceInfoAnalyticsFields(info) {
6681
7033
  terminal_id: info.terminalId
6682
7034
  } : {});
6683
7035
  }
6684
- // src/utils/contentMetadata.ts
6685
- var MAX_CONTENT_VALUE_LENGTH = 128;
6686
- var BRIDGE_KEYS = {
6687
- channelName: [
6688
- "channelName",
6689
- "ct_ch"
6690
- ],
6691
- programTitle: [
6692
- "programTitle",
6693
- "ct_ti"
6694
- ],
6695
- contentNetwork: [
6696
- "contentNetwork",
6697
- "ct_ne"
6698
- ]
6699
- };
6700
- function sanitizeContentValue(value) {
6701
- if (typeof value !== "string") return void 0;
6702
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
6703
- if (!cleaned) return void 0;
6704
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
6705
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
6706
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
6707
- }
6708
- function bridgeSources2() {
6709
- if (typeof window === "undefined") return [];
6710
- var w = window;
6711
- return [
6712
- w.__STORMCLOUD_CTV__,
6713
- w.__STORMCLOUD_CTV_AD_INFO__,
6714
- w.stormcloudCtv
6715
- ].filter(Boolean);
6716
- }
6717
- function readBridgeContentValue(keys) {
6718
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
6719
- try {
6720
- for(var _iterator = bridgeSources2()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
6721
- var source = _step.value;
6722
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
6723
- try {
6724
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
6725
- var key = _step1.value;
6726
- var value = void 0;
6727
- try {
6728
- value = source === null || source === void 0 ? void 0 : source[key];
6729
- if (typeof value === "function") value = value.call(source);
6730
- } catch (unused) {
6731
- value = void 0;
6732
- }
6733
- var sanitized = sanitizeContentValue(value);
6734
- if (sanitized) return sanitized;
6735
- }
6736
- } catch (err) {
6737
- _didIteratorError1 = true;
6738
- _iteratorError1 = err;
6739
- } finally{
6740
- try {
6741
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
6742
- _iterator1.return();
6743
- }
6744
- } finally{
6745
- if (_didIteratorError1) {
6746
- throw _iteratorError1;
6747
- }
6748
- }
6749
- }
6750
- }
6751
- } catch (err) {
6752
- _didIteratorError = true;
6753
- _iteratorError = err;
6754
- } finally{
6755
- try {
6756
- if (!_iteratorNormalCompletion && _iterator.return != null) {
6757
- _iterator.return();
6758
- }
6759
- } finally{
6760
- if (_didIteratorError) {
6761
- throw _iteratorError;
6762
- }
6763
- }
6764
- }
6765
- return void 0;
6766
- }
6767
- function resolveContentMetadata(config) {
6768
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
6769
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
6770
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
6771
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
6772
- return _object_spread({}, channelName ? {
6773
- channelName: channelName
6774
- } : {}, programTitle ? {
6775
- programTitle: programTitle
6776
- } : {}, contentNetwork ? {
6777
- contentNetwork: contentNetwork
6778
- } : {});
6779
- }
6780
- function appendMissingContentParams(url, meta) {
6781
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
6782
- try {
6783
- var parsed = new URL(url);
6784
- var add = function add(key, value) {
6785
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
6786
- };
6787
- add("ct_ch", meta.channelName);
6788
- add("ct_ti", meta.programTitle);
6789
- add("ct_ne", meta.contentNetwork);
6790
- return parsed.toString();
6791
- } catch (unused) {
6792
- return url;
6793
- }
6794
- }
6795
7036
  // src/utils/screenActivity.ts
6796
7037
  var hostStandby = false;
6797
7038
  function setHostStandby(standby) {
@@ -8793,6 +9034,13 @@ var Scte35CueManager = /*#__PURE__*/ function() {
8793
9034
  return Scte35CueManager;
8794
9035
  }();
8795
9036
  // src/player/AdConfigManager.ts
9037
+ function isGamAdUrl(rawUrl) {
9038
+ try {
9039
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
9040
+ } catch (unused) {
9041
+ return false;
9042
+ }
9043
+ }
8796
9044
  function withDeferredPodParams(rawUrl, deferNonce) {
8797
9045
  try {
8798
9046
  var url = new URL(rawUrl);
@@ -8810,11 +9058,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
8810
9058
  }
8811
9059
  var AdConfigManager = /*#__PURE__*/ function() {
8812
9060
  function AdConfigManager(config, video) {
9061
+ var _this = this;
8813
9062
  _class_call_check(this, AdConfigManager);
8814
9063
  this.vmapBreaks = [];
8815
9064
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
8816
9065
  this.streamCorrelator = generateCorrelator();
8817
9066
  this.consentSignals = {};
9067
+ this.isLiveStream = function() {
9068
+ return !!_this.config.isLiveStream;
9069
+ };
8818
9070
  this.podCounter = 0;
8819
9071
  this.podAssignedByPrefetch = false;
8820
9072
  this.lastHeartbeatTime = 0;
@@ -9265,13 +9517,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
9265
9517
  {
9266
9518
  key: "generatePodVastUrl",
9267
9519
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
9520
+ var _content_contentDurationSeconds;
9268
9521
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
9269
9522
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
9270
9523
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
9271
9524
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
9272
9525
  });
9273
9526
  var content = resolveContentMetadata(this.config);
9274
- var macroContext = _object_spread_props(_object_spread({
9527
+ var isLive = this.isLiveStream();
9528
+ var device = getDeviceInfo();
9529
+ var playerSize = resolvePlayerSize(this.video);
9530
+ var videoDuration = this.video.duration;
9531
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
9532
+ var userId = resolveUserId(this.config.adUserId);
9533
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
9534
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
9535
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
9275
9536
  correlator: this.viewCorrelator,
9276
9537
  streamCorrelator: this.streamCorrelator,
9277
9538
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -9293,8 +9554,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
9293
9554
  contentNetwork: content.contentNetwork
9294
9555
  } : {}), {
9295
9556
  consent: this.consentSignals,
9296
- palNonce: palNonce.getCurrentNonce() || void 0
9297
- });
9557
+ palNonce: palNonce.getCurrentNonce() || void 0,
9558
+ deviceIdSource: envSignals.deviceIdSource,
9559
+ isLive: isLive
9560
+ }), playerSize.width ? {
9561
+ playerWidth: playerSize.width
9562
+ } : {}, playerSize.height ? {
9563
+ playerHeight: playerSize.height
9564
+ } : {}), {
9565
+ timestamp: String(Date.now())
9566
+ }), device.make ? {
9567
+ deviceMake: device.make
9568
+ } : {}, device.model ? {
9569
+ deviceModel: device.model
9570
+ } : {}, device.hardwareVersion ? {
9571
+ deviceHardwareVersion: device.hardwareVersion
9572
+ } : {}, userAgent2 ? {
9573
+ userAgent: userAgent2
9574
+ } : {}, ipAddress ? {
9575
+ ipAddress: ipAddress
9576
+ } : {}, userId ? {
9577
+ userId: userId
9578
+ } : {}, content.contentType ? {
9579
+ contentType: content.contentType
9580
+ } : {}, content.contentCategory ? {
9581
+ contentCategory: content.contentCategory
9582
+ } : {}, content.contentGenre ? {
9583
+ contentGenre: content.contentGenre
9584
+ } : {}, content.contentLanguage ? {
9585
+ contentLanguage: content.contentLanguage
9586
+ } : {}, contentDurationSeconds != null ? {
9587
+ contentDurationSeconds: contentDurationSeconds
9588
+ } : {}, content.contentSeason ? {
9589
+ contentSeason: content.contentSeason
9590
+ } : {}, content.contentEpisode ? {
9591
+ contentEpisode: content.contentEpisode
9592
+ } : {}, content.contentRating ? {
9593
+ contentRating: content.contentRating
9594
+ } : {}, content.contentId ? {
9595
+ contentId: content.contentId
9596
+ } : {});
9298
9597
  var nonceReady = !!macroContext.palNonce;
9299
9598
  var finalUrl;
9300
9599
  if (hasScvpMacros(baseUrl)) {
@@ -9308,9 +9607,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
9308
9607
  } else {
9309
9608
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
9310
9609
  }
9311
- finalUrl = appendMissingContentParams(finalUrl, content);
9312
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9313
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
9610
+ if (isGamAdUrl(finalUrl)) {
9611
+ finalUrl = appendMissingContentParams(finalUrl, content);
9612
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
9613
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
9614
+ }
9314
9615
  }
9315
9616
  if (this.debug) {
9316
9617
  var id = envSignals.deviceId;
@@ -9323,7 +9624,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
9323
9624
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
9324
9625
  ct_ch: content.channelName,
9325
9626
  ct_ti: content.programTitle,
9326
- ct_ne: content.contentNetwork
9627
+ ct_ne: content.contentNetwork,
9628
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9629
+ live: isLive,
9630
+ player: playerSize,
9631
+ make: device.make,
9632
+ model: device.model
9327
9633
  });
9328
9634
  }
9329
9635
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
@@ -13494,6 +13800,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13494
13800
  return !!_this.adBreak && _this.adBreak.inAdBreak && !_this.shouldContinueLiveStreamDuringAds();
13495
13801
  }
13496
13802
  });
13803
+ this.adConfig.isLiveStream = function() {
13804
+ return _this.hlsEngine.isLiveStream;
13805
+ };
13497
13806
  this.adBreak = new AdBreakOrchestrator({
13498
13807
  config: this.config,
13499
13808
  video: this.video,
@@ -13855,16 +14164,20 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
13855
14164
  {
13856
14165
  key: "setContentMetadata",
13857
14166
  value: function setContentMetadata(meta) {
13858
- var _this = this;
13859
- var apply = function apply(key, value) {
13860
- if (value === void 0) return;
13861
- var clean = value === null ? void 0 : sanitizeContentValue(value);
13862
- if (clean) _this.config[key] = clean;
13863
- else delete _this.config[key];
13864
- };
13865
- apply("channelName", meta.channelName);
13866
- apply("programTitle", meta.programTitle);
13867
- apply("contentNetwork", meta.contentNetwork);
14167
+ applyContentMetadataUpdate(this.config, meta);
14168
+ }
14169
+ },
14170
+ {
14171
+ key: "setRequestSignals",
14172
+ value: function setRequestSignals(signals) {
14173
+ if (signals.userId !== void 0) {
14174
+ if (signals.userId) this.config.adUserId = signals.userId;
14175
+ else delete this.config.adUserId;
14176
+ }
14177
+ if (signals.ipAddress !== void 0) {
14178
+ if (signals.ipAddress) this.config.clientIpAddress = signals.ipAddress;
14179
+ else delete this.config.clientIpAddress;
14180
+ }
13868
14181
  }
13869
14182
  },
13870
14183
  {