stormcloud-video-player 0.7.17 → 0.7.19

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.d.cts CHANGED
@@ -270,6 +270,7 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
270
270
  wrapperStyle?: React.CSSProperties;
271
271
  licenseKey?: string;
272
272
  swirlProjectId?: number;
273
+ adcisionChannelId?: number;
273
274
  disableOverlays?: boolean;
274
275
  showAdsControl?: boolean;
275
276
  showOverlaysControl?: boolean;
package/lib/index.d.ts CHANGED
@@ -270,6 +270,7 @@ type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElemen
270
270
  wrapperStyle?: React.CSSProperties;
271
271
  licenseKey?: string;
272
272
  swirlProjectId?: number;
273
+ adcisionChannelId?: number;
273
274
  disableOverlays?: boolean;
274
275
  showAdsControl?: boolean;
275
276
  showOverlaysControl?: boolean;
package/lib/index.js CHANGED
@@ -367,7 +367,7 @@ function _ts_values(o) {
367
367
  throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
368
368
  }
369
369
  // src/ui/StormcloudVideoPlayer.tsx
370
- import React2, { useEffect as useEffect2, useRef as useRef2, useMemo as useMemo2, useCallback as useCallback2 } from "react";
370
+ import React2, { useEffect as useEffect2, useRef as useRef2, useMemo as useMemo2, useCallback as useCallback2, useState as useState2 } from "react";
371
371
  // src/player/StormcloudVideoPlayer.ts
372
372
  import Hls from "hls.js";
373
373
  // src/sdk/vastParser.ts
@@ -7202,6 +7202,33 @@ var OverlayRenderer = function OverlayRenderer(param) {
7202
7202
  })
7203
7203
  });
7204
7204
  };
7205
+ // src/utils/adcision.ts
7206
+ var ADCISION_API_BASE = "https://adstorm.co/api-adstorm-dev";
7207
+ function fetchAdcisionChannel(_0) {
7208
+ return _async_to_generator(function(channelId) {
7209
+ var apiBaseUrl, response;
7210
+ var _arguments = arguments;
7211
+ return _ts_generator(this, function(_state) {
7212
+ switch(_state.label){
7213
+ case 0:
7214
+ apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
7215
+ return [
7216
+ 4,
7217
+ fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId))
7218
+ ];
7219
+ case 1:
7220
+ response = _state.sent();
7221
+ if (!response.ok) {
7222
+ throw new Error("Failed to fetch adcision channel ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
7223
+ }
7224
+ return [
7225
+ 2,
7226
+ response.json()
7227
+ ];
7228
+ }
7229
+ });
7230
+ }).apply(this, arguments);
7231
+ }
7205
7232
  // src/ui/StormcloudVideoPlayer.tsx
7206
7233
  import { Fragment as Fragment2, jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
7207
7234
  var CRITICAL_PROPS = [
@@ -7221,7 +7248,7 @@ var PANEL_BASE_RIGHT_OFFSET = 10;
7221
7248
  var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7222
7249
  var _ref;
7223
7250
  var _aiLiveContext_context;
7224
- 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, disableOverlays = props.disableOverlays, showAdsControl = props.showAdsControl, showOverlaysControl = props.showOverlaysControl, showAiContextControl = props.showAiContextControl, showDebugControl = props.showDebugControl, restVideoAttrs = _object_without_properties(props, [
7251
+ 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, [
7225
7252
  "src",
7226
7253
  "autoplay",
7227
7254
  "muted",
@@ -7250,12 +7277,14 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7250
7277
  "disableAds",
7251
7278
  "disableFiller",
7252
7279
  "swirlProjectId",
7280
+ "adcisionChannelId",
7253
7281
  "disableOverlays",
7254
7282
  "showAdsControl",
7255
7283
  "showOverlaysControl",
7256
7284
  "showAiContextControl",
7257
7285
  "showDebugControl"
7258
7286
  ]);
7287
+ var _useState2 = _sliced_to_array(useState2(null), 2), adcisionSrc = _useState2[0], setAdcisionSrc = _useState2[1];
7259
7288
  var videoRef = useRef2(null);
7260
7289
  var playerRef = useRef2(null);
7261
7290
  var bufferingTimeoutRef = useRef2(null);
@@ -7455,21 +7484,43 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7455
7484
  var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
7456
7485
  var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
7457
7486
  var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
7487
+ useEffect2(function() {
7488
+ if (!adcisionChannelId) {
7489
+ setAdcisionSrc(null);
7490
+ return;
7491
+ }
7492
+ var cancelled = false;
7493
+ fetchAdcisionChannel(adcisionChannelId).then(function(ch) {
7494
+ if (!cancelled) setAdcisionSrc(ch.stream_url);
7495
+ }).catch(function(err) {
7496
+ if (!cancelled) {
7497
+ console.warn("[StormcloudVideoPlayer] Failed to fetch adcision channel:", err);
7498
+ }
7499
+ });
7500
+ return function() {
7501
+ cancelled = true;
7502
+ };
7503
+ }, [
7504
+ adcisionChannelId
7505
+ ]);
7506
+ var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
7458
7507
  var criticalPropsKey = useMemo2(function() {
7459
- return CRITICAL_PROPS.map(function(prop) {
7460
- return "".concat(prop, ":").concat(props[prop]);
7508
+ var baseParts = CRITICAL_PROPS.map(function(prop) {
7509
+ return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
7461
7510
  }).join("|");
7511
+ return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
7462
7512
  }, [
7463
- src,
7513
+ effectiveSrc,
7464
7514
  allowNativeHls,
7465
7515
  licenseKey,
7466
7516
  lowLatencyMode,
7467
- driftToleranceMs
7517
+ driftToleranceMs,
7518
+ adcisionChannelId
7468
7519
  ]);
7469
7520
  useEffect2(function() {
7470
7521
  if (typeof window === "undefined") return;
7471
7522
  var el = videoRef.current;
7472
- if (!el || !src) return;
7523
+ if (!el || !effectiveSrc) return;
7473
7524
  if (!licenseKey) {
7474
7525
  setShowLicenseWarning(true);
7475
7526
  setIsLoading(false);
@@ -7483,7 +7534,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7483
7534
  playerRef.current = null;
7484
7535
  }
7485
7536
  var cfg = {
7486
- src: src,
7537
+ src: effectiveSrc,
7487
7538
  videoElement: el
7488
7539
  };
7489
7540
  if (autoplay !== void 0) cfg.autoplay = autoplay;
@@ -7501,7 +7552,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7501
7552
  if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
7502
7553
  if (disableAds !== void 0) cfg.disableAds = disableAds;
7503
7554
  cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
7504
- if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7555
+ if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
7505
7556
  var player = new StormcloudVideoPlayer(cfg);
7506
7557
  playerRef.current = player;
7507
7558
  player.load().then(function() {
@@ -7523,7 +7574,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7523
7574
  criticalPropsKey
7524
7575
  ]);
7525
7576
  useEffect2(function() {
7526
- if (!swirlProjectId) {
7577
+ if (!swirlProjectId || adcisionChannelId) {
7527
7578
  setOverlays([]);
7528
7579
  setOverlayCoordSpace(null);
7529
7580
  return;
@@ -7540,7 +7591,8 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7540
7591
  cancelled = true;
7541
7592
  };
7542
7593
  }, [
7543
- swirlProjectId
7594
+ swirlProjectId,
7595
+ adcisionChannelId
7544
7596
  ]);
7545
7597
  useEffect2(function() {
7546
7598
  if (!swirlProjectId) return;
@@ -7782,7 +7834,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7782
7834
  criticalPropsKey
7783
7835
  ]);
7784
7836
  useEffect2(function() {
7785
- if (!swirlProjectId) {
7837
+ if (!swirlProjectId || adcisionChannelId) {
7786
7838
  setShowAiPanel(false);
7787
7839
  setAiLiveContext({
7788
7840
  context: null,
@@ -7792,10 +7844,11 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
7792
7844
  });
7793
7845
  }
7794
7846
  }, [
7795
- swirlProjectId
7847
+ swirlProjectId,
7848
+ adcisionChannelId
7796
7849
  ]);
7797
7850
  useEffect2(function() {
7798
- if (!showAiPanel || !swirlProjectId) return;
7851
+ if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
7799
7852
  var cancelled = false;
7800
7853
  var pollTimeoutId = null;
7801
7854
  var inFlight = false;
@@ -8831,7 +8884,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8831
8884
  size: Math.max(14, 18 * responsiveScale)
8832
8885
  })
8833
8886
  }),
8834
- swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
8887
+ (swirlProjectId || adcisionChannelId) && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
8835
8888
  className: "sc-ctrl-btn",
8836
8889
  onClick: function onClick() {
8837
8890
  setShowAiPanel(function(prev) {
@@ -8853,7 +8906,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
8853
8906
  title: showAiPanel ? "Hide AI context" : "Show AI context",
8854
8907
  children: "AI"
8855
8908
  }),
8856
- debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
8909
+ (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
8857
8910
  className: "sc-ctrl-btn",
8858
8911
  onClick: function onClick() {
8859
8912
  setShowDebugPanel(function(prev) {
@@ -9170,7 +9223,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9170
9223
  size: Math.max(14, 18 * responsiveScale)
9171
9224
  })
9172
9225
  }),
9173
- swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
9226
+ (swirlProjectId || adcisionChannelId) && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ jsx2("button", {
9174
9227
  className: "sc-ctrl-btn",
9175
9228
  onClick: function onClick() {
9176
9229
  setShowAiPanel(function(prev) {
@@ -9192,7 +9245,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9192
9245
  title: showAiPanel ? "Hide AI context" : "Show AI context",
9193
9246
  children: "AI"
9194
9247
  }),
9195
- debugAdTiming && (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
9248
+ (showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ jsx2("button", {
9196
9249
  className: "sc-ctrl-btn",
9197
9250
  onClick: function onClick() {
9198
9251
  setShowDebugPanel(function(prev) {
@@ -9295,6 +9348,7 @@ var StormcloudVideoPlayerComponent = React2.memo(function(props) {
9295
9348
  "poster",
9296
9349
  "children",
9297
9350
  "swirlProjectId",
9351
+ "adcisionChannelId",
9298
9352
  "disableOverlays",
9299
9353
  "showAdsControl",
9300
9354
  "showOverlaysControl",