stormcloud-video-player 0.7.20 → 0.7.22

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
@@ -3208,7 +3208,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3208
3208
  this.hls.on(import_hls.default.Events.FRAG_CHANGED, function(_evt, data) {
3209
3209
  var frag = data === null || data === void 0 ? void 0 : data.frag;
3210
3210
  if (!frag) return;
3211
- if (_this.lastAdInsertionPoint && !_this.inAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3211
+ if (_this.lastAdInsertionPoint && !_this.inAdBreak && !_this.pendingAdBreak && _this.lastAdInsertionPoint.updated_at !== _this.processedAdInsertionUpdatedAt) {
3212
3212
  var segmentName = _this.lastAdInsertionPoint.segment_ts_name;
3213
3213
  if (_this.fragmentMatchesSegment(frag, segmentName)) {
3214
3214
  var _ref;
@@ -4079,7 +4079,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4079
4079
  ]);
4080
4080
  return [
4081
4081
  4,
4082
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
4082
+ fetch("https://adstorm.co/api-adstorm-dev/adstorm/adcision/channels/".concat(encodeURIComponent(this.config.projectId), "/ad-insertion-point"))
4083
4083
  ];
4084
4084
  case 2:
4085
4085
  resp = _state.sent();
@@ -4100,7 +4100,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4100
4100
  this.pushAdInsertionDebug("api_response", data.segment_ts_name, {
4101
4101
  offsetSeconds: data.offset_seconds,
4102
4102
  updatedAt: data.updated_at,
4103
- detail: "project=".concat(data.project_id)
4103
+ detail: "ch=".concat(data.channel_id, " id=").concat(data.id)
4104
4104
  });
4105
4105
  if (segmentChanged && (this.pendingAdBreak || this.adInsertionOffsetTimerId != null)) {
4106
4106
  this.clearAdInsertionOffsetTimer();
@@ -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 = [
@@ -7681,7 +7706,8 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
7681
7706
  licenseKey,
7682
7707
  lowLatencyMode,
7683
7708
  driftToleranceMs,
7684
- adcisionChannelId
7709
+ adcisionChannelId,
7710
+ debugAdTiming
7685
7711
  ]);
7686
7712
  (0, import_react2.useEffect)(function() {
7687
7713
  if (typeof window === "undefined") return;
@@ -8014,13 +8040,13 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8014
8040
  adcisionChannelId
8015
8041
  ]);
8016
8042
  (0, import_react2.useEffect)(function() {
8017
- if (!showAiPanel || !swirlProjectId || adcisionChannelId) return;
8043
+ if (!showAiPanel || !swirlProjectId && !adcisionChannelId) return;
8018
8044
  var cancelled = false;
8019
8045
  var pollTimeoutId = null;
8020
8046
  var inFlight = false;
8021
8047
  var pollLiveContext = function pollLiveContext1() {
8022
8048
  return _async_to_generator(function() {
8023
- var response, payload, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
8049
+ var payload, adcisionCtx, response, error, message, _ref, _playerRef_current, segmentPollMs, nextPollMs;
8024
8050
  return _ts_generator(this, function(_state) {
8025
8051
  switch(_state.label){
8026
8052
  case 0:
@@ -8038,10 +8064,32 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8038
8064
  case 1:
8039
8065
  _state.trys.push([
8040
8066
  1,
8067
+ 7,
8068
+ 8,
8069
+ 9
8070
+ ]);
8071
+ if (!adcisionChannelId) return [
8072
+ 3,
8073
+ 3
8074
+ ];
8075
+ return [
8041
8076
  4,
8042
- 5,
8077
+ fetchAdcisionChannelLiveContext(adcisionChannelId)
8078
+ ];
8079
+ case 2:
8080
+ adcisionCtx = _state.sent();
8081
+ payload = {
8082
+ id: adcisionCtx.id,
8083
+ project_id: adcisionCtx.channel_id,
8084
+ keywords: adcisionCtx.keywords,
8085
+ context: adcisionCtx.context,
8086
+ updated_at: adcisionCtx.updated_at
8087
+ };
8088
+ return [
8089
+ 3,
8043
8090
  6
8044
- ]);
8091
+ ];
8092
+ case 3:
8045
8093
  return [
8046
8094
  4,
8047
8095
  fetch("https://adstorm.co/api-adstorm-dev/adstorm/swirl/projects/".concat(swirlProjectId, "/live-context"), {
@@ -8051,7 +8099,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8051
8099
  }
8052
8100
  })
8053
8101
  ];
8054
- case 2:
8102
+ case 4:
8055
8103
  response = _state.sent();
8056
8104
  if (!response.ok) {
8057
8105
  throw new Error("Live context request failed (".concat(response.status, " ").concat(response.statusText, ")"));
@@ -8060,8 +8108,10 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8060
8108
  4,
8061
8109
  response.json()
8062
8110
  ];
8063
- case 3:
8111
+ case 5:
8064
8112
  payload = _state.sent();
8113
+ _state.label = 6;
8114
+ case 6:
8065
8115
  if (cancelled) return [
8066
8116
  2
8067
8117
  ];
@@ -8073,9 +8123,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8073
8123
  });
8074
8124
  return [
8075
8125
  3,
8076
- 6
8126
+ 9
8077
8127
  ];
8078
- case 4:
8128
+ case 7:
8079
8129
  error = _state.sent();
8080
8130
  if (cancelled) return [
8081
8131
  2
@@ -8090,9 +8140,9 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8090
8140
  });
8091
8141
  return [
8092
8142
  3,
8093
- 6
8143
+ 9
8094
8144
  ];
8095
- case 5:
8145
+ case 8:
8096
8146
  inFlight = false;
8097
8147
  if (!cancelled) {
8098
8148
  ;
@@ -8104,7 +8154,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8104
8154
  return [
8105
8155
  7
8106
8156
  ];
8107
- case 6:
8157
+ case 9:
8108
8158
  return [
8109
8159
  2
8110
8160
  ];
@@ -8122,6 +8172,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8122
8172
  }, [
8123
8173
  showAiPanel,
8124
8174
  swirlProjectId,
8175
+ adcisionChannelId,
8125
8176
  criticalPropsKey
8126
8177
  ]);
8127
8178
  var handleWrapperMouseMove = (0, import_react2.useCallback)(function() {
@@ -8384,7 +8435,7 @@ var StormcloudVideoPlayerComponent = import_react2.default.memo(function(props)
8384
8435
  })
8385
8436
  ]
8386
8437
  }),
8387
- showAiPanel && !showLicenseWarning && swirlProjectId && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8438
+ showAiPanel && !showLicenseWarning && (swirlProjectId || adcisionChannelId) && /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", {
8388
8439
  style: _object_spread_props(_object_spread({
8389
8440
  position: "absolute",
8390
8441
  right: "".concat(panelBaseRight, "px")