unified-video-framework 1.4.215 → 1.4.216

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.
@@ -0,0 +1,442 @@
1
+ /**
2
+ * Comprehensive Ad Type Definitions for Unified Video Framework
3
+ * Based on google-ads-frontend-spec.json
4
+ * Author: Flicknexs Team
5
+ */
6
+
7
+ // ============================================================================
8
+ // ENUMS
9
+ // ============================================================================
10
+
11
+ export enum AdType {
12
+ // Google Standard Video Ads
13
+ SKIPPABLE_IN_STREAM = 'SKIPPABLE_IN_STREAM',
14
+ NON_SKIPPABLE_IN_STREAM = 'NON_SKIPPABLE_IN_STREAM',
15
+ BUMPER_ADS = 'BUMPER_ADS',
16
+
17
+ // Google Display Ads
18
+ RESPONSIVE_DISPLAY = 'RESPONSIVE_DISPLAY',
19
+ MASTHEAD = 'MASTHEAD',
20
+
21
+ // Custom Ads
22
+ PAUSE_OVERLAY = 'PAUSE_OVERLAY',
23
+ OVERLAY_AD = 'OVERLAY_AD',
24
+ INTERACTIVE_AD = 'INTERACTIVE_AD',
25
+ }
26
+
27
+ export enum AdPlacement {
28
+ PREROLL = 'preroll',
29
+ MIDROLL = 'midroll',
30
+ POSTROLL = 'postroll',
31
+ PAUSE = 'pause',
32
+ OVERLAY = 'overlay',
33
+ }
34
+
35
+ export enum AdEventType {
36
+ // Standard Events
37
+ IMPRESSION = 'impression',
38
+ LOADED = 'loaded',
39
+ STARTED = 'started',
40
+ FIRST_QUARTILE = 'firstQuartile',
41
+ MIDPOINT = 'midpoint',
42
+ THIRD_QUARTILE = 'thirdQuartile',
43
+ COMPLETED = 'completed',
44
+ SKIPPED = 'skipped',
45
+ CLICKED = 'clicked',
46
+ CLOSED = 'closed',
47
+ PAUSED = 'paused',
48
+ RESUMED = 'resumed',
49
+ MUTED = 'muted',
50
+ UNMUTED = 'unmuted',
51
+ FULLSCREEN = 'fullscreen',
52
+ EXIT_FULLSCREEN = 'exitFullscreen',
53
+ EXPANDED = 'expanded',
54
+ COLLAPSED = 'collapsed',
55
+
56
+ // Custom Events
57
+ USER_ENGAGEMENT = 'userEngagement',
58
+ BRAND_INTERACTION = 'brandInteraction',
59
+ SOCIAL_SHARE = 'socialShare',
60
+ PRODUCT_VIEW = 'productView',
61
+ ADD_TO_CART = 'addToCart',
62
+ PURCHASE = 'purchase',
63
+ SIGN_UP = 'signUp',
64
+ DOWNLOAD_APP = 'downloadApp',
65
+ VISIT_STORE = 'visitStore',
66
+
67
+ // Error Events
68
+ AD_ERROR = 'adError',
69
+ AD_BREAK_READY = 'adBreakReady',
70
+ AD_BREAK_STARTED = 'adBreakStarted',
71
+ AD_BREAK_COMPLETED = 'adBreakCompleted',
72
+ ALL_ADS_COMPLETED = 'allAdsCompleted',
73
+ }
74
+
75
+ // ============================================================================
76
+ // UI COMPONENT INTERFACES
77
+ // ============================================================================
78
+
79
+ export interface SkipButtonConfig {
80
+ enabled: boolean;
81
+ skipOffset: number; // seconds
82
+ text: string;
83
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
84
+ style: 'button' | 'text' | 'custom';
85
+ customStyle?: React.CSSProperties;
86
+ }
87
+
88
+ export interface CountdownConfig {
89
+ enabled: boolean;
90
+ format: string; // e.g., "Ad: {time}" or "{time}"
91
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
92
+ }
93
+
94
+ export interface ProgressBarConfig {
95
+ enabled: boolean;
96
+ color: string;
97
+ height?: number;
98
+ position?: 'top' | 'bottom';
99
+ }
100
+
101
+ export interface AdLabelConfig {
102
+ enabled: boolean;
103
+ text: string;
104
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
105
+ fontSize?: string;
106
+ }
107
+
108
+ export interface CloseButtonConfig {
109
+ enabled: boolean;
110
+ position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
111
+ style: string; // e.g., "×"
112
+ delay?: number; // seconds before showing
113
+ }
114
+
115
+ // ============================================================================
116
+ // AD TYPE CONFIGURATIONS
117
+ // ============================================================================
118
+
119
+ export interface SkippableInStreamAdConfig {
120
+ type: AdType.SKIPPABLE_IN_STREAM;
121
+ skipButton: SkipButtonConfig;
122
+ countdown: CountdownConfig;
123
+ progressBar: ProgressBarConfig;
124
+ controls: {
125
+ pauseOnClick: boolean;
126
+ volumeControl: boolean;
127
+ seekControl: boolean;
128
+ };
129
+ }
130
+
131
+ export interface NonSkippableInStreamAdConfig {
132
+ type: AdType.NON_SKIPPABLE_IN_STREAM;
133
+ countdown: CountdownConfig;
134
+ progressBar: ProgressBarConfig;
135
+ adLabel: AdLabelConfig;
136
+ controls: {
137
+ pauseOnClick: boolean;
138
+ volumeControl: boolean;
139
+ seekControl: boolean;
140
+ };
141
+ }
142
+
143
+ export interface BumperAdConfig {
144
+ type: AdType.BUMPER_ADS;
145
+ countdown: CountdownConfig;
146
+ adLabel: AdLabelConfig;
147
+ controls: {
148
+ pauseOnClick: boolean;
149
+ volumeControl: boolean;
150
+ seekControl: boolean;
151
+ };
152
+ }
153
+
154
+ export interface ResponsiveDisplayAdConfig {
155
+ type: AdType.RESPONSIVE_DISPLAY;
156
+ closeButton: CloseButtonConfig;
157
+ adLabel: AdLabelConfig;
158
+ responsive: {
159
+ breakpoints: {
160
+ mobile: string;
161
+ tablet: string;
162
+ desktop: string;
163
+ };
164
+ sizes: {
165
+ mobile: string[];
166
+ tablet: string[];
167
+ desktop: string[];
168
+ };
169
+ };
170
+ }
171
+
172
+ export interface MastheadAdConfig {
173
+ type: AdType.MASTHEAD;
174
+ playButton: {
175
+ enabled: boolean;
176
+ autoplay: boolean;
177
+ muted: boolean;
178
+ };
179
+ muteButton: {
180
+ enabled: boolean;
181
+ position: string;
182
+ };
183
+ companionBanners: {
184
+ enabled: boolean;
185
+ positions: string[];
186
+ };
187
+ }
188
+
189
+ // ============================================================================
190
+ // CUSTOM AD CONFIGURATIONS
191
+ // ============================================================================
192
+
193
+ export interface PauseOverlayAdConfig {
194
+ type: AdType.PAUSE_OVERLAY;
195
+ layout: {
196
+ type: 'split_screen' | 'overlay' | 'popup';
197
+ contentSide?: 'left' | 'right';
198
+ adSide?: 'left' | 'right';
199
+ splitRatio?: string; // e.g., "60:40"
200
+ };
201
+ closeButton: CloseButtonConfig;
202
+ resumeButton: {
203
+ enabled: boolean;
204
+ text: string;
205
+ position: string;
206
+ };
207
+ triggers: {
208
+ minPauseDuration: number; // seconds
209
+ maxDisplayTime: number; // seconds
210
+ frequency: 'always' | 'once_per_session' | 'once_per_video';
211
+ };
212
+ }
213
+
214
+ export interface OverlayAdConfig {
215
+ type: AdType.OVERLAY_AD;
216
+ positions: string[];
217
+ sizes: string[];
218
+ closeButton: CloseButtonConfig;
219
+ animation: {
220
+ entrance: 'slideUp' | 'slideDown' | 'fadeIn' | 'none';
221
+ exit: 'fadeOut' | 'slideDown' | 'slideUp' | 'none';
222
+ };
223
+ }
224
+
225
+ export interface InteractiveAdConfig {
226
+ type: AdType.INTERACTIVE_AD;
227
+ hotspots: {
228
+ enabled: boolean;
229
+ style: 'pulsing_dot' | 'icon' | 'custom';
230
+ hoverEffect: 'tooltip' | 'expand' | 'highlight';
231
+ };
232
+ callToAction: {
233
+ enabled: boolean;
234
+ text: string;
235
+ animation: 'bounce' | 'pulse' | 'shake' | 'none';
236
+ };
237
+ progressTracker: {
238
+ enabled: boolean;
239
+ showInteractions: boolean;
240
+ };
241
+ }
242
+
243
+ // ============================================================================
244
+ // AD BREAK & AD INTERFACES
245
+ // ============================================================================
246
+
247
+ export interface AdMetadata {
248
+ id: string;
249
+ title: string;
250
+ description?: string;
251
+ advertiser?: string;
252
+ duration: number; // seconds
253
+ skippable: boolean;
254
+ skipOffset?: number;
255
+ }
256
+
257
+ export interface TrackingUrls {
258
+ impression?: string[];
259
+ start?: string;
260
+ firstQuartile?: string;
261
+ midpoint?: string;
262
+ thirdQuartile?: string;
263
+ complete?: string;
264
+ skip?: string;
265
+ click?: string;
266
+ close?: string;
267
+ [key: string]: string | string[] | undefined;
268
+ }
269
+
270
+ export interface Ad {
271
+ id: string;
272
+ type: AdType;
273
+ vastUrl?: string;
274
+ vmapUrl?: string;
275
+ videoUrl?: string;
276
+ clickUrl?: string;
277
+ impressionUrls?: string[];
278
+ trackingUrls?: TrackingUrls;
279
+ metadata: AdMetadata;
280
+ targeting?: {
281
+ demographics?: any;
282
+ interests?: string[];
283
+ location?: any;
284
+ device?: string;
285
+ browser?: string;
286
+ };
287
+ config?:
288
+ | SkippableInStreamAdConfig
289
+ | NonSkippableInStreamAdConfig
290
+ | BumperAdConfig
291
+ | ResponsiveDisplayAdConfig
292
+ | MastheadAdConfig
293
+ | PauseOverlayAdConfig
294
+ | OverlayAdConfig
295
+ | InteractiveAdConfig;
296
+ }
297
+
298
+ export interface AdBreak {
299
+ id: string;
300
+ type: AdPlacement;
301
+ position: 'start' | 'end' | number | string; // start, end, time in seconds, or percentage
302
+ ads: Ad[];
303
+ }
304
+
305
+ export interface CompanionAd {
306
+ id: string;
307
+ width: number;
308
+ height: number;
309
+ resourceUrl: string;
310
+ clickUrl?: string;
311
+ containerId?: string;
312
+ }
313
+
314
+ // ============================================================================
315
+ // ADS MANAGER CONFIGURATION
316
+ // ============================================================================
317
+
318
+ export interface AdsManagerConfig {
319
+ // Google IMA SDK
320
+ adsEnabled: boolean;
321
+ adsManagerUrl?: string; // Default: https://imasdk.googleapis.com/js/sdkloader/ima3.js
322
+ debug?: boolean;
323
+
324
+ // Container Elements
325
+ adContainer: HTMLElement | string;
326
+ videoElement: HTMLElement | string;
327
+
328
+ // API Integration
329
+ apiEndpoint?: string; // Backend API for fetching ads
330
+
331
+ // Ad Breaks
332
+ preroll?: boolean | AdBreak;
333
+ midroll?: boolean | AdBreak[] | { enabled: boolean; interval: number };
334
+ postroll?: boolean | AdBreak;
335
+ pauseAds?: PauseOverlayAdConfig;
336
+ overlayAds?: OverlayAdConfig;
337
+
338
+ // Settings
339
+ maxAdsPerBreak?: number;
340
+ maxTotalAds?: number;
341
+ adTimeout?: number; // milliseconds
342
+ retryOnError?: boolean;
343
+ maxRetryAttempts?: number;
344
+
345
+ // Privacy
346
+ gdprConsent?: boolean;
347
+ coppa?: boolean;
348
+
349
+ // Callbacks
350
+ onAdBreakReady?: (adBreak: AdBreak) => void;
351
+ onAdBreakStarted?: (adBreak: AdBreak) => void;
352
+ onAdBreakCompleted?: (adBreak: AdBreak) => void;
353
+ onAdStarted?: (ad: Ad) => void;
354
+ onAdCompleted?: (ad: Ad) => void;
355
+ onAdSkipped?: (ad: Ad) => void;
356
+ onAdError?: (error: AdError) => void;
357
+ onAllAdsCompleted?: () => void;
358
+ }
359
+
360
+ // ============================================================================
361
+ // AD EVENT INTERFACES
362
+ // ============================================================================
363
+
364
+ export interface AdEvent {
365
+ type: AdEventType;
366
+ ad?: Ad;
367
+ adBreak?: AdBreak;
368
+ timestamp: string;
369
+ playerTime?: number;
370
+ customData?: any;
371
+ }
372
+
373
+ export interface AdError {
374
+ code: number;
375
+ message: string;
376
+ ad?: Ad;
377
+ adBreak?: AdBreak;
378
+ details?: any;
379
+ }
380
+
381
+ // ============================================================================
382
+ // API REQUEST/RESPONSE INTERFACES
383
+ // ============================================================================
384
+
385
+ export interface AdConfigRequest {
386
+ contentId: string;
387
+ userId?: string;
388
+ sessionId?: string;
389
+ placement: AdPlacement;
390
+ position?: number | string;
391
+ width: number;
392
+ height: number;
393
+ deviceType?: 'desktop' | 'mobile' | 'tablet' | 'tv';
394
+ browser?: string;
395
+ location?: any;
396
+ language?: string;
397
+ referrer?: string;
398
+ gdprConsent?: boolean;
399
+ coppa?: boolean;
400
+ }
401
+
402
+ export interface AdConfigResponse {
403
+ status: 'success' | 'error' | 'no_ads';
404
+ message?: string;
405
+ code?: number;
406
+ data?: {
407
+ adBreaks: AdBreak[];
408
+ vastUrl?: string;
409
+ vmapUrl?: string;
410
+ companionAds?: CompanionAd[];
411
+ settings?: {
412
+ maxAdsPerBreak?: number;
413
+ maxTotalAds?: number;
414
+ frequencyCapping?: any;
415
+ };
416
+ };
417
+ }
418
+
419
+ export interface TrackEventRequest {
420
+ eventType: AdEventType;
421
+ adId: string;
422
+ sessionId: string;
423
+ contentId?: string;
424
+ userId?: string;
425
+ timestamp: string;
426
+ playerTime: number;
427
+ customData?: any;
428
+ }
429
+
430
+ // ============================================================================
431
+ // EXPORTS
432
+ // ============================================================================
433
+
434
+ export type AdConfig =
435
+ | SkippableInStreamAdConfig
436
+ | NonSkippableInStreamAdConfig
437
+ | BumperAdConfig
438
+ | ResponsiveDisplayAdConfig
439
+ | MastheadAdConfig
440
+ | PauseOverlayAdConfig
441
+ | OverlayAdConfig
442
+ | InteractiveAdConfig;
@@ -14,5 +14,8 @@ export { SecureVideoPlayer } from './SecureVideoPlayer';
14
14
  // Export EPG (Electronic Program Guide) components
15
15
  export * from './react/EPG';
16
16
 
17
+ // Export Ads module (Google Ads Integration)
18
+ export * from './ads';
19
+
17
20
  // Version
18
21
  export const VERSION = '1.0.0';