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.cjs CHANGED
@@ -7395,6 +7395,31 @@ function fetchAdcisionChannel(_0) {
7395
7395
  });
7396
7396
  }).apply(this, arguments);
7397
7397
  }
7398
+ function fetchAdcisionChannelLiveContext(_0) {
7399
+ return _async_to_generator(function(channelId) {
7400
+ var apiBaseUrl, response;
7401
+ var _arguments = arguments;
7402
+ return _ts_generator(this, function(_state) {
7403
+ switch(_state.label){
7404
+ case 0:
7405
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7406
+ return [
7407
+ 4,
7408
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId, "/live-context"))
7409
+ ];
7410
+ case 1:
7411
+ response = _state.sent();
7412
+ if (!response.ok) {
7413
+ throw new Error("Failed to fetch adcision channel live context ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7414
+ }
7415
+ return [
7416
+ 2,
7417
+ response.json()
7418
+ ];
7419
+ }
7420
+ });
7421
+ }).apply(this, arguments);
7422
+ }
7398
7423
  // src/ui/StormcloudVideoPlayer.tsx
7399
7424
  var import_jsx_runtime2 = require("react/jsx-runtime");
7400
7425
  var CRITICAL_PROPS = [
@@ -7640,14 +7665,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7640
7665
  }
7641
7666
  setShowSpeedMenu(false);
7642
7667
  };
7643
- var isHlsStream = (src === null || src === void 0 ? void 0 : src.toLowerCase().includes(".m3u8")) || (src === null || src === void 0 ? void 0 : src.toLowerCase().includes("/hls/"));
7644
- var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7645
7668
  var analyzerPanelWidth = Math.min(420, Math.max(320, viewportWidth * 0.41));
7646
7669
  var analyzerPanelHeight = isPortrait ? "52vh" : "420px";
7647
7670
  var analyzerPanelMaxHeight = "60vh";
7648
7671
  var panelGap = Math.max(8, 12 * responsiveScale);
7649
7672
  var shouldStackPanels = isPortrait || viewportWidth < 980;
7650
- var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7651
7673
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7652
7674
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7653
7675
  (0, import_react2.useEffect)(function() {
@@ -7670,6 +7692,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7670
7692
  adcisionChannelId
7671
7693
  ]);
7672
7694
  var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7695
+ var isHlsStream = (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes(".m3u8")) || (effectiveSrc === null || effectiveSrc === void 0 ? void 0 : effectiveSrc.toLowerCase().includes("/hls/"));
7696
+ var shouldShowEnhancedControls = showCustomControls && (isHlsStream ? allowNativeHls : true);
7697
+ var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7673
7698
  var criticalPropsKey = (0, import_react2.useMemo)(function() {
7674
7699
  var baseParts = CRITICAL_PROPS.map(function(prop) {
7675
7700
  return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
@@ -8014,13 +8039,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8014
8039
  adcisionChannelId
8015
8040
  ]);
8016
8041
  (0, import_react2.useEffect)(function() {
8017
- if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
8042
+ if (!showAiPanel || !swirlProjectId && !adcisionChannelId) return;
8018
8043
  var cancelled = false;
8019
8044
  var pollTimeoutId = null;
8020
8045
  var inFlight = false;
8021
8046
  var pollLiveContext = function pollLiveContext1() {
8022
8047
  return _async_to_generator(function() {
8023
- var response, payload, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
8048
+ var payload, adcisionCtx, response, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
8024
8049
  return _ts_generator(this, function(_state) {
8025
8050
  switch(_state.label){
8026
8051
  case 0:
@@ -8038,10 +8063,32 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8038
8063
  case 1:
8039
8064
  _state.trys.push([
8040
8065
  1,
8066
+ 7,
8067
+ 8,
8068
+ 9
8069
+ ]);
8070
+ if (!adcisionChannelId) return [
8071
+ 3,
8072
+ 3
8073
+ ];
8074
+ return [
8041
8075
  4,
8042
- 5,
8076
+ fetchAdcisionChannelLiveContext(adcisionChannelId)
8077
+ ];
8078
+ case 2:
8079
+ adcisionCtx = _state.sent();
8080
+ payload = {
8081
+ id: adcisionCtx.id,
8082
+ project_id: adcisionCtx.channel_id,
8083
+ keywords: adcisionCtx.keywords,
8084
+ context: adcisionCtx.context,
8085
+ updated_at: adcisionCtx.updated_at
8086
+ };
8087
+ return [
8088
+ 3,
8043
8089
  6
8044
- ]);
8090
+ ];
8091
+ case 3:
8045
8092
  return [
8046
8093
  4,
8047
8094
  fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(swirlProjectId, "/live-context"), {
@@ -8051,7 +8098,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8051
8098
  }
8052
8099
  })
8053
8100
  ];
8054
- case 2:
8101
+ case 4:
8055
8102
  response = _state.sent();
8056
8103
  if (!response.ok) {
8057
8104
  throw new Error("Live context request failed (".concat(response.status, " ").concat(response.statusText, ")"));
@@ -8060,8 +8107,10 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8060
8107
  4,
8061
8108
  response.json()
8062
8109
  ];
8063
- case 3:
8110
+ case 5:
8064
8111
  payload = _state.sent();
8112
+ _state.label = 6;
8113
+ case 6:
8065
8114
  if (cancelled) return [
8066
8115
  2
8067
8116
  ];
@@ -8073,9 +8122,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8073
8122
  });
8074
8123
  return [
8075
8124
  3,
8076
- 6
8125
+ 9
8077
8126
  ];
8078
- case 4:
8127
+ case 7:
8079
8128
  error = _state.sent();
8080
8129
  if (cancelled) return [
8081
8130
  2
@@ -8090,9 +8139,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8090
8139
  });
8091
8140
  return [
8092
8141
  3,
8093
- 6
8142
+ 9
8094
8143
  ];
8095
- case 5:
8144
+ case 8:
8096
8145
  inFlight = false;
8097
8146
  if (!cancelled) {
8098
8147
  ;
@@ -8104,7 +8153,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8104
8153
  return [
8105
8154
  7
8106
8155
  ];
8107
- case 6:
8156
+ case 9:
8108
8157
  return [
8109
8158
  2
8110
8159
  ];
@@ -8122,6 +8171,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8122
8171
  }, [
8123
8172
  showAiPanel,
8124
8173
  swirlProjectId,
8174
+ adcisionChannelId,
8125
8175
  criticalPropsKey
8126
8176
  ]);
8127
8177
  var handleWrapperMouseMove = (0, import_react2.useCallback)(function() {
@@ -8384,7 +8434,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8384
8434
  })
8385
8435
  ]
8386
8436
  }),
8387
- showAiPanel && !showLicenseWarning && swirlProjectId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8437
+ showAiPanel && !showLicenseWarning && (swirlProjectId || adcisionChannelId) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8388
8438
  style: _object_spread_props(_object_spread({
8389
8439
  position: "absolute",
8390
8440
  right: "".concat(panelBaseRight, "px")