stormcloud-video-player 0.8.81 → 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 (36) hide show
  1. package/dist/stormcloud-vp.min.js +1 -1
  2. package/lib/Player.d.cts +1 -1
  3. package/lib/StormcloudPlayer.cjs +79 -7
  4. package/lib/StormcloudPlayer.cjs.map +1 -1
  5. package/lib/index.cjs +79 -7
  6. package/lib/index.cjs.map +1 -1
  7. package/lib/index.d.ts +3 -0
  8. package/lib/index.js +79 -7
  9. package/lib/index.js.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.cjs +63 -3
  11. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  12. package/lib/player/AdBreakOrchestrator.d.cts +1 -0
  13. package/lib/player/AdConfigManager.cjs +7 -2
  14. package/lib/player/AdConfigManager.cjs.map +1 -1
  15. package/lib/player/StormcloudVideoPlayer.cjs +79 -7
  16. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  17. package/lib/players/HlsPlayer.cjs +79 -7
  18. package/lib/players/HlsPlayer.cjs.map +1 -1
  19. package/lib/players/index.cjs +79 -7
  20. package/lib/players/index.cjs.map +1 -1
  21. package/lib/sdk/hlsAdPlayer.cjs +13 -0
  22. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  23. package/lib/types.d.cts +1 -0
  24. package/lib/ui/StormcloudVideoPlayer.cjs +79 -7
  25. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  26. package/lib/utils/__tests__/adSignals.test.cjs +6 -2
  27. package/lib/utils/__tests__/adSignals.test.cjs.map +1 -1
  28. package/lib/utils/browserCompat.cjs +33 -0
  29. package/lib/utils/browserCompat.cjs.map +1 -1
  30. package/lib/utils/browserCompat.d.cts +3 -1
  31. package/lib/utils/contentMetadata.cjs +15 -4
  32. package/lib/utils/contentMetadata.cjs.map +1 -1
  33. package/lib/utils/contentMetadata.d.cts +2 -0
  34. package/lib/utils/partnerSignals.cjs +3 -1
  35. package/lib/utils/partnerSignals.cjs.map +1 -1
  36. package/package.json +1 -1
package/lib/types.d.cts CHANGED
@@ -58,6 +58,7 @@ interface StormcloudVideoPlayerConfig {
58
58
  channelName?: string;
59
59
  contentNetwork?: string;
60
60
  contentDetails?: ContentDetails;
61
+ allowRepeatAdsInBreak?: boolean;
61
62
  adUserId?: string;
62
63
  clientIpAddress?: string;
63
64
  adDeviceId?: string;
@@ -1292,7 +1292,9 @@ var BRIDGE_KEYS = {
1292
1292
  ],
1293
1293
  contentRating: [
1294
1294
  "contentRating",
1295
- "ctr"
1295
+ "ctr",
1296
+ "programRating",
1297
+ "rating"
1296
1298
  ],
1297
1299
  contentId: [
1298
1300
  "contentId",
@@ -1304,7 +1306,9 @@ function sanitizeContentValue(value) {
1304
1306
  var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1305
1307
  if (!cleaned) return void 0;
1306
1308
  if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1307
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1309
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1310
+ return void 0;
1311
+ }
1308
1312
  return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1309
1313
  }
1310
1314
  function sanitizeContentScalar(value) {
@@ -1430,6 +1434,7 @@ function resolveContentMetadata(config) {
1430
1434
  } : {});
1431
1435
  }
1432
1436
  function applyContentMetadataUpdate(target, meta) {
1437
+ var _target_contentDetails;
1433
1438
  var apply = function apply(key, value) {
1434
1439
  if (value === void 0) return;
1435
1440
  var clean = value === null ? void 0 : sanitizeContentValue(value);
@@ -1439,9 +1444,15 @@ function applyContentMetadataUpdate(target, meta) {
1439
1444
  apply("channelName", meta.channelName);
1440
1445
  apply("programTitle", meta.programTitle);
1441
1446
  apply("contentNetwork", meta.contentNetwork);
1442
- if (meta.details === void 0) return;
1443
1447
  if (meta.details === null) delete target.contentDetails;
1444
- else target.contentDetails = _object_spread({}, meta.details);
1448
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1449
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1450
+ if (rating === void 0) return;
1451
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1452
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1453
+ if (cleanRating) details.rating = cleanRating;
1454
+ else delete details.rating;
1455
+ target.contentDetails = details;
1445
1456
  }
1446
1457
  function appendMissingContentParams(url, meta) {
1447
1458
  if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
@@ -2837,9 +2848,30 @@ function detectBrowser() {
2837
2848
  };
2838
2849
  }
2839
2850
  var singleDecoderOverride;
2851
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2852
+ var learnedSingleDecoder;
2840
2853
  function setSingleDecoderOverride(value) {
2841
2854
  singleDecoderOverride = value;
2842
2855
  }
2856
+ function readLearnedSingleDecoder() {
2857
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2858
+ try {
2859
+ var _window_localStorage;
2860
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2861
+ } catch (unused) {
2862
+ learnedSingleDecoder = false;
2863
+ }
2864
+ return learnedSingleDecoder;
2865
+ }
2866
+ function markSingleDecoderLearned() {
2867
+ if (readLearnedSingleDecoder()) return false;
2868
+ learnedSingleDecoder = true;
2869
+ try {
2870
+ var _window_localStorage;
2871
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2872
+ } catch (unused) {}
2873
+ return true;
2874
+ }
2843
2875
  function requiresMediaPipelineResetAfterAds() {
2844
2876
  var _browser_tizenVersion;
2845
2877
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2847,6 +2879,7 @@ function requiresMediaPipelineResetAfterAds() {
2847
2879
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2848
2880
  if (typeof globalOverride === "boolean") return globalOverride;
2849
2881
  } catch (unused) {}
2882
+ if (readLearnedSingleDecoder()) return true;
2850
2883
  var browser = detectBrowser();
2851
2884
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2852
2885
  }
@@ -9626,6 +9659,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
9626
9659
  ct_ch: content.channelName,
9627
9660
  ct_ti: content.programTitle,
9628
9661
  ct_ne: content.contentNetwork,
9662
+ rating: content.contentRating,
9629
9663
  ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9630
9664
  live: isLive,
9631
9665
  player: playerSize,
@@ -11309,6 +11343,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11309
11343
  this.adDetectSentForCurrentBreak = false;
11310
11344
  this.slotState = "IDLE";
11311
11345
  this.unusableResponsesInBreak = 0;
11346
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11312
11347
  this.controllerGeneration = 0;
11313
11348
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11314
11349
  this.breakFunnel = {};
@@ -11405,6 +11440,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11405
11440
  _this.recordRequestDiagnostic(payload);
11406
11441
  });
11407
11442
  adPlayer.on("ad_impression", function() {
11443
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11444
+ 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);
11445
+ if (impressionAdId != null && impressionAdId !== "") {
11446
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11447
+ }
11408
11448
  _this.timing.consecutiveFailures = 0;
11409
11449
  _this.setSlotState("PLAYING", "impression");
11410
11450
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11596,6 +11636,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11596
11636
  this.resetEdgeStateForBreak();
11597
11637
  this.followUpBaseVastUrl = void 0;
11598
11638
  this.unusableResponsesInBreak = 0;
11639
+ this.playedAdIdsInBreak.clear();
11599
11640
  this.timing.totalAdRequestsInBreak = 0;
11600
11641
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11601
11642
  this.noteOpportunity("vmap", breakKey, position);
@@ -11646,6 +11687,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11646
11687
  this.breakSource = "scte35";
11647
11688
  this.followUpBaseVastUrl = baseVastUrl;
11648
11689
  this.unusableResponsesInBreak = 0;
11690
+ this.playedAdIdsInBreak.clear();
11649
11691
  this.resetEdgeStateForBreak();
11650
11692
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11651
11693
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12485,6 +12527,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12485
12527
  var outcome;
12486
12528
  if (message.includes("ad_duration_exceeds_budget")) {
12487
12529
  outcome = "discarded_budget";
12530
+ } else if (message.includes("ad_repeated_in_break")) {
12531
+ outcome = "discarded_duplicate";
12488
12532
  } else if (message.includes("VAST fill rejected")) {
12489
12533
  outcome = "fill_rejected";
12490
12534
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12499,7 +12543,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12499
12543
  outcome = "request_failed";
12500
12544
  }
12501
12545
  this.timing.consecutiveFailures++;
12502
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12546
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12503
12547
  this.unusableResponsesInBreak++;
12504
12548
  }
12505
12549
  if (outcome === "no_fill") {
@@ -12513,7 +12557,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12513
12557
  }) ? diag.dispatchedUrl : vastTagUrl;
12514
12558
  if (this.timing.isTemporaryAdError(error)) {
12515
12559
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12516
- } else if (outcome !== "discarded_budget") {
12560
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12517
12561
  this.timing.failedVastUrls.add(failureKey);
12518
12562
  }
12519
12563
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12885,7 +12929,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12885
12929
  value: function playSingleAd(vastTagUrl) {
12886
12930
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12887
12931
  return _async_to_generator(function() {
12888
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12932
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12889
12933
  return _ts_generator(this, function(_state) {
12890
12934
  switch(_state.label){
12891
12935
  case 0:
@@ -12998,6 +13042,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12998
13042
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
12999
13043
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13000
13044
  }, this.analyticsContext).catch(function() {});
13045
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13046
+ 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))) {
13047
+ if (this.debug) {
13048
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13049
+ }
13050
+ this.logOrchestratorFunnel("discarded_duplicate", {
13051
+ adId: String(loadedAdId)
13052
+ });
13053
+ throw new Error("ad_repeated_in_break");
13054
+ }
13001
13055
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
13002
13056
  ;
13003
13057
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -13051,6 +13105,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13051
13105
  this.recordRequestFailure(error, vastTagUrl);
13052
13106
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
13053
13107
  this.recreateAdController("discarded_budget");
13108
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13109
+ this.recreateAdController("discarded_duplicate");
13054
13110
  }
13055
13111
  throw error;
13056
13112
  case 10:
@@ -13124,6 +13180,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13124
13180
  tagAllowsAudio: count("tag_allows_audio"),
13125
13181
  missingImpression: count("vast_missing_impression"),
13126
13182
  discardedBudget: count("discarded_budget"),
13183
+ discardedDuplicate: count("discarded_duplicate"),
13127
13184
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
13128
13185
  mediaRejected: count("media_candidate:rejected"),
13129
13186
  mediaFallbacks: count("media_fallback"),
@@ -13199,6 +13256,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13199
13256
  this.breakSource = void 0;
13200
13257
  this.followUpBaseVastUrl = void 0;
13201
13258
  this.unusableResponsesInBreak = 0;
13259
+ this.playedAdIdsInBreak.clear();
13202
13260
  this.resetEdgeStateForBreak();
13203
13261
  adPlayer.stop().catch(function() {});
13204
13262
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13299,9 +13357,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13299
13357
  var maxMonitorMs = 45e3;
13300
13358
  var startTime = Date.now();
13301
13359
  var baseline = resumeBaseline;
13360
+ var lastSeenTime = resumeBaseline;
13302
13361
  var recoveries = 0;
13303
13362
  var lastRecoveryAt = 0;
13304
13363
  var video = this.host.video;
13364
+ var onDecodeError = function onDecodeError() {
13365
+ var _video_error;
13366
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13367
+ if (markSingleDecoderLearned() && _this.debug) {
13368
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13369
+ }
13370
+ };
13371
+ video.addEventListener("error", onDecodeError);
13305
13372
  var listenersAttached = false;
13306
13373
  var onMediaEvent;
13307
13374
  var diagEvents = [
@@ -13351,6 +13418,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13351
13418
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13352
13419
  }
13353
13420
  var cleanup = function cleanup() {
13421
+ video.removeEventListener("error", onDecodeError);
13354
13422
  if (listenersAttached && onMediaEvent) {
13355
13423
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13356
13424
  try {
@@ -13381,6 +13449,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13381
13449
  return;
13382
13450
  }
13383
13451
  var currentTime = video.currentTime;
13452
+ if (currentTime + 1 < lastSeenTime) {
13453
+ baseline = currentTime;
13454
+ }
13455
+ lastSeenTime = currentTime;
13384
13456
  var advanced = currentTime > baseline + 0.5;
13385
13457
  var playing = !video.paused && video.readyState >= 3;
13386
13458
  if (advanced && playing) {