stormcloud-video-player 0.8.79 → 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 (90) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.cjs +6 -0
  3. package/lib/Player.cjs.map +1 -1
  4. package/lib/Player.d.cts +4 -1
  5. package/lib/StormcloudPlayer.cjs +1459 -167
  6. package/lib/StormcloudPlayer.cjs.map +1 -1
  7. package/lib/StormcloudPlayer.d.cts +3 -0
  8. package/lib/index.cjs +1547 -169
  9. package/lib/index.cjs.map +1 -1
  10. package/lib/index.d.cts +3 -0
  11. package/lib/index.d.ts +89 -3
  12. package/lib/index.js +1547 -169
  13. package/lib/index.js.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.cjs +452 -88
  15. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  16. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  17. package/lib/player/AdConfigManager.cjs +1024 -97
  18. package/lib/player/AdConfigManager.cjs.map +1 -1
  19. package/lib/player/AdConfigManager.d.cts +2 -0
  20. package/lib/player/AdTimingService.cjs +0 -9
  21. package/lib/player/AdTimingService.cjs.map +1 -1
  22. package/lib/player/AdTimingService.d.cts +1 -0
  23. package/lib/player/EdgePodRequest.d.cts +1 -0
  24. package/lib/player/FloorLadder.cjs +3 -0
  25. package/lib/player/FloorLadder.cjs.map +1 -1
  26. package/lib/player/FloorLadder.d.cts +1 -0
  27. package/lib/player/HlsEngine.cjs +7 -1
  28. package/lib/player/HlsEngine.cjs.map +1 -1
  29. package/lib/player/HlsEngine.d.cts +2 -0
  30. package/lib/player/OptimizedPodRequest.cjs +21 -6
  31. package/lib/player/OptimizedPodRequest.cjs.map +1 -1
  32. package/lib/player/OptimizedPodRequest.d.cts +1 -1
  33. package/lib/player/PlayerControls.d.cts +1 -0
  34. package/lib/player/Scte35CueManager.d.cts +1 -0
  35. package/lib/player/Scte35Parser.d.cts +1 -0
  36. package/lib/player/StormcloudVideoPlayer.cjs +1459 -167
  37. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  38. package/lib/player/StormcloudVideoPlayer.d.cts +19 -1
  39. package/lib/player/playerTypes.d.cts +1 -0
  40. package/lib/players/HlsPlayer.cjs +1459 -167
  41. package/lib/players/HlsPlayer.cjs.map +1 -1
  42. package/lib/players/HlsPlayer.d.cts +1 -0
  43. package/lib/players/index.cjs +1459 -167
  44. package/lib/players/index.cjs.map +1 -1
  45. package/lib/props.cjs +6 -0
  46. package/lib/props.cjs.map +1 -1
  47. package/lib/props.d.cts +3 -0
  48. package/lib/sdk/hlsAdPlayer.cjs +32 -3
  49. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  50. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  51. package/lib/sdk/pal.cjs +10 -3
  52. package/lib/sdk/pal.cjs.map +1 -1
  53. package/lib/sdk/pal.d.cts +3 -0
  54. package/lib/types.d.cts +29 -1
  55. package/lib/ui/StormcloudVideoPlayer.cjs +1547 -169
  56. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  57. package/lib/ui/StormcloudVideoPlayer.d.cts +3 -0
  58. package/lib/utils/__tests__/adSignals.test.cjs +25817 -0
  59. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -0
  60. package/lib/utils/__tests__/adSignals.test.d.cts +2 -0
  61. package/lib/utils/adIdentity.cjs +421 -0
  62. package/lib/utils/adIdentity.cjs.map +1 -0
  63. package/lib/utils/adIdentity.d.cts +30 -0
  64. package/lib/utils/browserCompat.cjs +13 -0
  65. package/lib/utils/browserCompat.cjs.map +1 -1
  66. package/lib/utils/browserCompat.d.cts +2 -1
  67. package/lib/utils/contentMetadata.cjs +324 -0
  68. package/lib/utils/contentMetadata.cjs.map +1 -0
  69. package/lib/utils/contentMetadata.d.cts +51 -0
  70. package/lib/utils/ctvVastSignals.cjs +250 -181
  71. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  72. package/lib/utils/deviceInfo.cjs +698 -0
  73. package/lib/utils/deviceInfo.cjs.map +1 -0
  74. package/lib/utils/deviceInfo.d.cts +46 -0
  75. package/lib/utils/partnerSignals.cjs +294 -0
  76. package/lib/utils/partnerSignals.cjs.map +1 -0
  77. package/lib/utils/partnerSignals.d.cts +12 -0
  78. package/lib/utils/screenActivity.cjs +125 -0
  79. package/lib/utils/screenActivity.cjs.map +1 -0
  80. package/lib/utils/screenActivity.d.cts +5 -0
  81. package/lib/utils/tracking.cjs +406 -56
  82. package/lib/utils/tracking.cjs.map +1 -1
  83. package/lib/utils/tracking.d.cts +2 -1
  84. package/lib/utils/vastEnvironmentSignals.cjs +255 -85
  85. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  86. package/lib/utils/vastEnvironmentSignals.d.cts +8 -2
  87. package/lib/utils/vastMacros.cjs +58 -1
  88. package/lib/utils/vastMacros.cjs.map +1 -1
  89. package/lib/utils/vastMacros.d.cts +21 -0
  90. package/package.json +1 -1
@@ -344,6 +344,50 @@ __export(AdBreakOrchestrator_exports, {
344
344
  }
345
345
  });
346
346
  module.exports = __toCommonJS(AdBreakOrchestrator_exports);
347
+ // src/utils/adIdentity.ts
348
+ var MAX_SESSION_ID_AGE_MS = 6 * 60 * 60 * 1e3;
349
+ var DEFAULT_FALLBACK_DEVICE_ID_MAX_AGE_MS = 24 * 60 * 60 * 1e3;
350
+ var ZEROED_IDS = /* @__PURE__ */ new Set([
351
+ "00000000-0000-0000-0000-000000000000",
352
+ "38400000-8cf0-11bd-b23e-10b96e40000d"
353
+ ]);
354
+ var lgUdidResult;
355
+ function isUsableAdId(value) {
356
+ if (typeof value !== "string") return false;
357
+ var t = value.trim();
358
+ if (!t) return false;
359
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(t)) return false;
360
+ if (/^(unknown|null|undefined|none|n\/a)$/i.test(t)) return false;
361
+ return !ZEROED_IDS.has(t.toLowerCase());
362
+ }
363
+ function isZeroedAdId(value) {
364
+ return typeof value === "string" && ZEROED_IDS.has(value.trim().toLowerCase());
365
+ }
366
+ function readSamsungTifa() {
367
+ try {
368
+ var _window_webapis;
369
+ var adinfo = typeof window !== "undefined" ? (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo : void 0;
370
+ if (!adinfo) return void 0;
371
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
372
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
373
+ if (isZeroedAdId(tifa)) return {
374
+ deviceIdType: "tifa",
375
+ limitAdTracking: true
376
+ };
377
+ if (!isUsableAdId(tifa)) return void 0;
378
+ return _object_spread({
379
+ deviceId: tifa.trim(),
380
+ deviceIdType: "tifa"
381
+ }, typeof lat === "boolean" ? {
382
+ limitAdTracking: lat
383
+ } : {});
384
+ } catch (unused) {
385
+ return void 0;
386
+ }
387
+ }
388
+ function readCachedLgUdid() {
389
+ return lgUdidResult ? _object_spread({}, lgUdidResult) : void 0;
390
+ }
347
391
  // src/utils/vastEnvironmentSignals.ts
348
392
  var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
349
393
  var DEVICE_ID_STORAGE_KEYS = [
@@ -384,26 +428,12 @@ var DEVICE_TYPE_HINT_ALIASES = {
384
428
  stb: DEVICE_TYPE_HINT.SET_TOP_BOX,
385
429
  settopbox: DEVICE_TYPE_HINT.SET_TOP_BOX
386
430
  };
387
- function inferDeviceIdType() {
388
- if (typeof navigator === "undefined") {
389
- return void 0;
390
- }
391
- var ua = navigator.userAgent;
392
- if (/Roku/i.test(ua)) return "rida";
393
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
394
- if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
395
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
396
- if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
397
- if (/Android|Google TV/i.test(ua)) return "aaid";
398
- if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
399
- return void 0;
400
- }
401
431
  function resolveNativeDeviceId() {
402
432
  var includeStored = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : true;
403
433
  var bridgeSignals = readNativeBridgeSignals();
404
434
  var platformDevice = readPlatformNativeDeviceId();
405
435
  var deviceId = bridgeSignals.deviceId || (includeStored ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
406
- if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
436
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId2(deviceId)) {
407
437
  return void 0;
408
438
  }
409
439
  return deviceId;
@@ -507,44 +537,10 @@ function performanceNow() {
507
537
  }
508
538
  function readPlatformNativeDeviceId() {
509
539
  if (typeof window === "undefined") return {};
510
- try {
511
- var _window_webapis;
512
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
513
- if (adinfo) {
514
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
515
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
516
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
517
- return _object_spread({
518
- deviceId: tifa,
519
- deviceIdType: "tifa"
520
- }, typeof lat === "boolean" ? {
521
- limitAdTracking: lat
522
- } : {});
523
- }
524
- }
525
- } catch (unused) {}
526
- try {
527
- var webOSDev = window.webOSDev;
528
- if (webOSDev) {
529
- var _webOSDev_lgudid;
530
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
531
- if (typeof lgudid === "string" && lgudid) {
532
- if (isZeroedAdId(lgudid)) {
533
- return {
534
- deviceIdType: "lgudid",
535
- limitAdTracking: true
536
- };
537
- }
538
- if (!isMacroPlaceholder(lgudid)) {
539
- return {
540
- deviceId: lgudid,
541
- deviceIdType: "lgudid",
542
- limitAdTracking: false
543
- };
544
- }
545
- }
546
- }
547
- } catch (unused) {}
540
+ var tifa = readSamsungTifa();
541
+ if (tifa) return tifa;
542
+ var lgudid = readCachedLgUdid();
543
+ if (lgudid) return lgudid;
548
544
  try {
549
545
  var roku = window.Roku;
550
546
  if (roku) {
@@ -568,7 +564,7 @@ function isMacroPlaceholder(value) {
568
564
  var t = value.trim();
569
565
  return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
570
566
  }
571
- function isZeroedAdId(value) {
567
+ function isZeroedAdId2(value) {
572
568
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
573
569
  }
574
570
  function readNativeBridgeSignals() {
@@ -612,7 +608,7 @@ function readNativeBridgeSignals() {
612
608
  "deviceIdType",
613
609
  "advertisingIdType",
614
610
  "idType"
615
- ]) || inferDeviceIdType();
611
+ ]) || void 0;
616
612
  var limitAdTracking = readBridgeBoolean(source, [
617
613
  "is_lat",
618
614
  "limitAdTracking",
@@ -900,7 +896,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
900
896
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
901
897
  "PMND",
902
898
  "PMXD",
903
- "PMAD"
899
+ "PMAD",
900
+ "MABD"
904
901
  ]);
905
902
  function safeDecode(value) {
906
903
  try {
@@ -1293,6 +1290,307 @@ function ingestPlayerTracking(licenseKey, channel, body) {
1293
1290
  });
1294
1291
  })();
1295
1292
  }
1293
+ // src/utils/deviceInfo.ts
1294
+ var CATEGORY_CODES = {
1295
+ "LG TV": "lg_tv",
1296
+ "LG Set-Top Box": "lg_stb",
1297
+ "Samsung TV": "samsung_tv",
1298
+ Other: "other"
1299
+ };
1300
+ var DEVICE_CATEGORIES = [
1301
+ "LG TV",
1302
+ "LG Set-Top Box",
1303
+ "Samsung TV",
1304
+ "Other"
1305
+ ];
1306
+ var hostDeviceInfo;
1307
+ var lgDeviceInfo;
1308
+ var platformCache;
1309
+ var primePromise;
1310
+ function cleanString(value) {
1311
+ var maxLength = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 128;
1312
+ if (typeof value !== "string") return void 0;
1313
+ var t = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1314
+ if (!t || /^(unknown|null|undefined|none|n\/a|-|0)$/i.test(t)) return void 0;
1315
+ return t.length > maxLength ? t.slice(0, maxLength) : t;
1316
+ }
1317
+ function safeCall(fn, thisArg) {
1318
+ if (typeof fn !== "function") return void 0;
1319
+ try {
1320
+ return fn.call(thisArg);
1321
+ } catch (unused) {
1322
+ return void 0;
1323
+ }
1324
+ }
1325
+ function userAgent() {
1326
+ return typeof navigator !== "undefined" ? navigator.userAgent || "" : "";
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 readBridge(keys) {
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 clean = cleanString(value);
1354
+ if (clean) return clean;
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 makeForCategory(category) {
1388
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
1389
+ if (category === "Samsung TV") return "Samsung";
1390
+ return void 0;
1391
+ }
1392
+ function normalizeCategory(value) {
1393
+ var v = cleanString(value);
1394
+ if (!v) return void 0;
1395
+ var exact = DEVICE_CATEGORIES.find(function(c) {
1396
+ return c.toLowerCase() === v.toLowerCase();
1397
+ });
1398
+ if (exact) return exact;
1399
+ var code = v.toLowerCase().replace(/[\s-]+/g, "_");
1400
+ var byCode = Object.keys(CATEGORY_CODES).find(function(c) {
1401
+ return CATEGORY_CODES[c] === code;
1402
+ });
1403
+ return byCode;
1404
+ }
1405
+ function parseUserAgentDeviceInfo(ua) {
1406
+ var sources = [];
1407
+ var out = {
1408
+ platform: "other",
1409
+ sources: sources
1410
+ };
1411
+ var chrome = ua.match(/(?:Chrome|PCBR)\/(\d+)\./) || ua.match(/\s(\d{2,3})\.\d+\.\d+\.\d+\/[\d.]+\s+TV\b/);
1412
+ if (chrome && chrome[1]) out.browserMajorVersion = parseInt(chrome[1], 10);
1413
+ if (/Web0S|webOS/i.test(ua)) {
1414
+ out.platform = "webos";
1415
+ var lg = ua.match(/LGE\s*;\s*([A-Za-z0-9][A-Za-z0-9._-]*)\s*;\s*(\d{2}\.\d{2}\.\d{2})/);
1416
+ if (lg && lg[1] && lg[2]) {
1417
+ out.model = lg[1];
1418
+ out.firmware = lg[2];
1419
+ sources.push("user_agent");
1420
+ }
1421
+ } else if (/Tizen/i.test(ua)) {
1422
+ out.platform = "tizen";
1423
+ var tizen = ua.match(/Tizen\s+(\d+(?:\.\d+)*)/i);
1424
+ if (tizen && tizen[1]) {
1425
+ out.osVersion = "Tizen ".concat(tizen[1]);
1426
+ sources.push("user_agent");
1427
+ }
1428
+ }
1429
+ return out;
1430
+ }
1431
+ function readSamsungProductInfo() {
1432
+ var _cleanString;
1433
+ var _window_webapis;
1434
+ if (typeof window === "undefined") return void 0;
1435
+ var productinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.productinfo;
1436
+ if (!productinfo) return void 0;
1437
+ var model = (_cleanString = cleanString(safeCall(productinfo.getRealModel, productinfo), 40)) !== null && _cleanString !== void 0 ? _cleanString : cleanString(safeCall(productinfo.getModel, productinfo), 40);
1438
+ var firmware = cleanString(safeCall(productinfo.getFirmware, productinfo), 64);
1439
+ var duid = cleanString(safeCall(productinfo.getDuid, productinfo), 128);
1440
+ if (!model && !firmware && !duid) return void 0;
1441
+ return _object_spread({}, model ? {
1442
+ model: model
1443
+ } : {}, firmware ? {
1444
+ firmware: firmware
1445
+ } : {}, duid ? {
1446
+ internalDeviceId: duid,
1447
+ internalDeviceIdSource: "samsung_duid"
1448
+ } : {});
1449
+ }
1450
+ function computePlatformInfo() {
1451
+ var info = parseUserAgentDeviceInfo(userAgent());
1452
+ var sources = _to_consumable_array(info.sources);
1453
+ var samsung = readSamsungProductInfo();
1454
+ if (samsung) {
1455
+ info.platform = "tizen";
1456
+ if (samsung.model) info.model = samsung.model;
1457
+ if (samsung.firmware) info.firmware = samsung.firmware;
1458
+ if (samsung.internalDeviceId) {
1459
+ info.internalDeviceId = samsung.internalDeviceId;
1460
+ info.internalDeviceIdSource = "samsung_duid";
1461
+ }
1462
+ sources.push("samsung_productinfo");
1463
+ }
1464
+ if (lgDeviceInfo) {
1465
+ info.platform = "webos";
1466
+ if (!info.model && lgDeviceInfo.model) info.model = lgDeviceInfo.model;
1467
+ if (!info.firmware && lgDeviceInfo.firmware) info.firmware = lgDeviceInfo.firmware;
1468
+ if (lgDeviceInfo.sdkVersion) info.osVersion = "webOS TV ".concat(lgDeviceInfo.sdkVersion);
1469
+ sources.push("lg_deviceinfo");
1470
+ }
1471
+ var lgUdid = readCachedLgUdid();
1472
+ if ((lgUdid === null || lgUdid === void 0 ? void 0 : lgUdid.deviceId) && !info.internalDeviceId) {
1473
+ info.internalDeviceId = lgUdid.deviceId;
1474
+ info.internalDeviceIdSource = "lg_udid";
1475
+ sources.push("lg_udid");
1476
+ }
1477
+ info.sources = sources;
1478
+ return info;
1479
+ }
1480
+ function categorize(platform, model) {
1481
+ if (platform === "tizen") return "Samsung TV";
1482
+ if (platform === "webos") {
1483
+ var ua = userAgent();
1484
+ if (model && /^STB-/i.test(model) || /\bSTB-\d{4}|LGSTB/i.test(ua)) return "LG Set-Top Box";
1485
+ return "LG TV";
1486
+ }
1487
+ return "Other";
1488
+ }
1489
+ function getDeviceInfo() {
1490
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
1491
+ var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
1492
+ if (primePromise && !platformCache) {} else {
1493
+ platformCache = platform;
1494
+ }
1495
+ var host = hostDeviceInfo !== null && hostDeviceInfo !== void 0 ? hostDeviceInfo : {};
1496
+ var bridge = {
1497
+ terminalId: readBridge([
1498
+ "terminalId",
1499
+ "terminal_id"
1500
+ ]),
1501
+ internalDeviceId: readBridge([
1502
+ "internalDeviceId",
1503
+ "internal_device_id"
1504
+ ]),
1505
+ model: readBridge([
1506
+ "deviceModel"
1507
+ ]),
1508
+ firmware: readBridge([
1509
+ "firmwareVersion"
1510
+ ]),
1511
+ category: normalizeCategory(readBridge([
1512
+ "deviceCategory"
1513
+ ])),
1514
+ make: readBridge([
1515
+ "deviceMake"
1516
+ ]),
1517
+ hardwareVersion: readBridge([
1518
+ "deviceHardwareVersion",
1519
+ "hardwareVersion"
1520
+ ])
1521
+ };
1522
+ var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
1523
+ var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
1524
+ var model = (_ref = (_cleanString2 = cleanString(host.model, 40)) !== null && _cleanString2 !== void 0 ? _cleanString2 : bridge.model) !== null && _ref !== void 0 ? _ref : platform.model;
1525
+ var firmware = (_ref1 = (_cleanString3 = cleanString(host.firmware, 64)) !== null && _cleanString3 !== void 0 ? _cleanString3 : bridge.firmware) !== null && _ref1 !== void 0 ? _ref1 : platform.firmware;
1526
+ var category = (_ref2 = (_normalizeCategory = normalizeCategory(host.category)) !== null && _normalizeCategory !== void 0 ? _normalizeCategory : bridge.category) !== null && _ref2 !== void 0 ? _ref2 : categorize(platform.platform, model);
1527
+ var sources = _to_consumable_array(platform.sources);
1528
+ var bridgeValues = [
1529
+ bridge.terminalId,
1530
+ bridge.internalDeviceId,
1531
+ bridge.model,
1532
+ bridge.firmware,
1533
+ bridge.category,
1534
+ bridge.make,
1535
+ bridge.hardwareVersion
1536
+ ];
1537
+ if (bridgeValues.some(function(v) {
1538
+ return v !== void 0;
1539
+ })) sources.unshift("bridge");
1540
+ if (hostDeviceInfo) sources.unshift("host");
1541
+ var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
1542
+ var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
1543
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
1544
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
1545
+ var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
1546
+ return _object_spread_props(_object_spread({
1547
+ category: category,
1548
+ categoryCode: CATEGORY_CODES[category]
1549
+ }, make ? {
1550
+ make: make
1551
+ } : {}, model ? {
1552
+ model: model
1553
+ } : {}, hardwareVersion ? {
1554
+ hardwareVersion: hardwareVersion
1555
+ } : {}, sonifiModel ? {
1556
+ sonifiModel: sonifiModel
1557
+ } : {}, firmware ? {
1558
+ firmware: firmware
1559
+ } : {}, platform.osVersion ? {
1560
+ osVersion: platform.osVersion
1561
+ } : {}, platform.browserMajorVersion != null ? {
1562
+ browserMajorVersion: platform.browserMajorVersion
1563
+ } : {}, internalDeviceId ? {
1564
+ internalDeviceId: internalDeviceId
1565
+ } : {}, internalDeviceId && internalDeviceIdSource ? {
1566
+ internalDeviceIdSource: internalDeviceIdSource
1567
+ } : {}, terminalId ? {
1568
+ terminalId: terminalId
1569
+ } : {}), {
1570
+ sources: sources
1571
+ });
1572
+ }
1573
+ function deviceInfoAnalyticsFields(info) {
1574
+ return _object_spread({
1575
+ device_category: info.category
1576
+ }, info.model ? {
1577
+ device_model: info.model
1578
+ } : {}, info.sonifiModel ? {
1579
+ sonifi_model: info.sonifiModel
1580
+ } : {}, info.firmware ? {
1581
+ firmware_version: info.firmware
1582
+ } : {}, info.osVersion ? {
1583
+ os_version: info.osVersion
1584
+ } : {}, info.browserMajorVersion != null ? {
1585
+ browser_major_version: info.browserMajorVersion
1586
+ } : {}, info.internalDeviceId ? {
1587
+ internal_device_id: info.internalDeviceId
1588
+ } : {}, info.internalDeviceIdSource ? {
1589
+ internal_device_id_source: info.internalDeviceIdSource
1590
+ } : {}, info.terminalId ? {
1591
+ terminal_id: info.terminalId
1592
+ } : {});
1593
+ }
1296
1594
  // src/utils/tracking.ts
1297
1595
  var cachedBrowserId = null;
1298
1596
  function buildAnalyticsContext(config) {
@@ -1312,6 +1610,9 @@ function buildAnalyticsContext(config) {
1312
1610
  if (config.isLiveStream !== void 0) {
1313
1611
  context.inputStreamType = config.isLiveStream ? "live" : "vod";
1314
1612
  }
1613
+ if (config.sendDeviceInfoToAnalytics) {
1614
+ context.includeDeviceInfo = true;
1615
+ }
1315
1616
  return context;
1316
1617
  }
1317
1618
  function getClientInfo() {
@@ -1607,7 +1908,7 @@ function buildPlayerMetricEvent() {
1607
1908
  capture_at: captureAt
1608
1909
  }, context.inputStreamType ? {
1609
1910
  input_stream_type: context.inputStreamType
1610
- } : {})
1911
+ } : {}, context.includeDeviceInfo ? deviceInfoAnalyticsFields(getDeviceInfo()) : {})
1611
1912
  ];
1612
1913
  }
1613
1914
  });
@@ -1938,15 +2239,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
1938
2239
  values.set("PMND", String(pod.pmnd));
1939
2240
  values.set("PMXD", String(pod.pmxd));
1940
2241
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
2242
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
1941
2243
  }
1942
2244
  var substituted = substituteScvpMacros(rawUrl, values);
1943
2245
  var finalUrl;
1944
2246
  try {
1945
2247
  var url = new URL(normalizeVastTagUrl(substituted.url));
2248
+ var isGam = GAM_AD_HOSTS.has(url.hostname);
2249
+ var setPodParam = function setPodParam(key, value) {
2250
+ if (isGam || url.searchParams.has(key)) url.searchParams.set(key, String(value));
2251
+ };
1946
2252
  if (pod) {
1947
- url.searchParams.set("pmnd", String(pod.pmnd));
1948
- url.searchParams.set("pmxd", String(pod.pmxd));
1949
- if (pod.pmad != null) url.searchParams.set("pmad", String(pod.pmad));
2253
+ setPodParam("pmnd", pod.pmnd);
2254
+ setPodParam("pmxd", pod.pmxd);
2255
+ if (pod.pmad != null) setPodParam("pmad", pod.pmad);
1950
2256
  else url.searchParams.delete("pmad");
1951
2257
  } else {
1952
2258
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2012,7 +2318,9 @@ function validateGamRequestUrl(url, expect) {
2012
2318
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2013
2319
  var params;
2014
2320
  try {
2015
- params = new URL(url).searchParams;
2321
+ var parsed = new URL(url);
2322
+ if (!GAM_AD_HOSTS.has(parsed.hostname)) return problems;
2323
+ params = parsed.searchParams;
2016
2324
  } catch (unused) {
2017
2325
  return problems.concat("URL could not be parsed");
2018
2326
  }
@@ -2084,6 +2392,54 @@ function computePodResponseDiagnostics(pmxdSent, vastAdCount, totalVastCreativeD
2084
2392
  function monotonicNow() {
2085
2393
  return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
2086
2394
  }
2395
+ // src/utils/screenActivity.ts
2396
+ var hostStandby = false;
2397
+ function toBoolean(value) {
2398
+ if (typeof value === "boolean") return value;
2399
+ if (typeof value === "number") return value === 1;
2400
+ if (typeof value === "string") {
2401
+ var v = value.trim().toLowerCase();
2402
+ if (v === "true" || v === "1" || v === "yes") return true;
2403
+ if (v === "false" || v === "0" || v === "no") return false;
2404
+ }
2405
+ return void 0;
2406
+ }
2407
+ function bridgeSaysStandby() {
2408
+ if (typeof window === "undefined") return false;
2409
+ var w = window;
2410
+ for(var _i = 0, _iter = [
2411
+ w.__STORMCLOUD_CTV__,
2412
+ w.__STORMCLOUD_CTV_AD_INFO__,
2413
+ w.stormcloudCtv
2414
+ ]; _i < _iter.length; _i++){
2415
+ var source = _iter[_i];
2416
+ if (!source) continue;
2417
+ for(var _i1 = 0, _iter1 = [
2418
+ "standby",
2419
+ "isStandby",
2420
+ "screenOff"
2421
+ ]; _i1 < _iter1.length; _i1++){
2422
+ var key = _iter1[_i1];
2423
+ var value = void 0;
2424
+ try {
2425
+ value = source[key];
2426
+ if (typeof value === "function") value = value.call(source);
2427
+ } catch (unused) {
2428
+ value = void 0;
2429
+ }
2430
+ if (toBoolean(value) === true) return true;
2431
+ }
2432
+ }
2433
+ return false;
2434
+ }
2435
+ function getScreenInactiveReason() {
2436
+ if (hostStandby) return "host_standby";
2437
+ if (typeof document !== "undefined" && document.visibilityState === "hidden") {
2438
+ return "document_hidden";
2439
+ }
2440
+ if (bridgeSaysStandby()) return "bridge_standby";
2441
+ return void 0;
2442
+ }
2087
2443
  // src/player/AdBreakOrchestrator.ts
2088
2444
  var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
2089
2445
  "no_fill",
@@ -2140,9 +2496,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2140
2496
  }
2141
2497
  },
2142
2498
  {
2143
- // ───────────────────────────────────────────────────────────────
2144
- // IMA event listeners
2145
- // ───────────────────────────────────────────────────────────────
2146
2499
  key: "nextAdRequestUrl",
2147
2500
  value: function nextAdRequestUrl(baseVastUrl) {
2148
2501
  return this.host.generatePodVastUrl(baseVastUrl);
@@ -2378,9 +2731,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2378
2731
  }
2379
2732
  },
2380
2733
  {
2381
- // ───────────────────────────────────────────────────────────────
2382
- // Ad break start
2383
- // ───────────────────────────────────────────────────────────────
2384
2734
  key: "isBreakActive",
2385
2735
  value: function isBreakActive() {
2386
2736
  return this.slotState !== "IDLE";
@@ -2408,7 +2758,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2408
2758
  key: "handleAdStart",
2409
2759
  value: function handleAdStart(marker) {
2410
2760
  return _async_to_generator(function() {
2411
- var baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
2761
+ var screenInactiveReason, baseVastUrl, edgeConfigured, adBreakDurationMs, currentMuted, currentVolume, epoch, mode, edgeUrl, outcome, podPlayed;
2412
2762
  return _ts_generator(this, function(_state) {
2413
2763
  switch(_state.label){
2414
2764
  case 0:
@@ -2421,6 +2771,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2421
2771
  2
2422
2772
  ];
2423
2773
  }
2774
+ screenInactiveReason = getScreenInactiveReason();
2775
+ if (screenInactiveReason) {
2776
+ this.logOrchestratorFunnel("break_skipped_screen_inactive", {
2777
+ reason: screenInactiveReason
2778
+ });
2779
+ this.clearPendingAdBreak();
2780
+ return [
2781
+ 2
2782
+ ];
2783
+ }
2424
2784
  baseVastUrl = this.adConfig.apiVastTagUrl;
2425
2785
  edgeConfigured = !!this.host.getEdgePodBaseUrl();
2426
2786
  if (!baseVastUrl && !edgeConfigured) {
@@ -2581,12 +2941,9 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2581
2941
  },
2582
2942
  {
2583
2943
  key: "startOptimizedPod",
2584
- value: // ───────────────────────────────────────────────────────────────
2585
- // Optimized pod (single multi-ad request)
2586
- // ───────────────────────────────────────────────────────────────
2587
- function startOptimizedPod(baseVastUrl) {
2944
+ value: function startOptimizedPod(baseVastUrl) {
2588
2945
  return _async_to_generator(function() {
2589
- var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, error;
2946
+ var podUrl, prefetched, epoch, generation, adPlayer, requestToken, requestUrl, _ref, _this_currentVastUrl, _adPlayer_getPodAdCount, finalizeRequestUrl, podCount, _this_host_config_maxAdBreakExtensionMs, remainingMs, overrunAllowanceMs, maxAdsCap, maxAds, error;
2590
2947
  return _ts_generator(this, function(_state) {
2591
2948
  switch(_state.label){
2592
2949
  case 0:
@@ -2694,6 +3051,26 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2694
3051
  false
2695
3052
  ];
2696
3053
  }
3054
+ if (this.isBreakTimeBounded() && adPlayer.limitPodToBudget) {
3055
+ ;
3056
+ remainingMs = this.timing.getRemainingAdMs();
3057
+ overrunAllowanceMs = Math.max(0, (_this_host_config_maxAdBreakExtensionMs = this.host.config.maxAdBreakExtensionMs) !== null && _this_host_config_maxAdBreakExtensionMs !== void 0 ? _this_host_config_maxAdBreakExtensionMs : 0);
3058
+ maxAdsCap = this.adConfig.resolveAdPodConfig().maxAdsPerBreak;
3059
+ maxAds = maxAdsCap != null ? Math.max(1, maxAdsCap - this.timing.totalAdsInBreak) : Number.MAX_SAFE_INTEGER;
3060
+ if (Number.isFinite(remainingMs)) {
3061
+ podCount = adPlayer.limitPodToBudget(remainingMs + overrunAllowanceMs, maxAds);
3062
+ if (podCount < 1) {
3063
+ if (this.timing.activeAdRequestToken === requestToken) {
3064
+ this.timing.activeAdRequestToken = null;
3065
+ }
3066
+ this.recordRequestFailure(new Error("No GAM ad fits the ".concat(Math.round(remainingMs), "ms left in the break")), podUrl);
3067
+ return [
3068
+ 2,
3069
+ false
3070
+ ];
3071
+ }
3072
+ }
3073
+ }
2697
3074
  this.setSlotState("READY", "vast_ready");
2698
3075
  if (this.debug) {
2699
3076
  console.log(podCount === 1 ? "[POD] Response contained a single ad; playing it and enabling pod top-up" : "[POD] Optimized pod returned ".concat(podCount, " ads; playing pod in one controller"));
@@ -2763,9 +3140,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2763
3140
  }
2764
3141
  },
2765
3142
  {
2766
- // ───────────────────────────────────────────────────────────────
2767
- // Edge-first pods (live SCTE-35 only, GAM fallback)
2768
- // ───────────────────────────────────────────────────────────────
2769
3143
  key: "resetEdgeStateForBreak",
2770
3144
  value: function resetEdgeStateForBreak() {
2771
3145
  this.edgeExhaustedForBreak = false;
@@ -2983,9 +3357,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2983
3357
  }
2984
3358
  },
2985
3359
  {
2986
- // ───────────────────────────────────────────────────────────────
2987
- // Next-ad scheduling (single flight)
2988
- // ───────────────────────────────────────────────────────────────
2989
3360
  key: "setSlotState",
2990
3361
  value: function setSlotState(next, reason) {
2991
3362
  if (this.slotState === next) return;
@@ -3035,6 +3406,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3035
3406
  {
3036
3407
  key: "getStopRequestingReason",
3037
3408
  value: function getStopRequestingReason(remainingMs) {
3409
+ var screenInactiveReason = getScreenInactiveReason();
3410
+ if (screenInactiveReason) return "screen_inactive:".concat(screenInactiveReason);
3038
3411
  if (this.breakSource === "vmap") {
3039
3412
  if (this.adPodQueue.length === 0) return "vmap_queue_empty";
3040
3413
  } else if (this.breakSource !== "scte35" || !this.followUpBaseVastUrl && !this.canRequestEdge()) {
@@ -3308,9 +3681,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3308
3681
  }
3309
3682
  },
3310
3683
  {
3311
- // ───────────────────────────────────────────────────────────────
3312
- // Per-request diagnostics
3313
- // ───────────────────────────────────────────────────────────────
3314
3684
  key: "recordRequestDiagnostic",
3315
3685
  value: function recordRequestDiagnostic(payload) {
3316
3686
  var requestId = payload.requestId;
@@ -3384,9 +3754,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3384
3754
  }
3385
3755
  },
3386
3756
  {
3387
- // ───────────────────────────────────────────────────────────────
3388
- // Single ad playback
3389
- // ───────────────────────────────────────────────────────────────
3390
3757
  key: "createGamDispatchFinalizer",
3391
3758
  value: function createGamDispatchFinalizer(requestToken) {
3392
3759
  var _this = this;
@@ -3849,9 +4216,6 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3849
4216
  }
3850
4217
  },
3851
4218
  {
3852
- // ───────────────────────────────────────────────────────────────
3853
- // Ad break completion
3854
- // ───────────────────────────────────────────────────────────────
3855
4219
  key: "logBreakFunnel",
3856
4220
  value: function logBreakFunnel(endReason) {
3857
4221
  var funnel = this.breakFunnel;