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/dist/stormcloud-vp.min.js +1 -1
- package/lib/index.cjs +71 -17
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +1 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +72 -18
- package/lib/index.js.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +71 -17
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -0
- package/lib/utils/adcision.cjs +253 -0
- package/lib/utils/adcision.cjs.map +1 -0
- package/lib/utils/adcision.d.cts +23 -0
- package/package.json +1 -1
package/lib/index.cjs
CHANGED
|
@@ -7368,6 +7368,33 @@ var OverlayRenderer = function OverlayRenderer(param) {
|
|
|
7368
7368
|
})
|
|
7369
7369
|
});
|
|
7370
7370
|
};
|
|
7371
|
+
// src/utils/adcision.ts
|
|
7372
|
+
var ADCISION_API_BASE = "https://adstorm.co/api-adstorm-dev";
|
|
7373
|
+
function fetchAdcisionChannel(_0) {
|
|
7374
|
+
return _async_to_generator(function(channelId) {
|
|
7375
|
+
var apiBaseUrl, response;
|
|
7376
|
+
var _arguments = arguments;
|
|
7377
|
+
return _ts_generator(this, function(_state) {
|
|
7378
|
+
switch(_state.label){
|
|
7379
|
+
case 0:
|
|
7380
|
+
apiBaseUrl = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : ADCISION_API_BASE;
|
|
7381
|
+
return [
|
|
7382
|
+
4,
|
|
7383
|
+
fetch("".concat(apiBaseUrl, "/adstorm/adcision/channels/").concat(channelId))
|
|
7384
|
+
];
|
|
7385
|
+
case 1:
|
|
7386
|
+
response = _state.sent();
|
|
7387
|
+
if (!response.ok) {
|
|
7388
|
+
throw new Error("Failed to fetch adcision channel ".concat(channelId, ": ").concat(response.status, " ").concat(response.statusText));
|
|
7389
|
+
}
|
|
7390
|
+
return [
|
|
7391
|
+
2,
|
|
7392
|
+
response.json()
|
|
7393
|
+
];
|
|
7394
|
+
}
|
|
7395
|
+
});
|
|
7396
|
+
}).apply(this, arguments);
|
|
7397
|
+
}
|
|
7371
7398
|
// src/ui/StormcloudVideoPlayer.tsx
|
|
7372
7399
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
7373
7400
|
var CRITICAL_PROPS = [
|
|
@@ -7387,7 +7414,7 @@ var PANEL_BASE_RIGHT_OFFSET = 10;
|
|
|
7387
7414
|
var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props) {
|
|
7388
7415
|
var _ref;
|
|
7389
7416
|
var _aiLiveContext_context;
|
|
7390
|
-
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, [
|
|
7417
|
+
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, [
|
|
7391
7418
|
"src",
|
|
7392
7419
|
"autoplay",
|
|
7393
7420
|
"muted",
|
|
@@ -7416,12 +7443,14 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7416
7443
|
"disableAds",
|
|
7417
7444
|
"disableFiller",
|
|
7418
7445
|
"swirlProjectId",
|
|
7446
|
+
"adcisionChannelId",
|
|
7419
7447
|
"disableOverlays",
|
|
7420
7448
|
"showAdsControl",
|
|
7421
7449
|
"showOverlaysControl",
|
|
7422
7450
|
"showAiContextControl",
|
|
7423
7451
|
"showDebugControl"
|
|
7424
7452
|
]);
|
|
7453
|
+
var _ref1 = _sliced_to_array((0, import_react2.useState)(null), 2), adcisionSrc = _ref1[0], setAdcisionSrc = _ref1[1];
|
|
7425
7454
|
var videoRef = (0, import_react2.useRef)(null);
|
|
7426
7455
|
var playerRef = (0, import_react2.useRef)(null);
|
|
7427
7456
|
var bufferingTimeoutRef = (0, import_react2.useRef)(null);
|
|
@@ -7621,21 +7650,43 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7621
7650
|
var debugPanelBottomOffset = shouldShowEnhancedControls ? Math.max(74, 92 * responsiveScale) : Math.max(52, 58 * responsiveScale);
|
|
7622
7651
|
var panelBaseRight = PANEL_BASE_RIGHT_OFFSET * responsiveScale;
|
|
7623
7652
|
var debugPanelRightOffset = showAiPanel && !shouldStackPanels ? panelBaseRight + analyzerPanelWidth + panelGap : panelBaseRight;
|
|
7653
|
+
(0, import_react2.useEffect)(function() {
|
|
7654
|
+
if (!adcisionChannelId) {
|
|
7655
|
+
setAdcisionSrc(null);
|
|
7656
|
+
return;
|
|
7657
|
+
}
|
|
7658
|
+
var cancelled = false;
|
|
7659
|
+
fetchAdcisionChannel(adcisionChannelId).then(function(ch) {
|
|
7660
|
+
if (!cancelled) setAdcisionSrc(ch.stream_url);
|
|
7661
|
+
}).catch(function(err) {
|
|
7662
|
+
if (!cancelled) {
|
|
7663
|
+
console.warn("[StormcloudVideoPlayer] Failed to fetch adcision channel:", err);
|
|
7664
|
+
}
|
|
7665
|
+
});
|
|
7666
|
+
return function() {
|
|
7667
|
+
cancelled = true;
|
|
7668
|
+
};
|
|
7669
|
+
}, [
|
|
7670
|
+
adcisionChannelId
|
|
7671
|
+
]);
|
|
7672
|
+
var effectiveSrc = adcisionChannelId ? adcisionSrc : src;
|
|
7624
7673
|
var criticalPropsKey = (0, import_react2.useMemo)(function() {
|
|
7625
|
-
|
|
7626
|
-
return "".concat(prop, ":").concat(props[prop]);
|
|
7674
|
+
var baseParts = CRITICAL_PROPS.map(function(prop) {
|
|
7675
|
+
return prop === "src" ? "src:".concat(effectiveSrc) : "".concat(prop, ":").concat(props[prop]);
|
|
7627
7676
|
}).join("|");
|
|
7677
|
+
return "".concat(baseParts, "|adcisionChannelId:").concat(adcisionChannelId !== null && adcisionChannelId !== void 0 ? adcisionChannelId : "");
|
|
7628
7678
|
}, [
|
|
7629
|
-
|
|
7679
|
+
effectiveSrc,
|
|
7630
7680
|
allowNativeHls,
|
|
7631
7681
|
licenseKey,
|
|
7632
7682
|
lowLatencyMode,
|
|
7633
|
-
driftToleranceMs
|
|
7683
|
+
driftToleranceMs,
|
|
7684
|
+
adcisionChannelId
|
|
7634
7685
|
]);
|
|
7635
7686
|
(0, import_react2.useEffect)(function() {
|
|
7636
7687
|
if (typeof window === "undefined") return;
|
|
7637
7688
|
var el = videoRef.current;
|
|
7638
|
-
if (!el || !
|
|
7689
|
+
if (!el || !effectiveSrc) return;
|
|
7639
7690
|
if (!licenseKey) {
|
|
7640
7691
|
setShowLicenseWarning(true);
|
|
7641
7692
|
setIsLoading(false);
|
|
@@ -7649,7 +7700,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7649
7700
|
playerRef.current = null;
|
|
7650
7701
|
}
|
|
7651
7702
|
var cfg = {
|
|
7652
|
-
src:
|
|
7703
|
+
src: effectiveSrc,
|
|
7653
7704
|
videoElement: el
|
|
7654
7705
|
};
|
|
7655
7706
|
if (autoplay !== void 0) cfg.autoplay = autoplay;
|
|
@@ -7667,7 +7718,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7667
7718
|
if (minSegmentsBeforePlay !== void 0) cfg.minSegmentsBeforePlay = minSegmentsBeforePlay;
|
|
7668
7719
|
if (disableAds !== void 0) cfg.disableAds = disableAds;
|
|
7669
7720
|
cfg.disableFiller = disableFiller !== null && disableFiller !== void 0 ? disableFiller : true;
|
|
7670
|
-
if (swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
|
|
7721
|
+
if (!adcisionChannelId && swirlProjectId !== void 0) cfg.projectId = String(swirlProjectId);
|
|
7671
7722
|
var player = new StormcloudVideoPlayer(cfg);
|
|
7672
7723
|
playerRef.current = player;
|
|
7673
7724
|
player.load().then(function() {
|
|
@@ -7689,7 +7740,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7689
7740
|
criticalPropsKey
|
|
7690
7741
|
]);
|
|
7691
7742
|
(0, import_react2.useEffect)(function() {
|
|
7692
|
-
if (!swirlProjectId) {
|
|
7743
|
+
if (!swirlProjectId || adcisionChannelId) {
|
|
7693
7744
|
setOverlays([]);
|
|
7694
7745
|
setOverlayCoordSpace(null);
|
|
7695
7746
|
return;
|
|
@@ -7706,7 +7757,8 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7706
7757
|
cancelled = true;
|
|
7707
7758
|
};
|
|
7708
7759
|
}, [
|
|
7709
|
-
swirlProjectId
|
|
7760
|
+
swirlProjectId,
|
|
7761
|
+
adcisionChannelId
|
|
7710
7762
|
]);
|
|
7711
7763
|
(0, import_react2.useEffect)(function() {
|
|
7712
7764
|
if (!swirlProjectId) return;
|
|
@@ -7948,7 +8000,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7948
8000
|
criticalPropsKey
|
|
7949
8001
|
]);
|
|
7950
8002
|
(0, import_react2.useEffect)(function() {
|
|
7951
|
-
if (!swirlProjectId) {
|
|
8003
|
+
if (!swirlProjectId || adcisionChannelId) {
|
|
7952
8004
|
setShowAiPanel(false);
|
|
7953
8005
|
setAiLiveContext({
|
|
7954
8006
|
context: null,
|
|
@@ -7958,10 +8010,11 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
7958
8010
|
});
|
|
7959
8011
|
}
|
|
7960
8012
|
}, [
|
|
7961
|
-
swirlProjectId
|
|
8013
|
+
swirlProjectId,
|
|
8014
|
+
adcisionChannelId
|
|
7962
8015
|
]);
|
|
7963
8016
|
(0, import_react2.useEffect)(function() {
|
|
7964
|
-
if (!showAiPanel || !swirlProjectId) return;
|
|
8017
|
+
if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
|
|
7965
8018
|
var cancelled = false;
|
|
7966
8019
|
var pollTimeoutId = null;
|
|
7967
8020
|
var inFlight = false;
|
|
@@ -8997,7 +9050,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
8997
9050
|
size: Math.max(14, 18 * responsiveScale)
|
|
8998
9051
|
})
|
|
8999
9052
|
}),
|
|
9000
|
-
swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9053
|
+
(swirlProjectId || adcisionChannelId) && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9001
9054
|
className: "sc-ctrl-btn",
|
|
9002
9055
|
onClick: function onClick() {
|
|
9003
9056
|
setShowAiPanel(function(prev) {
|
|
@@ -9019,7 +9072,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
9019
9072
|
title: showAiPanel ? "Hide AI context" : "Show AI context",
|
|
9020
9073
|
children: "AI"
|
|
9021
9074
|
}),
|
|
9022
|
-
|
|
9075
|
+
(showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9023
9076
|
className: "sc-ctrl-btn",
|
|
9024
9077
|
onClick: function onClick() {
|
|
9025
9078
|
setShowDebugPanel(function(prev) {
|
|
@@ -9336,7 +9389,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
9336
9389
|
size: Math.max(14, 18 * responsiveScale)
|
|
9337
9390
|
})
|
|
9338
9391
|
}),
|
|
9339
|
-
swirlProjectId && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9392
|
+
(swirlProjectId || adcisionChannelId) && (showAiContextControl !== null && showAiContextControl !== void 0 ? showAiContextControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9340
9393
|
className: "sc-ctrl-btn",
|
|
9341
9394
|
onClick: function onClick() {
|
|
9342
9395
|
setShowAiPanel(function(prev) {
|
|
@@ -9358,7 +9411,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
9358
9411
|
title: showAiPanel ? "Hide AI context" : "Show AI context",
|
|
9359
9412
|
children: "AI"
|
|
9360
9413
|
}),
|
|
9361
|
-
|
|
9414
|
+
(showDebugControl !== null && showDebugControl !== void 0 ? showDebugControl : true) && /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("button", {
|
|
9362
9415
|
className: "sc-ctrl-btn",
|
|
9363
9416
|
onClick: function onClick() {
|
|
9364
9417
|
setShowDebugPanel(function(prev) {
|
|
@@ -9461,6 +9514,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
|
|
|
9461
9514
|
"poster",
|
|
9462
9515
|
"children",
|
|
9463
9516
|
"swirlProjectId",
|
|
9517
|
+
"adcisionChannelId",
|
|
9464
9518
|
"disableOverlays",
|
|
9465
9519
|
"showAdsControl",
|
|
9466
9520
|
"showOverlaysControl",
|