stormcloud-video-player 0.7.16 → 0.7.18

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.
@@ -7190,6 +7190,33 @@ var OverlayRenderer = function OverlayRenderer(param) {
7190
7190
  })
7191
7191
  });
7192
7192
  };
7193
+ // src/utils/adcision.ts
7194
+ var ADCISION_API_BASE = "https://adstorm.co/api-adstorm-dev";
7195
+ function fetchAdcisionChannel(_0) {
7196
+ return _async_to_generator(function(channelId) {
7197
+ var apiBaseUrl, response;
7198
+ var _arguments = arguments;
7199
+ return _ts_generator(this, function(_state) {
7200
+ switch(_state.label){
7201
+ case 0:
7202
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7203
+ return [
7204
+ 4,
7205
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId))
7206
+ ];
7207
+ case 1:
7208
+ response = _state.sent();
7209
+ if (!response.ok) {
7210
+ throw new Error("Failed to fetch adcision channel ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7211
+ }
7212
+ return [
7213
+ 2,
7214
+ response.json()
7215
+ ];
7216
+ }
7217
+ });
7218
+ }).apply(this, arguments);
7219
+ }
7193
7220
  // src/ui/StormcloudVideoPlayer.tsx
7194
7221
  var import_jsx_runtime2 = require("react/jsx-runtime");
7195
7222
  var CRITICAL_PROPS = [
@@ -7209,7 +7236,7 @@ var PANEL_BASE_RIGHT_OFFSET = 10;
7209
7236
  var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props) {
7210
7237
  var _ref;
7211
7238
  var _aiLiveContext_context;
7212
- var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, swirlProjectId = props.swirlProjectId, restVideoAttrs = _object_without_properties(props, [
7239
+ var src = props.src, autoplay = props.autoplay, muted = props.muted, lowLatencyMode = props.lowLatencyMode, allowNativeHls = props.allowNativeHls, driftToleranceMs = props.driftToleranceMs, immediateManifestAds = props.immediateManifestAds, debugAdTiming = props.debugAdTiming, showCustomControls = props.showCustomControls, hideLoadingIndicator = props.hideLoadingIndicator, onVolumeToggle = props.onVolumeToggle, onFullscreenToggle = props.onFullscreenToggle, onControlClick = props.onControlClick, onReady = props.onReady, wrapperClassName = props.wrapperClassName, wrapperStyle = props.wrapperStyle, className = props.className, style = props.style, controls = props.controls, playsInline = props.playsInline, preload = props.preload, poster = props.poster, children = props.children, licenseKey = props.licenseKey, minSegmentsBeforePlay = props.minSegmentsBeforePlay, disableAds = props.disableAds, disableFiller = props.disableFiller, swirlProjectId = props.swirlProjectId, adcisionChannelId = props.adcisionChannelId, disableOverlays = props.disableOverlays, showAdsControl = props.showAdsControl, showOverlaysControl = props.showOverlaysControl, showAiContextControl = props.showAiContextControl, showDebugControl = props.showDebugControl, restVideoAttrs = _object_without_properties(props, [
7213
7240
  "src",
7214
7241
  "autoplay",
7215
7242
  "muted",
@@ -7237,8 +7264,15 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7237
7264
  "minSegmentsBeforePlay",
7238
7265
  "disableAds",
7239
7266
  "disableFiller",
7240
- "swirlProjectId"
7267
+ "swirlProjectId",
7268
+ "adcisionChannelId",
7269
+ "disableOverlays",
7270
+ "showAdsControl",
7271
+ "showOverlaysControl",
7272
+ "showAiContextControl",
7273
+ "showDebugControl"
7241
7274
  ]);
7275
+ var _ref1 = _sliced_to_array((0, import_react2.useState)(null), 2), adcisionSrc = _ref1[0], setAdcisionSrc = _ref1[1];
7242
7276
  var videoRef = (0, import_react2.useRef)(null);
7243
7277
  var playerRef = (0, import_react2.useRef)(null);
7244
7278
  var bufferingTimeoutRef = (0, import_react2.useRef)(null);
@@ -7274,12 +7308,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7274
7308
  var _import_react2_default_useState22 = _sliced_to_array(import_react2.default.useState([]), 2), debugMarkers = _import_react2_default_useState22[0], setDebugMarkers = _import_react2_default_useState22[1];
7275
7309
  var _import_react2_default_useState23 = _sliced_to_array(import_react2.default.useState(false), 2), showAiPanel = _import_react2_default_useState23[0], setShowAiPanel = _import_react2_default_useState23[1];
7276
7310
  var _import_react2_default_useState24 = _sliced_to_array(import_react2.default.useState(disableAds !== null && disableAds !== void 0 ? disableAds : false), 2), adsDisabled = _import_react2_default_useState24[0], setAdsDisabled = _import_react2_default_useState24[1];
7277
- var _import_react2_default_useState25 = _sliced_to_array(import_react2.default.useState({
7311
+ var _import_react2_default_useState25 = _sliced_to_array(import_react2.default.useState(disableOverlays !== null && disableOverlays !== void 0 ? disableOverlays : false), 2), overlaysDisabled = _import_react2_default_useState25[0], setOverlaysDisabled = _import_react2_default_useState25[1];
7312
+ var _import_react2_default_useState26 = _sliced_to_array(import_react2.default.useState({
7278
7313
  context: null,
7279
7314
  isLoading: false,
7280
7315
  error: null,
7281
7316
  lastPolledAt: null
7282
- }), 2), aiLiveContext = _import_react2_default_useState25[0], setAiLiveContext = _import_react2_default_useState25[1];
7317
+ }), 2), aiLiveContext = _import_react2_default_useState26[0], setAiLiveContext = _import_react2_default_useState26[1];
7283
7318
  var getResponsiveScale = function getResponsiveScale() {
7284
7319
  if (viewportWidth < 480) return 0.7;
7285
7320
  if (viewportWidth < 768) return 0.8;
@@ -7437,21 +7472,43 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7437
7472
  var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7438
7473
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7439
7474
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7475
+ (0, import_react2.useEffect)(function() {
7476
+ if (!adcisionChannelId) {
7477
+ setAdcisionSrc(null);
7478
+ return;
7479
+ }
7480
+ var cancelled = false;
7481
+ fetchAdcisionChannel(adcisionChannelId).then(function(ch) {
7482
+ if (!cancelled) setAdcisionSrc(ch.stream_url);
7483
+ }).catch(function(err) {
7484
+ if (!cancelled) {
7485
+ console.warn("[StormcloudVideoPlayer] Failed to fetch adcision channel:", err);
7486
+ }
7487
+ });
7488
+ return function() {
7489
+ cancelled = true;
7490
+ };
7491
+ }, [
7492
+ adcisionChannelId
7493
+ ]);
7494
+ var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7440
7495
  var criticalPropsKey = (0, import_react2.useMemo)(function() {
7441
- return CRITICAL_PROPS.map(function(prop) {
7442
- return "".concat(prop, ":").concat(props[prop]);
7496
+ var baseParts = CRITICAL_PROPS.map(function(prop) {
7497
+ return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
7443
7498
  }).join("|");
7499
+ return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
7444
7500
  }, [
7445
- src,
7501
+ effectiveSrc,
7446
7502
  allowNativeHls,
7447
7503
  licenseKey,
7448
7504
  lowLatencyMode,
7449
- driftToleranceMs
7505
+ driftToleranceMs,
7506
+ adcisionChannelId
7450
7507
  ]);
7451
7508
  (0, import_react2.useEffect)(function() {
7452
7509
  if (typeof window === "undefined") return;
7453
7510
  var el = videoRef.current;
7454
- if (!el || !src) return;
7511
+ if (!el || !effectiveSrc) return;
7455
7512
  if (!licenseKey) {
7456
7513
  setShowLicenseWarning(true);
7457
7514
  setIsLoading(false);
@@ -7465,7 +7522,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7465
7522
  playerRef.current = null;
7466
7523
  }
7467
7524
  var cfg = {
7468
- src: src,
7525
+ src: effectiveSrc,
7469
7526
  videoElement: el
7470
7527
  };
7471
7528
  if (autoplay !== void 0) cfg.autoplay = autoplay;
@@ -7483,7 +7540,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7483
7540
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7484
7541
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7485
7542
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7486
- if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7543
+ if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7487
7544
  var player = new StormcloudVideoPlayer(cfg);
7488
7545
  playerRef.current = player;
7489
7546
  player.load().then(function() {
@@ -7505,7 +7562,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7505
7562
  criticalPropsKey
7506
7563
  ]);
7507
7564
  (0, import_react2.useEffect)(function() {
7508
- if (!swirlProjectId) {
7565
+ if (!swirlProjectId || adcisionChannelId) {
7509
7566
  setOverlays([]);
7510
7567
  setOverlayCoordSpace(null);
7511
7568
  return;
@@ -7522,7 +7579,8 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7522
7579
  cancelled = true;
7523
7580
  };
7524
7581
  }, [
7525
- swirlProjectId
7582
+ swirlProjectId,
7583
+ adcisionChannelId
7526
7584
  ]);
7527
7585
  (0, import_react2.useEffect)(function() {
7528
7586
  if (!swirlProjectId) return;
@@ -7764,7 +7822,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7764
7822
  criticalPropsKey
7765
7823
  ]);
7766
7824
  (0, import_react2.useEffect)(function() {
7767
- if (!swirlProjectId) {
7825
+ if (!swirlProjectId || adcisionChannelId) {
7768
7826
  setShowAiPanel(false);
7769
7827
  setAiLiveContext({
7770
7828
  context: null,
@@ -7774,10 +7832,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7774
7832
  });
7775
7833
  }
7776
7834
  }, [
7777
- swirlProjectId
7835
+ swirlProjectId,
7836
+ adcisionChannelId
7778
7837
  ]);
7779
7838
  (0, import_react2.useEffect)(function() {
7780
- if (!showAiPanel || !swirlProjectId) return;
7839
+ if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7781
7840
  var cancelled = false;
7782
7841
  var pollTimeoutId = null;
7783
7842
  var inFlight = false;
@@ -7954,7 +8013,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7954
8013
  }, restVideoAttrs), {
7955
8014
  children: children
7956
8015
  })),
7957
- overlays.length > 0 && !adStatus.showAds && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OverlayRenderer, {
8016
+ overlays.length > 0 && !adStatus.showAds && !overlaysDisabled && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(OverlayRenderer, {
7958
8017
  overlays: overlays,
7959
8018
  currentTime: currentTime,
7960
8019
  videoRef: videoRef,
@@ -8766,7 +8825,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8766
8825
  gap: "".concat(8 * responsiveScale, "px")
8767
8826
  },
8768
8827
  children: [
8769
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8828
+ (showAdsControl !== null && showAdsControl !== void 0 ? showAdsControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8770
8829
  className: "sc-ctrl-btn",
8771
8830
  onClick: function onClick() {
8772
8831
  var _playerRef_current;
@@ -8791,7 +8850,29 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8791
8850
  title: adsDisabled ? "Enable ads" : "Disable ads",
8792
8851
  children: "AD"
8793
8852
  }),
8794
- swirlProjectId && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8853
+ swirlProjectId && (showOverlaysControl !== null && showOverlaysControl !== void 0 ? showOverlaysControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8854
+ className: "sc-ctrl-btn",
8855
+ onClick: function onClick() {
8856
+ setOverlaysDisabled(function(prev) {
8857
+ return !prev;
8858
+ });
8859
+ resetControlsTimer();
8860
+ },
8861
+ style: {
8862
+ padding: "".concat(8 * responsiveScale, "px"),
8863
+ borderRadius: "50%",
8864
+ minWidth: "".concat(36 * responsiveScale, "px"),
8865
+ minHeight: "".concat(36 * responsiveScale, "px"),
8866
+ background: overlaysDisabled ? "rgba(239, 68, 68, 0.28)" : "transparent",
8867
+ color: overlaysDisabled ? "rgba(252, 165, 165, 0.9)" : "rgba(255, 255, 255, 0.75)",
8868
+ opacity: overlaysDisabled ? 1 : 0.9
8869
+ },
8870
+ title: overlaysDisabled ? "Enable overlays" : "Disable overlays",
8871
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa.FaLayerGroup, {
8872
+ size: Math.max(14, 18 * responsiveScale)
8873
+ })
8874
+ }),
8875
+ swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8795
8876
  className: "sc-ctrl-btn",
8796
8877
  onClick: function onClick() {
8797
8878
  setShowAiPanel(function(prev) {
@@ -8813,7 +8894,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8813
8894
  title: showAiPanel ? "Hide AI context" : "Show AI context",
8814
8895
  children: "AI"
8815
8896
  }),
8816
- debugAdTiming && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8897
+ debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
8817
8898
  className: "sc-ctrl-btn",
8818
8899
  onClick: function onClick() {
8819
8900
  setShowDebugPanel(function(prev) {
@@ -9084,7 +9165,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
9084
9165
  })
9085
9166
  ]
9086
9167
  }),
9087
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9168
+ (showAdsControl !== null && showAdsControl !== void 0 ? showAdsControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9088
9169
  className: "sc-ctrl-btn",
9089
9170
  onClick: function onClick() {
9090
9171
  var _playerRef_current;
@@ -9109,7 +9190,28 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
9109
9190
  title: adsDisabled ? "Enable ads" : "Disable ads",
9110
9191
  children: "AD"
9111
9192
  }),
9112
- swirlProjectId && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9193
+ swirlProjectId && (showOverlaysControl !== null && showOverlaysControl !== void 0 ? showOverlaysControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9194
+ className: "sc-ctrl-btn",
9195
+ onClick: function onClick() {
9196
+ setOverlaysDisabled(function(prev) {
9197
+ return !prev;
9198
+ });
9199
+ resetControlsTimer();
9200
+ },
9201
+ style: {
9202
+ padding: "".concat(8 * responsiveScale, "px"),
9203
+ borderRadius: "50%",
9204
+ minWidth: "".concat(36 * responsiveScale, "px"),
9205
+ minHeight: "".concat(36 * responsiveScale, "px"),
9206
+ background: overlaysDisabled ? "rgba(239, 68, 68, 0.28)" : "rgba(0, 0, 0, 0.6)",
9207
+ color: overlaysDisabled ? "rgba(252, 165, 165, 0.9)" : "rgba(255, 255, 255, 0.75)"
9208
+ },
9209
+ title: overlaysDisabled ? "Enable overlays" : "Disable overlays",
9210
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_fa.FaLayerGroup, {
9211
+ size: Math.max(14, 18 * responsiveScale)
9212
+ })
9213
+ }),
9214
+ swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9113
9215
  className: "sc-ctrl-btn",
9114
9216
  onClick: function onClick() {
9115
9217
  setShowAiPanel(function(prev) {
@@ -9131,7 +9233,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
9131
9233
  title: showAiPanel ? "Hide AI context" : "Show AI context",
9132
9234
  children: "AI"
9133
9235
  }),
9134
- debugAdTiming && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9236
+ debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
9135
9237
  className: "sc-ctrl-btn",
9136
9238
  onClick: function onClick() {
9137
9239
  setShowDebugPanel(function(prev) {
@@ -9233,7 +9335,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
9233
9335
  "preload",
9234
9336
  "poster",
9235
9337
  "children",
9236
- "swirlProjectId"
9338
+ "swirlProjectId",
9339
+ "adcisionChannelId",
9340
+ "disableOverlays",
9341
+ "showAdsControl",
9342
+ "showOverlaysControl",
9343
+ "showAiContextControl",
9344
+ "showDebugControl"
9237
9345
  ];
9238
9346
  var _iteratorNormalCompletion1 = true, _didIteratorError1 = false, _iteratorError1 = undefined;
9239
9347
  try {