stormcloud-video-player 0.8.4 → 0.8.5
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 +2 -2
- package/lib/index.cjs +200 -14
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +10 -0
- package/lib/index.d.ts +10 -0
- package/lib/index.js +200 -14
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +200 -14
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +7 -1
- package/lib/players/HlsPlayer.cjs +200 -14
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +200 -14
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/hlsAdPlayer.d.cts +1 -1
- package/lib/{types-BmF_60m2.d.cts → types-CUKMIqHL.d.cts} +4 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +200 -14
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/tracking.d.cts +1 -1
- package/lib/utils/vastMacros.cjs +231 -0
- package/lib/utils/vastMacros.cjs.map +1 -0
- package/lib/utils/vastMacros.d.cts +24 -0
- 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-CUKMIqHL.cjs';
|
|
3
3
|
|
|
4
4
|
interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
|
|
5
5
|
onMount?: (player: any) => void;
|
package/lib/players/index.cjs
CHANGED
|
@@ -2276,6 +2276,166 @@ function initializePolyfills() {
|
|
|
2276
2276
|
polyfillTextEncoder();
|
|
2277
2277
|
polyfillPromiseFinally();
|
|
2278
2278
|
}
|
|
2279
|
+
// src/utils/vastMacros.ts
|
|
2280
|
+
function generateCorrelator() {
|
|
2281
|
+
if (typeof crypto !== "undefined" && crypto.getRandomValues) {
|
|
2282
|
+
try {
|
|
2283
|
+
var _buf_, _buf_1;
|
|
2284
|
+
var buf = new Uint32Array(2);
|
|
2285
|
+
crypto.getRandomValues(buf);
|
|
2286
|
+
var value = ((_buf_ = buf[0]) !== null && _buf_ !== void 0 ? _buf_ : 0) * 2097152 + (((_buf_1 = buf[1]) !== null && _buf_1 !== void 0 ? _buf_1 : 0) & 2097151);
|
|
2287
|
+
if (value > 0) {
|
|
2288
|
+
return String(value);
|
|
2289
|
+
}
|
|
2290
|
+
} catch (unused) {}
|
|
2291
|
+
}
|
|
2292
|
+
return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
|
|
2293
|
+
}
|
|
2294
|
+
var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
|
|
2295
|
+
function applyVastMacros(baseUrl, ctx) {
|
|
2296
|
+
var url;
|
|
2297
|
+
try {
|
|
2298
|
+
url = new URL(baseUrl);
|
|
2299
|
+
} catch (unused) {
|
|
2300
|
+
return replaceCorrelatorFallback(baseUrl, ctx.correlator);
|
|
2301
|
+
}
|
|
2302
|
+
var params = url.searchParams;
|
|
2303
|
+
params.set("correlator", ctx.correlator);
|
|
2304
|
+
params.set("scor", ctx.streamCorrelator);
|
|
2305
|
+
if (ctx.pod != null) {
|
|
2306
|
+
params.set("pod", String(ctx.pod));
|
|
2307
|
+
}
|
|
2308
|
+
if (ctx.adPosition != null) {
|
|
2309
|
+
params.set("ppos", String(ctx.adPosition));
|
|
2310
|
+
}
|
|
2311
|
+
if (ctx.pageUrl) {
|
|
2312
|
+
params.set("url", ctx.pageUrl);
|
|
2313
|
+
params.set("description_url", ctx.pageUrl);
|
|
2314
|
+
}
|
|
2315
|
+
if (ctx.adWillPlayMuted != null) {
|
|
2316
|
+
params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
|
|
2317
|
+
}
|
|
2318
|
+
if (ctx.adWillAutoPlay != null) {
|
|
2319
|
+
params.set("vpa", ctx.adWillAutoPlay ? "auto" : "click");
|
|
2320
|
+
}
|
|
2321
|
+
if (ctx.deviceId && ctx.deviceIdType) {
|
|
2322
|
+
params.set("rdid", ctx.deviceId);
|
|
2323
|
+
params.set("idtype", ctx.deviceIdType);
|
|
2324
|
+
params.set("is_lat", ctx.limitAdTracking ? "1" : "0");
|
|
2325
|
+
} else {
|
|
2326
|
+
params.delete("rdid");
|
|
2327
|
+
params.delete("idtype");
|
|
2328
|
+
params.delete("is_lat");
|
|
2329
|
+
}
|
|
2330
|
+
var consent = ctx.consent;
|
|
2331
|
+
if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
|
|
2332
|
+
params.set("gdpr", consent.gdpr);
|
|
2333
|
+
}
|
|
2334
|
+
if ((consent === null || consent === void 0 ? void 0 : consent.gdprConsent) != null) {
|
|
2335
|
+
params.set("gdpr_consent", consent.gdprConsent);
|
|
2336
|
+
}
|
|
2337
|
+
if ((consent === null || consent === void 0 ? void 0 : consent.usPrivacy) != null) {
|
|
2338
|
+
params.set("us_privacy", consent.usPrivacy);
|
|
2339
|
+
}
|
|
2340
|
+
if (ctx.adTest) {
|
|
2341
|
+
params.set("adtest", "on");
|
|
2342
|
+
}
|
|
2343
|
+
var staleKeys = [];
|
|
2344
|
+
params.forEach(function(value, key) {
|
|
2345
|
+
if (UNEXPANDED_MACRO_PATTERN.test(value)) {
|
|
2346
|
+
staleKeys.push(key);
|
|
2347
|
+
}
|
|
2348
|
+
});
|
|
2349
|
+
var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
|
|
2350
|
+
try {
|
|
2351
|
+
for(var _iterator = staleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
|
|
2352
|
+
var key = _step.value;
|
|
2353
|
+
params.delete(key);
|
|
2354
|
+
}
|
|
2355
|
+
} catch (err) {
|
|
2356
|
+
_didIteratorError = true;
|
|
2357
|
+
_iteratorError = err;
|
|
2358
|
+
} finally{
|
|
2359
|
+
try {
|
|
2360
|
+
if (!_iteratorNormalCompletion && _iterator.return != null) {
|
|
2361
|
+
_iterator.return();
|
|
2362
|
+
}
|
|
2363
|
+
} finally{
|
|
2364
|
+
if (_didIteratorError) {
|
|
2365
|
+
throw _iteratorError;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
}
|
|
2369
|
+
return url.toString();
|
|
2370
|
+
}
|
|
2371
|
+
function replaceCorrelatorFallback(baseUrl, correlator) {
|
|
2372
|
+
var correlatorRegex = /([?&])correlator=([^&]*)/;
|
|
2373
|
+
if (correlatorRegex.test(baseUrl)) {
|
|
2374
|
+
return baseUrl.replace(correlatorRegex, "$1correlator=".concat(correlator));
|
|
2375
|
+
}
|
|
2376
|
+
var sep = baseUrl.includes("?") ? "&" : "?";
|
|
2377
|
+
return "".concat(baseUrl).concat(sep, "correlator=").concat(correlator);
|
|
2378
|
+
}
|
|
2379
|
+
function fetchConsentSignals() {
|
|
2380
|
+
var timeoutMs = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 1500;
|
|
2381
|
+
var signals = {};
|
|
2382
|
+
if (typeof window === "undefined") {
|
|
2383
|
+
return Promise.resolve(signals);
|
|
2384
|
+
}
|
|
2385
|
+
var tasks = [];
|
|
2386
|
+
var tcfApi = window.__tcfapi;
|
|
2387
|
+
if (typeof tcfApi === "function") {
|
|
2388
|
+
tasks.push(new Promise(function(resolve) {
|
|
2389
|
+
var settled = false;
|
|
2390
|
+
try {
|
|
2391
|
+
tcfApi("addEventListener", 2, function(tcData, success) {
|
|
2392
|
+
if (settled) return;
|
|
2393
|
+
if (success && tcData && (tcData.eventStatus === "tcloaded" || tcData.eventStatus === "useractioncomplete")) {
|
|
2394
|
+
settled = true;
|
|
2395
|
+
signals.gdpr = tcData.gdprApplies ? "1" : "0";
|
|
2396
|
+
if (typeof tcData.tcString === "string" && tcData.tcString) {
|
|
2397
|
+
signals.gdprConsent = tcData.tcString;
|
|
2398
|
+
}
|
|
2399
|
+
try {
|
|
2400
|
+
tcfApi("removeEventListener", 2, function() {}, tcData.listenerId);
|
|
2401
|
+
} catch (unused) {}
|
|
2402
|
+
resolve();
|
|
2403
|
+
}
|
|
2404
|
+
});
|
|
2405
|
+
} catch (unused) {
|
|
2406
|
+
resolve();
|
|
2407
|
+
}
|
|
2408
|
+
setTimeout(function() {
|
|
2409
|
+
if (!settled) {
|
|
2410
|
+
settled = true;
|
|
2411
|
+
resolve();
|
|
2412
|
+
}
|
|
2413
|
+
}, timeoutMs);
|
|
2414
|
+
}));
|
|
2415
|
+
}
|
|
2416
|
+
var uspApi = window.__uspapi;
|
|
2417
|
+
if (typeof uspApi === "function") {
|
|
2418
|
+
tasks.push(new Promise(function(resolve) {
|
|
2419
|
+
try {
|
|
2420
|
+
uspApi("getUSPData", 1, function(data, success) {
|
|
2421
|
+
if (success && typeof (data === null || data === void 0 ? void 0 : data.uspString) === "string" && data.uspString) {
|
|
2422
|
+
signals.usPrivacy = data.uspString;
|
|
2423
|
+
}
|
|
2424
|
+
resolve();
|
|
2425
|
+
});
|
|
2426
|
+
} catch (unused) {
|
|
2427
|
+
resolve();
|
|
2428
|
+
}
|
|
2429
|
+
setTimeout(resolve, timeoutMs);
|
|
2430
|
+
}));
|
|
2431
|
+
}
|
|
2432
|
+
if (tasks.length === 0) {
|
|
2433
|
+
return Promise.resolve(signals);
|
|
2434
|
+
}
|
|
2435
|
+
return Promise.all(tasks).then(function() {
|
|
2436
|
+
return signals;
|
|
2437
|
+
});
|
|
2438
|
+
}
|
|
2279
2439
|
// src/utils/browserCompat.ts
|
|
2280
2440
|
function getChromeVersion(ua) {
|
|
2281
2441
|
var match = ua.match(/Chrome\/(\d+)/);
|
|
@@ -2501,6 +2661,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2501
2661
|
this.preloadPoolLoopRunning = false;
|
|
2502
2662
|
this.adDetectSentForCurrentBreak = false;
|
|
2503
2663
|
this.palPlaybackStarted = false;
|
|
2664
|
+
this.streamCorrelator = generateCorrelator();
|
|
2665
|
+
this.consentSignals = {};
|
|
2666
|
+
this.podCounter = 0;
|
|
2667
|
+
this.podAssignedByPrefetch = false;
|
|
2668
|
+
this.adRequestPositionInBreak = 0;
|
|
2504
2669
|
this.continuousFetchLoopRunning = false;
|
|
2505
2670
|
initializePolyfills();
|
|
2506
2671
|
var browserOverrides = getBrowserConfigOverrides();
|
|
@@ -2573,6 +2738,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
2573
2738
|
adWillPlayMuted: !!this.config.muted,
|
|
2574
2739
|
continuousPlayback: (_this_config_lowLatencyMode = this.config.lowLatencyMode) !== null && _this_config_lowLatencyMode !== void 0 ? _this_config_lowLatencyMode : false
|
|
2575
2740
|
}).catch(function() {});
|
|
2741
|
+
fetchConsentSignals().then(function(signals) {
|
|
2742
|
+
_this.consentSignals = signals;
|
|
2743
|
+
}).catch(function() {});
|
|
2576
2744
|
this.initializeTracking();
|
|
2577
2745
|
if (!this.shouldUseNativeHls()) return [
|
|
2578
2746
|
3,
|
|
@@ -4869,25 +5037,35 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4869
5037
|
return this.getRemainingAdMs();
|
|
4870
5038
|
}
|
|
4871
5039
|
},
|
|
5040
|
+
{
|
|
5041
|
+
key: "beginNewAdPod",
|
|
5042
|
+
value: function beginNewAdPod() {
|
|
5043
|
+
this.podCounter++;
|
|
5044
|
+
this.adRequestPositionInBreak = 0;
|
|
5045
|
+
}
|
|
5046
|
+
},
|
|
4872
5047
|
{
|
|
4873
5048
|
key: "generateVastUrlsWithCorrelators",
|
|
4874
5049
|
value: function generateVastUrlsWithCorrelators(baseUrl, count) {
|
|
4875
5050
|
var urls = [];
|
|
4876
|
-
var baseTimestamp = Date.now();
|
|
4877
5051
|
for(var i = 0; i < count; i++){
|
|
4878
|
-
|
|
4879
|
-
var
|
|
4880
|
-
var
|
|
4881
|
-
|
|
4882
|
-
|
|
4883
|
-
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
|
|
4887
|
-
|
|
4888
|
-
|
|
4889
|
-
|
|
4890
|
-
|
|
5052
|
+
this.adRequestPositionInBreak++;
|
|
5053
|
+
var adWillPlayMuted = this.inAdBreak ? this.adPlayer.getOriginalMutedState() : this.video.muted;
|
|
5054
|
+
var urlWithMacros = applyVastMacros(baseUrl, {
|
|
5055
|
+
correlator: generateCorrelator(),
|
|
5056
|
+
streamCorrelator: this.streamCorrelator,
|
|
5057
|
+
pod: this.podCounter > 0 ? this.podCounter : void 0,
|
|
5058
|
+
adPosition: this.adRequestPositionInBreak,
|
|
5059
|
+
pageUrl: typeof window !== "undefined" ? window.location.href : void 0,
|
|
5060
|
+
adWillPlayMuted: adWillPlayMuted,
|
|
5061
|
+
adWillAutoPlay: !!this.config.autoplay,
|
|
5062
|
+
deviceId: this.config.deviceId,
|
|
5063
|
+
deviceIdType: this.config.deviceIdType,
|
|
5064
|
+
limitAdTracking: this.config.limitAdTracking,
|
|
5065
|
+
adTest: this.config.adTest,
|
|
5066
|
+
consent: this.consentSignals
|
|
5067
|
+
});
|
|
5068
|
+
urls.push(this.palNonce.injectNonce(urlWithMacros));
|
|
4891
5069
|
}
|
|
4892
5070
|
return urls;
|
|
4893
5071
|
}
|
|
@@ -4957,6 +5135,8 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4957
5135
|
}
|
|
4958
5136
|
return;
|
|
4959
5137
|
}
|
|
5138
|
+
this.beginNewAdPod();
|
|
5139
|
+
this.podAssignedByPrefetch = true;
|
|
4960
5140
|
var urlsToPregenerate = 5;
|
|
4961
5141
|
var generatedUrls = this.generateVastUrlsWithCorrelators(baseVastUrl, urlsToPregenerate);
|
|
4962
5142
|
this.pendingAdBreak = _object_spread_props(_object_spread({
|
|
@@ -4994,6 +5174,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4994
5174
|
}
|
|
4995
5175
|
this.pendingAdBreak = null;
|
|
4996
5176
|
this.pendingScte35CueKey = void 0;
|
|
5177
|
+
this.podAssignedByPrefetch = false;
|
|
4997
5178
|
}
|
|
4998
5179
|
},
|
|
4999
5180
|
{
|
|
@@ -5430,6 +5611,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
5430
5611
|
this.continuousFetchingActive = true;
|
|
5431
5612
|
this.isShowingPlaceholder = false;
|
|
5432
5613
|
this.totalAdRequestsInBreak = 0;
|
|
5614
|
+
if (this.podAssignedByPrefetch) {
|
|
5615
|
+
this.podAssignedByPrefetch = false;
|
|
5616
|
+
} else {
|
|
5617
|
+
this.beginNewAdPod();
|
|
5618
|
+
}
|
|
5433
5619
|
currentMuted = this.video.muted;
|
|
5434
5620
|
currentVolume = this.video.volume;
|
|
5435
5621
|
this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
|