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
@@ -5,6 +5,7 @@ import { AdConfigManager } from './AdConfigManager.cjs';
5
5
  import { Scte35CueManager } from './Scte35CueManager.cjs';
6
6
  import { PlaceholderLayer } from './PlaceholderLayer.cjs';
7
7
  import './OptimizedPodRequest.cjs';
8
+ import '../utils/contentMetadata.cjs';
8
9
  import '../sdk/pal.cjs';
9
10
  import '../utils/vastMacros.cjs';
10
11
  import './playerTypes.cjs';
@@ -1102,6 +1102,294 @@ function normalizeBoolean(value) {
1102
1102
  }
1103
1103
  return void 0;
1104
1104
  }
1105
+ // src/utils/contentMetadata.ts
1106
+ var MAX_CONTENT_VALUE_LENGTH = 128;
1107
+ var BRIDGE_KEYS = {
1108
+ channelName: [
1109
+ "channelName",
1110
+ "ct_ch"
1111
+ ],
1112
+ programTitle: [
1113
+ "programTitle",
1114
+ "ct_ti"
1115
+ ],
1116
+ contentNetwork: [
1117
+ "contentNetwork",
1118
+ "ct_ne"
1119
+ ],
1120
+ contentType: [
1121
+ "contentType",
1122
+ "ctt"
1123
+ ],
1124
+ contentCategory: [
1125
+ "contentCategory",
1126
+ "ctc"
1127
+ ],
1128
+ contentGenre: [
1129
+ "contentGenre",
1130
+ "ctgr"
1131
+ ],
1132
+ contentLanguage: [
1133
+ "contentLanguage",
1134
+ "ctlg"
1135
+ ],
1136
+ contentDuration: [
1137
+ "contentDuration",
1138
+ "ctd"
1139
+ ],
1140
+ contentSeason: [
1141
+ "contentSeason",
1142
+ "cts"
1143
+ ],
1144
+ contentEpisode: [
1145
+ "contentEpisode",
1146
+ "cte"
1147
+ ],
1148
+ contentRating: [
1149
+ "contentRating",
1150
+ "ctr"
1151
+ ],
1152
+ contentId: [
1153
+ "contentId",
1154
+ "ctid"
1155
+ ]
1156
+ };
1157
+ function sanitizeContentValue(value) {
1158
+ if (typeof value !== "string") return void 0;
1159
+ var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1160
+ if (!cleaned) return void 0;
1161
+ if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1162
+ if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1163
+ return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1164
+ }
1165
+ function sanitizeContentScalar(value) {
1166
+ if (typeof value === "number") {
1167
+ return Number.isFinite(value) ? String(value) : void 0;
1168
+ }
1169
+ return sanitizeContentValue(value);
1170
+ }
1171
+ function normalizeContentLanguage(value) {
1172
+ var cleaned = sanitizeContentValue(value);
1173
+ if (!cleaned) return void 0;
1174
+ var match = cleaned.match(/^([A-Za-z]{2})(?:[-_][A-Za-z0-9]{1,8})*$/);
1175
+ return match && match[1] ? match[1].toLowerCase() : void 0;
1176
+ }
1177
+ function normalizeContentDuration(value) {
1178
+ var raw = sanitizeContentScalar(value);
1179
+ if (raw == null || !/^-?\d+(\.\d+)?$/.test(raw)) return void 0;
1180
+ var seconds = Number(raw);
1181
+ if (seconds === -1) return -1;
1182
+ return seconds > 0 ? Math.round(seconds) : void 0;
1183
+ }
1184
+ function bridgeSources() {
1185
+ if (typeof window === "undefined") return [];
1186
+ var w = window;
1187
+ return [
1188
+ w.__STORMCLOUD_CTV__,
1189
+ w.__STORMCLOUD_CTV_AD_INFO__,
1190
+ w.stormcloudCtv
1191
+ ].filter(Boolean);
1192
+ }
1193
+ function readBridgeValue2(keys, sanitize) {
1194
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1195
+ try {
1196
+ for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1197
+ var source = _step.value;
1198
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1199
+ try {
1200
+ for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1201
+ var key = _step1.value;
1202
+ var value = void 0;
1203
+ try {
1204
+ value = source === null || source === void 0 ? void 0 : source[key];
1205
+ if (typeof value === "function") value = value.call(source);
1206
+ } catch (unused) {
1207
+ value = void 0;
1208
+ }
1209
+ var sanitized = sanitize(value);
1210
+ if (sanitized != null) return sanitized;
1211
+ }
1212
+ } catch (err) {
1213
+ _didIteratorError1 = true;
1214
+ _iteratorError1 = err;
1215
+ } finally{
1216
+ try {
1217
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1218
+ _iterator1.return();
1219
+ }
1220
+ } finally{
1221
+ if (_didIteratorError1) {
1222
+ throw _iteratorError1;
1223
+ }
1224
+ }
1225
+ }
1226
+ }
1227
+ } catch (err) {
1228
+ _didIteratorError = true;
1229
+ _iteratorError = err;
1230
+ } finally{
1231
+ try {
1232
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1233
+ _iterator.return();
1234
+ }
1235
+ } finally{
1236
+ if (_didIteratorError) {
1237
+ throw _iteratorError;
1238
+ }
1239
+ }
1240
+ }
1241
+ return void 0;
1242
+ }
1243
+ function readBridgeContentValue(keys) {
1244
+ return readBridgeValue2(keys, sanitizeContentValue);
1245
+ }
1246
+ function resolveContentMetadata(config) {
1247
+ var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2, _config_contentDetails, _sanitizeContentValue3, _sanitizeContentValue4, _sanitizeContentValue5, _normalizeContentLanguage, _normalizeContentDuration, _sanitizeContentScalar, _sanitizeContentScalar1, _sanitizeContentValue6, _sanitizeContentValue7;
1248
+ var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1249
+ var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1250
+ var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1251
+ var details = (_config_contentDetails = config.contentDetails) !== null && _config_contentDetails !== void 0 ? _config_contentDetails : {};
1252
+ var contentType = (_sanitizeContentValue3 = sanitizeContentValue(details.contentType)) !== null && _sanitizeContentValue3 !== void 0 ? _sanitizeContentValue3 : readBridgeContentValue(BRIDGE_KEYS.contentType);
1253
+ var contentCategory = (_sanitizeContentValue4 = sanitizeContentValue(details.category)) !== null && _sanitizeContentValue4 !== void 0 ? _sanitizeContentValue4 : readBridgeContentValue(BRIDGE_KEYS.contentCategory);
1254
+ var contentGenre = (_sanitizeContentValue5 = sanitizeContentValue(details.genre)) !== null && _sanitizeContentValue5 !== void 0 ? _sanitizeContentValue5 : readBridgeContentValue(BRIDGE_KEYS.contentGenre);
1255
+ var contentLanguage = (_normalizeContentLanguage = normalizeContentLanguage(details.language)) !== null && _normalizeContentLanguage !== void 0 ? _normalizeContentLanguage : readBridgeValue2(BRIDGE_KEYS.contentLanguage, normalizeContentLanguage);
1256
+ var contentDurationSeconds = (_normalizeContentDuration = normalizeContentDuration(details.durationSeconds)) !== null && _normalizeContentDuration !== void 0 ? _normalizeContentDuration : readBridgeValue2(BRIDGE_KEYS.contentDuration, normalizeContentDuration);
1257
+ var contentSeason = (_sanitizeContentScalar = sanitizeContentScalar(details.season)) !== null && _sanitizeContentScalar !== void 0 ? _sanitizeContentScalar : readBridgeValue2(BRIDGE_KEYS.contentSeason, sanitizeContentScalar);
1258
+ var contentEpisode = (_sanitizeContentScalar1 = sanitizeContentScalar(details.episode)) !== null && _sanitizeContentScalar1 !== void 0 ? _sanitizeContentScalar1 : readBridgeValue2(BRIDGE_KEYS.contentEpisode, sanitizeContentScalar);
1259
+ var contentRating = (_sanitizeContentValue6 = sanitizeContentValue(details.rating)) !== null && _sanitizeContentValue6 !== void 0 ? _sanitizeContentValue6 : readBridgeContentValue(BRIDGE_KEYS.contentRating);
1260
+ var contentId = (_sanitizeContentValue7 = sanitizeContentValue(details.contentId)) !== null && _sanitizeContentValue7 !== void 0 ? _sanitizeContentValue7 : readBridgeContentValue(BRIDGE_KEYS.contentId);
1261
+ return _object_spread({}, channelName ? {
1262
+ channelName: channelName
1263
+ } : {}, programTitle ? {
1264
+ programTitle: programTitle
1265
+ } : {}, contentNetwork ? {
1266
+ contentNetwork: contentNetwork
1267
+ } : {}, contentType ? {
1268
+ contentType: contentType
1269
+ } : {}, contentCategory ? {
1270
+ contentCategory: contentCategory
1271
+ } : {}, contentGenre ? {
1272
+ contentGenre: contentGenre
1273
+ } : {}, contentLanguage ? {
1274
+ contentLanguage: contentLanguage
1275
+ } : {}, contentDurationSeconds != null ? {
1276
+ contentDurationSeconds: contentDurationSeconds
1277
+ } : {}, contentSeason ? {
1278
+ contentSeason: contentSeason
1279
+ } : {}, contentEpisode ? {
1280
+ contentEpisode: contentEpisode
1281
+ } : {}, contentRating ? {
1282
+ contentRating: contentRating
1283
+ } : {}, contentId ? {
1284
+ contentId: contentId
1285
+ } : {});
1286
+ }
1287
+ function appendMissingContentParams(url, meta) {
1288
+ if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1289
+ try {
1290
+ var parsed = new URL(url);
1291
+ var add = function add(key, value) {
1292
+ if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1293
+ };
1294
+ add("ct_ch", meta.channelName);
1295
+ add("ct_ti", meta.programTitle);
1296
+ add("ct_ne", meta.contentNetwork);
1297
+ return parsed.toString();
1298
+ } catch (unused) {
1299
+ return url;
1300
+ }
1301
+ }
1302
+ // src/utils/partnerSignals.ts
1303
+ var PLATFORM_IFA_TYPES = /* @__PURE__ */ new Set([
1304
+ "aaid",
1305
+ "adid",
1306
+ "afai",
1307
+ "idfa",
1308
+ "lgudid",
1309
+ "msai",
1310
+ "rida",
1311
+ "tifa",
1312
+ "tvos",
1313
+ "vaid",
1314
+ "vida"
1315
+ ]);
1316
+ function toIabIfaType(deviceIdType, source) {
1317
+ if (!deviceIdType) return void 0;
1318
+ var type = deviceIdType.trim().toLowerCase();
1319
+ if (source === "generated") return "sessionid";
1320
+ if (PLATFORM_IFA_TYPES.has(type)) return type;
1321
+ if (source === "platform") return "dpid";
1322
+ return "ppid";
1323
+ }
1324
+ function playbackMethodCode(autoPlay, muted) {
1325
+ if (autoPlay === false) return 3;
1326
+ if (autoPlay !== true || muted == null) return void 0;
1327
+ return muted ? 2 : 1;
1328
+ }
1329
+ function resolvePlayerSize(video) {
1330
+ var width = video ? video.clientWidth : 0;
1331
+ var height = video ? video.clientHeight : 0;
1332
+ if (!(width > 0 && height > 0) && typeof window !== "undefined") {
1333
+ width = window.innerWidth;
1334
+ height = window.innerHeight;
1335
+ }
1336
+ if (!(width > 0 && height > 0)) return {};
1337
+ return {
1338
+ width: Math.round(width),
1339
+ height: Math.round(height)
1340
+ };
1341
+ }
1342
+ function sanitizeUserId(value) {
1343
+ var cleaned = sanitizeContentValue(value);
1344
+ if (!cleaned || /\s/.test(cleaned)) return void 0;
1345
+ return cleaned;
1346
+ }
1347
+ function isPublicIpv4(ip) {
1348
+ var parts = ip.split(".");
1349
+ if (parts.length !== 4) return false;
1350
+ var nums = parts.map(function(p) {
1351
+ return /^\d{1,3}$/.test(p) ? Number(p) : NaN;
1352
+ });
1353
+ if (nums.some(function(n) {
1354
+ return !(n >= 0 && n <= 255);
1355
+ })) return false;
1356
+ var _nums = _sliced_to_array(nums, 2), a = _nums[0], b = _nums[1];
1357
+ if (a === 0 || a === 10 || a === 127 || a >= 224) return false;
1358
+ if (a === 100 && b >= 64 && b <= 127) return false;
1359
+ if (a === 169 && b === 254) return false;
1360
+ if (a === 172 && b >= 16 && b <= 31) return false;
1361
+ if (a === 192 && b === 168) return false;
1362
+ return true;
1363
+ }
1364
+ function isPublicIpv6(ip) {
1365
+ var lower = ip.toLowerCase();
1366
+ if (!/^[0-9a-f:]+$/.test(lower) || lower.split(":").length < 3) return false;
1367
+ if (lower === "::" || lower === "::1") return false;
1368
+ if (/^fe[89ab]/.test(lower)) return false;
1369
+ if (/^f[cd]/.test(lower)) return false;
1370
+ return true;
1371
+ }
1372
+ function sanitizePublicIp(value) {
1373
+ var cleaned = sanitizeContentValue(value);
1374
+ if (!cleaned) return void 0;
1375
+ if (cleaned.includes(".")) return isPublicIpv4(cleaned) ? cleaned : void 0;
1376
+ return isPublicIpv6(cleaned) ? cleaned : void 0;
1377
+ }
1378
+ function resolveUserId(configValue) {
1379
+ var _sanitizeUserId;
1380
+ return (_sanitizeUserId = sanitizeUserId(configValue)) !== null && _sanitizeUserId !== void 0 ? _sanitizeUserId : readBridgeValue2([
1381
+ "userId",
1382
+ "uid"
1383
+ ], sanitizeUserId);
1384
+ }
1385
+ function resolveClientIp(configValue) {
1386
+ var _sanitizePublicIp;
1387
+ return (_sanitizePublicIp = sanitizePublicIp(configValue)) !== null && _sanitizePublicIp !== void 0 ? _sanitizePublicIp : readBridgeValue2([
1388
+ "ipAddress",
1389
+ "clientIp",
1390
+ "ip"
1391
+ ], sanitizePublicIp);
1392
+ }
1105
1393
  // src/utils/vastMacros.ts
1106
1394
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
1107
1395
  var INVALID_VAST_PARAM_KEY = /^\s|\s$/;
@@ -1419,7 +1707,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1419
1707
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1420
1708
  "PMND",
1421
1709
  "PMXD",
1422
- "PMAD"
1710
+ "PMAD",
1711
+ "MABD"
1423
1712
  ]);
1424
1713
  function hasScvpMacros(url) {
1425
1714
  return !!url && SCVP_MACRO_DETECT.test(url);
@@ -1464,6 +1753,8 @@ function resolveScvpMacroValues(ctx) {
1464
1753
  set("RDID", deviceId);
1465
1754
  set("IDTYPE", deviceIdType);
1466
1755
  set("IS-LAT", (_toFlag = toFlag(ctx.limitAdTracking)) !== null && _toFlag !== void 0 ? _toFlag : "0");
1756
+ set("IFA", deviceId);
1757
+ set("IFA-TYPE", toIabIfaType(deviceIdType, ctx.deviceIdSource));
1467
1758
  }
1468
1759
  set("SID", ctx.sessionId);
1469
1760
  set("DTH", ctx.deviceTypeHint);
@@ -1481,6 +1772,26 @@ function resolveScvpMacroValues(ctx) {
1481
1772
  set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1482
1773
  set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1483
1774
  set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1775
+ set("PLAYER-WIDTH", ctx.playerWidth);
1776
+ set("PLAYER-HEIGHT", ctx.playerHeight);
1777
+ set("TIMESTAMP", ctx.timestamp);
1778
+ set("LIVE", toFlag(ctx.isLive));
1779
+ set("VPMT", playbackMethodCode(ctx.isCtv ? true : ctx.adWillAutoPlay, ctx.adWillPlayMuted));
1780
+ set("DEVICE-MAKE", ctx.deviceMake);
1781
+ set("DEVICE-MODEL", ctx.deviceModel);
1782
+ set("DEVICE-HWV", ctx.deviceHardwareVersion);
1783
+ set("UA", ctx.userAgent);
1784
+ set("IP", ctx.ipAddress);
1785
+ set("UID", ctx.userId);
1786
+ set("CT-TYPE", ctx.contentType);
1787
+ set("CT-CATEGORY", ctx.contentCategory);
1788
+ set("CT-GENRE", ctx.contentGenre);
1789
+ set("CT-LANGUAGE", ctx.contentLanguage);
1790
+ set("CT-DURATION", ctx.contentDurationSeconds != null ? ctx.contentDurationSeconds : ctx.isLive ? -1 : void 0);
1791
+ set("CT-SEASON", ctx.contentSeason);
1792
+ set("CT-EPISODE", ctx.contentEpisode);
1793
+ set("CT-RATING", ctx.contentRating);
1794
+ set("CT-ID", ctx.contentId);
1484
1795
  return values;
1485
1796
  }
1486
1797
  var keepNone = function keepNone() {
@@ -1751,117 +2062,6 @@ function resolveAdPodConfig(config) {
1751
2062
  exactDuration: config.podExactDuration === true
1752
2063
  };
1753
2064
  }
1754
- // src/utils/contentMetadata.ts
1755
- var MAX_CONTENT_VALUE_LENGTH = 128;
1756
- var BRIDGE_KEYS = {
1757
- channelName: [
1758
- "channelName",
1759
- "ct_ch"
1760
- ],
1761
- programTitle: [
1762
- "programTitle",
1763
- "ct_ti"
1764
- ],
1765
- contentNetwork: [
1766
- "contentNetwork",
1767
- "ct_ne"
1768
- ]
1769
- };
1770
- function sanitizeContentValue(value) {
1771
- if (typeof value !== "string") return void 0;
1772
- var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1773
- if (!cleaned) return void 0;
1774
- if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1775
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1776
- return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1777
- }
1778
- function bridgeSources() {
1779
- if (typeof window === "undefined") return [];
1780
- var w = window;
1781
- return [
1782
- w.__STORMCLOUD_CTV__,
1783
- w.__STORMCLOUD_CTV_AD_INFO__,
1784
- w.stormcloudCtv
1785
- ].filter(Boolean);
1786
- }
1787
- function readBridgeContentValue(keys) {
1788
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1789
- try {
1790
- for(var _iterator = bridgeSources()[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1791
- var source = _step.value;
1792
- var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
1793
- try {
1794
- for(var _iterator1 = keys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
1795
- var key = _step1.value;
1796
- var value = void 0;
1797
- try {
1798
- value = source === null || source === void 0 ? void 0 : source[key];
1799
- if (typeof value === "function") value = value.call(source);
1800
- } catch (unused) {
1801
- value = void 0;
1802
- }
1803
- var sanitized = sanitizeContentValue(value);
1804
- if (sanitized) return sanitized;
1805
- }
1806
- } catch (err) {
1807
- _didIteratorError1 = true;
1808
- _iteratorError1 = err;
1809
- } finally{
1810
- try {
1811
- if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
1812
- _iterator1.return();
1813
- }
1814
- } finally{
1815
- if (_didIteratorError1) {
1816
- throw _iteratorError1;
1817
- }
1818
- }
1819
- }
1820
- }
1821
- } catch (err) {
1822
- _didIteratorError = true;
1823
- _iteratorError = err;
1824
- } finally{
1825
- try {
1826
- if (!_iteratorNormalCompletion && _iterator.return != null) {
1827
- _iterator.return();
1828
- }
1829
- } finally{
1830
- if (_didIteratorError) {
1831
- throw _iteratorError;
1832
- }
1833
- }
1834
- }
1835
- return void 0;
1836
- }
1837
- function resolveContentMetadata(config) {
1838
- var _sanitizeContentValue, _sanitizeContentValue1, _sanitizeContentValue2;
1839
- var channelName = (_sanitizeContentValue = sanitizeContentValue(config.channelName)) !== null && _sanitizeContentValue !== void 0 ? _sanitizeContentValue : readBridgeContentValue(BRIDGE_KEYS.channelName);
1840
- var programTitle = (_sanitizeContentValue1 = sanitizeContentValue(config.programTitle)) !== null && _sanitizeContentValue1 !== void 0 ? _sanitizeContentValue1 : readBridgeContentValue(BRIDGE_KEYS.programTitle);
1841
- var contentNetwork = (_sanitizeContentValue2 = sanitizeContentValue(config.contentNetwork)) !== null && _sanitizeContentValue2 !== void 0 ? _sanitizeContentValue2 : readBridgeContentValue(BRIDGE_KEYS.contentNetwork);
1842
- return _object_spread({}, channelName ? {
1843
- channelName: channelName
1844
- } : {}, programTitle ? {
1845
- programTitle: programTitle
1846
- } : {}, contentNetwork ? {
1847
- contentNetwork: contentNetwork
1848
- } : {});
1849
- }
1850
- function appendMissingContentParams(url, meta) {
1851
- if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
1852
- try {
1853
- var parsed = new URL(url);
1854
- var add = function add(key, value) {
1855
- if (value && !parsed.searchParams.has(key)) parsed.searchParams.set(key, value);
1856
- };
1857
- add("ct_ch", meta.channelName);
1858
- add("ct_ti", meta.programTitle);
1859
- add("ct_ne", meta.contentNetwork);
1860
- return parsed.toString();
1861
- } catch (unused) {
1862
- return url;
1863
- }
1864
- }
1865
2065
  // src/utils/deviceInfo.ts
1866
2066
  var CATEGORY_CODES = {
1867
2067
  "LG TV": "lg_tv",
@@ -1956,6 +2156,11 @@ function readBridge(keys) {
1956
2156
  }
1957
2157
  return void 0;
1958
2158
  }
2159
+ function makeForCategory(category) {
2160
+ if (category === "LG TV" || category === "LG Set-Top Box") return "LG";
2161
+ if (category === "Samsung TV") return "Samsung";
2162
+ return void 0;
2163
+ }
1959
2164
  function normalizeCategory(value) {
1960
2165
  var v = cleanString(value);
1961
2166
  if (!v) return void 0;
@@ -2054,7 +2259,7 @@ function categorize(platform, model) {
2054
2259
  return "Other";
2055
2260
  }
2056
2261
  function getDeviceInfo() {
2057
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
2262
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
2058
2263
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
2059
2264
  if (primePromise && !platformCache) {} else {
2060
2265
  platformCache = platform;
@@ -2077,7 +2282,14 @@ function getDeviceInfo() {
2077
2282
  ]),
2078
2283
  category: normalizeCategory(readBridge([
2079
2284
  "deviceCategory"
2080
- ]))
2285
+ ])),
2286
+ make: readBridge([
2287
+ "deviceMake"
2288
+ ]),
2289
+ hardwareVersion: readBridge([
2290
+ "deviceHardwareVersion",
2291
+ "hardwareVersion"
2292
+ ])
2081
2293
  };
2082
2294
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
2083
2295
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -2090,7 +2302,9 @@ function getDeviceInfo() {
2090
2302
  bridge.internalDeviceId,
2091
2303
  bridge.model,
2092
2304
  bridge.firmware,
2093
- bridge.category
2305
+ bridge.category,
2306
+ bridge.make,
2307
+ bridge.hardwareVersion
2094
2308
  ];
2095
2309
  if (bridgeValues.some(function(v) {
2096
2310
  return v !== void 0;
@@ -2098,12 +2312,18 @@ function getDeviceInfo() {
2098
2312
  if (hostDeviceInfo) sources.unshift("host");
2099
2313
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
2100
2314
  var internalDeviceIdSource = hostInternalId ? "host" : platform.internalDeviceIdSource;
2315
+ var make = (_ref3 = (_cleanString4 = cleanString(host.make, 40)) !== null && _cleanString4 !== void 0 ? _cleanString4 : bridge.make) !== null && _ref3 !== void 0 ? _ref3 : makeForCategory(category);
2316
+ var hardwareVersion = (_cleanString5 = cleanString(host.hardwareVersion, 40)) !== null && _cleanString5 !== void 0 ? _cleanString5 : bridge.hardwareVersion;
2101
2317
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
2102
2318
  return _object_spread_props(_object_spread({
2103
2319
  category: category,
2104
2320
  categoryCode: CATEGORY_CODES[category]
2105
- }, model ? {
2321
+ }, make ? {
2322
+ make: make
2323
+ } : {}, model ? {
2106
2324
  model: model
2325
+ } : {}, hardwareVersion ? {
2326
+ hardwareVersion: hardwareVersion
2107
2327
  } : {}, sonifiModel ? {
2108
2328
  sonifiModel: sonifiModel
2109
2329
  } : {}, firmware ? {
@@ -2739,6 +2959,13 @@ function sendHeartbeat(_0) {
2739
2959
  }).apply(this, arguments);
2740
2960
  }
2741
2961
  // src/player/AdConfigManager.ts
2962
+ function isGamAdUrl(rawUrl) {
2963
+ try {
2964
+ return GAM_AD_HOSTS.has(new URL(rawUrl).hostname);
2965
+ } catch (unused) {
2966
+ return false;
2967
+ }
2968
+ }
2742
2969
  function withDeferredPodParams(rawUrl, deferNonce) {
2743
2970
  try {
2744
2971
  var url = new URL(rawUrl);
@@ -2756,11 +2983,15 @@ function withDeferredPodParams(rawUrl, deferNonce) {
2756
2983
  }
2757
2984
  var AdConfigManager = /*#__PURE__*/ function() {
2758
2985
  function AdConfigManager(config, video) {
2986
+ var _this = this;
2759
2987
  _class_call_check(this, AdConfigManager);
2760
2988
  this.vmapBreaks = [];
2761
2989
  this.consumedVmapBreakIds = /* @__PURE__ */ new Set();
2762
2990
  this.streamCorrelator = generateCorrelator();
2763
2991
  this.consentSignals = {};
2992
+ this.isLiveStream = function() {
2993
+ return !!_this.config.isLiveStream;
2994
+ };
2764
2995
  this.podCounter = 0;
2765
2996
  this.podAssignedByPrefetch = false;
2766
2997
  this.lastHeartbeatTime = 0;
@@ -3211,13 +3442,22 @@ var AdConfigManager = /*#__PURE__*/ function() {
3211
3442
  {
3212
3443
  key: "generatePodVastUrl",
3213
3444
  value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
3445
+ var _content_contentDurationSeconds;
3214
3446
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
3215
3447
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest, {
3216
3448
  fallbackDeviceIdMaxAgeMs: this.config.fallbackDeviceIdMaxAgeMs,
3217
3449
  sessionIdMaxAgeMs: this.config.sessionIdMaxAgeMs
3218
3450
  });
3219
3451
  var content = resolveContentMetadata(this.config);
3220
- var macroContext = _object_spread_props(_object_spread({
3452
+ var isLive = this.isLiveStream();
3453
+ var device = getDeviceInfo();
3454
+ var playerSize = resolvePlayerSize(this.video);
3455
+ var videoDuration = this.video.duration;
3456
+ var contentDurationSeconds = (_content_contentDurationSeconds = content.contentDurationSeconds) !== null && _content_contentDurationSeconds !== void 0 ? _content_contentDurationSeconds : !isLive && Number.isFinite(videoDuration) && videoDuration > 0 ? Math.round(videoDuration) : void 0;
3457
+ var userId = resolveUserId(this.config.adUserId);
3458
+ var ipAddress = resolveClientIp(this.config.clientIpAddress);
3459
+ var userAgent2 = typeof navigator !== "undefined" && navigator.userAgent ? navigator.userAgent : void 0;
3460
+ var macroContext = _object_spread(_object_spread_props(_object_spread(_object_spread_props(_object_spread({
3221
3461
  correlator: this.viewCorrelator,
3222
3462
  streamCorrelator: this.streamCorrelator,
3223
3463
  pod: this.podCounter > 0 ? this.podCounter : void 0,
@@ -3239,8 +3479,46 @@ var AdConfigManager = /*#__PURE__*/ function() {
3239
3479
  contentNetwork: content.contentNetwork
3240
3480
  } : {}), {
3241
3481
  consent: this.consentSignals,
3242
- palNonce: palNonce.getCurrentNonce() || void 0
3243
- });
3482
+ palNonce: palNonce.getCurrentNonce() || void 0,
3483
+ deviceIdSource: envSignals.deviceIdSource,
3484
+ isLive: isLive
3485
+ }), playerSize.width ? {
3486
+ playerWidth: playerSize.width
3487
+ } : {}, playerSize.height ? {
3488
+ playerHeight: playerSize.height
3489
+ } : {}), {
3490
+ timestamp: String(Date.now())
3491
+ }), device.make ? {
3492
+ deviceMake: device.make
3493
+ } : {}, device.model ? {
3494
+ deviceModel: device.model
3495
+ } : {}, device.hardwareVersion ? {
3496
+ deviceHardwareVersion: device.hardwareVersion
3497
+ } : {}, userAgent2 ? {
3498
+ userAgent: userAgent2
3499
+ } : {}, ipAddress ? {
3500
+ ipAddress: ipAddress
3501
+ } : {}, userId ? {
3502
+ userId: userId
3503
+ } : {}, content.contentType ? {
3504
+ contentType: content.contentType
3505
+ } : {}, content.contentCategory ? {
3506
+ contentCategory: content.contentCategory
3507
+ } : {}, content.contentGenre ? {
3508
+ contentGenre: content.contentGenre
3509
+ } : {}, content.contentLanguage ? {
3510
+ contentLanguage: content.contentLanguage
3511
+ } : {}, contentDurationSeconds != null ? {
3512
+ contentDurationSeconds: contentDurationSeconds
3513
+ } : {}, content.contentSeason ? {
3514
+ contentSeason: content.contentSeason
3515
+ } : {}, content.contentEpisode ? {
3516
+ contentEpisode: content.contentEpisode
3517
+ } : {}, content.contentRating ? {
3518
+ contentRating: content.contentRating
3519
+ } : {}, content.contentId ? {
3520
+ contentId: content.contentId
3521
+ } : {});
3244
3522
  var nonceReady = !!macroContext.palNonce;
3245
3523
  var finalUrl;
3246
3524
  if (hasScvpMacros(baseUrl)) {
@@ -3254,9 +3532,11 @@ var AdConfigManager = /*#__PURE__*/ function() {
3254
3532
  } else {
3255
3533
  finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
3256
3534
  }
3257
- finalUrl = appendMissingContentParams(finalUrl, content);
3258
- if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
3259
- finalUrl = applyDeviceKeyValues(finalUrl, getDeviceInfo());
3535
+ if (isGamAdUrl(finalUrl)) {
3536
+ finalUrl = appendMissingContentParams(finalUrl, content);
3537
+ if (this.config.ctvAdRequest && this.config.sendDeviceKeyValues !== false) {
3538
+ finalUrl = applyDeviceKeyValues(finalUrl, device);
3539
+ }
3260
3540
  }
3261
3541
  if (this.debug) {
3262
3542
  var id = envSignals.deviceId;
@@ -3269,7 +3549,12 @@ var AdConfigManager = /*#__PURE__*/ function() {
3269
3549
  sidTail: envSignals.sessionId ? envSignals.sessionId.slice(-4) : void 0,
3270
3550
  ct_ch: content.channelName,
3271
3551
  ct_ti: content.programTitle,
3272
- ct_ne: content.contentNetwork
3552
+ ct_ne: content.contentNetwork,
3553
+ ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
3554
+ live: isLive,
3555
+ player: playerSize,
3556
+ make: device.make,
3557
+ model: device.model
3273
3558
  });
3274
3559
  }
3275
3560
  console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);