-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapp.js
More file actions
57 lines (46 loc) · 1.72 KB
/
app.js
File metadata and controls
57 lines (46 loc) · 1.72 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
/**
* DownloadLib main module
* Initializes the application, registers services, and sets up the UI
* @license MIT
* @author ivanvit
* @version 1.0.6
*/
'use strict';
(function() {
console.log('[App] Initializing...');
const extensionApi = typeof getExtensionApi === 'function'
? getExtensionApi()
: ((typeof browser !== 'undefined' && browser) || (typeof chrome !== 'undefined' && chrome) || null);
if (!extensionApi)
console.warn('[App] Extension API is not available in this context');
const dependencies = [
'EventBus',
'RateLimiter',
'ServiceRegistry',
'DownloadManager',
'MangaPatcher',
'ExporterRegistry',
'PopupController'
];
const missing = dependencies.filter(dep => typeof window[dep] === 'undefined');
if (missing.length > 0) {
console.error('[App] Missing dependencies:', missing);
document.body.innerHTML = `<div style="padding: 20px; color: red;">Ошибка загрузки модулей: ${missing.join(', ')}</div>`;
return;
}
console.log('[App] All dependencies loaded');
function initUI() {
console.log('[App] Initializing UI...');
try {
window.popupController = new window.PopupController();
} catch (e) {
console.error('[App] Failed to initialize PopupController:', e);
document.getElementById('error').textContent = `Ошибка инициализации: ${e.message}`;
document.getElementById('error').classList.remove('hidden');
}
}
if (document.readyState === 'loading')
document.addEventListener('DOMContentLoaded', initUI);
else
setTimeout(initUI, 100);
})();