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.
- package/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +23 -118
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +7 -47
- package/lib/index.d.ts +7 -47
- package/lib/index.js +23 -118
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +20 -111
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/FilePlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +20 -111
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +20 -111
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.cjs.map +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/sdk/prebid.cjs +11 -77
- package/lib/sdk/prebid.cjs.map +1 -1
- package/lib/sdk/prebid.d.cts +6 -3
- package/lib/sdk/prebidController.cjs +16 -99
- package/lib/sdk/prebidController.cjs.map +1 -1
- package/lib/sdk/prebidController.d.cts +3 -2
- package/lib/sdk/vastParser.cjs.map +1 -1
- package/lib/{types-g2d4Akez.d.cts → types-CRi_KrjM.d.cts} +1 -45
- package/lib/ui/StormcloudVideoPlayer.cjs +23 -118
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/browserCompat.cjs.map +1 -1
- package/lib/utils/polyfills.cjs.map +1 -1
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Component } from 'react';
|
|
2
|
-
import { S as StormcloudVideoPlayerConfig } from '../types-
|
|
2
|
+
import { S as StormcloudVideoPlayerConfig } from '../types-CRi_KrjM.cjs';
|
|
3
3
|
|
|
4
4
|
interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
|
|
5
5
|
onMount?: (player: any) => void;
|
package/lib/players/index.cjs
CHANGED
|
@@ -2511,12 +2511,12 @@ function createHlsAdPlayer(contentVideo, options) {
|
|
|
2511
2511
|
}
|
|
2512
2512
|
// src/sdk/prebid.ts
|
|
2513
2513
|
var DEFAULT_TIMEOUT_MS = 3e3;
|
|
2514
|
-
var
|
|
2515
|
-
function createPrebidManager(
|
|
2514
|
+
var AUCTION_URL = "https://sspproxy.adstorm.co/openrtb2/auction/adstorm";
|
|
2515
|
+
function createPrebidManager() {
|
|
2516
|
+
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
2516
2517
|
var initialized = false;
|
|
2517
|
-
var
|
|
2518
|
-
var
|
|
2519
|
-
var debug = (_config_debug = config.debug) !== null && _config_debug !== void 0 ? _config_debug : false;
|
|
2518
|
+
var _options_debug;
|
|
2519
|
+
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
2520
2520
|
function log() {
|
|
2521
2521
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
2522
2522
|
args[_key] = arguments[_key];
|
|
@@ -2537,49 +2537,6 @@ function createPrebidManager(config) {
|
|
|
2537
2537
|
"[Prebid]"
|
|
2538
2538
|
].concat(_to_consumable_array(args)));
|
|
2539
2539
|
}
|
|
2540
|
-
function resolveServerUrl() {
|
|
2541
|
-
var _config_ortbRequest_ext_prebid_server, _config_ortbRequest_ext_prebid, _config_ortbRequest_ext, _config_ortbRequest;
|
|
2542
|
-
if (config.serverUrl) {
|
|
2543
|
-
return config.serverUrl.replace(/\/$/, "");
|
|
2544
|
-
}
|
|
2545
|
-
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;
|
|
2546
|
-
if (typeof extUrl === "string" && extUrl.length > 0) {
|
|
2547
|
-
return extUrl.replace(/\/$/, "");
|
|
2548
|
-
}
|
|
2549
|
-
throw new Error("Prebid Server URL not configured. Provide serverUrl in PrebidConfig or ext.prebid.server.externalurl in the OpenRTB request.");
|
|
2550
|
-
}
|
|
2551
|
-
function buildRequest() {
|
|
2552
|
-
var req = JSON.parse(JSON.stringify(config.ortbRequest));
|
|
2553
|
-
req.id = "".concat(req.id || "prebid", "-").concat(Date.now(), "-").concat(Math.random().toString(36).slice(2, 8));
|
|
2554
|
-
if (!req.ext) req.ext = {};
|
|
2555
|
-
if (!req.ext.prebid) req.ext.prebid = {};
|
|
2556
|
-
if (!req.ext.prebid.cache) req.ext.prebid.cache = {};
|
|
2557
|
-
if (!req.ext.prebid.cache.vastxml) req.ext.prebid.cache.vastxml = {};
|
|
2558
|
-
if (!req.ext.prebid.targeting) {
|
|
2559
|
-
req.ext.prebid.targeting = {
|
|
2560
|
-
includewinners: true,
|
|
2561
|
-
includebidderkeys: false
|
|
2562
|
-
};
|
|
2563
|
-
}
|
|
2564
|
-
if (!req.device) req.device = {};
|
|
2565
|
-
if (typeof navigator !== "undefined") {
|
|
2566
|
-
if (!req.device.ua) req.device.ua = navigator.userAgent;
|
|
2567
|
-
if (!req.device.language) {
|
|
2568
|
-
req.device.language = (navigator.language || "").split("-")[0] || "en";
|
|
2569
|
-
}
|
|
2570
|
-
}
|
|
2571
|
-
if (typeof window !== "undefined") {
|
|
2572
|
-
var _window_screen, _window_screen1;
|
|
2573
|
-
if (!req.device.w) req.device.w = ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : _window_screen.width) || window.innerWidth;
|
|
2574
|
-
if (!req.device.h) req.device.h = ((_window_screen1 = window.screen) === null || _window_screen1 === void 0 ? void 0 : _window_screen1.height) || window.innerHeight;
|
|
2575
|
-
}
|
|
2576
|
-
if (!req.site) req.site = {};
|
|
2577
|
-
if (typeof window !== "undefined") {
|
|
2578
|
-
if (!req.site.page) req.site.page = window.location.href;
|
|
2579
|
-
if (!req.site.domain) req.site.domain = window.location.hostname;
|
|
2580
|
-
}
|
|
2581
|
-
return req;
|
|
2582
|
-
}
|
|
2583
2540
|
function parseResponse(data) {
|
|
2584
2541
|
var bids = [];
|
|
2585
2542
|
var seatbids = (data === null || data === void 0 ? void 0 : data.seatbid) || [];
|
|
@@ -2649,12 +2606,6 @@ function createPrebidManager(config) {
|
|
|
2649
2606
|
function extractVastUrl(bids) {
|
|
2650
2607
|
if (bids.length === 0) return null;
|
|
2651
2608
|
var winner = bids[0];
|
|
2652
|
-
var _config_cpmFloor;
|
|
2653
|
-
var cpmFloor = (_config_cpmFloor = config.cpmFloor) !== null && _config_cpmFloor !== void 0 ? _config_cpmFloor : 0;
|
|
2654
|
-
if (cpmFloor > 0 && winner.cpm < cpmFloor) {
|
|
2655
|
-
log("Winning bid $".concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
|
|
2656
|
-
return null;
|
|
2657
|
-
}
|
|
2658
2609
|
if (winner.vastUrl) {
|
|
2659
2610
|
log("Using cached VAST URL from ".concat(winner.bidder, " ($").concat(winner.cpm.toFixed(2), " ").concat(winner.currency, ")"));
|
|
2660
2611
|
return winner.vastUrl;
|
|
@@ -2676,22 +2627,12 @@ function createPrebidManager(config) {
|
|
|
2676
2627
|
}
|
|
2677
2628
|
function initialize() {
|
|
2678
2629
|
return _async_to_generator(function() {
|
|
2679
|
-
var _config_ortbRequest;
|
|
2680
2630
|
return _ts_generator(this, function(_state) {
|
|
2681
2631
|
if (initialized) return [
|
|
2682
2632
|
2
|
|
2683
2633
|
];
|
|
2684
|
-
serverUrl = resolveServerUrl();
|
|
2685
|
-
if (!((_config_ortbRequest = config.ortbRequest) === null || _config_ortbRequest === void 0 ? void 0 : _config_ortbRequest.imp) || config.ortbRequest.imp.length === 0) {
|
|
2686
|
-
throw new Error("No impressions (imp) defined in the OpenRTB request.");
|
|
2687
|
-
}
|
|
2688
2634
|
initialized = true;
|
|
2689
|
-
log("Initialized
|
|
2690
|
-
log("Bidders:", config.ortbRequest.imp.map(function(imp) {
|
|
2691
|
-
var _imp_ext_prebid, _imp_ext;
|
|
2692
|
-
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;
|
|
2693
|
-
return bidders ? Object.keys(bidders).join(", ") : "none";
|
|
2694
|
-
}).join("; "));
|
|
2635
|
+
log("Initialized, auction URL:", AUCTION_URL);
|
|
2695
2636
|
return [
|
|
2696
2637
|
2
|
|
2697
2638
|
];
|
|
@@ -2700,17 +2641,15 @@ function createPrebidManager(config) {
|
|
|
2700
2641
|
}
|
|
2701
2642
|
function requestBids() {
|
|
2702
2643
|
return _async_to_generator(function() {
|
|
2703
|
-
var
|
|
2644
|
+
var timeout, controller, timeoutId, _data_ext, _data_ext1, fetchOptions, response, body, data, bids, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, b, error;
|
|
2704
2645
|
return _ts_generator(this, function(_state) {
|
|
2705
2646
|
switch(_state.label){
|
|
2706
2647
|
case 0:
|
|
2707
2648
|
if (!initialized) {
|
|
2708
2649
|
throw new Error("Prebid not initialized. Call initialize() first.");
|
|
2709
2650
|
}
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
timeout = (_ref = (_config_timeout = config.timeout) !== null && _config_timeout !== void 0 ? _config_timeout : config.ortbRequest.tmax) !== null && _ref !== void 0 ? _ref : DEFAULT_TIMEOUT_MS;
|
|
2713
|
-
log("Sending auction request to:", auctionUrl);
|
|
2651
|
+
timeout = DEFAULT_TIMEOUT_MS;
|
|
2652
|
+
log("Fetching auction response from:", AUCTION_URL);
|
|
2714
2653
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
2715
2654
|
timeoutId = setTimeout(function() {
|
|
2716
2655
|
controller === null || controller === void 0 ? void 0 : controller.abort();
|
|
@@ -2724,18 +2663,14 @@ function createPrebidManager(config) {
|
|
|
2724
2663
|
7
|
|
2725
2664
|
]);
|
|
2726
2665
|
fetchOptions = {
|
|
2727
|
-
method: "POST"
|
|
2728
|
-
headers: {
|
|
2729
|
-
"Content-Type": "application/json"
|
|
2730
|
-
},
|
|
2731
|
-
body: JSON.stringify(request)
|
|
2666
|
+
method: "POST"
|
|
2732
2667
|
};
|
|
2733
2668
|
if (controller) {
|
|
2734
2669
|
fetchOptions.signal = controller.signal;
|
|
2735
2670
|
}
|
|
2736
2671
|
return [
|
|
2737
2672
|
4,
|
|
2738
|
-
fetch(
|
|
2673
|
+
fetch(AUCTION_URL, fetchOptions)
|
|
2739
2674
|
];
|
|
2740
2675
|
case 2:
|
|
2741
2676
|
response = _state.sent();
|
|
@@ -2852,7 +2787,6 @@ function createPrebidManager(config) {
|
|
|
2852
2787
|
}
|
|
2853
2788
|
function destroy() {
|
|
2854
2789
|
initialized = false;
|
|
2855
|
-
serverUrl = "";
|
|
2856
2790
|
log("Destroyed");
|
|
2857
2791
|
}
|
|
2858
2792
|
return {
|
|
@@ -2868,7 +2802,7 @@ function createPrebidManager(config) {
|
|
|
2868
2802
|
// src/sdk/prebidController.ts
|
|
2869
2803
|
var import_hls2 = __toESM(require("hls.js"), 1);
|
|
2870
2804
|
var LOG = "[PrebidController]";
|
|
2871
|
-
function createPrebidController(contentVideo,
|
|
2805
|
+
function createPrebidController(contentVideo, options) {
|
|
2872
2806
|
var adPlaying = false;
|
|
2873
2807
|
var originalMutedState = false;
|
|
2874
2808
|
var originalVolume = Math.max(0, Math.min(1, contentVideo.volume || 1));
|
|
@@ -2882,11 +2816,9 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
2882
2816
|
var sessionId;
|
|
2883
2817
|
var destroyed = false;
|
|
2884
2818
|
var trackingFired = createEmptyTrackingState();
|
|
2885
|
-
var
|
|
2886
|
-
|
|
2887
|
-
|
|
2888
|
-
debug: prebidDebug
|
|
2889
|
-
}));
|
|
2819
|
+
var prebidManager = createPrebidManager((options === null || options === void 0 ? void 0 : options.debug) !== void 0 ? {
|
|
2820
|
+
debug: options.debug
|
|
2821
|
+
} : {});
|
|
2890
2822
|
var prebidInitialized = false;
|
|
2891
2823
|
function emit(event, payload) {
|
|
2892
2824
|
var set = listeners.get(event);
|
|
@@ -3109,19 +3041,12 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
3109
3041
|
}
|
|
3110
3042
|
function ensurePrebidInitialized() {
|
|
3111
3043
|
return _async_to_generator(function() {
|
|
3112
|
-
var _prebidConfig_ortbRequest_imp, _prebidConfig_ortbRequest;
|
|
3113
3044
|
return _ts_generator(this, function(_state) {
|
|
3114
3045
|
switch(_state.label){
|
|
3115
3046
|
case 0:
|
|
3116
3047
|
if (prebidInitialized) return [
|
|
3117
3048
|
2
|
|
3118
3049
|
];
|
|
3119
|
-
if (prebidConfig.enabled === false) {
|
|
3120
|
-
throw new Error("Prebid is disabled in config");
|
|
3121
|
-
}
|
|
3122
|
-
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)) {
|
|
3123
|
-
throw new Error("No impressions configured in ortbRequest");
|
|
3124
|
-
}
|
|
3125
3050
|
return [
|
|
3126
3051
|
4,
|
|
3127
3052
|
prebidManager.initialize()
|
|
@@ -3139,7 +3064,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
3139
3064
|
}
|
|
3140
3065
|
function runPrebidAuction() {
|
|
3141
3066
|
return _async_to_generator(function() {
|
|
3142
|
-
var bids,
|
|
3067
|
+
var bids, winner;
|
|
3143
3068
|
return _ts_generator(this, function(_state) {
|
|
3144
3069
|
switch(_state.label){
|
|
3145
3070
|
case 0:
|
|
@@ -3162,15 +3087,7 @@ function createPrebidController(contentVideo, prebidConfig, options) {
|
|
|
3162
3087
|
null
|
|
3163
3088
|
];
|
|
3164
3089
|
}
|
|
3165
|
-
cpmFloor = (_prebidConfig_cpmFloor = prebidConfig.cpmFloor) !== null && _prebidConfig_cpmFloor !== void 0 ? _prebidConfig_cpmFloor : 0;
|
|
3166
3090
|
winner = bids[0];
|
|
3167
|
-
if (cpmFloor > 0 && winner.cpm < cpmFloor) {
|
|
3168
|
-
console.log("".concat(LOG, " Winning bid $").concat(winner.cpm.toFixed(2), " below CPM floor $").concat(cpmFloor.toFixed(2), ", rejecting"));
|
|
3169
|
-
return [
|
|
3170
|
-
2,
|
|
3171
|
-
null
|
|
3172
|
-
];
|
|
3173
|
-
}
|
|
3174
3091
|
console.log("".concat(LOG, " Winning bid: ").concat(winner.bidder, " $").concat(winner.cpm.toFixed(2), " ").concat(winner.currency));
|
|
3175
3092
|
if (winner.vastXml) {
|
|
3176
3093
|
console.log("".concat(LOG, " Parsing VAST XML from bid response (inline)"));
|
|
@@ -4275,22 +4192,14 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4275
4192
|
adPlayerType = "hls";
|
|
4276
4193
|
}
|
|
4277
4194
|
if (adPlayerType === "prebid") {
|
|
4278
|
-
if (!this.config.prebid) {
|
|
4279
|
-
console.warn("[StormcloudVideoPlayer] adPlayerType is 'prebid' but no prebid config provided, falling back to HLS ad player");
|
|
4280
|
-
return createHlsAdPlayer(this.video, _object_spread({
|
|
4281
|
-
continueLiveStreamDuringAds: continueLiveStreamDuringAds
|
|
4282
|
-
}, this.config.licenseKey ? {
|
|
4283
|
-
licenseKey: this.config.licenseKey
|
|
4284
|
-
} : {}, this.hls ? {
|
|
4285
|
-
mainHlsInstance: this.hls
|
|
4286
|
-
} : {}));
|
|
4287
|
-
}
|
|
4288
4195
|
if (this.config.debugAdTiming) {
|
|
4289
4196
|
console.log("[StormcloudVideoPlayer] Creating Prebid ad controller (standalone, no IMA SDK)");
|
|
4290
4197
|
}
|
|
4291
|
-
return createPrebidController(this.video,
|
|
4198
|
+
return createPrebidController(this.video, _object_spread({
|
|
4292
4199
|
continueLiveStreamDuringAds: continueLiveStreamDuringAds
|
|
4293
|
-
}, this.config.
|
|
4200
|
+
}, this.config.debugAdTiming !== void 0 ? {
|
|
4201
|
+
debug: this.config.debugAdTiming
|
|
4202
|
+
} : {}, this.config.licenseKey ? {
|
|
4294
4203
|
licenseKey: this.config.licenseKey
|
|
4295
4204
|
} : {}, this.hls ? {
|
|
4296
4205
|
mainHlsInstance: this.hls
|