stormcloud-video-player 0.8.13 → 0.8.15

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,5 +1,5 @@
1
1
  import { Component } from 'react';
2
- import { S as StormcloudVideoPlayerConfig } from '../types-BM5cceAy.cjs';
2
+ import { S as StormcloudVideoPlayerConfig } from '../types-CWWADkvd.cjs';
3
3
 
4
4
  interface HlsPlayerProps extends StormcloudVideoPlayerConfig {
5
5
  onMount?: (player: any) => void;
@@ -2376,6 +2376,20 @@ function generateCorrelator() {
2376
2376
  return String(Math.floor(Math.random() * Number.MAX_SAFE_INTEGER) + 1);
2377
2377
  }
2378
2378
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
2379
+ var CTV_UNSUPPORTED_PARAMS = [
2380
+ "description_url",
2381
+ "tfcd",
2382
+ "npa",
2383
+ "min_ad_duration",
2384
+ "max_ad_duration",
2385
+ "unviewed_position_start",
2386
+ "impl",
2387
+ "scor",
2388
+ "vad_type",
2389
+ "gdpr",
2390
+ "gdpr_consent",
2391
+ "us_privacy"
2392
+ ];
2379
2393
  function applyVastMacros(baseUrl, ctx) {
2380
2394
  var url;
2381
2395
  try {
@@ -2385,16 +2399,42 @@ function applyVastMacros(baseUrl, ctx) {
2385
2399
  }
2386
2400
  var params = url.searchParams;
2387
2401
  params.set("correlator", ctx.correlator);
2388
- params.set("scor", ctx.streamCorrelator);
2402
+ if (ctx.isCtv) {
2403
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2404
+ try {
2405
+ for(var _iterator = CTV_UNSUPPORTED_PARAMS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2406
+ var key = _step.value;
2407
+ params.delete(key);
2408
+ }
2409
+ } catch (err) {
2410
+ _didIteratorError = true;
2411
+ _iteratorError = err;
2412
+ } finally{
2413
+ try {
2414
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2415
+ _iterator.return();
2416
+ }
2417
+ } finally{
2418
+ if (_didIteratorError) {
2419
+ throw _iteratorError;
2420
+ }
2421
+ }
2422
+ }
2423
+ } else {
2424
+ params.set("scor", ctx.streamCorrelator);
2425
+ }
2389
2426
  if (ctx.pod != null) {
2390
2427
  params.set("pod", String(ctx.pod));
2391
2428
  }
2392
2429
  if (ctx.adPosition != null) {
2393
2430
  params.set("ppos", String(ctx.adPosition));
2394
2431
  }
2395
- if (ctx.pageUrl) {
2396
- params.set("url", ctx.pageUrl);
2397
- params.set("description_url", ctx.pageUrl);
2432
+ var requestUrl = ctx.contentUrl || ctx.pageUrl;
2433
+ if (requestUrl) {
2434
+ params.set("url", requestUrl);
2435
+ if (!ctx.isCtv) {
2436
+ params.set("description_url", requestUrl);
2437
+ }
2398
2438
  }
2399
2439
  if (ctx.adWillPlayMuted != null) {
2400
2440
  params.set("vpmute", ctx.adWillPlayMuted ? "1" : "0");
@@ -2402,6 +2442,20 @@ function applyVastMacros(baseUrl, ctx) {
2402
2442
  if (ctx.adWillAutoPlay != null) {
2403
2443
  params.set("vpa", ctx.adWillAutoPlay ? "auto" : "click");
2404
2444
  }
2445
+ if (ctx.appId) {
2446
+ params.set("msid", ctx.appId);
2447
+ }
2448
+ if (ctx.appName) {
2449
+ params.set("an", ctx.appName);
2450
+ }
2451
+ if (ctx.sessionId) {
2452
+ params.set("sid", ctx.sessionId);
2453
+ }
2454
+ if (ctx.deviceTypeHint != null) {
2455
+ params.set("dth", String(ctx.deviceTypeHint));
2456
+ } else if (ctx.isCtv) {
2457
+ params.set("dth", "5");
2458
+ }
2405
2459
  if (ctx.deviceId && ctx.deviceIdType) {
2406
2460
  params.set("rdid", ctx.deviceId);
2407
2461
  params.set("idtype", ctx.deviceIdType);
@@ -2411,15 +2465,17 @@ function applyVastMacros(baseUrl, ctx) {
2411
2465
  params.delete("idtype");
2412
2466
  params.delete("is_lat");
2413
2467
  }
2414
- var consent = ctx.consent;
2415
- if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
2416
- params.set("gdpr", consent.gdpr);
2417
- }
2418
- if ((consent === null || consent === void 0 ? void 0 : consent.gdprConsent) != null) {
2419
- params.set("gdpr_consent", consent.gdprConsent);
2420
- }
2421
- if ((consent === null || consent === void 0 ? void 0 : consent.usPrivacy) != null) {
2422
- params.set("us_privacy", consent.usPrivacy);
2468
+ if (!ctx.isCtv) {
2469
+ var consent = ctx.consent;
2470
+ if ((consent === null || consent === void 0 ? void 0 : consent.gdpr) != null) {
2471
+ params.set("gdpr", consent.gdpr);
2472
+ }
2473
+ if ((consent === null || consent === void 0 ? void 0 : consent.gdprConsent) != null) {
2474
+ params.set("gdpr_consent", consent.gdprConsent);
2475
+ }
2476
+ if ((consent === null || consent === void 0 ? void 0 : consent.usPrivacy) != null) {
2477
+ params.set("us_privacy", consent.usPrivacy);
2478
+ }
2423
2479
  }
2424
2480
  if (ctx.adTest) {
2425
2481
  params.set("adtest", "on");
@@ -2430,23 +2486,23 @@ function applyVastMacros(baseUrl, ctx) {
2430
2486
  staleKeys.push(key);
2431
2487
  }
2432
2488
  });
2433
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2489
+ var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
2434
2490
  try {
2435
- for(var _iterator = staleKeys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2436
- var key = _step.value;
2437
- params.delete(key);
2491
+ for(var _iterator1 = staleKeys[Symbol.iterator](), _step1; !(_iteratorNormalCompletion1 = (_step1 = _iterator1.next()).done); _iteratorNormalCompletion1 = true){
2492
+ var key1 = _step1.value;
2493
+ params.delete(key1);
2438
2494
  }
2439
2495
  } catch (err) {
2440
- _didIteratorError = true;
2441
- _iteratorError = err;
2496
+ _didIteratorError1 = true;
2497
+ _iteratorError1 = err;
2442
2498
  } finally{
2443
2499
  try {
2444
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2445
- _iterator.return();
2500
+ if (!_iteratorNormalCompletion1 && _iterator1.return != null) {
2501
+ _iterator1.return();
2446
2502
  }
2447
2503
  } finally{
2448
- if (_didIteratorError) {
2449
- throw _iteratorError;
2504
+ if (_didIteratorError1) {
2505
+ throw _iteratorError1;
2450
2506
  }
2451
2507
  }
2452
2508
  }
@@ -2686,6 +2742,272 @@ function logBrowserInfo() {
2686
2742
  userAgent: navigator.userAgent
2687
2743
  }));
2688
2744
  }
2745
+ // src/utils/ctvVastSignals.ts
2746
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2747
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
2748
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2749
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2750
+ var DEVICE_ID_STORAGE_KEYS = [
2751
+ "rdid",
2752
+ "ifa",
2753
+ "advertisingId",
2754
+ "advertising_id",
2755
+ "deviceAdvertisingId",
2756
+ "aaid",
2757
+ "adid",
2758
+ "rida",
2759
+ "tifa"
2760
+ ];
2761
+ function resolveCtvVastSignals() {
2762
+ var _ref, _bridgeSignals_limitAdTracking;
2763
+ var bridgeSignals = readNativeBridgeSignals();
2764
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId();
2765
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || inferDeviceIdType();
2766
+ var contentUrl = bridgeSignals.contentUrl || readStoredString("contentUrl") || AIRY_DEFAULT_CONTENT_URL;
2767
+ return _object_spread_props(_object_spread({
2768
+ contentUrl: contentUrl,
2769
+ appId: AIRY_ANDROID_APP_ID,
2770
+ appName: AIRY_APP_NAME,
2771
+ sessionId: getOrCreateCtvSessionId()
2772
+ }, deviceId ? {
2773
+ deviceId: deviceId
2774
+ } : {}, deviceId && deviceIdType ? {
2775
+ deviceIdType: deviceIdType
2776
+ } : {}, deviceId ? {
2777
+ limitAdTracking: (_ref = (_bridgeSignals_limitAdTracking = bridgeSignals.limitAdTracking) !== null && _bridgeSignals_limitAdTracking !== void 0 ? _bridgeSignals_limitAdTracking : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false
2778
+ } : {}), {
2779
+ deviceTypeHint: 5
2780
+ });
2781
+ }
2782
+ function getOrCreateCtvSessionId() {
2783
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2784
+ if (existing) {
2785
+ return existing;
2786
+ }
2787
+ var sessionId = createUuid();
2788
+ try {
2789
+ var _window_localStorage;
2790
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2791
+ } catch (unused) {}
2792
+ return sessionId;
2793
+ }
2794
+ function createUuid() {
2795
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2796
+ return crypto.randomUUID();
2797
+ }
2798
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2799
+ var value = Math.floor(Math.random() * 16);
2800
+ var nibble = char === "x" ? value : value & 3 | 8;
2801
+ return nibble.toString(16);
2802
+ });
2803
+ }
2804
+ function readNativeBridgeSignals() {
2805
+ if (typeof window === "undefined") {
2806
+ return {};
2807
+ }
2808
+ var candidates = [
2809
+ window.__STORMCLOUD_CTV_AD_INFO__,
2810
+ window.__STORMCLOUD_CTV__,
2811
+ window.stormcloudCtv,
2812
+ window.AiryTV,
2813
+ window.Android
2814
+ ].filter(Boolean);
2815
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2816
+ try {
2817
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2818
+ var source = _step.value;
2819
+ var contentUrl = readBridgeValue(source, [
2820
+ "contentUrl",
2821
+ "url",
2822
+ "videoUrl",
2823
+ "canonicalUrl"
2824
+ ]) || void 0;
2825
+ var deviceId = readBridgeValue(source, [
2826
+ "rdid",
2827
+ "ifa",
2828
+ "advertisingId",
2829
+ "adId",
2830
+ "deviceId"
2831
+ ]) || void 0;
2832
+ if (!contentUrl && !deviceId) continue;
2833
+ var deviceIdType = readBridgeValue(source, [
2834
+ "idtype",
2835
+ "deviceIdType",
2836
+ "advertisingIdType"
2837
+ ]) || inferDeviceIdType();
2838
+ var limitAdTracking = readBridgeBoolean(source, [
2839
+ "is_lat",
2840
+ "limitAdTracking",
2841
+ "limitedAdTracking",
2842
+ "lat"
2843
+ ]);
2844
+ return _object_spread({}, contentUrl ? {
2845
+ contentUrl: contentUrl
2846
+ } : {}, deviceId ? {
2847
+ deviceId: deviceId
2848
+ } : {}, deviceId && deviceIdType ? {
2849
+ deviceIdType: deviceIdType
2850
+ } : {}, deviceId && limitAdTracking != null ? {
2851
+ limitAdTracking: limitAdTracking
2852
+ } : {});
2853
+ }
2854
+ } catch (err) {
2855
+ _didIteratorError = true;
2856
+ _iteratorError = err;
2857
+ } finally{
2858
+ try {
2859
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2860
+ _iterator.return();
2861
+ }
2862
+ } finally{
2863
+ if (_didIteratorError) {
2864
+ throw _iteratorError;
2865
+ }
2866
+ }
2867
+ }
2868
+ return {};
2869
+ }
2870
+ function readBridgeValue(source, keys) {
2871
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2872
+ try {
2873
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2874
+ var key = _step.value;
2875
+ var value = source === null || source === void 0 ? void 0 : source[key];
2876
+ if (typeof value === "string" && value) {
2877
+ return value;
2878
+ }
2879
+ if (typeof value === "function") {
2880
+ try {
2881
+ var result = value.call(source);
2882
+ if (typeof result === "string" && result) {
2883
+ return result;
2884
+ }
2885
+ } catch (unused) {}
2886
+ }
2887
+ }
2888
+ } catch (err) {
2889
+ _didIteratorError = true;
2890
+ _iteratorError = err;
2891
+ } finally{
2892
+ try {
2893
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2894
+ _iterator.return();
2895
+ }
2896
+ } finally{
2897
+ if (_didIteratorError) {
2898
+ throw _iteratorError;
2899
+ }
2900
+ }
2901
+ }
2902
+ return void 0;
2903
+ }
2904
+ function readBridgeBoolean(source, keys) {
2905
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2906
+ try {
2907
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2908
+ var key = _step.value;
2909
+ var value = source === null || source === void 0 ? void 0 : source[key];
2910
+ var normalized = normalizeBoolean(value);
2911
+ if (normalized != null) {
2912
+ return normalized;
2913
+ }
2914
+ if (typeof value === "function") {
2915
+ try {
2916
+ var result = normalizeBoolean(value.call(source));
2917
+ if (result != null) {
2918
+ return result;
2919
+ }
2920
+ } catch (unused) {}
2921
+ }
2922
+ }
2923
+ } catch (err) {
2924
+ _didIteratorError = true;
2925
+ _iteratorError = err;
2926
+ } finally{
2927
+ try {
2928
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2929
+ _iterator.return();
2930
+ }
2931
+ } finally{
2932
+ if (_didIteratorError) {
2933
+ throw _iteratorError;
2934
+ }
2935
+ }
2936
+ }
2937
+ return void 0;
2938
+ }
2939
+ function readStoredDeviceId() {
2940
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2941
+ try {
2942
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2943
+ var key = _step.value;
2944
+ var value = readStoredString(key);
2945
+ if (value) {
2946
+ return value;
2947
+ }
2948
+ }
2949
+ } catch (err) {
2950
+ _didIteratorError = true;
2951
+ _iteratorError = err;
2952
+ } finally{
2953
+ try {
2954
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
2955
+ _iterator.return();
2956
+ }
2957
+ } finally{
2958
+ if (_didIteratorError) {
2959
+ throw _iteratorError;
2960
+ }
2961
+ }
2962
+ }
2963
+ return void 0;
2964
+ }
2965
+ function readStoredString(key) {
2966
+ if (typeof window === "undefined") {
2967
+ return void 0;
2968
+ }
2969
+ try {
2970
+ var _window_localStorage;
2971
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2972
+ return value || void 0;
2973
+ } catch (unused) {
2974
+ return void 0;
2975
+ }
2976
+ }
2977
+ function readStoredLimitAdTracking() {
2978
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2979
+ }
2980
+ function normalizeBoolean(value) {
2981
+ if (typeof value === "boolean") {
2982
+ return value;
2983
+ }
2984
+ if (typeof value === "number") {
2985
+ return value === 1;
2986
+ }
2987
+ if (typeof value === "string") {
2988
+ var normalized = value.toLowerCase();
2989
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
2990
+ return true;
2991
+ }
2992
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
2993
+ return false;
2994
+ }
2995
+ }
2996
+ return void 0;
2997
+ }
2998
+ function inferDeviceIdType() {
2999
+ if (typeof navigator === "undefined") {
3000
+ return void 0;
3001
+ }
3002
+ var ua = navigator.userAgent;
3003
+ if (/Roku/i.test(ua)) return "rida";
3004
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
3005
+ if (/AppleTV/i.test(ua)) return "tvOS";
3006
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
3007
+ if (/Web0S|webOS|LG/i.test(ua)) return "lgudid";
3008
+ if (/Android|Google TV/i.test(ua)) return "aaid";
3009
+ return void 0;
3010
+ }
2689
3011
  // src/player/StormcloudVideoPlayer.ts
2690
3012
  var StormcloudVideoPlayer = /*#__PURE__*/ function() {
2691
3013
  function StormcloudVideoPlayer(config) {
@@ -5127,17 +5449,24 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5127
5449
  for(var i = 0; i < count; i++){
5128
5450
  this.adRequestPositionInBreak++;
5129
5451
  var adWillPlayMuted = this.inAdBreak ? this.adPlayer.getOriginalMutedState() : this.video.muted;
5452
+ var ctvSignals = this.config.ctvAdRequest ? resolveCtvVastSignals() : void 0;
5130
5453
  var urlWithMacros = applyVastMacros(baseUrl, {
5131
5454
  correlator: generateCorrelator(),
5132
5455
  streamCorrelator: this.streamCorrelator,
5133
5456
  pod: this.podCounter > 0 ? this.podCounter : void 0,
5134
5457
  adPosition: this.adRequestPositionInBreak,
5135
- pageUrl: typeof window !== "undefined" ? window.location.href : void 0,
5458
+ isCtv: this.config.ctvAdRequest,
5459
+ contentUrl: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.contentUrl,
5460
+ pageUrl: !this.config.ctvAdRequest && typeof window !== "undefined" ? window.location.href : void 0,
5136
5461
  adWillPlayMuted: adWillPlayMuted,
5137
5462
  adWillAutoPlay: !!this.config.autoplay,
5138
- deviceId: this.config.deviceId,
5139
- deviceIdType: this.config.deviceIdType,
5140
- limitAdTracking: this.config.limitAdTracking,
5463
+ appId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appId,
5464
+ appName: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.appName,
5465
+ sessionId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.sessionId,
5466
+ deviceId: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceId,
5467
+ deviceIdType: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceIdType,
5468
+ limitAdTracking: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.limitAdTracking,
5469
+ deviceTypeHint: ctvSignals === null || ctvSignals === void 0 ? void 0 : ctvSignals.deviceTypeHint,
5141
5470
  adTest: this.config.adTest,
5142
5471
  consent: this.consentSignals
5143
5472
  });
@@ -7979,6 +8308,7 @@ var HlsPlayer = /*#__PURE__*/ function(_import_react2_Component) {
7979
8308
  if (_this1.props.licenseKey !== void 0) config.licenseKey = _this1.props.licenseKey;
7980
8309
  if (_this1.props.adFailsafeTimeoutMs !== void 0) config.adFailsafeTimeoutMs = _this1.props.adFailsafeTimeoutMs;
7981
8310
  if (_this1.props.minSegmentsBeforePlay !== void 0) config.minSegmentsBeforePlay = _this1.props.minSegmentsBeforePlay;
8311
+ if (_this1.props.ctvAdRequest !== void 0) config.ctvAdRequest = _this1.props.ctvAdRequest;
7982
8312
  _this1.player = new StormcloudVideoPlayer(config);
7983
8313
  (_this_props_onMount = (_this_props = _this1.props).onMount) === null || _this_props_onMount === void 0 ? void 0 : _this_props_onMount.call(_this_props, _this1);
7984
8314
  return [