Repository navigation
Expand file tree
/
Copy pathconfig.js
More file actions
310 lines (284 loc) · 9.9 KB
/
Copy pathconfig.js
File metadata and controls
310 lines (284 loc) · 9.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
* Configuration Module
* Handles browser-safe application settings.
*/
const ENV = typeof process !== 'undefined' && process.env ? process.env : {};
const BROWSER_CONFIG = typeof window !== 'undefined' && window.UGC_CONFIG ? window.UGC_CONFIG : {};
const CONFIG = {
// API Configuration
API: {
// Google Gemini API Key - set this locally for development only.
GEMINI_API_KEY: BROWSER_CONFIG.GEMINI_API_KEY || ENV.GEMINI_API_KEY || '',
// API Endpoints
ENDPOINTS: {
GEMINI_BASE: 'https://generativelanguage.googleapis.com/v1beta',
GEMINI_FLASH: 'models/gemini-2.5-flash:generateContent',
GEMINI_IMAGE: 'models/gemini-2.5-flash-image:generateContent',
VEO: 'models/veo-3.1-generate-preview:predictLongRunning'
},
// API Timeouts (in milliseconds)
TIMEOUTS: {
SCRIPT_GENERATION: 30000, // 30 seconds
IMAGE_COMPOSITION: 60000, // 60 seconds
VIDEO_GENERATION: 180000, // 3 minutes
POLLING_INTERVAL: 5000 // 5 seconds for status checks
},
// Rate Limiting
RATE_LIMITS: {
MAX_RETRIES: 3,
RETRY_DELAY: 2000, // 2 seconds between retries
BACKOFF_MULTIPLIER: 2
}
},
// File Upload Configuration
UPLOAD: {
MAX_FILE_SIZE: 10 * 1024 * 1024, // 10MB in bytes
ALLOWED_TYPES: ['image/png', 'image/jpeg', 'image/jpg'],
ALLOWED_EXTENSIONS: ['.png', '.jpg', '.jpeg']
},
// Content Style Configurations
CONTENT_STYLES: {
tiktok_testimonial: {
label: 'TikTok Testimonial',
description: 'Casual, energetic testimonial style popular on TikTok',
tone: 'Authentic, relatable, enthusiastic'
},
product_review: {
label: 'Product Review',
description: 'Detailed product review with pros and cons',
tone: 'Honest, informative, balanced'
},
promo_offer: {
label: 'Promo / Special Offer',
description: 'Promotional content highlighting special deals',
tone: 'Exciting, urgent, value-focused'
},
before_after: {
label: 'Before/After',
description: 'Transformation story showing results',
tone: 'Dramatic, emotional, inspiring'
},
unboxing: {
label: 'Unboxing',
description: 'First impressions and unboxing experience',
tone: 'Excited, curious, detailed'
}
},
// Setting/Background Configurations
SETTINGS: {
modern_studio: {
label: 'Modern Studio',
description: 'Clean, professional studio environment',
lighting: 'bright, even lighting',
ambiance: 'quiet studio ambiance'
},
cozy_home: {
label: 'Cozy Home',
description: 'Comfortable home setting',
lighting: 'warm, natural indoor lighting',
ambiance: 'subtle home sounds'
},
parisian_cafe: {
label: 'Parisian Café',
description: 'Charming café atmosphere',
lighting: 'soft, warm café lighting',
ambiance: 'gentle café chatter and espresso machine sounds'
},
outdoor_terrace: {
label: 'Outdoor Terrace',
description: 'Natural outdoor environment',
lighting: 'natural daylight',
ambiance: 'light outdoor ambient sounds, birds chirping'
},
professional_office: {
label: 'Professional Office',
description: 'Modern office environment',
lighting: 'professional office lighting',
ambiance: 'quiet office background'
}
},
// Video Output Specifications
VIDEO: {
RESOLUTION: {
WIDTH: 1080,
HEIGHT: 1920
},
ASPECT_RATIO: '9:16',
FRAME_RATE: 24,
DURATION: 8, // seconds
BITRATE: '8-10 Mbps',
CODEC: 'H.264',
FORMAT: 'mp4'
},
// Subtitle Configuration. Burned-in subtitles require server-side video processing.
SUBTITLES: {
ENABLED: false,
LANGUAGE: 'fr',
STYLE: {
FONT_FAMILY: 'Arial, sans-serif',
FONT_SIZE: '24px',
FONT_WEIGHT: 'bold',
COLOR: '#FFFFFF',
OUTLINE_COLOR: '#000000',
OUTLINE_WIDTH: '2px',
POSITION: 'bottom-third',
BACKGROUND: 'rgba(0, 0, 0, 0.5)',
PADDING: '8px 12px'
}
},
// Progress Steps Configuration
PROGRESS_STEPS: [
{
id: 1,
label: 'Analyse des images',
icon: '⏳',
duration: 10, // Estimated duration in seconds
progressPercentage: 25
},
{
id: 2,
label: 'Génération du script',
icon: '✍️',
duration: 15,
progressPercentage: 50
},
{
id: 3,
label: 'Composition de la scène',
icon: '🎨',
duration: 15,
progressPercentage: 75
},
{
id: 4,
label: 'Création de la vidéo',
icon: '🎬',
duration: 30,
progressPercentage: 100
}
],
// Error Messages (French)
ERRORS: {
UPLOAD: {
FILE_TOO_LARGE: 'Erreur lors du téléversement. Le fichier est trop volumineux (max 10MB).',
INVALID_FORMAT: 'Format de fichier invalide. Utilisez PNG ou JPG uniquement.',
UPLOAD_FAILED: 'Erreur lors du téléversement. Veuillez réessayer.',
NETWORK_ERROR: 'Erreur réseau. Vérifiez votre connexion internet.'
},
API: {
GENERATION_FAILED: 'La génération a échoué. Veuillez réessayer.',
RATE_LIMIT: 'Limite d\'API atteinte. Veuillez patienter quelques minutes.',
TIMEOUT: 'La requête a expiré. Veuillez réessayer.',
INVALID_RESPONSE: 'Réponse invalide de l\'API. Veuillez réessayer.',
API_KEY_MISSING: 'Clé API manquante. Veuillez configurer votre clé Gemini API.',
AUTHENTICATION_FAILED: 'Échec de l\'authentification. Vérifiez votre clé API.'
},
VALIDATION: {
MISSING_IMAGES: 'Veuillez téléverser les deux images (produit et personne).',
MISSING_STYLE: 'Veuillez sélectionner un style de contenu.',
MISSING_SETTING: 'Veuillez sélectionner un décor.'
},
GENERAL: {
UNKNOWN_ERROR: 'Une erreur inattendue s\'est produite. Veuillez réessayer.',
PROCESSING_ERROR: 'Erreur lors du traitement. Veuillez réessayer.'
}
},
// Success Messages (French)
SUCCESS: {
UPLOAD_COMPLETE: 'Image téléversée avec succès',
API_KEY_SAVED: 'Clé API enregistrée dans ce navigateur',
VIDEO_GENERATED: 'Vidéo générée avec succès!',
DOWNLOAD_STARTED: 'Téléchargement en cours...'
},
// Analytics Configuration (placeholder)
ANALYTICS: {
ENABLED: false,
TRACKING_ID: '',
EVENTS: {
IMAGE_UPLOADED: 'image_uploaded',
STYLE_SELECTED: 'style_selected',
VIDEO_GENERATED: 'video_generated',
VIDEO_DOWNLOADED: 'video_downloaded',
GENERATION_FAILED: 'generation_failed'
}
},
// Feature Flags
FEATURES: {
ENABLE_RETRY: true,
ENABLE_CACHE: true,
ENABLE_LOGO_WATERMARK: false,
ENABLE_DOWNLOAD: true,
ENABLE_REGENERATE: true,
ENABLE_PREVIEW: true
},
// Debug Mode
DEBUG: Boolean(BROWSER_CONFIG.DEBUG || ENV.NODE_ENV === 'development' || ENV.DEBUG === 'true')
};
/**
* Validates the configuration on load
* @returns {boolean} True if configuration is valid
*/
function validateConfig() {
const warnings = [];
// Check API key
if (!CONFIG.API.GEMINI_API_KEY) {
warnings.push('⚠️ GEMINI_API_KEY is not set. API calls will fail.');
}
// Check file size limits
if (CONFIG.UPLOAD.MAX_FILE_SIZE < 1024 * 1024) {
warnings.push('⚠️ MAX_FILE_SIZE is very small. Consider increasing it.');
}
// Log warnings in debug mode
if (CONFIG.DEBUG && warnings.length > 0) {
console.warn('Configuration Warnings:');
warnings.forEach(warning => console.warn(warning));
}
return warnings.length === 0;
}
/**
* Gets a configuration value by path
* @param {string} path - Dot-notation path to config value (e.g., 'API.TIMEOUTS.SCRIPT_GENERATION')
* @returns {*} The configuration value
*/
function getConfig(path) {
return path.split('.').reduce((obj, key) => obj?.[key], CONFIG);
}
/**
* Sets the API key (useful for dynamic configuration)
* @param {string} apiKey - The Gemini API key
*/
function setApiKey(apiKey) {
CONFIG.API.GEMINI_API_KEY = apiKey;
if (CONFIG.DEBUG) {
console.log('✅ API key configured');
}
}
/**
* Logs configuration in debug mode
*/
function logConfig() {
if (CONFIG.DEBUG) {
console.log('📋 Application Configuration:', {
apiKeySet: !!CONFIG.API.GEMINI_API_KEY,
maxFileSize: `${CONFIG.UPLOAD.MAX_FILE_SIZE / (1024 * 1024)}MB`,
videoResolution: `${CONFIG.VIDEO.RESOLUTION.WIDTH}x${CONFIG.VIDEO.RESOLUTION.HEIGHT}`,
features: CONFIG.FEATURES
});
}
}
// Initialize configuration validation
if (typeof window !== 'undefined') {
// Browser environment
document.addEventListener('DOMContentLoaded', () => {
validateConfig();
logConfig();
});
} else {
// Node.js environment
validateConfig();
logConfig();
}
// Export for use in other modules
if (typeof module !== 'undefined' && module.exports) {
module.exports = { CONFIG, getConfig, setApiKey, validateConfig };
}