This repository has been archived by the owner on Jan 6, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 63
/
index.js
110 lines (90 loc) · 4.2 KB
/
index.js
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
require('v8-compile-cache');
const {app, session} = require('electron');
// Initialize the Preferences so verbose doesnt fuck up
const appFuncs = require('./resources/functions/app-init');
app.ame = appFuncs()
// Run all the Before App is Ready Stuff
app.ame.init.LoggingInit();
app.ame.handler.LaunchHandler();
app.ame.handler.InstanceHandler();
app.ame.init.BaseInit();
// Creating the Application Window and Calling all the Functions
function CreateWindow() {
if (app.isQuiting) { app.quit(); return; }
app.win = app.ame.win.CreateBrowserWindow() // Create the BrowserWindow
app.splash = require("./resources/functions/splash").CreateWindow()
app.ame.handler.WindowStateHandler(); // Handling the Window
app.ame.handler.RendererListenerHandlers(); // Renderer Listeners
app.ame.handler.SettingsHandler(); // Handles updates to settings
app.ame.handler.PlaybackStateHandler(); // Playback Change Listener
app.ame.handler.MediaStateHandler(); // Media Change Listener
app.ame.handler.LyricsHandler(); // Lyrics Handling
app.ame.handler.AudioHandler(); // Exclusive Audio Stuff
app.ame.handler.GoogleCastHandler(); // Chromecast
if(process.platform === "win32") {
app.win.show()
}
if (process.platform === 'win32') {
app.updater = require("./resources/functions/updater_win32")
} // Show the window so SetThumbarButtons doesnt break
app.ame.win.SetButtons() // Set Inactive Thumbnail Toolbar Icons or TouchBar
app.ame.win.SetApplicationMenu()
app.ame.win.SetTaskList()
app.ame.utils.checkForUpdates()
app.ame.win.HandleBrowserWindow();
}
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* App Event Handlers
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
app.on('ready', () => {
if (app.isQuiting) { app.quit(); return; }
// Apple Header tomfoolery.
session.defaultSession.webRequest.onHeadersReceived((details, callback) => {
if(details.url.match(/^https:\/\/store-\d{3}\.blobstore\.apple\.com/) || details.url.startsWith("https://store-037.blobstore.apple.com")){
details.responseHeaders['Access-Control-Allow-Origin'] = '*';}
if(details.url.includes('encoderWorker.umd.js')){
details.responseHeaders['Content-Type'] = `text/javascript`;
}
details.responseHeaders['Content-Security-Policy'] = 'unsafe-inline'
callback({ responseHeaders: details.responseHeaders })
})
const {AppReady} = require('./resources/functions/init')
AppReady()
console.log('[Apple-Music-Electron] Application is Ready. Creating Window.')
CreateWindow()
});
// macOS Activate Handler
app.on('activate', () => {
if (app.win === null) {
CreateWindow()
} else {
// app.win.show()
}
})
app.on('before-quit', () => {
console.verbose('before-quit');
app.isQuiting = true;
app.ame.mpris.clearActivity();
app.ame.discord.disconnect();
console.warn('---------------------------------------------------------------------');
console.warn(`${app.getName()} has closed.`);
console.warn('---------------------------------------------------------------------');
});
app.on('will-quit', () => { console.verbose('will-quit'); })
app.on('quit', () => { console.verbose('quit'); })
app.on("window-all-closed", () => { console.verbose('window-all-closed'); if (process.platform !== 'darwin') app.quit(); });
// Widevine Stuff
app.on('widevine-ready', (version, lastVersion) => {
if (null !== lastVersion) {
console.log('[Apple-Music-Electron][Widevine] Widevine ' + version + ', upgraded from ' + lastVersion + ', is ready to be used!')
} else {
console.log('[Apple-Music-Electron][Widevine] Widevine ' + version + ' is ready to be used!')
}
})
app.on('widevine-update-pending', (currentVersion, pendingVersion) => {
console.log('[Apple-Music-Electron][Widevine] Widevine ' + currentVersion + ' is ready to be upgraded to ' + pendingVersion + '!')
})
app.on('widevine-error', (error) => {
console.log('[Apple-Music-Electron][Widevine] Widevine installation encountered an error: ' + error)
app.exit()
})