stormcloud-video-player 0.3.54 → 0.3.55
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 +806 -777
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +32 -1
- package/lib/index.d.ts +32 -1
- package/lib/index.js +796 -779
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +265 -3
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +2 -1
- package/lib/players/HlsPlayer.cjs +265 -3
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +265 -3
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/sdk/ima.d.cts +1 -1
- package/lib/{types-DYelrVG6.d.cts → types-C23mJ_hh.d.cts} +15 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +794 -777
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.cjs +264 -3
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +12 -2
- package/package.json +1 -1
|
@@ -2609,9 +2609,6 @@ function sendInitialTracking(licenseKey) {
|
|
|
2609
2609
|
headers = {
|
|
2610
2610
|
"Content-Type": "application/json"
|
|
2611
2611
|
};
|
|
2612
|
-
if (licenseKey) {
|
|
2613
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2614
|
-
}
|
|
2615
2612
|
return [
|
|
2616
2613
|
4,
|
|
2617
2614
|
fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track", {
|
|
@@ -2717,6 +2714,234 @@ function sendHeartbeat(licenseKey) {
|
|
|
2717
2714
|
});
|
|
2718
2715
|
})();
|
|
2719
2716
|
}
|
|
2717
|
+
var TRACK_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
|
|
2718
|
+
function mapToAdTrackingSource(source, adPlayerType) {
|
|
2719
|
+
if (source === "prebid" || source === "ima" || source === "hls") {
|
|
2720
|
+
return source;
|
|
2721
|
+
}
|
|
2722
|
+
if (source === "preload" || source === "ssp") {
|
|
2723
|
+
return source === "ssp" ? "prebid" : "ima";
|
|
2724
|
+
}
|
|
2725
|
+
return adPlayerType === "hls" ? "hls" : "ima";
|
|
2726
|
+
}
|
|
2727
|
+
function postAdTracking(licenseKey, body) {
|
|
2728
|
+
return _async_to_generator(function() {
|
|
2729
|
+
var headers, response;
|
|
2730
|
+
return _ts_generator(this, function(_state) {
|
|
2731
|
+
switch(_state.label){
|
|
2732
|
+
case 0:
|
|
2733
|
+
headers = {
|
|
2734
|
+
"Content-Type": "application/json"
|
|
2735
|
+
};
|
|
2736
|
+
if (licenseKey) {
|
|
2737
|
+
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2738
|
+
}
|
|
2739
|
+
return [
|
|
2740
|
+
4,
|
|
2741
|
+
fetch(TRACK_API_URL, {
|
|
2742
|
+
method: "POST",
|
|
2743
|
+
headers: headers,
|
|
2744
|
+
body: JSON.stringify(body)
|
|
2745
|
+
})
|
|
2746
|
+
];
|
|
2747
|
+
case 1:
|
|
2748
|
+
response = _state.sent();
|
|
2749
|
+
if (!response.ok) {
|
|
2750
|
+
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2751
|
+
}
|
|
2752
|
+
return [
|
|
2753
|
+
4,
|
|
2754
|
+
response.json()
|
|
2755
|
+
];
|
|
2756
|
+
case 2:
|
|
2757
|
+
_state.sent();
|
|
2758
|
+
return [
|
|
2759
|
+
2
|
|
2760
|
+
];
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
})();
|
|
2764
|
+
}
|
|
2765
|
+
function sendAdDetectTracking(licenseKey, payload) {
|
|
2766
|
+
return _async_to_generator(function() {
|
|
2767
|
+
var _payload_source, _payload_timestamp, clientInfo, browserId, adDetectInfo, body, error;
|
|
2768
|
+
return _ts_generator(this, function(_state) {
|
|
2769
|
+
switch(_state.label){
|
|
2770
|
+
case 0:
|
|
2771
|
+
_state.trys.push([
|
|
2772
|
+
0,
|
|
2773
|
+
3,
|
|
2774
|
+
,
|
|
2775
|
+
4
|
|
2776
|
+
]);
|
|
2777
|
+
clientInfo = getClientInfo();
|
|
2778
|
+
return [
|
|
2779
|
+
4,
|
|
2780
|
+
getBrowserID(clientInfo)
|
|
2781
|
+
];
|
|
2782
|
+
case 1:
|
|
2783
|
+
browserId = _state.sent();
|
|
2784
|
+
adDetectInfo = _object_spread({
|
|
2785
|
+
source: (_payload_source = payload.source) !== null && _payload_source !== void 0 ? _payload_source : "scte35",
|
|
2786
|
+
timestamp: (_payload_timestamp = payload.timestamp) !== null && _payload_timestamp !== void 0 ? _payload_timestamp : /* @__PURE__ */ new Date().toISOString()
|
|
2787
|
+
}, payload.durationSeconds != null && {
|
|
2788
|
+
durationSeconds: payload.durationSeconds
|
|
2789
|
+
}, payload.ptsSeconds != null && {
|
|
2790
|
+
ptsSeconds: payload.ptsSeconds
|
|
2791
|
+
}, payload.detectedAtFragmentSn != null && {
|
|
2792
|
+
detectedAtFragmentSn: payload.detectedAtFragmentSn
|
|
2793
|
+
});
|
|
2794
|
+
body = _object_spread_props(_object_spread({
|
|
2795
|
+
browserId: browserId
|
|
2796
|
+
}, clientInfo, licenseKey && {
|
|
2797
|
+
licenseKey: licenseKey
|
|
2798
|
+
}), {
|
|
2799
|
+
adDetectInfo: adDetectInfo
|
|
2800
|
+
});
|
|
2801
|
+
return [
|
|
2802
|
+
4,
|
|
2803
|
+
postAdTracking(licenseKey, body)
|
|
2804
|
+
];
|
|
2805
|
+
case 2:
|
|
2806
|
+
_state.sent();
|
|
2807
|
+
return [
|
|
2808
|
+
3,
|
|
2809
|
+
4
|
|
2810
|
+
];
|
|
2811
|
+
case 3:
|
|
2812
|
+
error = _state.sent();
|
|
2813
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-detect tracking:", error);
|
|
2814
|
+
return [
|
|
2815
|
+
3,
|
|
2816
|
+
4
|
|
2817
|
+
];
|
|
2818
|
+
case 4:
|
|
2819
|
+
return [
|
|
2820
|
+
2
|
|
2821
|
+
];
|
|
2822
|
+
}
|
|
2823
|
+
});
|
|
2824
|
+
})();
|
|
2825
|
+
}
|
|
2826
|
+
function sendAdLoadedTracking(licenseKey, payload, adPlayerType) {
|
|
2827
|
+
return _async_to_generator(function() {
|
|
2828
|
+
var clientInfo, browserId, source, adLoadedInfo, body, error;
|
|
2829
|
+
return _ts_generator(this, function(_state) {
|
|
2830
|
+
switch(_state.label){
|
|
2831
|
+
case 0:
|
|
2832
|
+
_state.trys.push([
|
|
2833
|
+
0,
|
|
2834
|
+
3,
|
|
2835
|
+
,
|
|
2836
|
+
4
|
|
2837
|
+
]);
|
|
2838
|
+
clientInfo = getClientInfo();
|
|
2839
|
+
return [
|
|
2840
|
+
4,
|
|
2841
|
+
getBrowserID(clientInfo)
|
|
2842
|
+
];
|
|
2843
|
+
case 1:
|
|
2844
|
+
browserId = _state.sent();
|
|
2845
|
+
source = mapToAdTrackingSource(payload.source, adPlayerType);
|
|
2846
|
+
adLoadedInfo = _object_spread({
|
|
2847
|
+
source: source,
|
|
2848
|
+
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2849
|
+
}, payload.vastUrl != null && {
|
|
2850
|
+
vastUrl: payload.vastUrl
|
|
2851
|
+
}, payload.durationSeconds != null && {
|
|
2852
|
+
durationSeconds: payload.durationSeconds
|
|
2853
|
+
});
|
|
2854
|
+
body = _object_spread_props(_object_spread({
|
|
2855
|
+
browserId: browserId
|
|
2856
|
+
}, clientInfo, licenseKey && {
|
|
2857
|
+
licenseKey: licenseKey
|
|
2858
|
+
}), {
|
|
2859
|
+
adLoadedInfo: adLoadedInfo
|
|
2860
|
+
});
|
|
2861
|
+
return [
|
|
2862
|
+
4,
|
|
2863
|
+
postAdTracking(licenseKey, body)
|
|
2864
|
+
];
|
|
2865
|
+
case 2:
|
|
2866
|
+
_state.sent();
|
|
2867
|
+
return [
|
|
2868
|
+
3,
|
|
2869
|
+
4
|
|
2870
|
+
];
|
|
2871
|
+
case 3:
|
|
2872
|
+
error = _state.sent();
|
|
2873
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-loaded tracking:", error);
|
|
2874
|
+
return [
|
|
2875
|
+
3,
|
|
2876
|
+
4
|
|
2877
|
+
];
|
|
2878
|
+
case 4:
|
|
2879
|
+
return [
|
|
2880
|
+
2
|
|
2881
|
+
];
|
|
2882
|
+
}
|
|
2883
|
+
});
|
|
2884
|
+
})();
|
|
2885
|
+
}
|
|
2886
|
+
function sendAdImpressionTracking(licenseKey, payload, adPlayerType) {
|
|
2887
|
+
return _async_to_generator(function() {
|
|
2888
|
+
var clientInfo, browserId, source, adImpressionInfo, body, error;
|
|
2889
|
+
return _ts_generator(this, function(_state) {
|
|
2890
|
+
switch(_state.label){
|
|
2891
|
+
case 0:
|
|
2892
|
+
_state.trys.push([
|
|
2893
|
+
0,
|
|
2894
|
+
3,
|
|
2895
|
+
,
|
|
2896
|
+
4
|
|
2897
|
+
]);
|
|
2898
|
+
clientInfo = getClientInfo();
|
|
2899
|
+
return [
|
|
2900
|
+
4,
|
|
2901
|
+
getBrowserID(clientInfo)
|
|
2902
|
+
];
|
|
2903
|
+
case 1:
|
|
2904
|
+
browserId = _state.sent();
|
|
2905
|
+
source = mapToAdTrackingSource(payload.source, adPlayerType);
|
|
2906
|
+
adImpressionInfo = _object_spread({
|
|
2907
|
+
source: source,
|
|
2908
|
+
adIndex: payload.adIndex,
|
|
2909
|
+
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
2910
|
+
}, payload.durationSeconds != null && {
|
|
2911
|
+
durationSeconds: payload.durationSeconds
|
|
2912
|
+
});
|
|
2913
|
+
body = _object_spread_props(_object_spread({
|
|
2914
|
+
browserId: browserId
|
|
2915
|
+
}, clientInfo, licenseKey && {
|
|
2916
|
+
licenseKey: licenseKey
|
|
2917
|
+
}), {
|
|
2918
|
+
adImpressionInfo: adImpressionInfo
|
|
2919
|
+
});
|
|
2920
|
+
return [
|
|
2921
|
+
4,
|
|
2922
|
+
postAdTracking(licenseKey, body)
|
|
2923
|
+
];
|
|
2924
|
+
case 2:
|
|
2925
|
+
_state.sent();
|
|
2926
|
+
return [
|
|
2927
|
+
3,
|
|
2928
|
+
4
|
|
2929
|
+
];
|
|
2930
|
+
case 3:
|
|
2931
|
+
error = _state.sent();
|
|
2932
|
+
console.error("[StormcloudVideoPlayer] Error sending ad-impression tracking:", error);
|
|
2933
|
+
return [
|
|
2934
|
+
3,
|
|
2935
|
+
4
|
|
2936
|
+
];
|
|
2937
|
+
case 4:
|
|
2938
|
+
return [
|
|
2939
|
+
2
|
|
2940
|
+
];
|
|
2941
|
+
}
|
|
2942
|
+
});
|
|
2943
|
+
})();
|
|
2944
|
+
}
|
|
2720
2945
|
// src/utils/polyfills.ts
|
|
2721
2946
|
function polyfillURLSearchParams() {
|
|
2722
2947
|
if (typeof URLSearchParams !== "undefined") {
|
|
@@ -3017,6 +3242,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3017
3242
|
this.maxPreloadPoolSize = 2;
|
|
3018
3243
|
this.preloadPoolActive = false;
|
|
3019
3244
|
this.preloadPoolLoopRunning = false;
|
|
3245
|
+
this.adDetectSentForCurrentBreak = false;
|
|
3020
3246
|
this.continuousFetchLoopRunning = false;
|
|
3021
3247
|
initializePolyfills();
|
|
3022
3248
|
var browserOverrides = getBrowserConfigOverrides();
|
|
@@ -3486,6 +3712,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3486
3712
|
value: function attachImaEventListeners() {
|
|
3487
3713
|
var _this = this;
|
|
3488
3714
|
this.ima.on("all_ads_completed", function() {
|
|
3715
|
+
sendAdImpressionTracking(_this.config.licenseKey, {
|
|
3716
|
+
adIndex: _this.currentAdIndex
|
|
3717
|
+
}, _this.config.adPlayerType).catch(function() {});
|
|
3489
3718
|
var remaining = _this.getRemainingAdMs();
|
|
3490
3719
|
_this.consecutiveFailures = 0;
|
|
3491
3720
|
if (_this.config.debugAdTiming) {
|
|
@@ -3548,6 +3777,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3548
3777
|
}
|
|
3549
3778
|
});
|
|
3550
3779
|
this.ima.on("content_resume", function() {
|
|
3780
|
+
sendAdImpressionTracking(_this.config.licenseKey, {
|
|
3781
|
+
adIndex: _this.currentAdIndex
|
|
3782
|
+
}, _this.config.adPlayerType).catch(function() {});
|
|
3551
3783
|
if (!_this.video.muted) {
|
|
3552
3784
|
_this.video.muted = true;
|
|
3553
3785
|
_this.video.volume = 0;
|
|
@@ -3931,6 +4163,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3931
4163
|
}
|
|
3932
4164
|
return;
|
|
3933
4165
|
}
|
|
4166
|
+
if (!this.adDetectSentForCurrentBreak) {
|
|
4167
|
+
this.adDetectSentForCurrentBreak = true;
|
|
4168
|
+
var detectPayload = {};
|
|
4169
|
+
if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
|
|
4170
|
+
if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
|
|
4171
|
+
sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
|
|
4172
|
+
}
|
|
3934
4173
|
var hasPrefetchedAds = this.pendingAdBreak && this.pendingAdBreak.vastUrls.length > 0;
|
|
3935
4174
|
this.inAdBreak = true;
|
|
3936
4175
|
var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_pendingAdBreak = this.pendingAdBreak) === null || _this_pendingAdBreak === void 0 ? void 0 : _this_pendingAdBreak.marker.durationSeconds) != null ? this.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
|
|
@@ -4488,6 +4727,12 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4488
4727
|
isFetching: false,
|
|
4489
4728
|
fetchStartTime: Date.now()
|
|
4490
4729
|
});
|
|
4730
|
+
this.adDetectSentForCurrentBreak = true;
|
|
4731
|
+
var detectPayload = {};
|
|
4732
|
+
if (marker.durationSeconds != null) detectPayload.durationSeconds = marker.durationSeconds;
|
|
4733
|
+
if (marker.ptsSeconds != null) detectPayload.ptsSeconds = marker.ptsSeconds;
|
|
4734
|
+
if (fragmentSn !== void 0) detectPayload.detectedAtFragmentSn = fragmentSn;
|
|
4735
|
+
sendAdDetectTracking(this.config.licenseKey, detectPayload).catch(function() {});
|
|
4491
4736
|
if (this.config.debugAdTiming) {
|
|
4492
4737
|
console.log("[PREFETCH] \uD83D\uDD04 Starting ad prefetch for upcoming ad break");
|
|
4493
4738
|
console.log("[PREFETCH] \uD83D\uDCCB Pre-generated ".concat(generatedUrls.length, " VAST URLs"));
|
|
@@ -4963,6 +5208,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4963
5208
|
firstAdUrl = preloaded.vastUrl;
|
|
4964
5209
|
preloadedController = preloaded.imaController;
|
|
4965
5210
|
usePreloadedAd = true;
|
|
5211
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5212
|
+
source: "preload",
|
|
5213
|
+
vastUrl: firstAdUrl
|
|
5214
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
4966
5215
|
if (this.config.debugAdTiming) {
|
|
4967
5216
|
console.log("[CONTINUOUS-FETCH] \uD83D\uDE80 Using preloaded ad from pool (preloaded in advance, ready immediately!)");
|
|
4968
5217
|
console.log("[CONTINUOUS-FETCH] Pool still has ".concat(this.preloadPool.length, " preloaded ads ready"));
|
|
@@ -5052,6 +5301,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5052
5301
|
];
|
|
5053
5302
|
case 5:
|
|
5054
5303
|
_state.sent();
|
|
5304
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5305
|
+
source: "ssp",
|
|
5306
|
+
vastUrl: firstAdUrl
|
|
5307
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
5055
5308
|
if (this.config.debugAdTiming) {
|
|
5056
5309
|
console.log("[CONTINUOUS-FETCH] \u2705 First ad request successful, starting playback");
|
|
5057
5310
|
}
|
|
@@ -5448,6 +5701,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5448
5701
|
if (this.config.debugAdTiming) {
|
|
5449
5702
|
console.log("[CONTINUOUS-FETCH] \uD83C\uDFAF Using preloaded ad from pool (".concat(this.preloadPool.length, " remaining in pool)"));
|
|
5450
5703
|
}
|
|
5704
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
5705
|
+
source: "preload",
|
|
5706
|
+
vastUrl: preloaded.vastUrl
|
|
5707
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
5451
5708
|
_state.label = 1;
|
|
5452
5709
|
case 1:
|
|
5453
5710
|
_state.trys.push([
|
|
@@ -6152,6 +6409,10 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6152
6409
|
];
|
|
6153
6410
|
case 3:
|
|
6154
6411
|
_state.sent();
|
|
6412
|
+
sendAdLoadedTracking(this.config.licenseKey, {
|
|
6413
|
+
source: "ssp",
|
|
6414
|
+
vastUrl: vastTagUrl
|
|
6415
|
+
}, this.config.adPlayerType).catch(function() {});
|
|
6155
6416
|
this.clearAdRequestWatchdog();
|
|
6156
6417
|
if (this.activeAdRequestToken !== requestToken) {
|
|
6157
6418
|
return [
|
|
@@ -6366,6 +6627,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6366
6627
|
}
|
|
6367
6628
|
this.adRequestQueue = [];
|
|
6368
6629
|
this.inAdBreak = false;
|
|
6630
|
+
this.adDetectSentForCurrentBreak = false;
|
|
6369
6631
|
this.expectedAdBreakDurationMs = void 0;
|
|
6370
6632
|
this.currentAdBreakStartWallClockMs = void 0;
|
|
6371
6633
|
this.clearAdStartTimer();
|