stormcloud-video-player 0.7.19 → 0.7.21

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/lib/index.js CHANGED
@@ -7229,6 +7229,31 @@ function fetchAdcisionChannel(_0) {
7229
7229
  });
7230
7230
  }).apply(this, arguments);
7231
7231
  }
7232
+ function fetchAdcisionChannelLiveContext(_0) {
7233
+ return _async_to_generator(function(channelId) {
7234
+ var apiBaseUrl, response;
7235
+ var _arguments = arguments;
7236
+ return _ts_generator(this, function(_state) {
7237
+ switch(_state.label){
7238
+ case 0:
7239
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7240
+ return [
7241
+ 4,
7242
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId, "/live-context"))
7243
+ ];
7244
+ case 1:
7245
+ response = _state.sent();
7246
+ if (!response.ok) {
7247
+ throw new Error("Failed to fetch adcision channel live context ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7248
+ }
7249
+ return [
7250
+ 2,
7251
+ response.json()
7252
+ ];
7253
+ }
7254
+ });
7255
+ }).apply(this, arguments);
7256
+ }
7232
7257
  // src/ui/StormcloudVideoPlayer.tsx
7233
7258
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
7234
7259
  var CRITICAL_PROPS = [
@@ -7474,14 +7499,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7474
7499
  }
7475
7500
  setShowSpeedMenu(false);
7476
7501
  };
7477
- var isHlsStream = (src === null || src === void 0 ? void 0 : src.toLowerCase().includes(".m3u8")) || (src === null || src === void 0 ? void 0 : src.toLowerCase().includes("/hls/"));
7478
- var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7479
7502
  var analyzerPanelWidth = Math.min(420, Math.max(320, viewportWidth * 0.41));
7480
7503
  var analyzerPanelHeight = isPortrait ? "52vh" : "420px";
7481
7504
  var analyzerPanelMaxHeight = "60vh";
7482
7505
  var panelGap = Math.max(8, 12 * responsiveScale);
7483
7506
  var shouldStackPanels = isPortrait || viewportWidth < 980;
7484
- var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7485
7507
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7486
7508
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7487
7509
  useEffect2(function() {
@@ -7504,6 +7526,9 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7504
7526
  adcisionChannelId
7505
7527
  ]);
7506
7528
  var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7529
+ var isHlsStream = (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes(".m3u8")) || (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes("/hls/"));
7530
+ var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7531
+ var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7507
7532
  var criticalPropsKey = useMemo2(function() {
7508
7533
  var baseParts = CRITICAL_PROPS.map(function(prop) {
7509
7534
  return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
@@ -7848,13 +7873,13 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7848
7873
  adcisionChannelId
7849
7874
  ]);
7850
7875
  useEffect2(function() {
7851
- if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7876
+ if (!showAiPanel || !swirlProjectId && !adcisionChannelId) return;
7852
7877
  var cancelled = false;
7853
7878
  var pollTimeoutId = null;
7854
7879
  var inFlight = false;
7855
7880
  var pollLiveContext = function pollLiveContext1() {
7856
7881
  return _async_to_generator(function() {
7857
- var response, payload, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
7882
+ var payload, adcisionCtx, response, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
7858
7883
  return _ts_generator(this, function(_state) {
7859
7884
  switch(_state.label){
7860
7885
  case 0:
@@ -7872,10 +7897,32 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7872
7897
  case 1:
7873
7898
  _state.trys.push([
7874
7899
  1,
7900
+ 7,
7901
+ 8,
7902
+ 9
7903
+ ]);
7904
+ if (!adcisionChannelId) return [
7905
+ 3,
7906
+ 3
7907
+ ];
7908
+ return [
7875
7909
  4,
7876
- 5,
7910
+ fetchAdcisionChannelLiveContext(adcisionChannelId)
7911
+ ];
7912
+ case 2:
7913
+ adcisionCtx = _state.sent();
7914
+ payload = {
7915
+ id: adcisionCtx.id,
7916
+ project_id: adcisionCtx.channel_id,
7917
+ keywords: adcisionCtx.keywords,
7918
+ context: adcisionCtx.context,
7919
+ updated_at: adcisionCtx.updated_at
7920
+ };
7921
+ return [
7922
+ 3,
7877
7923
  6
7878
- ]);
7924
+ ];
7925
+ case 3:
7879
7926
  return [
7880
7927
  4,
7881
7928
  fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(swirlProjectId, "/live-context"), {
@@ -7885,7 +7932,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7885
7932
  }
7886
7933
  })
7887
7934
  ];
7888
- case 2:
7935
+ case 4:
7889
7936
  response = _state.sent();
7890
7937
  if (!response.ok) {
7891
7938
  throw new Error("Live context request failed (".concat(response.status, " ").concat(response.statusText, ")"));
@@ -7894,8 +7941,10 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7894
7941
  4,
7895
7942
  response.json()
7896
7943
  ];
7897
- case 3:
7944
+ case 5:
7898
7945
  payload = _state.sent();
7946
+ _state.label = 6;
7947
+ case 6:
7899
7948
  if (cancelled) return [
7900
7949
  2
7901
7950
  ];
@@ -7907,9 +7956,9 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7907
7956
  });
7908
7957
  return [
7909
7958
  3,
7910
- 6
7959
+ 9
7911
7960
  ];
7912
- case 4:
7961
+ case 7:
7913
7962
  error = _state.sent();
7914
7963
  if (cancelled) return [
7915
7964
  2
@@ -7924,9 +7973,9 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7924
7973
  });
7925
7974
  return [
7926
7975
  3,
7927
- 6
7976
+ 9
7928
7977
  ];
7929
- case 5:
7978
+ case 8:
7930
7979
  inFlight = false;
7931
7980
  if (!cancelled) {
7932
7981
  ;
@@ -7938,7 +7987,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7938
7987
  return [
7939
7988
  7
7940
7989
  ];
7941
- case 6:
7990
+ case 9:
7942
7991
  return [
7943
7992
  2
7944
7993
  ];
@@ -7956,6 +8005,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7956
8005
  }, [
7957
8006
  showAiPanel,
7958
8007
  swirlProjectId,
8008
+ adcisionChannelId,
7959
8009
  criticalPropsKey
7960
8010
  ]);
7961
8011
  var handleWrapperMouseMove = useCallback2(function() {
@@ -8218,7 +8268,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8218
8268
  })
8219
8269
  ]
8220
8270
  }),
8221
- showAiPanel && !showLicenseWarning && swirlProjectId && /* @__PURE__ */ jsxs2("div", {
8271
+ showAiPanel && !showLicenseWarning && (swirlProjectId || adcisionChannelId) && /* @__PURE__ */ jsxs2("div", {
8222
8272
  style: _object_spread_props(_object_spread({
8223
8273
  position: "absolute",
8224
8274
  right: "".concat(panelBaseRight, "px")