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
@@ -2423,12 +2423,12 @@ function createHlsAdPlayer(contentVideo, options) {
2423
2423
  }
2424
2424
  // src/sdk/prebid.ts
2425
2425
  var DEFAULT_TIMEOUT_MS = 3e3;
2426
- var AUCTION_PATH = "/openrtb2/auction";
2427
- function createPrebidManager(config) {
2426
+ var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
2427
+ function createPrebidManager() {
2428
+ var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
2428
2429
  var initialized = false;
2429
- var serverUrl = "";
2430
- var _config_debug;
2431
- var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
2430
+ var _options_debug;
2431
+ var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
2432
2432
  function log() {
2433
2433
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
2434
2434
  args[_key] = arguments[_key];
@@ -2449,49 +2449,6 @@ function createPrebidManager(config) {
2449
2449
  "[Prebid]"
2450
2450
  ].concat(_to_consumable_array(args)));
2451
2451
  }
2452
- function resolveServerUrl() {
2453
- var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
2454
- if (config.serverUrl) {
2455
- return config.serverUrl.replace(/\/$/, "");
2456
- }
2457
- 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;
2458
- if (typeof extUrl === "string" && extUrl.length > 0) {
2459
- return extUrl.replace(/\/$/, "");
2460
- }
2461
- throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
2462
- }
2463
- function buildRequest() {
2464
- var req = JSON.parse(JSON.stringify(config.ortbRequest));
2465
- req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
2466
- if (!req.ext) req.ext = {};
2467
- if (!req.ext.prebid) req.ext.prebid = {};
2468
- if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
2469
- if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
2470
- if (!req.ext.prebid.targeting) {
2471
- req.ext.prebid.targeting = {
2472
- includewinners: true,
2473
- includebidderkeys: false
2474
- };
2475
- }
2476
- if (!req.device) req.device = {};
2477
- if (typeof navigator !== "undefined") {
2478
- if (!req.device.ua) req.device.ua = navigator.userAgent;
2479
- if (!req.device.language) {
2480
- req.device.language = (navigator.language || "").split("-")[0] || "en";
2481
- }
2482
- }
2483
- if (typeof window !== "undefined") {
2484
- var _window_screen, _window_screen1;
2485
- if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
2486
- if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
2487
- }
2488
- if (!req.site) req.site = {};
2489
- if (typeof window !== "undefined") {
2490
- if (!req.site.page) req.site.page = window.location.href;
2491
- if (!req.site.domain) req.site.domain = window.location.hostname;
2492
- }
2493
- return req;
2494
- }
2495
2452
  function parseResponse(data) {
2496
2453
  var bids = [];
2497
2454
  var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
@@ -2561,12 +2518,6 @@ function createPrebidManager(config) {
2561
2518
  function extractVastUrl(bids) {
2562
2519
  if (bids.length === 0) return null;
2563
2520
  var winner = bids[0];
2564
- var _config_cpmFloor;
2565
- var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
2566
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
2567
- log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
2568
- return null;
2569
- }
2570
2521
  if (winner.vastUrl) {
2571
2522
  log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
2572
2523
  return winner.vastUrl;
@@ -2588,22 +2539,12 @@ function createPrebidManager(config) {
2588
2539
  }
2589
2540
  function initialize() {
2590
2541
  return _async_to_generator(function() {
2591
- var _config_ortbRequest;
2592
2542
  return _ts_generator(this, function(_state) {
2593
2543
  if (initialized) return [
2594
2544
  2
2595
2545
  ];
2596
- serverUrl = resolveServerUrl();
2597
- if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
2598
- throw new Error("No impressions (imp) defined in the OpenRTB request.");
2599
- }
2600
2546
  initialized = true;
2601
- log("Initialized with server:", serverUrl);
2602
- log("Bidders:", config.ortbRequest.imp.map(function(imp) {
2603
- var _imp_ext_prebid, _imp_ext;
2604
- 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;
2605
- return bidders ? Object.keys(bidders).join(", ") : "none";
2606
- }).join("; "));
2547
+ log("Initialized, auction URL:", AUCTION_URL);
2607
2548
  return [
2608
2549
  2
2609
2550
  ];
@@ -2612,17 +2553,15 @@ function createPrebidManager(config) {
2612
2553
  }
2613
2554
  function requestBids() {
2614
2555
  return _async_to_generator(function() {
2615
- 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;
2556
+ var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
2616
2557
  return _ts_generator(this, function(_state) {
2617
2558
  switch(_state.label){
2618
2559
  case 0:
2619
2560
  if (!initialized) {
2620
2561
  throw new Error("Prebid not initialized. Call initialize() first.");
2621
2562
  }
2622
- auctionUrl = "".concat(serverUrl).concat(AUCTION_PATH);
2623
- request = buildRequest();
2624
- timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
2625
- log("Sending auction request to:", auctionUrl);
2563
+ timeout = DEFAULT_TIMEOUT_MS;
2564
+ log("Fetching auction response from:", AUCTION_URL);
2626
2565
  controller = typeof AbortController !== "undefined" ? new AbortController() : null;
2627
2566
  timeoutId = setTimeout(function() {
2628
2567
  controller === null || controller === void 0 ? void 0 : controller.abort();
@@ -2636,18 +2575,14 @@ function createPrebidManager(config) {
2636
2575
  7
2637
2576
  ]);
2638
2577
  fetchOptions = {
2639
- method: "POST",
2640
- headers: {
2641
- "Content-Type": "application/json"
2642
- },
2643
- body: JSON.stringify(request)
2578
+ method: "POST"
2644
2579
  };
2645
2580
  if (controller) {
2646
2581
  fetchOptions.signal = controller.signal;
2647
2582
  }
2648
2583
  return [
2649
2584
  4,
2650
- fetch(auctionUrl, fetchOptions)
2585
+ fetch(AUCTION_URL, fetchOptions)
2651
2586
  ];
2652
2587
  case 2:
2653
2588
  response = _state.sent();
@@ -2764,7 +2699,6 @@ function createPrebidManager(config) {
2764
2699
  }
2765
2700
  function destroy() {
2766
2701
  initialized = false;
2767
- serverUrl = "";
2768
2702
  log("Destroyed");
2769
2703
  }
2770
2704
  return {
@@ -2780,7 +2714,7 @@ function createPrebidManager(config) {
2780
2714
  // src/sdk/prebidController.ts
2781
2715
  var import_hls2 = __toESM(require("hls.js"), 1);
2782
2716
  var LOG = "[PrebidController]";
2783
- function createPrebidController(contentVideo, prebidConfig, options) {
2717
+ function createPrebidController(contentVideo, options) {
2784
2718
  var adPlaying = false;
2785
2719
  var originalMutedState = false;
2786
2720
  var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
@@ -2794,11 +2728,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
2794
2728
  var sessionId;
2795
2729
  var destroyed = false;
2796
2730
  var trackingFired = createEmptyTrackingState();
2797
- var _prebidConfig_debug;
2798
- var prebidDebug = (_prebidConfig_debug = prebidConfig.debug) !== null && _prebidConfig_debug !== void 0 ? _prebidConfig_debug : false;
2799
- var prebidManager = createPrebidManager(_object_spread_props(_object_spread({}, prebidConfig), {
2800
- debug: prebidDebug
2801
- }));
2731
+ var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
2732
+ debug: options.debug
2733
+ } : {});
2802
2734
  var prebidInitialized = false;
2803
2735
  function emit(event, payload) {
2804
2736
  var set = listeners.get(event);
@@ -3021,19 +2953,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3021
2953
  }
3022
2954
  function ensurePrebidInitialized() {
3023
2955
  return _async_to_generator(function() {
3024
- var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
3025
2956
  return _ts_generator(this, function(_state) {
3026
2957
  switch(_state.label){
3027
2958
  case 0:
3028
2959
  if (prebidInitialized) return [
3029
2960
  2
3030
2961
  ];
3031
- if (prebidConfig.enabled === false) {
3032
- throw new Error("Prebid is disabled in config");
3033
- }
3034
- 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)) {
3035
- throw new Error("No impressions configured in ortbRequest");
3036
- }
3037
2962
  return [
3038
2963
  4,
3039
2964
  prebidManager.initialize()
@@ -3051,7 +2976,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3051
2976
  }
3052
2977
  function runPrebidAuction() {
3053
2978
  return _async_to_generator(function() {
3054
- var bids, _prebidConfig_cpmFloor, cpmFloor, winner;
2979
+ var bids, winner;
3055
2980
  return _ts_generator(this, function(_state) {
3056
2981
  switch(_state.label){
3057
2982
  case 0:
@@ -3074,15 +2999,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
3074
2999
  null
3075
3000
  ];
3076
3001
  }
3077
- cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
3078
3002
  winner = bids[0];
3079
- if (cpmFloor > 0 && winner.cpm < cpmFloor) {
3080
- console.log("".concat(LOG, " Winning bid $").concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
3081
- return [
3082
- 2,
3083
- null
3084
- ];
3085
- }
3086
3003
  console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
3087
3004
  if (winner.vastXml) {
3088
3005
  console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
@@ -4187,22 +4104,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4187
4104
  adPlayerType = "hls";
4188
4105
  }
4189
4106
  if (adPlayerType === "prebid") {
4190
- if (!this.config.prebid) {
4191
- console.warn("[StormcloudVideoPlayer] adPlayerType is 'prebid' but no prebid config provided, falling back to HLS ad player");
4192
- return createHlsAdPlayer(this.video, _object_spread({
4193
- continueLiveStreamDuringAds: continueLiveStreamDuringAds
4194
- }, this.config.licenseKey ? {
4195
- licenseKey: this.config.licenseKey
4196
- } : {}, this.hls ? {
4197
- mainHlsInstance: this.hls
4198
- } : {}));
4199
- }
4200
4107
  if (this.config.debugAdTiming) {
4201
4108
  console.log("[StormcloudVideoPlayer] Creating Prebid ad controller (standalone, no IMA SDK)");
4202
4109
  }
4203
- return createPrebidController(this.video, this.config.prebid, _object_spread({
4110
+ return createPrebidController(this.video, _object_spread({
4204
4111
  continueLiveStreamDuringAds: continueLiveStreamDuringAds
4205
- }, this.config.licenseKey ? {
4112
+ }, this.config.debugAdTiming !== void 0 ? {
4113
+ debug: this.config.debugAdTiming
4114
+ } : {}, this.config.licenseKey ? {
4206
4115
  licenseKey: this.config.licenseKey
4207
4116
  } : {}, this.hls ? {
4208
4117
  mainHlsInstance: this.hls