stormcloud-video-player 0.8.80 → 0.8.82

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 (64) hide show
  1. package/dist/stormcloud-vp.min.js +2 -2
  2. package/lib/Player.d.cts +1 -0
  3. package/lib/StormcloudPlayer.cjs +527 -142
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/StormcloudPlayer.d.cts +1 -0
  6. package/lib/index.cjs +553 -143
  7. package/lib/index.cjs.map +1 -1
  8. package/lib/index.d.cts +1 -0
  9. package/lib/index.d.ts +33 -5
  10. package/lib/index.js +553 -143
  11. package/lib/index.js.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.cjs +100 -12
  13. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  14. package/lib/player/AdBreakOrchestrator.d.cts +2 -0
  15. package/lib/player/AdConfigManager.cjs +413 -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 +527 -142
  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 +527 -142
  32. package/lib/players/HlsPlayer.cjs.map +1 -1
  33. package/lib/players/HlsPlayer.d.cts +1 -0
  34. package/lib/players/index.cjs +527 -142
  35. package/lib/players/index.cjs.map +1 -1
  36. package/lib/props.d.cts +1 -0
  37. package/lib/sdk/hlsAdPlayer.cjs +13 -0
  38. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  39. package/lib/sdk/hlsAdPlayer.d.cts +1 -0
  40. package/lib/types.d.cts +8 -1
  41. package/lib/ui/StormcloudVideoPlayer.cjs +553 -143
  42. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  43. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
  44. package/lib/utils/__tests__/adSignals.test.cjs +174 -15
  45. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  46. package/lib/utils/browserCompat.cjs +33 -0
  47. package/lib/utils/browserCompat.cjs.map +1 -1
  48. package/lib/utils/browserCompat.d.cts +3 -1
  49. package/lib/utils/contentMetadata.cjs +132 -5
  50. package/lib/utils/contentMetadata.cjs.map +1 -1
  51. package/lib/utils/contentMetadata.d.cts +39 -1
  52. package/lib/utils/deviceInfo.cjs +24 -4
  53. package/lib/utils/deviceInfo.cjs.map +1 -1
  54. package/lib/utils/deviceInfo.d.cts +3 -0
  55. package/lib/utils/partnerSignals.cjs +296 -0
  56. package/lib/utils/partnerSignals.cjs.map +1 -0
  57. package/lib/utils/partnerSignals.d.cts +12 -0
  58. package/lib/utils/tracking.cjs +24 -4
  59. package/lib/utils/tracking.cjs.map +1 -1
  60. package/lib/utils/tracking.d.cts +1 -0
  61. package/lib/utils/vastMacros.cjs +51 -1
  62. package/lib/utils/vastMacros.cjs.map +1 -1
  63. package/lib/utils/vastMacros.d.cts +20 -0
  64. package/package.json +1 -1
@@ -896,7 +896,8 @@ var NESTED_QUERY_PARAM_KEYS = /* @__PURE__ */ new Set([
896
896
  var SCVP_POD_MACROS = /* @__PURE__ */ new Set([
897
897
  "PMND",
898
898
  "PMXD",
899
- "PMAD"
899
+ "PMAD",
900
+ "MABD"
900
901
  ]);
901
902
  function safeDecode(value) {
902
903
  try {
@@ -1383,6 +1384,11 @@ function readBridge(keys) {
1383
1384
  }
1384
1385
  return void 0;
1385
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
+ }
1386
1392
  function normalizeCategory(value) {
1387
1393
  var v = cleanString(value);
1388
1394
  if (!v) return void 0;
@@ -1481,7 +1487,7 @@ function categorize(platform, model) {
1481
1487
  return "Other";
1482
1488
  }
1483
1489
  function getDeviceInfo() {
1484
- var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory;
1490
+ var _cleanString, _cleanString1, _ref, _cleanString2, _ref1, _cleanString3, _ref2, _normalizeCategory, _ref3, _cleanString4, _cleanString5;
1485
1491
  var platform = platformCache !== null && platformCache !== void 0 ? platformCache : computePlatformInfo();
1486
1492
  if (primePromise && !platformCache) {} else {
1487
1493
  platformCache = platform;
@@ -1504,7 +1510,14 @@ function getDeviceInfo() {
1504
1510
  ]),
1505
1511
  category: normalizeCategory(readBridge([
1506
1512
  "deviceCategory"
1507
- ]))
1513
+ ])),
1514
+ make: readBridge([
1515
+ "deviceMake"
1516
+ ]),
1517
+ hardwareVersion: readBridge([
1518
+ "deviceHardwareVersion",
1519
+ "hardwareVersion"
1520
+ ])
1508
1521
  };
1509
1522
  var terminalId = (_cleanString = cleanString(host.terminalId)) !== null && _cleanString !== void 0 ? _cleanString : bridge.terminalId;
1510
1523
  var hostInternalId = (_cleanString1 = cleanString(host.internalDeviceId)) !== null && _cleanString1 !== void 0 ? _cleanString1 : bridge.internalDeviceId;
@@ -1517,7 +1530,9 @@ function getDeviceInfo() {
1517
1530
  bridge.internalDeviceId,
1518
1531
  bridge.model,
1519
1532
  bridge.firmware,
1520
- bridge.category
1533
+ bridge.category,
1534
+ bridge.make,
1535
+ bridge.hardwareVersion
1521
1536
  ];
1522
1537
  if (bridgeValues.some(function(v) {
1523
1538
  return v !== void 0;
@@ -1525,12 +1540,18 @@ function getDeviceInfo() {
1525
1540
  if (hostDeviceInfo) sources.unshift("host");
1526
1541
  var internalDeviceId = hostInternalId !== null && hostInternalId !== void 0 ? hostInternalId : platform.internalDeviceId;
1527
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;
1528
1545
  var sonifiModel = model && category === "Samsung TV" && !/^SAMSUNG-IPTV-/i.test(model) ? "SAMSUNG-IPTV-".concat(model) : model;
1529
1546
  return _object_spread_props(_object_spread({
1530
1547
  category: category,
1531
1548
  categoryCode: CATEGORY_CODES[category]
1532
- }, model ? {
1549
+ }, make ? {
1550
+ make: make
1551
+ } : {}, model ? {
1533
1552
  model: model
1553
+ } : {}, hardwareVersion ? {
1554
+ hardwareVersion: hardwareVersion
1534
1555
  } : {}, sonifiModel ? {
1535
1556
  sonifiModel: sonifiModel
1536
1557
  } : {}, firmware ? {
@@ -2218,15 +2239,20 @@ function finalizeGamRequestUrl(rawUrl, ctx) {
2218
2239
  values.set("PMND", String(pod.pmnd));
2219
2240
  values.set("PMXD", String(pod.pmxd));
2220
2241
  if (pod.pmad != null) values.set("PMAD", String(pod.pmad));
2242
+ values.set("MABD", String(Math.max(1, Math.floor(pod.pmxd / 1e3))));
2221
2243
  }
2222
2244
  var substituted = substituteScvpMacros(rawUrl, values);
2223
2245
  var finalUrl;
2224
2246
  try {
2225
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
+ };
2226
2252
  if (pod) {
2227
- url.searchParams.set("pmnd", String(pod.pmnd));
2228
- url.searchParams.set("pmxd", String(pod.pmxd));
2229
- 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);
2230
2256
  else url.searchParams.delete("pmad");
2231
2257
  } else {
2232
2258
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2292,7 +2318,9 @@ function validateGamRequestUrl(url, expect) {
2292
2318
  if (leftover.length > 0) problems.push("unresolved SCVP macros: ".concat(leftover.join(", ")));
2293
2319
  var params;
2294
2320
  try {
2295
- 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;
2296
2324
  } catch (unused) {
2297
2325
  return problems.concat("URL could not be parsed");
2298
2326
  }
@@ -2412,6 +2440,28 @@ function getScreenInactiveReason() {
2412
2440
  if (bridgeSaysStandby()) return "bridge_standby";
2413
2441
  return void 0;
2414
2442
  }
2443
+ // src/utils/browserCompat.ts
2444
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2445
+ var learnedSingleDecoder;
2446
+ function readLearnedSingleDecoder() {
2447
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2448
+ try {
2449
+ var _window_localStorage;
2450
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2451
+ } catch (unused) {
2452
+ learnedSingleDecoder = false;
2453
+ }
2454
+ return learnedSingleDecoder;
2455
+ }
2456
+ function markSingleDecoderLearned() {
2457
+ if (readLearnedSingleDecoder()) return false;
2458
+ learnedSingleDecoder = true;
2459
+ try {
2460
+ var _window_localStorage;
2461
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2462
+ } catch (unused) {}
2463
+ return true;
2464
+ }
2415
2465
  // src/player/AdBreakOrchestrator.ts
2416
2466
  var REQUEST_FAILURE_STAGES = /* @__PURE__ */ new Set([
2417
2467
  "no_fill",
@@ -2434,6 +2484,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2434
2484
  this.adDetectSentForCurrentBreak = false;
2435
2485
  this.slotState = "IDLE";
2436
2486
  this.unusableResponsesInBreak = 0;
2487
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
2437
2488
  this.controllerGeneration = 0;
2438
2489
  this.requestDiagnostics = /* @__PURE__ */ new Map();
2439
2490
  this.breakFunnel = {};
@@ -2530,6 +2581,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2530
2581
  _this.recordRequestDiagnostic(payload);
2531
2582
  });
2532
2583
  adPlayer.on("ad_impression", function() {
2584
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
2585
+ var impressionAdId = (_this_host_getAdPlayer_getLoadedAdId = (_this_host_getAdPlayer = _this.host.getAdPlayer()).getLoadedAdId) === null || _this_host_getAdPlayer_getLoadedAdId === void 0 ? void 0 : _this_host_getAdPlayer_getLoadedAdId.call(_this_host_getAdPlayer);
2586
+ if (impressionAdId != null && impressionAdId !== "") {
2587
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
2588
+ }
2533
2589
  _this.timing.consecutiveFailures = 0;
2534
2590
  _this.setSlotState("PLAYING", "impression");
2535
2591
  if (!_this.playbackStartedForCurrentRequest) {
@@ -2721,6 +2777,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2721
2777
  this.resetEdgeStateForBreak();
2722
2778
  this.followUpBaseVastUrl = void 0;
2723
2779
  this.unusableResponsesInBreak = 0;
2780
+ this.playedAdIdsInBreak.clear();
2724
2781
  this.timing.totalAdRequestsInBreak = 0;
2725
2782
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
2726
2783
  this.noteOpportunity("vmap", breakKey, position);
@@ -2771,6 +2828,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
2771
2828
  this.breakSource = "scte35";
2772
2829
  this.followUpBaseVastUrl = baseVastUrl;
2773
2830
  this.unusableResponsesInBreak = 0;
2831
+ this.playedAdIdsInBreak.clear();
2774
2832
  this.resetEdgeStateForBreak();
2775
2833
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
2776
2834
  if (this.adConfig.podAssignedByPrefetch) {
@@ -3610,6 +3668,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3610
3668
  var outcome;
3611
3669
  if (message.includes("ad_duration_exceeds_budget")) {
3612
3670
  outcome = "discarded_budget";
3671
+ } else if (message.includes("ad_repeated_in_break")) {
3672
+ outcome = "discarded_duplicate";
3613
3673
  } else if (message.includes("VAST fill rejected")) {
3614
3674
  outcome = "fill_rejected";
3615
3675
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -3624,7 +3684,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3624
3684
  outcome = "request_failed";
3625
3685
  }
3626
3686
  this.timing.consecutiveFailures++;
3627
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
3687
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
3628
3688
  this.unusableResponsesInBreak++;
3629
3689
  }
3630
3690
  if (outcome === "no_fill") {
@@ -3638,7 +3698,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
3638
3698
  }) ? diag.dispatchedUrl : vastTagUrl;
3639
3699
  if (this.timing.isTemporaryAdError(error)) {
3640
3700
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
3641
- } else if (outcome !== "discarded_budget") {
3701
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
3642
3702
  this.timing.failedVastUrls.add(failureKey);
3643
3703
  }
3644
3704
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -4010,7 +4070,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4010
4070
  value: function playSingleAd(vastTagUrl) {
4011
4071
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
4012
4072
  return _async_to_generator(function() {
4013
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
4073
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
4014
4074
  return _ts_generator(this, function(_state) {
4015
4075
  switch(_state.label){
4016
4076
  case 0:
@@ -4123,6 +4183,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4123
4183
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
4124
4184
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
4125
4185
  }, this.analyticsContext).catch(function() {});
4186
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
4187
+ if (!this.host.config.allowRepeatAdsInBreak && loadedAdId != null && loadedAdId !== "" && ((_ref = (_ap_getPodAdCount = ap.getPodAdCount) === null || _ap_getPodAdCount === void 0 ? void 0 : _ap_getPodAdCount.call(ap)) !== null && _ref !== void 0 ? _ref : 1) <= 1 && this.playedAdIdsInBreak.has(String(loadedAdId))) {
4188
+ if (this.debug) {
4189
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
4190
+ }
4191
+ this.logOrchestratorFunnel("discarded_duplicate", {
4192
+ adId: String(loadedAdId)
4193
+ });
4194
+ throw new Error("ad_repeated_in_break");
4195
+ }
4126
4196
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
4127
4197
  ;
4128
4198
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -4176,6 +4246,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4176
4246
  this.recordRequestFailure(error, vastTagUrl);
4177
4247
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
4178
4248
  this.recreateAdController("discarded_budget");
4249
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
4250
+ this.recreateAdController("discarded_duplicate");
4179
4251
  }
4180
4252
  throw error;
4181
4253
  case 10:
@@ -4249,6 +4321,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4249
4321
  tagAllowsAudio: count("tag_allows_audio"),
4250
4322
  missingImpression: count("vast_missing_impression"),
4251
4323
  discardedBudget: count("discarded_budget"),
4324
+ discardedDuplicate: count("discarded_duplicate"),
4252
4325
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
4253
4326
  mediaRejected: count("media_candidate:rejected"),
4254
4327
  mediaFallbacks: count("media_fallback"),
@@ -4324,6 +4397,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4324
4397
  this.breakSource = void 0;
4325
4398
  this.followUpBaseVastUrl = void 0;
4326
4399
  this.unusableResponsesInBreak = 0;
4400
+ this.playedAdIdsInBreak.clear();
4327
4401
  this.resetEdgeStateForBreak();
4328
4402
  adPlayer.stop().catch(function() {});
4329
4403
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -4424,9 +4498,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4424
4498
  var maxMonitorMs = 45e3;
4425
4499
  var startTime = Date.now();
4426
4500
  var baseline = resumeBaseline;
4501
+ var lastSeenTime = resumeBaseline;
4427
4502
  var recoveries = 0;
4428
4503
  var lastRecoveryAt = 0;
4429
4504
  var video = this.host.video;
4505
+ var onDecodeError = function onDecodeError() {
4506
+ var _video_error;
4507
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
4508
+ if (markSingleDecoderLearned() && _this.debug) {
4509
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
4510
+ }
4511
+ };
4512
+ video.addEventListener("error", onDecodeError);
4430
4513
  var listenersAttached = false;
4431
4514
  var onMediaEvent;
4432
4515
  var diagEvents = [
@@ -4476,6 +4559,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4476
4559
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
4477
4560
  }
4478
4561
  var cleanup = function cleanup() {
4562
+ video.removeEventListener("error", onDecodeError);
4479
4563
  if (listenersAttached && onMediaEvent) {
4480
4564
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
4481
4565
  try {
@@ -4506,6 +4590,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
4506
4590
  return;
4507
4591
  }
4508
4592
  var currentTime = video.currentTime;
4593
+ if (currentTime + 1 < lastSeenTime) {
4594
+ baseline = currentTime;
4595
+ }
4596
+ lastSeenTime = currentTime;
4509
4597
  var advanced = currentTime > baseline + 0.5;
4510
4598
  var playing = !video.paused && video.readyState >= 3;
4511
4599
  if (advanced && playing) {