stormcloud-video-player 0.8.12 → 0.8.14

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.
@@ -1,4 +1,4 @@
1
- import { S as StormcloudVideoPlayerConfig } from '../types-BM5cceAy.cjs';
1
+ import { S as StormcloudVideoPlayerConfig } from '../types-CWWADkvd.cjs';
2
2
 
3
3
  declare class StormcloudVideoPlayer {
4
4
  private readonly video;
@@ -2340,6 +2340,20 @@ function generateCorrelator() {
2340
2340
  return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2341
2341
  }
2342
2342
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2343
+ var CTV_UNSUPPORTED_PARAMS = [
2344
+ "description_url",
2345
+ "tfcd",
2346
+ "npa",
2347
+ "min_ad_duration",
2348
+ "max_ad_duration",
2349
+ "unviewed_position_start",
2350
+ "impl",
2351
+ "scor",
2352
+ "vad_type",
2353
+ "gdpr",
2354
+ "gdpr_consent",
2355
+ "us_privacy"
2356
+ ];
2343
2357
  function applyVastMacros(baseUrl, ctx) {
2344
2358
  var url;
2345
2359
  try {
@@ -2349,16 +2363,42 @@ function applyVastMacros(baseUrl, ctx) {
2349
2363
  }
2350
2364
  var params = url.searchParams;
2351
2365
  params.set("correlator", ctx.correlator);
2352
- params.set("scor", ctx.streamCorrelator);
2366
+ if (ctx.isCtv) {
2367
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2368
+ try {
2369
+ for(var _iterator = CTV_UNSUPPORTED_PARAMS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2370
+ var key = _step.value;
2371
+ params.delete(key);
2372
+ }
2373
+ } catch (err) {
2374
+ _didIteratorError = true;
2375
+ _iteratorError = err;
2376
+ } finally{
2377
+ try {
2378
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2379
+ _iterator.return();
2380
+ }
2381
+ } finally{
2382
+ if (_didIteratorError) {
2383
+ throw _iteratorError;
2384
+ }
2385
+ }
2386
+ }
2387
+ } else {
2388
+ params.set("scor", ctx.streamCorrelator);
2389
+ }
2353
2390
  if (ctx.pod != null) {
2354
2391
  params.set("pod", String(ctx.pod));
2355
2392
  }
2356
2393
  if (ctx.adPosition != null) {
2357
2394
  params.set("ppos", String(ctx.adPosition));
2358
2395
  }
2359
- if (ctx.pageUrl) {
2360
- params.set("url", ctx.pageUrl);
2361
- params.set("description_url", ctx.pageUrl);
2396
+ var requestUrl = ctx.contentUrl || ctx.pageUrl;
2397
+ if (requestUrl) {
2398
+ params.set("url", requestUrl);
2399
+ if (!ctx.isCtv) {
2400
+ params.set("description_url", requestUrl);
2401
+ }
2362
2402
  }
2363
2403
  if (ctx.adWillPlayMuted != null) {
2364
2404
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2366,6 +2406,20 @@ function applyVastMacros(baseUrl, ctx) {
2366
2406
  if (ctx.adWillAutoPlay != null) {
2367
2407
  params.set("vpa", ctx.adWillAutoPlay ? "auto" : "click");
2368
2408
  }
2409
+ if (ctx.appId) {
2410
+ params.set("msid", ctx.appId);
2411
+ }
2412
+ if (ctx.appName) {
2413
+ params.set("an", ctx.appName);
2414
+ }
2415
+ if (ctx.sessionId) {
2416
+ params.set("sid", ctx.sessionId);
2417
+ }
2418
+ if (ctx.deviceTypeHint != null) {
2419
+ params.set("dth", String(ctx.deviceTypeHint));
2420
+ } else if (ctx.isCtv) {
2421
+ params.set("dth", "5");
2422
+ }
2369
2423
  if (ctx.deviceId && ctx.deviceIdType) {
2370
2424
  params.set("rdid", ctx.deviceId);
2371
2425
  params.set("idtype", ctx.deviceIdType);
@@ -2375,15 +2429,17 @@ function applyVastMacros(baseUrl, ctx) {
2375
2429
  params.delete("idtype");
2376
2430
  params.delete("is_lat");
2377
2431
  }
2378
- var consent = ctx.consent;
2379
- if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
2380
- params.set("gdpr", consent.gdpr);
2381
- }
2382
- if ((consent === null || consent === void 0 ? void 0 : consent.gdprConsent) != null) {
2383
- params.set("gdpr_consent", consent.gdprConsent);
2384
- }
2385
- if ((consent === null || consent === void 0 ? void 0 : consent.usPrivacy) != null) {
2386
- params.set("us_privacy", consent.usPrivacy);
2432
+ if (!ctx.isCtv) {
2433
+ var consent = ctx.consent;
2434
+ if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
2435
+ params.set("gdpr", consent.gdpr);
2436
+ }
2437
+ if ((consent === null || consent === void 0 ? void 0 : consent.gdprConsent) != null) {
2438
+ params.set("gdpr_consent", consent.gdprConsent);
2439
+ }
2440
+ if ((consent === null || consent === void 0 ? void 0 : consent.usPrivacy) != null) {
2441
+ params.set("us_privacy", consent.usPrivacy);
2442
+ }
2387
2443
  }
2388
2444
  if (ctx.adTest) {
2389
2445
  params.set("adtest", "on");
@@ -2394,23 +2450,23 @@ function applyVastMacros(baseUrl, ctx) {
2394
2450
  staleKeys.push(key);
2395
2451
  }
2396
2452
  });
2397
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2453
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2398
2454
  try {
2399
- for(var _iterator = staleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2400
- var key = _step.value;
2401
- params.delete(key);
2455
+ for(var _iterator1 = staleKeys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2456
+ var key1 = _step1.value;
2457
+ params.delete(key1);
2402
2458
  }
2403
2459
  } catch (err) {
2404
- _didIteratorError = true;
2405
- _iteratorError = err;
2460
+ _didIteratorError1 = true;
2461
+ _iteratorError1 = err;
2406
2462
  } finally{
2407
2463
  try {
2408
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2409
- _iterator.return();
2464
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2465
+ _iterator1.return();
2410
2466
  }
2411
2467
  } finally{
2412
- if (_didIteratorError) {
2413
- throw _iteratorError;
2468
+ if (_didIteratorError1) {
2469
+ throw _iteratorError1;
2414
2470
  }
2415
2471
  }
2416
2472
  }
@@ -2650,6 +2706,262 @@ function logBrowserInfo() {
2650
2706
  userAgent: navigator.userAgent
2651
2707
  }));
2652
2708
  }
2709
+ // src/utils/ctvVastSignals.ts
2710
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2711
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2712
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2713
+ var DEVICE_ID_STORAGE_KEYS = [
2714
+ "rdid",
2715
+ "ifa",
2716
+ "advertisingId",
2717
+ "advertising_id",
2718
+ "deviceAdvertisingId",
2719
+ "aaid",
2720
+ "adid",
2721
+ "rida",
2722
+ "tifa"
2723
+ ];
2724
+ function resolveCtvVastSignals() {
2725
+ var _ref, _bridgeSignals_limitAdTracking;
2726
+ var bridgeSignals = readNativeBridgeSignals();
2727
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2728
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
2729
+ return _object_spread_props(_object_spread({
2730
+ contentUrl: "https://".concat(AIRY_ANDROID_APP_ID, ".example.com"),
2731
+ appId: AIRY_ANDROID_APP_ID,
2732
+ appName: AIRY_APP_NAME,
2733
+ sessionId: getOrCreateCtvSessionId()
2734
+ }, deviceId ? {
2735
+ deviceId: deviceId
2736
+ } : {}, deviceId && deviceIdType ? {
2737
+ deviceIdType: deviceIdType
2738
+ } : {}, deviceId ? {
2739
+ limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
2740
+ } : {}), {
2741
+ deviceTypeHint: 5
2742
+ });
2743
+ }
2744
+ function getOrCreateCtvSessionId() {
2745
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2746
+ if (existing) {
2747
+ return existing;
2748
+ }
2749
+ var sessionId = createUuid();
2750
+ try {
2751
+ var _window_localStorage;
2752
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2753
+ } catch (unused) {}
2754
+ return sessionId;
2755
+ }
2756
+ function createUuid() {
2757
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2758
+ return crypto.randomUUID();
2759
+ }
2760
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2761
+ var value = Math.floor(Math.random() * 16);
2762
+ var nibble = char === "x" ? value : value & 3 | 8;
2763
+ return nibble.toString(16);
2764
+ });
2765
+ }
2766
+ function readNativeBridgeSignals() {
2767
+ if (typeof window === "undefined") {
2768
+ return {};
2769
+ }
2770
+ var candidates = [
2771
+ window.__STORMCLOUD_CTV_AD_INFO__,
2772
+ window.__STORMCLOUD_CTV__,
2773
+ window.stormcloudCtv,
2774
+ window.AiryTV,
2775
+ window.Android
2776
+ ].filter(Boolean);
2777
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2778
+ try {
2779
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2780
+ var source = _step.value;
2781
+ var deviceId = readBridgeValue(source, [
2782
+ "rdid",
2783
+ "ifa",
2784
+ "advertisingId",
2785
+ "adId",
2786
+ "deviceId"
2787
+ ]) || void 0;
2788
+ if (!deviceId) continue;
2789
+ var deviceIdType = readBridgeValue(source, [
2790
+ "idtype",
2791
+ "deviceIdType",
2792
+ "advertisingIdType"
2793
+ ]) || inferDeviceIdType();
2794
+ var limitAdTracking = readBridgeBoolean(source, [
2795
+ "is_lat",
2796
+ "limitAdTracking",
2797
+ "limitedAdTracking",
2798
+ "lat"
2799
+ ]);
2800
+ return _object_spread({
2801
+ deviceId: deviceId
2802
+ }, deviceIdType ? {
2803
+ deviceIdType: deviceIdType
2804
+ } : {}, limitAdTracking != null ? {
2805
+ limitAdTracking: limitAdTracking
2806
+ } : {});
2807
+ }
2808
+ } catch (err) {
2809
+ _didIteratorError = true;
2810
+ _iteratorError = err;
2811
+ } finally{
2812
+ try {
2813
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2814
+ _iterator.return();
2815
+ }
2816
+ } finally{
2817
+ if (_didIteratorError) {
2818
+ throw _iteratorError;
2819
+ }
2820
+ }
2821
+ }
2822
+ return {};
2823
+ }
2824
+ function readBridgeValue(source, keys) {
2825
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2826
+ try {
2827
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2828
+ var key = _step.value;
2829
+ var value = source === null || source === void 0 ? void 0 : source[key];
2830
+ if (typeof value === "string" && value) {
2831
+ return value;
2832
+ }
2833
+ if (typeof value === "function") {
2834
+ try {
2835
+ var result = value.call(source);
2836
+ if (typeof result === "string" && result) {
2837
+ return result;
2838
+ }
2839
+ } catch (unused) {}
2840
+ }
2841
+ }
2842
+ } catch (err) {
2843
+ _didIteratorError = true;
2844
+ _iteratorError = err;
2845
+ } finally{
2846
+ try {
2847
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2848
+ _iterator.return();
2849
+ }
2850
+ } finally{
2851
+ if (_didIteratorError) {
2852
+ throw _iteratorError;
2853
+ }
2854
+ }
2855
+ }
2856
+ return void 0;
2857
+ }
2858
+ function readBridgeBoolean(source, keys) {
2859
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2860
+ try {
2861
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2862
+ var key = _step.value;
2863
+ var value = source === null || source === void 0 ? void 0 : source[key];
2864
+ var normalized = normalizeBoolean(value);
2865
+ if (normalized != null) {
2866
+ return normalized;
2867
+ }
2868
+ if (typeof value === "function") {
2869
+ try {
2870
+ var result = normalizeBoolean(value.call(source));
2871
+ if (result != null) {
2872
+ return result;
2873
+ }
2874
+ } catch (unused) {}
2875
+ }
2876
+ }
2877
+ } catch (err) {
2878
+ _didIteratorError = true;
2879
+ _iteratorError = err;
2880
+ } finally{
2881
+ try {
2882
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2883
+ _iterator.return();
2884
+ }
2885
+ } finally{
2886
+ if (_didIteratorError) {
2887
+ throw _iteratorError;
2888
+ }
2889
+ }
2890
+ }
2891
+ return void 0;
2892
+ }
2893
+ function readStoredDeviceId() {
2894
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2895
+ try {
2896
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2897
+ var key = _step.value;
2898
+ var value = readStoredString(key);
2899
+ if (value) {
2900
+ return value;
2901
+ }
2902
+ }
2903
+ } catch (err) {
2904
+ _didIteratorError = true;
2905
+ _iteratorError = err;
2906
+ } finally{
2907
+ try {
2908
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2909
+ _iterator.return();
2910
+ }
2911
+ } finally{
2912
+ if (_didIteratorError) {
2913
+ throw _iteratorError;
2914
+ }
2915
+ }
2916
+ }
2917
+ return void 0;
2918
+ }
2919
+ function readStoredString(key) {
2920
+ if (typeof window === "undefined") {
2921
+ return void 0;
2922
+ }
2923
+ try {
2924
+ var _window_localStorage;
2925
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2926
+ return value || void 0;
2927
+ } catch (unused) {
2928
+ return void 0;
2929
+ }
2930
+ }
2931
+ function readStoredLimitAdTracking() {
2932
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2933
+ }
2934
+ function normalizeBoolean(value) {
2935
+ if (typeof value === "boolean") {
2936
+ return value;
2937
+ }
2938
+ if (typeof value === "number") {
2939
+ return value === 1;
2940
+ }
2941
+ if (typeof value === "string") {
2942
+ var normalized = value.toLowerCase();
2943
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2944
+ return true;
2945
+ }
2946
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2947
+ return false;
2948
+ }
2949
+ }
2950
+ return void 0;
2951
+ }
2952
+ function inferDeviceIdType() {
2953
+ if (typeof navigator === "undefined") {
2954
+ return void 0;
2955
+ }
2956
+ var ua = navigator.userAgent;
2957
+ if (/Roku/i.test(ua)) return "rida";
2958
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
2959
+ if (/AppleTV/i.test(ua)) return "tvOS";
2960
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2961
+ if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
2962
+ if (/Android|Google TV/i.test(ua)) return "aaid";
2963
+ return void 0;
2964
+ }
2653
2965
  // src/player/StormcloudVideoPlayer.ts
2654
2966
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2655
2967
  function StormcloudVideoPlayer(config) {
@@ -5091,17 +5403,24 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5091
5403
  for(var i = 0; i < count; i++){
5092
5404
  this.adRequestPositionInBreak++;
5093
5405
  var adWillPlayMuted = this.inAdBreak ? this.adPlayer.getOriginalMutedState() : this.video.muted;
5406
+ var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
5094
5407
  var urlWithMacros = applyVastMacros(baseUrl, {
5095
5408
  correlator: generateCorrelator(),
5096
5409
  streamCorrelator: this.streamCorrelator,
5097
5410
  pod: this.podCounter > 0 ? this.podCounter : void 0,
5098
5411
  adPosition: this.adRequestPositionInBreak,
5099
- pageUrl: typeof window !== "undefined" ? window.location.href : void 0,
5412
+ isCtv: this.config.ctvAdRequest,
5413
+ contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
5414
+ pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
5100
5415
  adWillPlayMuted: adWillPlayMuted,
5101
5416
  adWillAutoPlay: !!this.config.autoplay,
5102
- deviceId: this.config.deviceId,
5103
- deviceIdType: this.config.deviceIdType,
5104
- limitAdTracking: this.config.limitAdTracking,
5417
+ appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
5418
+ appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
5419
+ sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
5420
+ deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
5421
+ deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
5422
+ limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
5423
+ deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
5105
5424
  adTest: this.config.adTest,
5106
5425
  consent: this.consentSignals
5107
5426
  });
@@ -5685,21 +6004,13 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5685
6004
  currentMuted = this.video.muted;
5686
6005
  currentVolume = this.video.volume;
5687
6006
  this.adPlayer.updateOriginalMutedState(currentMuted, currentVolume);
5688
- if (!this.video.muted) {
5689
- this.video.muted = true;
5690
- if (this.config.debugAdTiming) {
5691
- console.log("[StormcloudVideoPlayer] Muted video in handleAdStart");
5692
- }
5693
- }
5694
6007
  this.inAdBreak = true;
5695
6008
  this.currentAdBreakStartWallClockMs = Date.now();
5696
6009
  this.adBreakPlayedDurationMs = 0;
5697
6010
  this.currentAdIndex = 0;
5698
6011
  this.totalAdsInBreak = 0;
5699
6012
  this.adPodQueue = [];
5700
- this.showAds = true;
5701
- this.showPlaceholderLayer();
5702
- this.adPlayer.showPlaceholder();
6013
+ this.showAds = false;
5703
6014
  if (this.expectedAdBreakDurationMs == null && adBreakDurationMs != null) {
5704
6015
  this.expectedAdBreakDurationMs = adBreakDurationMs;
5705
6016
  }
@@ -7979,6 +8290,7 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react_Component) {
7979
8290
  if (_this1.props.licenseKey !== void 0) config.licenseKey = _this1.props.licenseKey;
7980
8291
  if (_this1.props.adFailsafeTimeoutMs !== void 0) config.adFailsafeTimeoutMs = _this1.props.adFailsafeTimeoutMs;
7981
8292
  if (_this1.props.minSegmentsBeforePlay !== void 0) config.minSegmentsBeforePlay = _this1.props.minSegmentsBeforePlay;
8293
+ if (_this1.props.ctvAdRequest !== void 0) config.ctvAdRequest = _this1.props.ctvAdRequest;
7982
8294
  _this1.player = new StormcloudVideoPlayer(config);
7983
8295
  (_this_props_onMount = (_this_props = _this1.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this1);
7984
8296
  return [