stormcloud-video-player 0.5.2 → 0.5.3

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/index.cjs +23 -118
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +7 -47
  5. package/lib/index.d.ts +7 -47
  6. package/lib/index.js +23 -118
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/StormcloudVideoPlayer.cjs +20 -111
  9. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  10. package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
  11. package/lib/players/FilePlayer.cjs.map +1 -1
  12. package/lib/players/HlsPlayer.cjs +20 -111
  13. package/lib/players/HlsPlayer.cjs.map +1 -1
  14. package/lib/players/HlsPlayer.d.cts +1 -1
  15. package/lib/players/index.cjs +20 -111
  16. package/lib/players/index.cjs.map +1 -1
  17. package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
  18. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  19. package/lib/sdk/ima.cjs.map +1 -1
  20. package/lib/sdk/ima.d.cts +1 -1
  21. package/lib/sdk/prebid.cjs +11 -77
  22. package/lib/sdk/prebid.cjs.map +1 -1
  23. package/lib/sdk/prebid.d.cts +6 -3
  24. package/lib/sdk/prebidController.cjs +16 -99
  25. package/lib/sdk/prebidController.cjs.map +1 -1
  26. package/lib/sdk/prebidController.d.cts +3 -2
  27. package/lib/sdk/vastParser.cjs.map +1 -1
  28. package/lib/{types-g2d4Akez.d.cts → types-CRi_KrjM.d.cts} +1 -45
  29. package/lib/ui/StormcloudVideoPlayer.cjs +23 -118
  30. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  31. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  32. package/lib/utils/browserCompat.cjs.map +1 -1
  33. package/lib/utils/polyfills.cjs.map +1 -1
  34. package/lib/utils/tracking.cjs.map +1 -1
  35. package/lib/utils/tracking.d.cts +1 -1
  36. package/package.json +1 -1
package/lib/index.cjs CHANGED
@@ -2637,12 +2637,12 @@ function createHlsAdPlayer(contentVideo, options) {
2637
2637
  }
2638
2638
  // src/sdk/prebid.ts
2639
2639
  var DEFAULT_TIMEOUT_MS = 3e3;
2640
- var AUCTION_PATH = "/openrtb2/auction";
2641
- function createPrebidManager(config) {
2640
+ var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
2641
+ function createPrebidManager() {
2642
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2642
2643
  var initialized = false;
2643
- var serverUrl = "";
2644
- var _config_debug;
2645
- var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
2644
+ var _options_debug;
2645
+ var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
2646
2646
  function log() {
2647
2647
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2648
2648
  args[_key] = arguments[_key];
@@ -2663,49 +2663,6 @@ function createPrebidManager(config) {
2663
2663
  "[Prebid]"
2664
2664
  ].concat(_to_consumable_array(args)));
2665
2665
  }
2666
- function resolveServerUrl() {
2667
- var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
2668
- if (config.serverUrl) {
2669
- return config.serverUrl.replace(/\/$/, "");
2670
- }
2671
- var extUrl = (_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : (_config_ortbRequest_ext = _config_ortbRequest.ext) === null || _config_ortbRequest_ext === void 0 ? void 0 : (_config_ortbRequest_ext_prebid = _config_ortbRequest_ext.prebid) === null || _config_ortbRequest_ext_prebid === void 0 ? void 0 : (_config_ortbRequest_ext_prebid_server = _config_ortbRequest_ext_prebid.server) === null || _config_ortbRequest_ext_prebid_server === void 0 ? void 0 : _config_ortbRequest_ext_prebid_server.externalurl;
2672
- if (typeof extUrl === "string" && extUrl.length > 0) {
2673
- return extUrl.replace(/\/$/, "");
2674
- }
2675
- throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
2676
- }
2677
- function buildRequest() {
2678
- var req = JSON.parse(JSON.stringify(config.ortbRequest));
2679
- req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
2680
- if (!req.ext) req.ext = {};
2681
- if (!req.ext.prebid) req.ext.prebid = {};
2682
- if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
2683
- if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
2684
- if (!req.ext.prebid.targeting) {
2685
- req.ext.prebid.targeting = {
2686
- includewinners: true,
2687
- includebidderkeys: false
2688
- };
2689
- }
2690
- if (!req.device) req.device = {};
2691
- if (typeof navigator !== "undefined") {
2692
- if (!req.device.ua) req.device.ua = navigator.userAgent;
2693
- if (!req.device.language) {
2694
- req.device.language = (navigator.language || "").split("-")[0] || "en";
2695
- }
2696
- }
2697
- if (typeof window !== "undefined") {
2698
- var _window_screen, _window_screen1;
2699
- if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
2700
- if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
2701
- }
2702
- if (!req.site) req.site = {};
2703
- if (typeof window !== "undefined") {
2704
- if (!req.site.page) req.site.page = window.location.href;
2705
- if (!req.site.domain) req.site.domain = window.location.hostname;
2706
- }
2707
- return req;
2708
- }
2709
2666
  function parseResponse(data) {
2710
2667
  var bids = [];
2711
2668
  var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
@@ -2775,12 +2732,6 @@ function createPrebidManager(config) {
2775
2732
  function extractVastUrl(bids) {
2776
2733
  if (bids.length === 0) return null;
2777
2734
  var winner = bids[0];
2778
- var _config_cpmFloor;
2779
- var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
2780
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
2781
- log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
2782
- return null;
2783
- }
2784
2735
  if (winner.vastUrl) {
2785
2736
  log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
2786
2737
  return winner.vastUrl;
@@ -2802,22 +2753,12 @@ function createPrebidManager(config) {
2802
2753
  }
2803
2754
  function initialize() {
2804
2755
  return _async_to_generator(function() {
2805
- var _config_ortbRequest;
2806
2756
  return _ts_generator(this, function(_state) {
2807
2757
  if (initialized) return [
2808
2758
  2
2809
2759
  ];
2810
- serverUrl = resolveServerUrl();
2811
- if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
2812
- throw new Error("No impressions (imp) defined in the OpenRTB request.");
2813
- }
2814
2760
  initialized = true;
2815
- log("Initialized with server:", serverUrl);
2816
- log("Bidders:", config.ortbRequest.imp.map(function(imp) {
2817
- var _imp_ext_prebid, _imp_ext;
2818
- var bidders = (_imp_ext = imp.ext) === null || _imp_ext === void 0 ? void 0 : (_imp_ext_prebid = _imp_ext.prebid) === null || _imp_ext_prebid === void 0 ? void 0 : _imp_ext_prebid.bidder;
2819
- return bidders ? Object.keys(bidders).join(", ") : "none";
2820
- }).join("; "));
2761
+ log("Initialized, auction URL:", AUCTION_URL);
2821
2762
  return [
2822
2763
  2
2823
2764
  ];
@@ -2826,17 +2767,15 @@ function createPrebidManager(config) {
2826
2767
  }
2827
2768
  function requestBids() {
2828
2769
  return _async_to_generator(function() {
2829
- var auctionUrl, request, _config_timeout, _ref, timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
2770
+ var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
2830
2771
  return _ts_generator(this, function(_state) {
2831
2772
  switch(_state.label){
2832
2773
  case 0:
2833
2774
  if (!initialized) {
2834
2775
  throw new Error("Prebid not initialized. Call initialize() first.");
2835
2776
  }
2836
- auctionUrl = "".concat(serverUrl).concat(AUCTION_PATH);
2837
- request = buildRequest();
2838
- timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
2839
- log("Sending auction request to:", auctionUrl);
2777
+ timeout = DEFAULT_TIMEOUT_MS;
2778
+ log("Fetching auction response from:", AUCTION_URL);
2840
2779
  controller = typeof AbortController !== "undefined" ? new AbortController() : null;
2841
2780
  timeoutId = setTimeout(function() {
2842
2781
  controller === null || controller === void 0 ? void 0 : controller.abort();
@@ -2850,18 +2789,14 @@ function createPrebidManager(config) {
2850
2789
  7
2851
2790
  ]);
2852
2791
  fetchOptions = {
2853
- method: "POST",
2854
- headers: {
2855
- "Content-Type": "application/json"
2856
- },
2857
- body: JSON.stringify(request)
2792
+ method: "POST"
2858
2793
  };
2859
2794
  if (controller) {
2860
2795
  fetchOptions.signal = controller.signal;
2861
2796
  }
2862
2797
  return [
2863
2798
  4,
2864
- fetch(auctionUrl, fetchOptions)
2799
+ fetch(AUCTION_URL, fetchOptions)
2865
2800
  ];
2866
2801
  case 2:
2867
2802
  response = _state.sent();
@@ -2978,7 +2913,6 @@ function createPrebidManager(config) {
2978
2913
  }
2979
2914
  function destroy() {
2980
2915
  initialized = false;
2981
- serverUrl = "";
2982
2916
  log("Destroyed");
2983
2917
  }
2984
2918
  return {
@@ -2994,7 +2928,7 @@ function createPrebidManager(config) {
2994
2928
  // src/sdk/prebidController.ts
2995
2929
  var import_hls2 = __toESM(require("hls.js"), 1);
2996
2930
  var LOG = "[PrebidController]";
2997
- function createPrebidController(contentVideo, prebidConfig, options) {
2931
+ function createPrebidController(contentVideo, options) {
2998
2932
  var adPlaying = false;
2999
2933
  var originalMutedState = false;
3000
2934
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -3008,11 +2942,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3008
2942
  var sessionId;
3009
2943
  var destroyed = false;
3010
2944
  var trackingFired = createEmptyTrackingState();
3011
- var _prebidConfig_debug;
3012
- var prebidDebug = (_prebidConfig_debug = prebidConfig.debug) !== null && _prebidConfig_debug !== void 0 ? _prebidConfig_debug : false;
3013
- var prebidManager = createPrebidManager(_object_spread_props(_object_spread({}, prebidConfig), {
3014
- debug: prebidDebug
3015
- }));
2945
+ var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
2946
+ debug: options.debug
2947
+ } : {});
3016
2948
  var prebidInitialized = false;
3017
2949
  function emit(event, payload) {
3018
2950
  var set = listeners.get(event);
@@ -3235,19 +3167,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3235
3167
  }
3236
3168
  function ensurePrebidInitialized() {
3237
3169
  return _async_to_generator(function() {
3238
- var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
3239
3170
  return _ts_generator(this, function(_state) {
3240
3171
  switch(_state.label){
3241
3172
  case 0:
3242
3173
  if (prebidInitialized) return [
3243
3174
  2
3244
3175
  ];
3245
- if (prebidConfig.enabled === false) {
3246
- throw new Error("Prebid is disabled in config");
3247
- }
3248
- if (!((_prebidConfig_ortbRequest = prebidConfig.ortbRequest) === null || _prebidConfig_ortbRequest === void 0 ? void 0 : (_prebidConfig_ortbRequest_imp = _prebidConfig_ortbRequest.imp) === null || _prebidConfig_ortbRequest_imp === void 0 ? void 0 : _prebidConfig_ortbRequest_imp.length)) {
3249
- throw new Error("No impressions configured in ortbRequest");
3250
- }
3251
3176
  return [
3252
3177
  4,
3253
3178
  prebidManager.initialize()
@@ -3265,7 +3190,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3265
3190
  }
3266
3191
  function runPrebidAuction() {
3267
3192
  return _async_to_generator(function() {
3268
- var bids, _prebidConfig_cpmFloor, cpmFloor, winner;
3193
+ var bids, winner;
3269
3194
  return _ts_generator(this, function(_state) {
3270
3195
  switch(_state.label){
3271
3196
  case 0:
@@ -3288,15 +3213,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3288
3213
  null
3289
3214
  ];
3290
3215
  }
3291
- cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
3292
3216
  winner = bids[0];
3293
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
3294
- console.log("".concat(LOG, " Winning bid $").concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
3295
- return [
3296
- 2,
3297
- null
3298
- ];
3299
- }
3300
3217
  console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
3301
3218
  if (winner.vastXml) {
3302
3219
  console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
@@ -4401,22 +4318,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4401
4318
  adPlayerType = "hls";
4402
4319
  }
4403
4320
  if (adPlayerType === "prebid") {
4404
- if (!this.config.prebid) {
4405
- console.warn("[StormcloudVideoPlayer] adPlayerType is 'prebid' but no prebid config provided, falling back to HLS ad player");
4406
- return createHlsAdPlayer(this.video, _object_spread({
4407
- continueLiveStreamDuringAds: continueLiveStreamDuringAds
4408
- }, this.config.licenseKey ? {
4409
- licenseKey: this.config.licenseKey
4410
- } : {}, this.hls ? {
4411
- mainHlsInstance: this.hls
4412
- } : {}));
4413
- }
4414
4321
  if (this.config.debugAdTiming) {
4415
4322
  console.log("[StormcloudVideoPlayer] Creating Prebid ad controller (standalone, no IMA SDK)");
4416
4323
  }
4417
- return createPrebidController(this.video, this.config.prebid, _object_spread({
4324
+ return createPrebidController(this.video, _object_spread({
4418
4325
  continueLiveStreamDuringAds: continueLiveStreamDuringAds
4419
- }, this.config.licenseKey ? {
4326
+ }, this.config.debugAdTiming !== void 0 ? {
4327
+ debug: this.config.debugAdTiming
4328
+ } : {}, this.config.licenseKey ? {
4420
4329
  licenseKey: this.config.licenseKey
4421
4330
  } : {}, this.hls ? {
4422
4331
  mainHlsInstance: this.hls
@@ -8113,11 +8022,10 @@ var CRITICAL_PROPS = [
8113
8022
  "lowLatencyMode",
8114
8023
  "driftToleranceMs",
8115
8024
  "vastMode",
8116
- "adPlayerType",
8117
- "prebid"
8025
+ "adPlayerType"
8118
8026
  ];
8119
8027
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8120
- var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, adPlayerType = props.adPlayerType, prebid = props.prebid, minSegmentsBeforePlay = props.minSegmentsBeforePlay, restVideoAttrs = _object_without_properties(props, [
8028
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, vastMode = props.vastMode, vastTagUrl = props.vastTagUrl, adPlayerType = props.adPlayerType, minSegmentsBeforePlay = props.minSegmentsBeforePlay, restVideoAttrs = _object_without_properties(props, [
8121
8029
  "src",
8122
8030
  "autoplay",
8123
8031
  "muted",
@@ -8145,7 +8053,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8145
8053
  "vastMode",
8146
8054
  "vastTagUrl",
8147
8055
  "adPlayerType",
8148
- "prebid",
8149
8056
  "minSegmentsBeforePlay"
8150
8057
  ]);
8151
8058
  var videoRef = (0, import_react.useRef)(null);
@@ -8255,8 +8162,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8255
8162
  lowLatencyMode,
8256
8163
  driftToleranceMs,
8257
8164
  vastMode,
8258
- adPlayerType,
8259
- prebid
8165
+ adPlayerType
8260
8166
  ]);
8261
8167
  (0, import_react.useEffect)(function() {
8262
8168
  if (typeof window === "undefined") return;
@@ -8297,7 +8203,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8297
8203
  if (vastMode !== void 0) cfg.vastMode = vastMode;
8298
8204
  if (vastTagUrl !== void 0) cfg.vastTagUrl = vastTagUrl;
8299
8205
  if (adPlayerType !== void 0) cfg.adPlayerType = adPlayerType;
8300
- if (prebid !== void 0) cfg.prebid = prebid;
8301
8206
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
8302
8207
  var player = new StormcloudVideoPlayer(cfg);
8303
8208
  playerRef.current = player;