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.
@@ -7217,6 +7217,31 @@ function fetchAdcisionChannel(_0) {
7217
7217
  });
7218
7218
  }).apply(this, arguments);
7219
7219
  }
7220
+ function fetchAdcisionChannelLiveContext(_0) {
7221
+ return _async_to_generator(function(channelId) {
7222
+ var apiBaseUrl, response;
7223
+ var _arguments = arguments;
7224
+ return _ts_generator(this, function(_state) {
7225
+ switch(_state.label){
7226
+ case 0:
7227
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7228
+ return [
7229
+ 4,
7230
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId, "/live-context"))
7231
+ ];
7232
+ case 1:
7233
+ response = _state.sent();
7234
+ if (!response.ok) {
7235
+ throw new Error("Failed to fetch adcision channel live context ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7236
+ }
7237
+ return [
7238
+ 2,
7239
+ response.json()
7240
+ ];
7241
+ }
7242
+ });
7243
+ }).apply(this, arguments);
7244
+ }
7220
7245
  // src/ui/StormcloudVideoPlayer.tsx
7221
7246
  var import_jsx_runtime2 = require("react/jsx-runtime");
7222
7247
  var CRITICAL_PROPS = [
@@ -7462,14 +7487,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7462
7487
  }
7463
7488
  setShowSpeedMenu(false);
7464
7489
  };
7465
- var isHlsStream = (src === null || src === void 0 ? void 0 : src.toLowerCase().includes(".m3u8")) || (src === null || src === void 0 ? void 0 : src.toLowerCase().includes("/hls/"));
7466
- var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7467
7490
  var analyzerPanelWidth = Math.min(420, Math.max(320, viewportWidth * 0.41));
7468
7491
  var analyzerPanelHeight = isPortrait ? "52vh" : "420px";
7469
7492
  var analyzerPanelMaxHeight = "60vh";
7470
7493
  var panelGap = Math.max(8, 12 * responsiveScale);
7471
7494
  var shouldStackPanels = isPortrait || viewportWidth < 980;
7472
- var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7473
7495
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7474
7496
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7475
7497
  (0, import_react2.useEffect)(function() {
@@ -7492,6 +7514,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7492
7514
  adcisionChannelId
7493
7515
  ]);
7494
7516
  var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7517
+ var isHlsStream = (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes(".m3u8")) || (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes("/hls/"));
7518
+ var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7519
+ var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7495
7520
  var criticalPropsKey = (0, import_react2.useMemo)(function() {
7496
7521
  var baseParts = CRITICAL_PROPS.map(function(prop) {
7497
7522
  return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
@@ -7836,13 +7861,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7836
7861
  adcisionChannelId
7837
7862
  ]);
7838
7863
  (0, import_react2.useEffect)(function() {
7839
- if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7864
+ if (!showAiPanel || !swirlProjectId && !adcisionChannelId) return;
7840
7865
  var cancelled = false;
7841
7866
  var pollTimeoutId = null;
7842
7867
  var inFlight = false;
7843
7868
  var pollLiveContext = function pollLiveContext1() {
7844
7869
  return _async_to_generator(function() {
7845
- var response, payload, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
7870
+ var payload, adcisionCtx, response, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
7846
7871
  return _ts_generator(this, function(_state) {
7847
7872
  switch(_state.label){
7848
7873
  case 0:
@@ -7860,10 +7885,32 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7860
7885
  case 1:
7861
7886
  _state.trys.push([
7862
7887
  1,
7888
+ 7,
7889
+ 8,
7890
+ 9
7891
+ ]);
7892
+ if (!adcisionChannelId) return [
7893
+ 3,
7894
+ 3
7895
+ ];
7896
+ return [
7863
7897
  4,
7864
- 5,
7898
+ fetchAdcisionChannelLiveContext(adcisionChannelId)
7899
+ ];
7900
+ case 2:
7901
+ adcisionCtx = _state.sent();
7902
+ payload = {
7903
+ id: adcisionCtx.id,
7904
+ project_id: adcisionCtx.channel_id,
7905
+ keywords: adcisionCtx.keywords,
7906
+ context: adcisionCtx.context,
7907
+ updated_at: adcisionCtx.updated_at
7908
+ };
7909
+ return [
7910
+ 3,
7865
7911
  6
7866
- ]);
7912
+ ];
7913
+ case 3:
7867
7914
  return [
7868
7915
  4,
7869
7916
  fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(swirlProjectId, "/live-context"), {
@@ -7873,7 +7920,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7873
7920
  }
7874
7921
  })
7875
7922
  ];
7876
- case 2:
7923
+ case 4:
7877
7924
  response = _state.sent();
7878
7925
  if (!response.ok) {
7879
7926
  throw new Error("Live context request failed (".concat(response.status, " ").concat(response.statusText, ")"));
@@ -7882,8 +7929,10 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7882
7929
  4,
7883
7930
  response.json()
7884
7931
  ];
7885
- case 3:
7932
+ case 5:
7886
7933
  payload = _state.sent();
7934
+ _state.label = 6;
7935
+ case 6:
7887
7936
  if (cancelled) return [
7888
7937
  2
7889
7938
  ];
@@ -7895,9 +7944,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7895
7944
  });
7896
7945
  return [
7897
7946
  3,
7898
- 6
7947
+ 9
7899
7948
  ];
7900
- case 4:
7949
+ case 7:
7901
7950
  error = _state.sent();
7902
7951
  if (cancelled) return [
7903
7952
  2
@@ -7912,9 +7961,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7912
7961
  });
7913
7962
  return [
7914
7963
  3,
7915
- 6
7964
+ 9
7916
7965
  ];
7917
- case 5:
7966
+ case 8:
7918
7967
  inFlight = false;
7919
7968
  if (!cancelled) {
7920
7969
  ;
@@ -7926,7 +7975,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7926
7975
  return [
7927
7976
  7
7928
7977
  ];
7929
- case 6:
7978
+ case 9:
7930
7979
  return [
7931
7980
  2
7932
7981
  ];
@@ -7944,6 +7993,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7944
7993
  }, [
7945
7994
  showAiPanel,
7946
7995
  swirlProjectId,
7996
+ adcisionChannelId,
7947
7997
  criticalPropsKey
7948
7998
  ]);
7949
7999
  var handleWrapperMouseMove = (0, import_react2.useCallback)(function() {
@@ -8206,7 +8256,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8206
8256
  })
8207
8257
  ]
8208
8258
  }),
8209
- showAiPanel && !showLicenseWarning && swirlProjectId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8259
+ showAiPanel && !showLicenseWarning && (swirlProjectId || adcisionChannelId) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8210
8260
  style: _object_spread_props(_object_spread({
8211
8261
  position: "absolute",
8212
8262
  right: "".concat(panelBaseRight, "px")