stormcloud-video-player 0.7.49 → 0.7.51

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
@@ -1,6 +1,25 @@
1
1
  import React, { CSSProperties, lazy as lazy$1 } from 'react';
2
2
  import * as csstype from 'csstype';
3
3
 
4
+ declare const MQTT_CA_CERT_FILE = "src/certs/emqxsl-ca.crt";
5
+ type MQTTConfig = {
6
+ enabled: boolean;
7
+ brokerAddress: string;
8
+ brokerPort: number;
9
+ wsPort: number;
10
+ username: string;
11
+ password: string;
12
+ topicPrefix: string;
13
+ qos: 0 | 1 | 2;
14
+ brokerUrl?: string;
15
+ };
16
+ declare const DEFAULT_MQTT_CONFIG: MQTTConfig;
17
+ declare const mqttConfig: MQTTConfig;
18
+ declare function applyMQTTConfig(overrides: Partial<MQTTConfig>): void;
19
+ declare function isMQTTEnabled(): boolean;
20
+ declare function buildMQTTBrokerUrl(): string;
21
+ declare function buildPlayerTopic(licenseKey: string, channel: "metrics" | "impressions" | "heartbeat"): string;
22
+
4
23
  type LateJoinPolicy = "play_remaining" | "skip_to_content";
5
24
  interface AdBreak {
6
25
  id?: string;
@@ -37,6 +56,7 @@ interface StormcloudVideoPlayerConfig {
37
56
  singlePipelineMode?: boolean;
38
57
  projectId?: string;
39
58
  channelId?: number;
59
+ mqttConfig?: Partial<MQTTConfig>;
40
60
  }
41
61
  interface AdController {
42
62
  initialize: () => void;
@@ -94,8 +114,39 @@ interface ClientInfo {
94
114
  interface TrackingData extends ClientInfo {
95
115
  browserId: string;
96
116
  }
117
+ interface PlayerAnalyticsContext {
118
+ inputStreamType?: string;
119
+ }
97
120
  interface HeartbeatData {
98
121
  browserId: string;
122
+ player_id: string;
123
+ device_type: ClientInfo["deviceType"];
124
+ input_stream_type?: string;
125
+ os: string;
126
+ ad_loaded?: boolean;
127
+ ad_detect?: boolean;
128
+ license_key?: string;
129
+ capture_at: string;
130
+ timestamp: string;
131
+ }
132
+ interface AdDetectInfo {
133
+ source: "scte35";
134
+ durationSeconds?: number;
135
+ ptsSeconds?: number;
136
+ detectedAtFragmentSn?: number;
137
+ timestamp: string;
138
+ }
139
+ interface AdLoadedInfo {
140
+ source: "vast" | "ima" | "hls";
141
+ vastUrl?: string;
142
+ durationSeconds?: number;
143
+ timestamp: string;
144
+ }
145
+ interface AdImpressionInfo {
146
+ source: "vast" | "ima" | "hls";
147
+ adIndex: number;
148
+ adUrl?: string;
149
+ durationSeconds?: number;
99
150
  timestamp: string;
100
151
  }
101
152
  interface VastBidResponse {
@@ -199,6 +250,7 @@ declare class StormcloudVideoPlayer {
199
250
  setDisableAds(disabled: boolean): void;
200
251
  private syncMainContentAudioWhenVisible;
201
252
  getStreamType(): "hls" | "other";
253
+ private getPlayerAnalyticsContext;
202
254
  shouldShowNativeControls(): boolean;
203
255
  private shouldContinueLiveStreamDuringAds;
204
256
  private startAdPrefetch;
@@ -4013,8 +4065,26 @@ declare const SUPPORTS_DASH: () => boolean;
4013
4065
 
4014
4066
  declare function getClientInfo(): ClientInfo;
4015
4067
  declare function getBrowserID(clientInfo: ClientInfo): Promise<string>;
4016
- declare function sendInitialTracking(licenseKey?: string): Promise<void>;
4017
- declare function sendHeartbeat(licenseKey?: string): Promise<void>;
4068
+ type PlayerMetricFlags = {
4069
+ adLoaded?: boolean;
4070
+ adDetect?: boolean;
4071
+ captureAt?: string;
4072
+ };
4073
+ declare function sendInitialTracking(licenseKey?: string, context?: PlayerAnalyticsContext): Promise<void>;
4074
+ declare function sendAdDetectTracking(licenseKey: string | undefined, adDetectInfo: AdDetectInfo, context?: PlayerAnalyticsContext): Promise<void>;
4075
+ declare function sendAdLoadedTracking(licenseKey: string | undefined, adLoadedInfo: AdLoadedInfo, context?: PlayerAnalyticsContext): Promise<void>;
4076
+ declare function sendAdImpressionTracking(licenseKey: string | undefined, adImpressionInfo: AdImpressionInfo, context?: PlayerAnalyticsContext): Promise<void>;
4077
+ declare function sendHeartbeat(licenseKey?: string, context?: PlayerAnalyticsContext, flags?: PlayerMetricFlags): Promise<void>;
4078
+
4079
+ type MQTTStatus = "disconnected" | "connecting" | "connected" | "error";
4080
+ declare function getMQTTStatus(): MQTTStatus;
4081
+ declare function isMQTTConnected(): boolean;
4082
+ declare function isMQTTConfigured(): boolean;
4083
+ declare function configureMQTT(overrides: Partial<MQTTConfig>): void;
4084
+ declare function initMQTTClient(): void;
4085
+ declare function ensureMQTTClient(): void;
4086
+ declare function publishMQTT(topic: string, payload: Record<string, unknown>): boolean;
4087
+ declare function disconnectMQTT(): void;
4018
4088
 
4019
4089
  declare const OVERLAY_API_BASE = "https://adstorm.co/api-adstorm-dev";
4020
4090
  interface OverlayCoordinateSpace {
@@ -4142,4 +4212,4 @@ interface AdStormAdLayer extends AdController {
4142
4212
  }
4143
4213
  declare function createAdStormPlayer(contentVideo: HTMLVideoElement, options: AdStormPlayerOptions): AdStormAdLayer;
4144
4214
 
4145
- export { type AdBreak, type AdSchedule, type AdStormAdLayer, type AdStormLayerOptionsUpdate, type AdStormPlayerOptions, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, OVERLAY_API_BASE, type OnProgressProps, type OverlayCoordinateSpace, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type SwirlOverlay, type SwirlOverlayType, type SwirlScrollerConfig, type TrackingData, type VastBidResponse, canPlay, createAdStormPlayer, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, fetchProjectOverlays, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, isOverlayActive, lazy, logBrowserInfo, merge, normalizeSwirlOverlay, omit, parseQuery, players, randomString, resolveImageUrl, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode, timeStringToSeconds };
4215
+ export { type AdBreak, type AdDetectInfo, type AdImpressionInfo, type AdLoadedInfo, type AdSchedule, type AdStormAdLayer, type AdStormLayerOptionsUpdate, type AdStormPlayerOptions, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, DEFAULT_MQTT_CONFIG, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type MQTTConfig, type MQTTStatus, MQTT_CA_CERT_FILE, OVERLAY_API_BASE, type OnProgressProps, type OverlayCoordinateSpace, type PlayerAnalyticsContext, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type SwirlOverlay, type SwirlOverlayType, type SwirlScrollerConfig, type TrackingData, type VastBidResponse, applyMQTTConfig, buildMQTTBrokerUrl, buildPlayerTopic, canPlay, configureMQTT, createAdStormPlayer, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, ensureMQTTClient, fetchProjectOverlays, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMQTTEnabled, isMediaStream, isOverlayActive, lazy, logBrowserInfo, merge, mqttConfig, normalizeSwirlOverlay, omit, parseQuery, players, publishMQTT, randomString, resolveImageUrl, sendAdDetectTracking, sendAdImpressionTracking, sendAdLoadedTracking, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode, timeStringToSeconds };
package/lib/index.d.ts CHANGED
@@ -1,6 +1,25 @@
1
1
  import React, { CSSProperties, lazy as lazy$1 } from 'react';
2
2
  import * as csstype from 'csstype';
3
3
 
4
+ declare const MQTT_CA_CERT_FILE = "src/certs/emqxsl-ca.crt";
5
+ type MQTTConfig = {
6
+ enabled: boolean;
7
+ brokerAddress: string;
8
+ brokerPort: number;
9
+ wsPort: number;
10
+ username: string;
11
+ password: string;
12
+ topicPrefix: string;
13
+ qos: 0 | 1 | 2;
14
+ brokerUrl?: string;
15
+ };
16
+ declare const DEFAULT_MQTT_CONFIG: MQTTConfig;
17
+ declare const mqttConfig: MQTTConfig;
18
+ declare function applyMQTTConfig(overrides: Partial<MQTTConfig>): void;
19
+ declare function isMQTTEnabled(): boolean;
20
+ declare function buildMQTTBrokerUrl(): string;
21
+ declare function buildPlayerTopic(licenseKey: string, channel: "metrics" | "impressions" | "heartbeat"): string;
22
+
4
23
  type LateJoinPolicy = "play_remaining" | "skip_to_content";
5
24
  interface AdBreak {
6
25
  id?: string;
@@ -37,6 +56,7 @@ interface StormcloudVideoPlayerConfig {
37
56
  singlePipelineMode?: boolean;
38
57
  projectId?: string;
39
58
  channelId?: number;
59
+ mqttConfig?: Partial<MQTTConfig>;
40
60
  }
41
61
  interface AdController {
42
62
  initialize: () => void;
@@ -94,8 +114,39 @@ interface ClientInfo {
94
114
  interface TrackingData extends ClientInfo {
95
115
  browserId: string;
96
116
  }
117
+ interface PlayerAnalyticsContext {
118
+ inputStreamType?: string;
119
+ }
97
120
  interface HeartbeatData {
98
121
  browserId: string;
122
+ player_id: string;
123
+ device_type: ClientInfo["deviceType"];
124
+ input_stream_type?: string;
125
+ os: string;
126
+ ad_loaded?: boolean;
127
+ ad_detect?: boolean;
128
+ license_key?: string;
129
+ capture_at: string;
130
+ timestamp: string;
131
+ }
132
+ interface AdDetectInfo {
133
+ source: "scte35";
134
+ durationSeconds?: number;
135
+ ptsSeconds?: number;
136
+ detectedAtFragmentSn?: number;
137
+ timestamp: string;
138
+ }
139
+ interface AdLoadedInfo {
140
+ source: "vast" | "ima" | "hls";
141
+ vastUrl?: string;
142
+ durationSeconds?: number;
143
+ timestamp: string;
144
+ }
145
+ interface AdImpressionInfo {
146
+ source: "vast" | "ima" | "hls";
147
+ adIndex: number;
148
+ adUrl?: string;
149
+ durationSeconds?: number;
99
150
  timestamp: string;
100
151
  }
101
152
  interface VastBidResponse {
@@ -199,6 +250,7 @@ declare class StormcloudVideoPlayer {
199
250
  setDisableAds(disabled: boolean): void;
200
251
  private syncMainContentAudioWhenVisible;
201
252
  getStreamType(): "hls" | "other";
253
+ private getPlayerAnalyticsContext;
202
254
  shouldShowNativeControls(): boolean;
203
255
  private shouldContinueLiveStreamDuringAds;
204
256
  private startAdPrefetch;
@@ -4013,8 +4065,26 @@ declare const SUPPORTS_DASH: () => boolean;
4013
4065
 
4014
4066
  declare function getClientInfo(): ClientInfo;
4015
4067
  declare function getBrowserID(clientInfo: ClientInfo): Promise<string>;
4016
- declare function sendInitialTracking(licenseKey?: string): Promise<void>;
4017
- declare function sendHeartbeat(licenseKey?: string): Promise<void>;
4068
+ type PlayerMetricFlags = {
4069
+ adLoaded?: boolean;
4070
+ adDetect?: boolean;
4071
+ captureAt?: string;
4072
+ };
4073
+ declare function sendInitialTracking(licenseKey?: string, context?: PlayerAnalyticsContext): Promise<void>;
4074
+ declare function sendAdDetectTracking(licenseKey: string | undefined, adDetectInfo: AdDetectInfo, context?: PlayerAnalyticsContext): Promise<void>;
4075
+ declare function sendAdLoadedTracking(licenseKey: string | undefined, adLoadedInfo: AdLoadedInfo, context?: PlayerAnalyticsContext): Promise<void>;
4076
+ declare function sendAdImpressionTracking(licenseKey: string | undefined, adImpressionInfo: AdImpressionInfo, context?: PlayerAnalyticsContext): Promise<void>;
4077
+ declare function sendHeartbeat(licenseKey?: string, context?: PlayerAnalyticsContext, flags?: PlayerMetricFlags): Promise<void>;
4078
+
4079
+ type MQTTStatus = "disconnected" | "connecting" | "connected" | "error";
4080
+ declare function getMQTTStatus(): MQTTStatus;
4081
+ declare function isMQTTConnected(): boolean;
4082
+ declare function isMQTTConfigured(): boolean;
4083
+ declare function configureMQTT(overrides: Partial<MQTTConfig>): void;
4084
+ declare function initMQTTClient(): void;
4085
+ declare function ensureMQTTClient(): void;
4086
+ declare function publishMQTT(topic: string, payload: Record<string, unknown>): boolean;
4087
+ declare function disconnectMQTT(): void;
4018
4088
 
4019
4089
  declare const OVERLAY_API_BASE = "https://adstorm.co/api-adstorm-dev";
4020
4090
  interface OverlayCoordinateSpace {
@@ -4142,4 +4212,4 @@ interface AdStormAdLayer extends AdController {
4142
4212
  }
4143
4213
  declare function createAdStormPlayer(contentVideo: HTMLVideoElement, options: AdStormPlayerOptions): AdStormAdLayer;
4144
4214
 
4145
- export { type AdBreak, type AdSchedule, type AdStormAdLayer, type AdStormLayerOptionsUpdate, type AdStormPlayerOptions, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, OVERLAY_API_BASE, type OnProgressProps, type OverlayCoordinateSpace, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type SwirlOverlay, type SwirlOverlayType, type SwirlScrollerConfig, type TrackingData, type VastBidResponse, canPlay, createAdStormPlayer, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, fetchProjectOverlays, getBrowserConfigOverrides, getBrowserID, getClientInfo, initializePolyfills, isMediaStream, isOverlayActive, lazy, logBrowserInfo, merge, normalizeSwirlOverlay, omit, parseQuery, players, randomString, resolveImageUrl, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode, timeStringToSeconds };
4215
+ export { type AdBreak, type AdDetectInfo, type AdImpressionInfo, type AdLoadedInfo, type AdSchedule, type AdStormAdLayer, type AdStormLayerOptionsUpdate, type AdStormPlayerOptions, type BaseStormcloudPlayerProps, type BrowserInfo, type ClientInfo, DEFAULT_MQTT_CONFIG, type HeartbeatData, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, type LateJoinPolicy, type MQTTConfig, type MQTTStatus, MQTT_CA_CERT_FILE, OVERLAY_API_BASE, type OnProgressProps, type OverlayCoordinateSpace, type PlayerAnalyticsContext, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, type StormcloudVideoPlayerConfig, type StormcloudVideoPlayerProps, type SwirlOverlay, type SwirlOverlayType, type SwirlScrollerConfig, type TrackingData, type VastBidResponse, applyMQTTConfig, buildMQTTBrokerUrl, buildPlayerTopic, canPlay, configureMQTT, createAdStormPlayer, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, ensureMQTTClient, fetchProjectOverlays, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMQTTEnabled, isMediaStream, isOverlayActive, lazy, logBrowserInfo, merge, mqttConfig, normalizeSwirlOverlay, omit, parseQuery, players, publishMQTT, randomString, resolveImageUrl, sendAdDetectTracking, sendAdImpressionTracking, sendAdLoadedTracking, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode, timeStringToSeconds };