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
@@ -21,7 +21,6 @@ interface StormcloudVideoPlayerConfig {
21
21
  vastTagUrl?: string;
22
22
  vastMode?: 'adstorm' | 'default';
23
23
  minSegmentsBeforePlay?: number;
24
- prebid?: PrebidConfig;
25
24
  }
26
25
  interface ImaController {
27
26
  initialize: () => void;
@@ -76,49 +75,6 @@ interface ClientInfo {
76
75
  referrer: string;
77
76
  visibilityState: string;
78
77
  }
79
- interface PrebidServerImpVideo {
80
- w?: number;
81
- h?: number;
82
- mimes?: string[];
83
- placement?: number;
84
- protocols?: number[];
85
- minduration?: number;
86
- maxduration?: number;
87
- linearity?: number;
88
- skip?: number;
89
- playbackmethod?: number[];
90
- api?: number[];
91
- }
92
- interface PrebidServerImp {
93
- id: string;
94
- instl?: number;
95
- video?: PrebidServerImpVideo;
96
- banner?: {
97
- w?: number;
98
- h?: number;
99
- format?: Array<{
100
- w: number;
101
- h: number;
102
- }>;
103
- };
104
- ext?: Record<string, any>;
105
- }
106
- interface PrebidServerRequest {
107
- id: string;
108
- site?: Record<string, any>;
109
- device?: Record<string, any>;
110
- imp: PrebidServerImp[];
111
- tmax?: number;
112
- ext?: Record<string, any>;
113
- }
114
- interface PrebidConfig {
115
- enabled?: boolean;
116
- serverUrl?: string;
117
- ortbRequest: PrebidServerRequest;
118
- timeout?: number;
119
- debug?: boolean;
120
- cpmFloor?: number;
121
- }
122
78
  interface PrebidBidResponse {
123
79
  bidder: string;
124
80
  cpm: number;
@@ -140,4 +96,4 @@ interface PrebidManager {
140
96
  readonly isInitialized: boolean;
141
97
  }
142
98
 
143
- export type { ClientInfo as C, ImaController as I, PrebidConfig as P, StormcloudVideoPlayerConfig as S, PrebidManager as a };
99
+ export type { ClientInfo as C, ImaController as I, PrebidManager as P, StormcloudVideoPlayerConfig as S };
@@ -2452,12 +2452,12 @@ function createHlsAdPlayer(contentVideo, options) {
2452
2452
  }
2453
2453
  // src/sdk/prebid.ts
2454
2454
  var DEFAULT_TIMEOUT_MS = 3e3;
2455
- var AUCTION_PATH = "/openrtb2/auction";
2456
- function createPrebidManager(config) {
2455
+ var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
2456
+ function createPrebidManager() {
2457
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2457
2458
  var initialized = false;
2458
- var serverUrl = "";
2459
- var _config_debug;
2460
- var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
2459
+ var _options_debug;
2460
+ var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
2461
2461
  function log() {
2462
2462
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2463
2463
  args[_key] = arguments[_key];
@@ -2478,49 +2478,6 @@ function createPrebidManager(config) {
2478
2478
  "[Prebid]"
2479
2479
  ].concat(_to_consumable_array(args)));
2480
2480
  }
2481
- function resolveServerUrl() {
2482
- var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
2483
- if (config.serverUrl) {
2484
- return config.serverUrl.replace(/\/$/, "");
2485
- }
2486
- 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;
2487
- if (typeof extUrl === "string" && extUrl.length > 0) {
2488
- return extUrl.replace(/\/$/, "");
2489
- }
2490
- throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
2491
- }
2492
- function buildRequest() {
2493
- var req = JSON.parse(JSON.stringify(config.ortbRequest));
2494
- req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
2495
- if (!req.ext) req.ext = {};
2496
- if (!req.ext.prebid) req.ext.prebid = {};
2497
- if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
2498
- if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
2499
- if (!req.ext.prebid.targeting) {
2500
- req.ext.prebid.targeting = {
2501
- includewinners: true,
2502
- includebidderkeys: false
2503
- };
2504
- }
2505
- if (!req.device) req.device = {};
2506
- if (typeof navigator !== "undefined") {
2507
- if (!req.device.ua) req.device.ua = navigator.userAgent;
2508
- if (!req.device.language) {
2509
- req.device.language = (navigator.language || "").split("-")[0] || "en";
2510
- }
2511
- }
2512
- if (typeof window !== "undefined") {
2513
- var _window_screen, _window_screen1;
2514
- if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
2515
- if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
2516
- }
2517
- if (!req.site) req.site = {};
2518
- if (typeof window !== "undefined") {
2519
- if (!req.site.page) req.site.page = window.location.href;
2520
- if (!req.site.domain) req.site.domain = window.location.hostname;
2521
- }
2522
- return req;
2523
- }
2524
2481
  function parseResponse(data) {
2525
2482
  var bids = [];
2526
2483
  var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
@@ -2590,12 +2547,6 @@ function createPrebidManager(config) {
2590
2547
  function extractVastUrl(bids) {
2591
2548
  if (bids.length === 0) return null;
2592
2549
  var winner = bids[0];
2593
- var _config_cpmFloor;
2594
- var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
2595
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
2596
- log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
2597
- return null;
2598
- }
2599
2550
  if (winner.vastUrl) {
2600
2551
  log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
2601
2552
  return winner.vastUrl;
@@ -2617,22 +2568,12 @@ function createPrebidManager(config) {
2617
2568
  }
2618
2569
  function initialize() {
2619
2570
  return _async_to_generator(function() {
2620
- var _config_ortbRequest;
2621
2571
  return _ts_generator(this, function(_state) {
2622
2572
  if (initialized) return [
2623
2573
  2
2624
2574
  ];
2625
- serverUrl = resolveServerUrl();
2626
- if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
2627
- throw new Error("No impressions (imp) defined in the OpenRTB request.");
2628
- }
2629
2575
  initialized = true;
2630
- log("Initialized with server:", serverUrl);
2631
- log("Bidders:", config.ortbRequest.imp.map(function(imp) {
2632
- var _imp_ext_prebid, _imp_ext;
2633
- 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;
2634
- return bidders ? Object.keys(bidders).join(", ") : "none";
2635
- }).join("; "));
2576
+ log("Initialized, auction URL:", AUCTION_URL);
2636
2577
  return [
2637
2578
  2
2638
2579
  ];
@@ -2641,17 +2582,15 @@ function createPrebidManager(config) {
2641
2582
  }
2642
2583
  function requestBids() {
2643
2584
  return _async_to_generator(function() {
2644
- 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;
2585
+ var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
2645
2586
  return _ts_generator(this, function(_state) {
2646
2587
  switch(_state.label){
2647
2588
  case 0:
2648
2589
  if (!initialized) {
2649
2590
  throw new Error("Prebid not initialized. Call initialize() first.");
2650
2591
  }
2651
- auctionUrl = "".concat(serverUrl).concat(AUCTION_PATH);
2652
- request = buildRequest();
2653
- timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
2654
- log("Sending auction request to:", auctionUrl);
2592
+ timeout = DEFAULT_TIMEOUT_MS;
2593
+ log("Fetching auction response from:", AUCTION_URL);
2655
2594
  controller = typeof AbortController !== "undefined" ? new AbortController() : null;
2656
2595
  timeoutId = setTimeout(function() {
2657
2596
  controller === null || controller === void 0 ? void 0 : controller.abort();
@@ -2665,18 +2604,14 @@ function createPrebidManager(config) {
2665
2604
  7
2666
2605
  ]);
2667
2606
  fetchOptions = {
2668
- method: "POST",
2669
- headers: {
2670
- "Content-Type": "application/json"
2671
- },
2672
- body: JSON.stringify(request)
2607
+ method: "POST"
2673
2608
  };
2674
2609
  if (controller) {
2675
2610
  fetchOptions.signal = controller.signal;
2676
2611
  }
2677
2612
  return [
2678
2613
  4,
2679
- fetch(auctionUrl, fetchOptions)
2614
+ fetch(AUCTION_URL, fetchOptions)
2680
2615
  ];
2681
2616
  case 2:
2682
2617
  response = _state.sent();
@@ -2793,7 +2728,6 @@ function createPrebidManager(config) {
2793
2728
  }
2794
2729
  function destroy() {
2795
2730
  initialized = false;
2796
- serverUrl = "";
2797
2731
  log("Destroyed");
2798
2732
  }
2799
2733
  return {
@@ -2809,7 +2743,7 @@ function createPrebidManager(config) {
2809
2743
  // src/sdk/prebidController.ts
2810
2744
  var import_hls2 = __toESM(require("hls.js"), 1);
2811
2745
  var LOG = "[PrebidController]";
2812
- function createPrebidController(contentVideo, prebidConfig, options) {
2746
+ function createPrebidController(contentVideo, options) {
2813
2747
  var adPlaying = false;
2814
2748
  var originalMutedState = false;
2815
2749
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -2823,11 +2757,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
2823
2757
  var sessionId;
2824
2758
  var destroyed = false;
2825
2759
  var trackingFired = createEmptyTrackingState();
2826
- var _prebidConfig_debug;
2827
- var prebidDebug = (_prebidConfig_debug = prebidConfig.debug) !== null && _prebidConfig_debug !== void 0 ? _prebidConfig_debug : false;
2828
- var prebidManager = createPrebidManager(_object_spread_props(_object_spread({}, prebidConfig), {
2829
- debug: prebidDebug
2830
- }));
2760
+ var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
2761
+ debug: options.debug
2762
+ } : {});
2831
2763
  var prebidInitialized = false;
2832
2764
  function emit(event, payload) {
2833
2765
  var set = listeners.get(event);
@@ -3050,19 +2982,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3050
2982
  }
3051
2983
  function ensurePrebidInitialized() {
3052
2984
  return _async_to_generator(function() {
3053
- var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
3054
2985
  return _ts_generator(this, function(_state) {
3055
2986
  switch(_state.label){
3056
2987
  case 0:
3057
2988
  if (prebidInitialized) return [
3058
2989
  2
3059
2990
  ];
3060
- if (prebidConfig.enabled === false) {
3061
- throw new Error("Prebid is disabled in config");
3062
- }
3063
- 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)) {
3064
- throw new Error("No impressions configured in ortbRequest");
3065
- }
3066
2991
  return [
3067
2992
  4,
3068
2993
  prebidManager.initialize()
@@ -3080,7 +3005,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3080
3005
  }
3081
3006
  function runPrebidAuction() {
3082
3007
  return _async_to_generator(function() {
3083
- var bids, _prebidConfig_cpmFloor, cpmFloor, winner;
3008
+ var bids, winner;
3084
3009
  return _ts_generator(this, function(_state) {
3085
3010
  switch(_state.label){
3086
3011
  case 0:
@@ -3103,15 +3028,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3103
3028
  null
3104
3029
  ];
3105
3030
  }
3106
- cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
3107
3031
  winner = bids[0];
3108
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
3109
- console.log("".concat(LOG, " Winning bid $").concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
3110
- return [
3111
- 2,
3112
- null
3113
- ];
3114
- }
3115
3032
  console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
3116
3033
  if (winner.vastXml) {
3117
3034
  console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
@@ -4216,22 +4133,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4216
4133
  adPlayerType = "hls";
4217
4134
  }
4218
4135
  if (adPlayerType === "prebid") {
4219
- if (!this.config.prebid) {
4220
- console.warn("[StormcloudVideoPlayer] adPlayerType is 'prebid' but no prebid config provided, falling back to HLS ad player");
4221
- return createHlsAdPlayer(this.video, _object_spread({
4222
- continueLiveStreamDuringAds: continueLiveStreamDuringAds
4223
- }, this.config.licenseKey ? {
4224
- licenseKey: this.config.licenseKey
4225
- } : {}, this.hls ? {
4226
- mainHlsInstance: this.hls
4227
- } : {}));
4228
- }
4229
4136
  if (this.config.debugAdTiming) {
4230
4137
  console.log("[StormcloudVideoPlayer] Creating Prebid ad controller (standalone, no IMA SDK)");
4231
4138
  }
4232
- return createPrebidController(this.video, this.config.prebid, _object_spread({
4139
+ return createPrebidController(this.video, _object_spread({
4233
4140
  continueLiveStreamDuringAds: continueLiveStreamDuringAds
4234
- }, this.config.licenseKey ? {
4141
+ }, this.config.debugAdTiming !== void 0 ? {
4142
+ debug: this.config.debugAdTiming
4143
+ } : {}, this.config.licenseKey ? {
4235
4144
  licenseKey: this.config.licenseKey
4236
4145
  } : {}, this.hls ? {
4237
4146
  mainHlsInstance: this.hls
@@ -7928,11 +7837,10 @@ var CRITICAL_PROPS = [
7928
7837
  "lowLatencyMode",
7929
7838
  "driftToleranceMs",
7930
7839
  "vastMode",
7931
- "adPlayerType",
7932
- "prebid"
7840
+ "adPlayerType"
7933
7841
  ];
7934
7842
  var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
7935
- 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, [
7843
+ 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, [
7936
7844
  "src",
7937
7845
  "autoplay",
7938
7846
  "muted",
@@ -7960,7 +7868,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
7960
7868
  "vastMode",
7961
7869
  "vastTagUrl",
7962
7870
  "adPlayerType",
7963
- "prebid",
7964
7871
  "minSegmentsBeforePlay"
7965
7872
  ]);
7966
7873
  var videoRef = (0, import_react.useRef)(null);
@@ -8070,8 +7977,7 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8070
7977
  lowLatencyMode,
8071
7978
  driftToleranceMs,
8072
7979
  vastMode,
8073
- adPlayerType,
8074
- prebid
7980
+ adPlayerType
8075
7981
  ]);
8076
7982
  (0, import_react.useEffect)(function() {
8077
7983
  if (typeof window === "undefined") return;
@@ -8112,7 +8018,6 @@ var StormcloudVideoPlayerComponent = import_react.default.memo(function(props) {
8112
8018
  if (vastMode !== void 0) cfg.vastMode = vastMode;
8113
8019
  if (vastTagUrl !== void 0) cfg.vastTagUrl = vastTagUrl;
8114
8020
  if (adPlayerType !== void 0) cfg.adPlayerType = adPlayerType;
8115
- if (prebid !== void 0) cfg.prebid = prebid;
8116
8021
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
8117
8022
  var player = new StormcloudVideoPlayer(cfg);
8118
8023
  playerRef.current = player;