stormcloud-video-player 0.8.73 → 0.8.74

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 (61) hide show
  1. package/README.md +10 -70
  2. package/dist/stormcloud-vp.min.js +1 -1
  3. package/lib/Player.d.cts +1 -0
  4. package/lib/StormcloudPlayer.cjs +987 -273
  5. package/lib/StormcloudPlayer.cjs.map +1 -1
  6. package/lib/StormcloudPlayer.d.cts +1 -0
  7. package/lib/index.cjs +998 -278
  8. package/lib/index.cjs.map +1 -1
  9. package/lib/index.d.cts +1 -0
  10. package/lib/index.d.ts +40 -3
  11. package/lib/index.js +991 -279
  12. package/lib/index.js.map +1 -1
  13. package/lib/player/AdBreakOrchestrator.cjs +767 -67
  14. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  15. package/lib/player/AdBreakOrchestrator.d.cts +7 -9
  16. package/lib/player/AdConfigManager.cjs +314 -62
  17. package/lib/player/AdConfigManager.cjs.map +1 -1
  18. package/lib/player/AdConfigManager.d.cts +7 -12
  19. package/lib/player/AdTimingService.cjs +37 -1
  20. package/lib/player/AdTimingService.cjs.map +1 -1
  21. package/lib/player/AdTimingService.d.cts +8 -1
  22. package/lib/player/EdgePodRequest.d.cts +1 -0
  23. package/lib/player/FloorLadder.d.cts +1 -0
  24. package/lib/player/HlsEngine.d.cts +1 -0
  25. package/lib/player/OptimizedPodRequest.cjs +719 -0
  26. package/lib/player/OptimizedPodRequest.cjs.map +1 -0
  27. package/lib/player/OptimizedPodRequest.d.cts +101 -0
  28. package/lib/player/PlayerControls.d.cts +1 -0
  29. package/lib/player/Scte35CueManager.d.cts +1 -0
  30. package/lib/player/Scte35Parser.d.cts +1 -0
  31. package/lib/player/StormcloudVideoPlayer.cjs +987 -273
  32. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  33. package/lib/player/StormcloudVideoPlayer.d.cts +1 -0
  34. package/lib/player/playerTypes.d.cts +1 -0
  35. package/lib/players/HlsPlayer.cjs +987 -273
  36. package/lib/players/HlsPlayer.cjs.map +1 -1
  37. package/lib/players/HlsPlayer.d.cts +1 -0
  38. package/lib/players/index.cjs +987 -273
  39. package/lib/players/index.cjs.map +1 -1
  40. package/lib/props.d.cts +1 -0
  41. package/lib/sdk/hlsAdPlayer.cjs +316 -51
  42. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  43. package/lib/sdk/hlsAdPlayer.d.cts +3 -1
  44. package/lib/sdk/pal.cjs +108 -83
  45. package/lib/sdk/pal.cjs.map +1 -1
  46. package/lib/sdk/pal.d.cts +1 -0
  47. package/lib/types.d.cts +9 -2
  48. package/lib/ui/StormcloudVideoPlayer.cjs +990 -278
  49. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  50. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  51. package/lib/utils/ctvVastSignals.cjs +9 -7
  52. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  53. package/lib/utils/tracking.cjs +17 -3
  54. package/lib/utils/tracking.cjs.map +1 -1
  55. package/lib/utils/tracking.d.cts +2 -1
  56. package/lib/utils/vastEnvironmentSignals.cjs +9 -7
  57. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  58. package/lib/utils/vastMacros.cjs +250 -10
  59. package/lib/utils/vastMacros.cjs.map +1 -1
  60. package/lib/utils/vastMacros.d.cts +13 -4
  61. package/package.json +5 -3
@@ -4,6 +4,7 @@ import { AdTimingService } from './AdTimingService.cjs';
4
4
  import { AdConfigManager } from './AdConfigManager.cjs';
5
5
  import { Scte35CueManager } from './Scte35CueManager.cjs';
6
6
  import { PlaceholderLayer } from './PlaceholderLayer.cjs';
7
+ import './OptimizedPodRequest.cjs';
7
8
  import '../sdk/pal.cjs';
8
9
  import '../utils/vastMacros.cjs';
9
10
  import './playerTypes.cjs';
@@ -21,8 +22,8 @@ interface AdBreakOrchestratorHost {
21
22
  reloadLiveStream(): void;
22
23
  recoverMediaError(): void;
23
24
  requiresMediaPipelineResetAfterAds(): boolean;
24
- generatePodVastUrl(baseUrl: string, breakDurationMs?: number): string;
25
- /** Validated Edge pod URL, or undefined when Edge-first is disabled. */
25
+ generatePodVastUrl(baseUrl: string): string;
26
+ completeGamRequestSignals(url: string): Promise<string>;
26
27
  getEdgePodBaseUrl(): string | undefined;
27
28
  getFloorSnapshot(position: AdPosition): OpportunityFloor | undefined;
28
29
  onAdClick(): void;
@@ -88,12 +89,6 @@ declare class AdBreakOrchestrator {
88
89
  private isLiveBreak;
89
90
  private canRequestEdge;
90
91
  private markEdgeExhausted;
91
- /**
92
- * Builds the next Edge request from the budget left right now, or marks Edge
93
- * exhausted for this break. Synchronous on purpose: callers must reach the
94
- * REQUESTING state in the same tick so a second completion event cannot race
95
- * in a parallel request.
96
- */
97
92
  private prepareEdgePodRequest;
98
93
  private runEdgePod;
99
94
  private continueAfterEdgeOutcome;
@@ -112,7 +107,10 @@ declare class AdBreakOrchestrator {
112
107
  private recordRequestFailure;
113
108
  private recordRequestDiagnostic;
114
109
  private finalizeRequestDiagnostics;
115
- private withCurrentPodBudget;
110
+ private createGamDispatchFinalizer;
111
+ private logPodDispatch;
112
+ private recordPodResponseDiagnostics;
113
+ private handlePodRequestNotSent;
116
114
  private opportunityFloorFields;
117
115
  private requestFloorFields;
118
116
  private applyOpportunityFloor;
@@ -328,21 +328,20 @@ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
328
328
  "adid"
329
329
  ]);
330
330
  function resolveVastEnvironmentSignals(isCtv) {
331
- var _ref;
332
331
  var bridgeSignals = readNativeBridgeSignals();
333
332
  var platformDevice = readPlatformNativeDeviceId();
334
- var realDeviceId = bridgeSignals.deviceId || (isCtv ? readStoredDeviceId() : void 0) || platformDevice.deviceId;
333
+ var bridgeDeviceId = validDeviceId(bridgeSignals.deviceId);
334
+ var realDeviceId = bridgeDeviceId || (isCtv ? validDeviceId(readStoredDeviceId()) : void 0) || validDeviceId(platformDevice.deviceId);
335
335
  var deviceId = realDeviceId;
336
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
337
- var platformLat = bridgeSignals.deviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
338
- var limitAdTracking = deviceId != null ? (_ref = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
336
+ var deviceIdType = (bridgeDeviceId ? bridgeSignals.deviceIdType : void 0) || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType();
337
+ var platformLat = bridgeDeviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
338
+ var limitAdTracking = deviceId != null ? platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking() : void 0;
339
339
  if (!deviceId && isCtv) {
340
340
  var dpid = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
341
341
  if (dpid) {
342
- var _ref1;
343
342
  deviceId = dpid;
344
343
  deviceIdType = "dpid";
345
- limitAdTracking = (_ref1 = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref1 !== void 0 ? _ref1 : false;
344
+ limitAdTracking = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking();
346
345
  }
347
346
  }
348
347
  var deviceTypeHint = resolveDeviceTypeHint(isCtv);
@@ -707,6 +706,9 @@ function isMacroPlaceholder(value) {
707
706
  var t = value.trim();
708
707
  return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
709
708
  }
709
+ function validDeviceId(value) {
710
+ return value && !isMacroPlaceholder(value) ? value : void 0;
711
+ }
710
712
  function isZeroedAdId(value) {
711
713
  return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
712
714
  }
@@ -1239,6 +1241,191 @@ function ensureVideoAdType(rawUrl) {
1239
1241
  return rawUrl;
1240
1242
  }
1241
1243
  }
1244
+ var SCVP_MACRO_DETECT = /\[SCVP-|%5BSCVP-|\(SCVP-|%28SCVP-/i;
1245
+ var SCVP_MACRO_PATTERN = /\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\)/gi;
1246
+ var SCVP_WHOLE_VALUE_PATTERN = /^\s*(?:\[SCVP-([A-Z0-9-]+)\]|\(SCVP-([A-Z0-9-]+)\))\s*$/i;
1247
+ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
1248
+ "cust_params"
1249
+ ]);
1250
+ var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
1251
+ "PMND",
1252
+ "PMXD",
1253
+ "PMAD"
1254
+ ]);
1255
+ function hasScvpMacros(url) {
1256
+ return !!url && SCVP_MACRO_DETECT.test(url);
1257
+ }
1258
+ function safeDecode(value) {
1259
+ try {
1260
+ return decodeURIComponent(value.replace(/\+/g, " "));
1261
+ } catch (unused) {
1262
+ return value;
1263
+ }
1264
+ }
1265
+ function findScvpMacroNames(url) {
1266
+ if (!url) return [];
1267
+ var names = /* @__PURE__ */ new Set();
1268
+ var text = url;
1269
+ for(var pass = 0; pass < 3; pass++){
1270
+ text.replace(SCVP_MACRO_PATTERN, function(_m, bracketName, parenName) {
1271
+ names.add(String(bracketName || parenName).toUpperCase());
1272
+ return "";
1273
+ });
1274
+ var decoded = safeDecode(text);
1275
+ if (decoded === text) break;
1276
+ text = decoded;
1277
+ }
1278
+ return Array.from(names);
1279
+ }
1280
+ function resolveScvpMacroValues(ctx) {
1281
+ var _ctx_deviceId, _ctx_deviceIdType, _ctx_consent, _ctx_consent1, _ctx_consent2;
1282
+ var values = /* @__PURE__ */ new Map();
1283
+ var set = function set(name, value) {
1284
+ if (value == null) return;
1285
+ var str = String(value).trim();
1286
+ if (str) values.set(name, str);
1287
+ };
1288
+ var toFlag = function toFlag(value) {
1289
+ return value == null ? void 0 : value ? "1" : "0";
1290
+ };
1291
+ var deviceId = (_ctx_deviceId = ctx.deviceId) === null || _ctx_deviceId === void 0 ? void 0 : _ctx_deviceId.trim();
1292
+ var deviceIdType = deviceId ? ((_ctx_deviceIdType = ctx.deviceIdType) === null || _ctx_deviceIdType === void 0 ? void 0 : _ctx_deviceIdType.trim()) || inferDeviceIdType() : void 0;
1293
+ if (deviceId && deviceIdType) {
1294
+ set("RDID", deviceId);
1295
+ set("IDTYPE", deviceIdType);
1296
+ set("IS-LAT", toFlag(ctx.limitAdTracking));
1297
+ }
1298
+ set("SID", ctx.sessionId);
1299
+ set("DTH", ctx.deviceTypeHint);
1300
+ set("GIVN", ctx.palNonce);
1301
+ set("CT-TI", ctx.programTitle);
1302
+ set("CT-CH", ctx.channelName);
1303
+ set("POD", ctx.pod);
1304
+ set("CORRELATOR", ctx.correlator);
1305
+ set("SCOR", ctx.streamCorrelator);
1306
+ set("VPMUTE", toFlag(ctx.adWillPlayMuted));
1307
+ if (ctx.adWillAutoPlay != null) {
1308
+ set("VPA", ctx.adWillAutoPlay ? "auto" : "click");
1309
+ }
1310
+ set("GDPR", (_ctx_consent = ctx.consent) === null || _ctx_consent === void 0 ? void 0 : _ctx_consent.gdpr);
1311
+ set("GDPR-CONSENT", (_ctx_consent1 = ctx.consent) === null || _ctx_consent1 === void 0 ? void 0 : _ctx_consent1.gdprConsent);
1312
+ set("US-PRIVACY", (_ctx_consent2 = ctx.consent) === null || _ctx_consent2 === void 0 ? void 0 : _ctx_consent2.usPrivacy);
1313
+ return values;
1314
+ }
1315
+ var keepNone = function keepNone() {
1316
+ return false;
1317
+ };
1318
+ function substituteScvpParams(params, values, unresolved, keep, nested) {
1319
+ var out = [];
1320
+ var replaceMacro = function replaceMacro(match, bracketName, parenName) {
1321
+ var name = String(bracketName || parenName).toUpperCase();
1322
+ var value = values.get(name);
1323
+ if (value != null) return value;
1324
+ if (keep(name)) return match;
1325
+ unresolved.add(name);
1326
+ return "";
1327
+ };
1328
+ params.forEach(function(value, key) {
1329
+ var whole = value.match(SCVP_WHOLE_VALUE_PATTERN);
1330
+ if (whole) {
1331
+ var name = String(whole[1] || whole[2]).toUpperCase();
1332
+ var resolved = values.get(name);
1333
+ if (resolved != null) {
1334
+ out.push([
1335
+ key,
1336
+ resolved
1337
+ ]);
1338
+ } else if (keep(name)) {
1339
+ out.push([
1340
+ key,
1341
+ value
1342
+ ]);
1343
+ } else {
1344
+ unresolved.add(name);
1345
+ }
1346
+ return;
1347
+ }
1348
+ if (!SCVP_MACRO_DETECT.test(value)) {
1349
+ out.push([
1350
+ key,
1351
+ value
1352
+ ]);
1353
+ return;
1354
+ }
1355
+ if (!nested && NESTED_QUERY_PARAM_KEYS.has(key)) {
1356
+ var inner = substituteScvpParams(new URLSearchParams(value), values, unresolved, keep, true);
1357
+ if (inner.length > 0) {
1358
+ out.push([
1359
+ key,
1360
+ inner.map(function(param) {
1361
+ var _param = _sliced_to_array(param, 2), k = _param[0], v = _param[1];
1362
+ return "".concat(encodeURIComponent(k), "=").concat(encodeURIComponent(v));
1363
+ }).join("&")
1364
+ ]);
1365
+ }
1366
+ return;
1367
+ }
1368
+ out.push([
1369
+ key,
1370
+ value.replace(SCVP_MACRO_PATTERN, replaceMacro)
1371
+ ]);
1372
+ });
1373
+ return out;
1374
+ }
1375
+ function substituteScvpMacros(baseUrl, values) {
1376
+ var keep = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : keepNone;
1377
+ var unresolved = /* @__PURE__ */ new Set();
1378
+ var url;
1379
+ try {
1380
+ url = new URL(normalizeVastTagUrl(baseUrl));
1381
+ } catch (unused) {
1382
+ var replaced = baseUrl.replace(SCVP_MACRO_PATTERN, function(match, bracketName, parenName) {
1383
+ var name = String(bracketName || parenName).toUpperCase();
1384
+ var value = values.get(name);
1385
+ if (value != null) return encodeURIComponent(value);
1386
+ if (keep(name)) return match;
1387
+ unresolved.add(name);
1388
+ return "";
1389
+ });
1390
+ return {
1391
+ url: replaced,
1392
+ unresolved: Array.from(unresolved)
1393
+ };
1394
+ }
1395
+ var entries = substituteScvpParams(url.searchParams, values, unresolved, keep, false);
1396
+ var search = new URLSearchParams();
1397
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1398
+ try {
1399
+ for(var _iterator = entries[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1400
+ var _step_value = _sliced_to_array(_step.value, 2), key = _step_value[0], value = _step_value[1];
1401
+ search.append(key, value);
1402
+ }
1403
+ } catch (err) {
1404
+ _didIteratorError = true;
1405
+ _iteratorError = err;
1406
+ } finally{
1407
+ try {
1408
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1409
+ _iterator.return();
1410
+ }
1411
+ } finally{
1412
+ if (_didIteratorError) {
1413
+ throw _iteratorError;
1414
+ }
1415
+ }
1416
+ }
1417
+ url.search = search.toString();
1418
+ return {
1419
+ url: url.toString(),
1420
+ unresolved: Array.from(unresolved)
1421
+ };
1422
+ }
1423
+ function applyScvpMacros(baseUrl, ctx) {
1424
+ var deferred = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : /* @__PURE__ */ new Set();
1425
+ return substituteScvpMacros(baseUrl, resolveScvpMacroValues(ctx), function(name) {
1426
+ return deferred.has(name);
1427
+ });
1428
+ }
1242
1429
  function applyVastMacros(baseUrl, ctx) {
1243
1430
  var expandedUrl = expandInlineMacroPlaceholders(baseUrl, ctx);
1244
1431
  var url;
@@ -1280,15 +1467,6 @@ function applyVastMacros(baseUrl, ctx) {
1280
1467
  }
1281
1468
  params.delete("ppos");
1282
1469
  params.delete("lip");
1283
- if (ctx.podMinDurationMs != null) {
1284
- params.set("pmnd", String(Math.max(0, Math.round(ctx.podMinDurationMs))));
1285
- }
1286
- if (ctx.podMaxDurationMs != null) {
1287
- params.set("pmxd", String(Math.max(0, Math.round(ctx.podMaxDurationMs))));
1288
- }
1289
- if (ctx.podMaxAds != null) {
1290
- params.set("pmad", String(Math.max(1, Math.round(ctx.podMaxAds))));
1291
- }
1292
1470
  var existingUrl = params.get("url") || "";
1293
1471
  if (EXAMPLE_COM_URL.test(existingUrl)) {
1294
1472
  params.delete("url");
@@ -1380,6 +1558,25 @@ function replaceCorrelatorFallback(baseUrl, correlator) {
1380
1558
  var sep = baseUrl.includes("?") ? "&" : "?";
1381
1559
  return "".concat(baseUrl).concat(sep, "correlator=").concat(correlator);
1382
1560
  }
1561
+ // src/player/OptimizedPodRequest.ts
1562
+ var DEFAULT_REQUEST_SAFETY_MS = 1500;
1563
+ function nonNegativeInt(value) {
1564
+ return typeof value === "number" && Number.isFinite(value) && value >= 0 ? Math.floor(value) : void 0;
1565
+ }
1566
+ function positiveInt(value) {
1567
+ return typeof value === "number" && Number.isFinite(value) && value >= 1 ? Math.floor(value) : void 0;
1568
+ }
1569
+ function resolveAdPodConfig(config) {
1570
+ var _config_adPodConfig, _nonNegativeInt, _nonNegativeInt1, _positiveInt;
1571
+ var pod = (_config_adPodConfig = config.adPodConfig) !== null && _config_adPodConfig !== void 0 ? _config_adPodConfig : {};
1572
+ return {
1573
+ requestSafetyMs: (_nonNegativeInt = nonNegativeInt(pod.requestSafetyMs)) !== null && _nonNegativeInt !== void 0 ? _nonNegativeInt : DEFAULT_REQUEST_SAFETY_MS,
1574
+ minPodDurationMs: (_nonNegativeInt1 = nonNegativeInt(pod.minPodDurationMs)) !== null && _nonNegativeInt1 !== void 0 ? _nonNegativeInt1 : 0,
1575
+ maxAdsPerBreak: pod.maxAdsPerBreak === void 0 ? positiveInt(config.podMaxAds) : positiveInt(pod.maxAdsPerBreak),
1576
+ maxPodDurationMs: (_positiveInt = positiveInt(pod.maxPodDurationMs)) !== null && _positiveInt !== void 0 ? _positiveInt : positiveInt(config.podMaxDurationMs),
1577
+ exactDuration: config.podExactDuration === true
1578
+ };
1579
+ }
1383
1580
  // src/utils/devUrl.ts
1384
1581
  var PRIVATE_HOST_PATTERNS = [
1385
1582
  /^localhost$/i,
@@ -1496,7 +1693,14 @@ function ingestPlayerTracking(licenseKey, channel, body) {
1496
1693
  // src/utils/tracking.ts
1497
1694
  var cachedBrowserId = null;
1498
1695
  function buildAnalyticsContext(config) {
1696
+ var _config_contentNetwork, _config_channelName, _config_programTitle;
1499
1697
  var context = {};
1698
+ var contentNetwork = (_config_contentNetwork = config.contentNetwork) === null || _config_contentNetwork === void 0 ? void 0 : _config_contentNetwork.trim();
1699
+ var contentChannel = (_config_channelName = config.channelName) === null || _config_channelName === void 0 ? void 0 : _config_channelName.trim();
1700
+ var contentTitle = (_config_programTitle = config.programTitle) === null || _config_programTitle === void 0 ? void 0 : _config_programTitle.trim();
1701
+ if (contentNetwork) context.contentNetwork = contentNetwork;
1702
+ if (contentChannel) context.contentChannel = contentChannel;
1703
+ if (contentTitle) context.contentTitle = contentTitle;
1500
1704
  if (config.debugAdTiming) {
1501
1705
  context.debugAdTiming = true;
1502
1706
  }
@@ -1913,6 +2117,21 @@ function sendHeartbeat(_0) {
1913
2117
  }).apply(this, arguments);
1914
2118
  }
1915
2119
  // src/player/AdConfigManager.ts
2120
+ function withDeferredPodParams(rawUrl, deferNonce) {
2121
+ try {
2122
+ var url = new URL(rawUrl);
2123
+ url.searchParams.set("pmnd", "[SCVP-PMND]");
2124
+ url.searchParams.set("pmxd", "[SCVP-PMXD]");
2125
+ url.searchParams.set("pmad", "[SCVP-PMAD]");
2126
+ if (deferNonce && !url.searchParams.get("givn")) {
2127
+ url.searchParams.delete("paln");
2128
+ url.searchParams.set("givn", "[SCVP-GIVN]");
2129
+ }
2130
+ return url.toString();
2131
+ } catch (unused) {
2132
+ return rawUrl;
2133
+ }
2134
+ }
1916
2135
  var AdConfigManager = /*#__PURE__*/ function() {
1917
2136
  function AdConfigManager(config, video) {
1918
2137
  _class_call_check(this, AdConfigManager);
@@ -1923,8 +2142,8 @@ var AdConfigManager = /*#__PURE__*/ function() {
1923
2142
  this.podCounter = 0;
1924
2143
  this.podAssignedByPrefetch = false;
1925
2144
  this.lastHeartbeatTime = 0;
1926
- this.defaultPodMaxAds = 6;
1927
- this.defaultPodMaxDurationMs = 12e4;
2145
+ this.defaultEdgePodMaxAds = 6;
2146
+ this.palNonceDispatchWaitMs = 1500;
1928
2147
  this.config = config;
1929
2148
  this.video = video;
1930
2149
  }
@@ -1952,7 +2171,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
1952
2171
  key: "fetchAdConfiguration",
1953
2172
  value: function fetchAdConfiguration() {
1954
2173
  return _async_to_generator(function() {
1955
- var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1, vastMode, vastEndpoint, apiUrl, headers, response, data, imaPayload, decodedPayload, numberAds;
2174
+ var _data_response_ima_publisherdeskima, _data_response_ima, _data_response, _data_response_options_vast_cue_tones, _data_response_options_vast, _data_response_options, _data_response1, apiUrl, headers, response, data, imaPayload, decodedPayload, numberAds;
1956
2175
  return _ts_generator(this, function(_state) {
1957
2176
  switch(_state.label){
1958
2177
  case 0:
@@ -1973,28 +2192,6 @@ var AdConfigManager = /*#__PURE__*/ function() {
1973
2192
  2
1974
2193
  ];
1975
2194
  case 2:
1976
- vastMode = this.config.vastMode || "default";
1977
- if (this.debug) {
1978
- console.log("[StormcloudVideoPlayer] VAST mode:", vastMode);
1979
- }
1980
- if (vastMode === "adstorm") {
1981
- if (!this.config.licenseKey) {
1982
- if (this.debug) {
1983
- console.warn("[StormcloudVideoPlayer] AdStorm mode requires a license key");
1984
- }
1985
- return [
1986
- 2
1987
- ];
1988
- }
1989
- vastEndpoint = "https://adstorm.co/api-adstorm-dev/adstorm/vast/".concat(this.config.licenseKey);
1990
- this.apiVastTagUrl = vastEndpoint;
1991
- if (this.debug) {
1992
- console.log("[StormcloudVideoPlayer] Using AdStorm VAST endpoint (adstorm mode):", vastEndpoint);
1993
- }
1994
- return [
1995
- 2
1996
- ];
1997
- }
1998
2195
  if (this.config.vastTagUrl) {
1999
2196
  this.apiVastTagUrl = normalizeVastTagUrl(this.config.vastTagUrl);
2000
2197
  if (this.debug) {
@@ -2004,7 +2201,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
2004
2201
  2
2005
2202
  ];
2006
2203
  }
2007
- apiUrl = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
2204
+ apiUrl = "https://edge.stormcloudhub.com/api/v1/adstorm/ads/web";
2008
2205
  if (this.debug) {
2009
2206
  console.log("[StormcloudVideoPlayer] Fetching ad configuration from:", apiUrl);
2010
2207
  }
@@ -2351,16 +2548,16 @@ var AdConfigManager = /*#__PURE__*/ function() {
2351
2548
  }
2352
2549
  },
2353
2550
  {
2354
- key: "resolvePodParams",
2355
- value: function resolvePodParams(breakDurationMs) {
2356
- var maxDurationMs = breakDurationMs != null && breakDurationMs > 0 ? breakDurationMs : this.config.podMaxDurationMs != null && this.config.podMaxDurationMs > 0 ? this.config.podMaxDurationMs : this.defaultPodMaxDurationMs;
2357
- var maxAds = this.config.podMaxAds && this.config.podMaxAds > 0 ? this.config.podMaxAds : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultPodMaxAds;
2358
- var minDurationMs = this.config.podExactDuration && maxDurationMs != null ? maxDurationMs : 0;
2359
- return {
2360
- maxAds: maxAds,
2361
- minDurationMs: minDurationMs,
2362
- maxDurationMs: maxDurationMs
2363
- };
2551
+ key: "resolveAdPodConfig",
2552
+ value: function resolveAdPodConfig1() {
2553
+ return resolveAdPodConfig(this.config);
2554
+ }
2555
+ },
2556
+ {
2557
+ key: "resolveEdgeMaxAds",
2558
+ value: function resolveEdgeMaxAds() {
2559
+ var _this_resolveAdPodConfig_maxAdsPerBreak;
2560
+ return (_this_resolveAdPodConfig_maxAdsPerBreak = this.resolveAdPodConfig().maxAdsPerBreak) !== null && _this_resolveAdPodConfig_maxAdsPerBreak !== void 0 ? _this_resolveAdPodConfig_maxAdsPerBreak : this.apiNumberAds && this.apiNumberAds > 0 ? this.apiNumberAds : this.defaultEdgePodMaxAds;
2364
2561
  }
2365
2562
  },
2366
2563
  {
@@ -2377,17 +2574,13 @@ var AdConfigManager = /*#__PURE__*/ function() {
2377
2574
  },
2378
2575
  {
2379
2576
  key: "generatePodVastUrl",
2380
- value: function generatePodVastUrl(baseUrl, podParams, adPlayer, palNonce, inAdBreak) {
2381
- var _podParams_maxDurationMs;
2577
+ value: function generatePodVastUrl(baseUrl, adPlayer, palNonce, inAdBreak) {
2382
2578
  var adWillPlayMuted = inAdBreak ? adPlayer.getOriginalMutedState() : this.video.muted;
2383
2579
  var envSignals = resolveVastEnvironmentSignals(!!this.config.ctvAdRequest);
2384
- var urlWithMacros = applyVastMacros(baseUrl, _object_spread_props(_object_spread({
2580
+ var macroContext = _object_spread_props(_object_spread({
2385
2581
  correlator: this.viewCorrelator,
2386
2582
  streamCorrelator: this.streamCorrelator,
2387
2583
  pod: this.podCounter > 0 ? this.podCounter : void 0,
2388
- podMaxAds: podParams.maxAds,
2389
- podMinDurationMs: podParams.minDurationMs,
2390
- podMaxDurationMs: podParams.maxDurationMs,
2391
2584
  isCtv: envSignals.isCtv,
2392
2585
  pageUrl: !envSignals.isCtv && typeof window !== "undefined" ? toDevSafeUrl(window.location.href) : void 0,
2393
2586
  adWillPlayMuted: adWillPlayMuted,
@@ -2403,13 +2596,72 @@ var AdConfigManager = /*#__PURE__*/ function() {
2403
2596
  } : {}, this.config.channelName ? {
2404
2597
  channelName: this.config.channelName
2405
2598
  } : {}), {
2406
- consent: this.consentSignals
2407
- }));
2408
- var finalUrl = palNonce.injectNonce(ensureVideoAdType(urlWithMacros));
2409
- console.log("[StormcloudVideoPlayer] Resolved optimized-pod request URL (pod=".concat(this.podCounter, ", pmad=").concat(podParams.maxAds, ", pmnd=").concat(podParams.minDurationMs, ", pmxd=").concat((_podParams_maxDurationMs = podParams.maxDurationMs) !== null && _podParams_maxDurationMs !== void 0 ? _podParams_maxDurationMs : "?", "):"), finalUrl);
2599
+ consent: this.consentSignals,
2600
+ palNonce: palNonce.getCurrentNonce() || void 0
2601
+ });
2602
+ var nonceReady = !!macroContext.palNonce;
2603
+ var finalUrl;
2604
+ if (hasScvpMacros(baseUrl)) {
2605
+ var deferred = new Set(SCVP_POD_MACROS);
2606
+ if (!nonceReady) deferred.add("GIVN");
2607
+ var _applyScvpMacros = applyScvpMacros(baseUrl, macroContext, deferred), url = _applyScvpMacros.url, unresolved = _applyScvpMacros.unresolved;
2608
+ if (unresolved.length > 0) {
2609
+ console.warn("[StormcloudVideoPlayer] Unresolved SCVP macros (removed from request):", unresolved.join(", "));
2610
+ }
2611
+ finalUrl = ensureVideoAdType(url);
2612
+ } else {
2613
+ finalUrl = withDeferredPodParams(palNonce.injectNonce(ensureVideoAdType(applyVastMacros(baseUrl, macroContext))), !nonceReady);
2614
+ }
2615
+ console.log("[StormcloudVideoPlayer] Prepared optimized-pod request URL (pod=".concat(this.podCounter, "; pmnd/pmxd/pmad resolved at dispatch):"), finalUrl);
2410
2616
  return finalUrl;
2411
2617
  }
2412
2618
  },
2619
+ {
2620
+ key: "completeDeferredRequestSignals",
2621
+ value: function completeDeferredRequestSignals(url, palNonce) {
2622
+ return _async_to_generator(function() {
2623
+ var nonce, _tmp;
2624
+ return _ts_generator(this, function(_state) {
2625
+ switch(_state.label){
2626
+ case 0:
2627
+ if (findScvpMacroNames(url).indexOf("GIVN") === -1) return [
2628
+ 2,
2629
+ url
2630
+ ];
2631
+ _tmp = palNonce.getCurrentNonce();
2632
+ if (_tmp) return [
2633
+ 3,
2634
+ 2
2635
+ ];
2636
+ return [
2637
+ 4,
2638
+ palNonce.waitForNonce(this.palNonceDispatchWaitMs)
2639
+ ];
2640
+ case 1:
2641
+ _tmp = _state.sent();
2642
+ _state.label = 2;
2643
+ case 2:
2644
+ nonce = _tmp;
2645
+ if (!nonce) return [
2646
+ 2,
2647
+ url
2648
+ ];
2649
+ return [
2650
+ 2,
2651
+ substituteScvpMacros(url, /* @__PURE__ */ new Map([
2652
+ [
2653
+ "GIVN",
2654
+ nonce
2655
+ ]
2656
+ ]), function(name) {
2657
+ return name !== "GIVN";
2658
+ }).url
2659
+ ];
2660
+ }
2661
+ });
2662
+ }).call(this);
2663
+ }
2664
+ },
2413
2665
  {
2414
2666
  // --- Tracking ---
2415
2667
  key: "initializeTracking",