used typescript the way its supposed to be used
This commit is contained in:
parent
4590e90037
commit
a8dc524e6a
7 changed files with 330 additions and 332 deletions
|
@ -1,41 +1,40 @@
|
|||
require('v8-compile-cache');
|
||||
|
||||
// Analytics for debugging fun yeah.
|
||||
import * as sentry from '@sentry/electron';
|
||||
import * as electron from 'electron';
|
||||
import {Win} from "./base/win";
|
||||
import {ConfigStore} from "./base/store";
|
||||
import {init as Sentry} from '@sentry/electron';
|
||||
import {app, components, ipcMain} from 'electron';
|
||||
import {Store} from "./base/store";
|
||||
import {AppEvents} from "./base/app";
|
||||
import PluginHandler from "./base/plugins";
|
||||
import {Plugins} from "./base/plugins";
|
||||
import {utils} from "./base/utils";
|
||||
import {BrowserWindow} from "./base/browserwindow";
|
||||
|
||||
sentry.init({dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214"});
|
||||
Sentry({dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214"});
|
||||
|
||||
const config = new ConfigStore();
|
||||
const App = new AppEvents(config.store);
|
||||
const Cider = new Win(electron.app, config.store)
|
||||
const plug = new PluginHandler(config.store);
|
||||
|
||||
let win: Electron.BrowserWindow;
|
||||
new Store();
|
||||
const Cider = new AppEvents();
|
||||
const CiderPlug = new Plugins();
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
* App Event Handlers
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
electron.app.on('ready', () => {
|
||||
App.ready(plug);
|
||||
app.on('ready', () => {
|
||||
Cider.ready(CiderPlug);
|
||||
|
||||
console.log('[Cider] Application is Ready. Creating Window.')
|
||||
if (!electron.app.isPackaged) {
|
||||
if (!app.isPackaged) {
|
||||
console.info('[Cider] Running in development mode.')
|
||||
require('vue-devtools').install()
|
||||
}
|
||||
|
||||
electron.components.whenReady().then(async () => {
|
||||
win = await Cider.createWindow()
|
||||
App.bwCreated(win, Cider.i18n);
|
||||
/// please dont change this for plugins to get proper and fully initialized Win objects
|
||||
plug.callPlugins('onReady', win);
|
||||
components.whenReady().then(async () => {
|
||||
const bw = new BrowserWindow()
|
||||
const win = await bw.createWindow()
|
||||
|
||||
win.on("ready-to-show", () => {
|
||||
Cider.bwCreated();
|
||||
CiderPlug.callPlugins('onReady', win);
|
||||
win.show();
|
||||
});
|
||||
});
|
||||
|
@ -46,17 +45,17 @@ electron.app.on('ready', () => {
|
|||
* Renderer Event Handlers
|
||||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
electron.ipcMain.on('playbackStateDidChange', (event, attributes) => {
|
||||
plug.callPlugins('onPlaybackStateDidChange', attributes);
|
||||
ipcMain.on('playbackStateDidChange', (event, attributes) => {
|
||||
CiderPlug.callPlugins('onPlaybackStateDidChange', attributes);
|
||||
});
|
||||
|
||||
electron.ipcMain.on('nowPlayingItemDidChange', (event, attributes) => {
|
||||
plug.callPlugins('onNowPlayingItemDidChange', attributes);
|
||||
ipcMain.on('nowPlayingItemDidChange', (event, attributes) => {
|
||||
CiderPlug.callPlugins('onNowPlayingItemDidChange', attributes);
|
||||
});
|
||||
|
||||
electron.app.on('before-quit', () => {
|
||||
plug.callPlugins('onBeforeQuit');
|
||||
console.warn(`${electron.app.getName()} exited.`);
|
||||
app.on('before-quit', () => {
|
||||
CiderPlug.callPlugins('onBeforeQuit');
|
||||
console.warn(`${app.getName()} exited.`);
|
||||
});
|
||||
|
||||
/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
@ -64,7 +63,7 @@ electron.app.on('before-quit', () => {
|
|||
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
|
||||
|
||||
// @ts-ignore
|
||||
electron.app.on('widevine-ready', (version, lastVersion) => {
|
||||
app.on('widevine-ready', (version, lastVersion) => {
|
||||
if (null !== lastVersion) {
|
||||
console.log('[Cider][Widevine] Widevine ' + version + ', upgraded from ' + lastVersion + ', is ready to be used!')
|
||||
} else {
|
||||
|
@ -73,12 +72,12 @@ electron.app.on('widevine-ready', (version, lastVersion) => {
|
|||
})
|
||||
|
||||
// @ts-ignore
|
||||
electron.app.on('widevine-update-pending', (currentVersion, pendingVersion) => {
|
||||
app.on('widevine-update-pending', (currentVersion, pendingVersion) => {
|
||||
console.log('[Cider][Widevine] Widevine ' + currentVersion + ' is ready to be upgraded to ' + pendingVersion + '!')
|
||||
})
|
||||
|
||||
// @ts-ignore
|
||||
electron.app.on('widevine-error', (error) => {
|
||||
app.on('widevine-error', (error) => {
|
||||
console.log('[Cider][Widevine] Widevine installation encountered an error: ' + error)
|
||||
electron.app.exit()
|
||||
app.exit()
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue