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/index.d.ts CHANGED
@@ -48,6 +48,8 @@ interface ContentMetadataUpdate {
48
48
  channelName?: string | null | undefined;
49
49
  programTitle?: string | null | undefined;
50
50
  contentNetwork?: string | null | undefined;
51
+ programRating?: string | null | undefined;
52
+ contentRating?: string | null | undefined;
51
53
  details?: ContentDetails | null | undefined;
52
54
  }
53
55
 
@@ -108,6 +110,7 @@ interface StormcloudVideoPlayerConfig {
108
110
  channelName?: string;
109
111
  contentNetwork?: string;
110
112
  contentDetails?: ContentDetails;
113
+ allowRepeatAdsInBreak?: boolean;
111
114
  adUserId?: string;
112
115
  clientIpAddress?: string;
113
116
  adDeviceId?: string;
package/lib/index.js CHANGED
@@ -1272,7 +1272,9 @@ var BRIDGE_KEYS = {
1272
1272
  ],
1273
1273
  contentRating: [
1274
1274
  "contentRating",
1275
- "ctr"
1275
+ "ctr",
1276
+ "programRating",
1277
+ "rating"
1276
1278
  ],
1277
1279
  contentId: [
1278
1280
  "contentId",
@@ -1284,7 +1286,9 @@ function sanitizeContentValue(value) {
1284
1286
  var cleaned = value.replace(/[\u0000-\u001f\u007f]/g, " ").replace(/\s+/g, " ").trim();
1285
1287
  if (!cleaned) return void 0;
1286
1288
  if (/^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%|\$\{[^}]+\})$/.test(cleaned)) return void 0;
1287
- if (/^(unknown|null|undefined|none|n\/a|-)$/i.test(cleaned)) return void 0;
1289
+ if (/^(unknown|null|undefined|none|n\/a|-|tbd|tba|to be (announced|determined))$/i.test(cleaned)) {
1290
+ return void 0;
1291
+ }
1288
1292
  return cleaned.length > MAX_CONTENT_VALUE_LENGTH ? cleaned.slice(0, MAX_CONTENT_VALUE_LENGTH).trim() : cleaned;
1289
1293
  }
1290
1294
  function sanitizeContentScalar(value) {
@@ -1410,6 +1414,7 @@ function resolveContentMetadata(config) {
1410
1414
  } : {});
1411
1415
  }
1412
1416
  function applyContentMetadataUpdate(target, meta) {
1417
+ var _target_contentDetails;
1413
1418
  var apply = function apply(key, value) {
1414
1419
  if (value === void 0) return;
1415
1420
  var clean = value === null ? void 0 : sanitizeContentValue(value);
@@ -1419,9 +1424,15 @@ function applyContentMetadataUpdate(target, meta) {
1419
1424
  apply("channelName", meta.channelName);
1420
1425
  apply("programTitle", meta.programTitle);
1421
1426
  apply("contentNetwork", meta.contentNetwork);
1422
- if (meta.details === void 0) return;
1423
1427
  if (meta.details === null) delete target.contentDetails;
1424
- else target.contentDetails = _object_spread({}, meta.details);
1428
+ else if (meta.details !== void 0) target.contentDetails = _object_spread({}, meta.details);
1429
+ var rating = meta.programRating !== void 0 ? meta.programRating : meta.contentRating;
1430
+ if (rating === void 0) return;
1431
+ var cleanRating = rating === null ? void 0 : sanitizeContentValue(rating);
1432
+ var details = _object_spread({}, (_target_contentDetails = target.contentDetails) !== null && _target_contentDetails !== void 0 ? _target_contentDetails : {});
1433
+ if (cleanRating) details.rating = cleanRating;
1434
+ else delete details.rating;
1435
+ target.contentDetails = details;
1425
1436
  }
1426
1437
  function appendMissingContentParams(url, meta) {
1427
1438
  if (!meta.channelName && !meta.programTitle && !meta.contentNetwork) return url;
@@ -2827,9 +2838,30 @@ function detectBrowser() {
2827
2838
  };
2828
2839
  }
2829
2840
  var singleDecoderOverride;
2841
+ var LEARNED_SINGLE_DECODER_KEY = "stormcloud.singleDecoder.learned.v1";
2842
+ var learnedSingleDecoder;
2830
2843
  function setSingleDecoderOverride(value) {
2831
2844
  singleDecoderOverride = value;
2832
2845
  }
2846
+ function readLearnedSingleDecoder() {
2847
+ if (learnedSingleDecoder !== void 0) return learnedSingleDecoder;
2848
+ try {
2849
+ var _window_localStorage;
2850
+ learnedSingleDecoder = typeof window !== "undefined" && ((_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(LEARNED_SINGLE_DECODER_KEY)) === "1";
2851
+ } catch (unused) {
2852
+ learnedSingleDecoder = false;
2853
+ }
2854
+ return learnedSingleDecoder;
2855
+ }
2856
+ function markSingleDecoderLearned() {
2857
+ if (readLearnedSingleDecoder()) return false;
2858
+ learnedSingleDecoder = true;
2859
+ try {
2860
+ var _window_localStorage;
2861
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(LEARNED_SINGLE_DECODER_KEY, "1");
2862
+ } catch (unused) {}
2863
+ return true;
2864
+ }
2833
2865
  function requiresMediaPipelineResetAfterAds() {
2834
2866
  var _browser_tizenVersion;
2835
2867
  if (singleDecoderOverride != null) return singleDecoderOverride;
@@ -2837,6 +2869,7 @@ function requiresMediaPipelineResetAfterAds() {
2837
2869
  var globalOverride = typeof window !== "undefined" ? window.__STORMCLOUD_SINGLE_DECODER__ : void 0;
2838
2870
  if (typeof globalOverride === "boolean") return globalOverride;
2839
2871
  } catch (unused) {}
2872
+ if (readLearnedSingleDecoder()) return true;
2840
2873
  var browser = detectBrowser();
2841
2874
  return browser.name === "Samsung Tizen" && ((_browser_tizenVersion = browser.tizenVersion) !== null && _browser_tizenVersion !== void 0 ? _browser_tizenVersion : 0) >= 5;
2842
2875
  }
@@ -9650,6 +9683,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
9650
9683
  ct_ch: content.channelName,
9651
9684
  ct_ti: content.programTitle,
9652
9685
  ct_ne: content.contentNetwork,
9686
+ rating: content.contentRating,
9653
9687
  ifaType: toIabIfaType(envSignals.deviceIdType, envSignals.deviceIdSource),
9654
9688
  live: isLive,
9655
9689
  player: playerSize,
@@ -11337,6 +11371,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11337
11371
  this.adDetectSentForCurrentBreak = false;
11338
11372
  this.slotState = "IDLE";
11339
11373
  this.unusableResponsesInBreak = 0;
11374
+ this.playedAdIdsInBreak = /* @__PURE__ */ new Set();
11340
11375
  this.controllerGeneration = 0;
11341
11376
  this.requestDiagnostics = /* @__PURE__ */ new Map();
11342
11377
  this.breakFunnel = {};
@@ -11433,6 +11468,11 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11433
11468
  _this.recordRequestDiagnostic(payload);
11434
11469
  });
11435
11470
  adPlayer.on("ad_impression", function() {
11471
+ var _this_host_getAdPlayer_getLoadedAdId, _this_host_getAdPlayer;
11472
+ 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);
11473
+ if (impressionAdId != null && impressionAdId !== "") {
11474
+ _this.playedAdIdsInBreak.add(String(impressionAdId));
11475
+ }
11436
11476
  _this.timing.consecutiveFailures = 0;
11437
11477
  _this.setSlotState("PLAYING", "impression");
11438
11478
  if (!_this.playbackStartedForCurrentRequest) {
@@ -11624,6 +11664,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11624
11664
  this.resetEdgeStateForBreak();
11625
11665
  this.followUpBaseVastUrl = void 0;
11626
11666
  this.unusableResponsesInBreak = 0;
11667
+ this.playedAdIdsInBreak.clear();
11627
11668
  this.timing.totalAdRequestsInBreak = 0;
11628
11669
  this.setSlotState("NEEDS_NEXT_AD", "vmap_break_start");
11629
11670
  this.noteOpportunity("vmap", breakKey, position);
@@ -11674,6 +11715,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
11674
11715
  this.breakSource = "scte35";
11675
11716
  this.followUpBaseVastUrl = baseVastUrl;
11676
11717
  this.unusableResponsesInBreak = 0;
11718
+ this.playedAdIdsInBreak.clear();
11677
11719
  this.resetEdgeStateForBreak();
11678
11720
  this.setSlotState("NEEDS_NEXT_AD", "scte35_break_start");
11679
11721
  if (this.adConfig.podAssignedByPrefetch) {
@@ -12513,6 +12555,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12513
12555
  var outcome;
12514
12556
  if (message.includes("ad_duration_exceeds_budget")) {
12515
12557
  outcome = "discarded_budget";
12558
+ } else if (message.includes("ad_repeated_in_break")) {
12559
+ outcome = "discarded_duplicate";
12516
12560
  } else if (message.includes("VAST fill rejected")) {
12517
12561
  outcome = "fill_rejected";
12518
12562
  } else if (/no ads available|no fill|nofill/i.test(message)) {
@@ -12527,7 +12571,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12527
12571
  outcome = "request_failed";
12528
12572
  }
12529
12573
  this.timing.consecutiveFailures++;
12530
- if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget") {
12574
+ if (outcome === "no_fill" || outcome === "fill_rejected" || outcome === "discarded_budget" || outcome === "discarded_duplicate") {
12531
12575
  this.unusableResponsesInBreak++;
12532
12576
  }
12533
12577
  if (outcome === "no_fill") {
@@ -12541,7 +12585,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12541
12585
  }) ? diag.dispatchedUrl : vastTagUrl;
12542
12586
  if (this.timing.isTemporaryAdError(error)) {
12543
12587
  this.timing.temporaryFailureUrls.set(failureKey, Date.now());
12544
- } else if (outcome !== "discarded_budget") {
12588
+ } else if (outcome !== "discarded_budget" && outcome !== "discarded_duplicate") {
12545
12589
  this.timing.failedVastUrls.add(failureKey);
12546
12590
  }
12547
12591
  this.countFunnelStage("request_outcome:".concat(outcome));
@@ -12913,7 +12957,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
12913
12957
  value: function playSingleAd(vastTagUrl) {
12914
12958
  var trigger = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "vmap";
12915
12959
  return _async_to_generator(function() {
12916
- var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, finalizeRequestUrl, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12960
+ var epoch, generation, requestToken, ap, requestUrl, _this_currentVastUrl, _ref, _ap_getLoadedAdId, _ap_getPodAdCount, finalizeRequestUrl, loadedAdId, _ap_getLoadedAdDuration, adDurationS, remainingMs, error;
12917
12961
  return _ts_generator(this, function(_state) {
12918
12962
  switch(_state.label){
12919
12963
  case 0:
@@ -13026,6 +13070,16 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13026
13070
  vastUrl: (_this_currentVastUrl = this.currentVastUrl) !== null && _this_currentVastUrl !== void 0 ? _this_currentVastUrl : requestUrl,
13027
13071
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
13028
13072
  }, this.analyticsContext).catch(function() {});
13073
+ loadedAdId = (_ap_getLoadedAdId = ap.getLoadedAdId) === null || _ap_getLoadedAdId === void 0 ? void 0 : _ap_getLoadedAdId.call(ap);
13074
+ 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))) {
13075
+ if (this.debug) {
13076
+ console.log("[AD-DURATION] Rejected ad id=".concat(loadedAdId, ": already played in this break — requesting another ad"));
13077
+ }
13078
+ this.logOrchestratorFunnel("discarded_duplicate", {
13079
+ adId: String(loadedAdId)
13080
+ });
13081
+ throw new Error("ad_repeated_in_break");
13082
+ }
13029
13083
  if (!this.timing.ensureLoadedAdFitsBudget(ap)) {
13030
13084
  ;
13031
13085
  adDurationS = (_ap_getLoadedAdDuration = ap.getLoadedAdDuration) === null || _ap_getLoadedAdDuration === void 0 ? void 0 : _ap_getLoadedAdDuration.call(ap);
@@ -13079,6 +13133,8 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13079
13133
  this.recordRequestFailure(error, vastTagUrl);
13080
13134
  if ((error === null || error === void 0 ? void 0 : error.message) === "ad_duration_exceeds_budget") {
13081
13135
  this.recreateAdController("discarded_budget");
13136
+ } else if ((error === null || error === void 0 ? void 0 : error.message) === "ad_repeated_in_break") {
13137
+ this.recreateAdController("discarded_duplicate");
13082
13138
  }
13083
13139
  throw error;
13084
13140
  case 10:
@@ -13152,6 +13208,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13152
13208
  tagAllowsAudio: count("tag_allows_audio"),
13153
13209
  missingImpression: count("vast_missing_impression"),
13154
13210
  discardedBudget: count("discarded_budget"),
13211
+ discardedDuplicate: count("discarded_duplicate"),
13155
13212
  mediaCandidates: count("media_candidate:accepted") + count("media_candidate:rejected"),
13156
13213
  mediaRejected: count("media_candidate:rejected"),
13157
13214
  mediaFallbacks: count("media_fallback"),
@@ -13227,6 +13284,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13227
13284
  this.breakSource = void 0;
13228
13285
  this.followUpBaseVastUrl = void 0;
13229
13286
  this.unusableResponsesInBreak = 0;
13287
+ this.playedAdIdsInBreak.clear();
13230
13288
  this.resetEdgeStateForBreak();
13231
13289
  adPlayer.stop().catch(function() {});
13232
13290
  if (!alreadyEnded) this.logBreakFunnel(reason);
@@ -13327,9 +13385,18 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13327
13385
  var maxMonitorMs = 45e3;
13328
13386
  var startTime = Date.now();
13329
13387
  var baseline = resumeBaseline;
13388
+ var lastSeenTime = resumeBaseline;
13330
13389
  var recoveries = 0;
13331
13390
  var lastRecoveryAt = 0;
13332
13391
  var video = this.host.video;
13392
+ var onDecodeError = function onDecodeError() {
13393
+ var _video_error;
13394
+ if (needsReset || ((_video_error = video.error) === null || _video_error === void 0 ? void 0 : _video_error.code) !== 3) return;
13395
+ if (markSingleDecoderLearned() && _this.debug) {
13396
+ console.warn("[StormcloudVideoPlayer] Decoder error while resuming after ads \u2014 using single-decoder mode on this device from the next break");
13397
+ }
13398
+ };
13399
+ video.addEventListener("error", onDecodeError);
13333
13400
  var listenersAttached = false;
13334
13401
  var onMediaEvent;
13335
13402
  var diagEvents = [
@@ -13379,6 +13446,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13379
13446
  console.log("[ResumeDiag] +0.0s monitor start — ".concat(this.describeVideoState()));
13380
13447
  }
13381
13448
  var cleanup = function cleanup() {
13449
+ video.removeEventListener("error", onDecodeError);
13382
13450
  if (listenersAttached && onMediaEvent) {
13383
13451
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
13384
13452
  try {
@@ -13409,6 +13477,10 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
13409
13477
  return;
13410
13478
  }
13411
13479
  var currentTime = video.currentTime;
13480
+ if (currentTime + 1 < lastSeenTime) {
13481
+ baseline = currentTime;
13482
+ }
13483
+ lastSeenTime = currentTime;
13412
13484
  var advanced = currentTime > baseline + 0.5;
13413
13485
  var playing = !video.paused && video.readyState >= 3;
13414
13486
  if (advanced && playing) {