diff --git a/.gitignore b/.gitignore index e1bcb518..5972eec3 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ dist yarn* package-lock.json .yarnclean +build # Misc .idea diff --git a/build/index.js b/build/index.js new file mode 100644 index 00000000..882db786 --- /dev/null +++ b/build/index.js @@ -0,0 +1,140 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true }); +require('v8-compile-cache'); +// import { app } from 'electron'; +// import { resolve } from 'path'; +const electron_1 = require("electron"); +const path = require("path"); +function createWindow() { + // Create the browser window. + const mainWindow = new electron_1.BrowserWindow({ + height: 600, + webPreferences: { + preload: path.join(__dirname, "preload.js"), + }, + width: 800, + }); + // and load the index.html of the app. + mainWindow.loadFile(path.join(__dirname, "./src/renderer/index.html")); + // Open the DevTools. + mainWindow.webContents.openDevTools(); +} +// This method will be called when Electron has finished +// initialization and is ready to create browser windows. +// Some APIs can only be used after this event occurs. +electron_1.app.on("ready", () => { + createWindow(); + electron_1.app.on("activate", function () { + // On macOS it's common to re-create a window in the app when the + // dock icon is clicked and there are no other windows open. + if (electron_1.BrowserWindow.getAllWindows().length === 0) + createWindow(); + }); +}); +// Quit when all windows are closed, except on macOS. There, it's common +// for applications and their menu bar to stay active until the user quits +// explicitly with Cmd + Q. +electron_1.app.on("window-all-closed", () => { + if (process.platform !== "darwin") { + electron_1.app.quit(); + } +}); +// Analytics for debugging fun yeah. +// const ElectronSentry = require("@sentry/electron"); +// ElectronSentry.init({ dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214" }); +// +// // const {Init} = require("./src/main/cider-base"); +// // Init() +// +// /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// * App Event Handlers +// * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +// +// app.on('ready', () => { +// if (app.isQuiting) { app.quit(); return; } +// +// console.log('[Cider] Application is Ready. Creating Window.') +// if (!app.isPackaged) { +// console.info('[Cider] Running in development mode.') +// require('vue-devtools').install() +// } +// +// // CiderBase.Start() +// }); +// +// app.on('before-quit', () => { +// app.isQuiting = true; +// console.warn(`${app.getName()} exited.`); +// }); +// +// // Widevine Stuff +// app.on('widevine-ready', (version, lastVersion) => { +// if (null !== lastVersion) { +// console.log('[Cider][Widevine] Widevine ' + version + ', upgraded from ' + lastVersion + ', is ready to be used!') +// } else { +// console.log('[Cider][Widevine] Widevine ' + version + ' is ready to be used!') +// } +// }) +// +// app.on('widevine-update-pending', (currentVersion, pendingVersion) => { +// console.log('[Cider][Widevine] Widevine ' + currentVersion + ' is ready to be upgraded to ' + pendingVersion + '!') +// }) +// +// app.on('widevine-error', (error) => { +// console.log('[Cider][Widevine] Widevine installation encountered an error: ' + error) +// app.exit() +// }) +// +// if (process.defaultApp) { +// if (process.argv.length >= 2) { +// app.setAsDefaultProtocolClient('cider', process.execPath, [resolve(process.argv[1])]) +// app.setAsDefaultProtocolClient('ame', process.execPath, [resolve(process.argv[1])]) +// app.setAsDefaultProtocolClient('itms', process.execPath, [resolve(process.argv[1])]) +// app.setAsDefaultProtocolClient('itmss', process.execPath, [resolve(process.argv[1])]) +// app.setAsDefaultProtocolClient('musics', process.execPath, [resolve(process.argv[1])]) +// app.setAsDefaultProtocolClient('music', process.execPath, [resolve(process.argv[1])]) +// } +// } else { +// app.setAsDefaultProtocolClient('cider') // Custom AME Protocol +// app.setAsDefaultProtocolClient('ame') // Custom AME Protocol +// app.setAsDefaultProtocolClient('itms') // iTunes HTTP Protocol +// app.setAsDefaultProtocolClient('itmss') // iTunes HTTPS Protocol +// app.setAsDefaultProtocolClient('musics') // macOS Client Protocol +// app.setAsDefaultProtocolClient('music') // macOS Client Protocol +// } +// +// app.on('open-url', (event, url) => { +// event.preventDefault() +// if (url.includes('ame://') || url.includes('itms://') || url.includes('itmss://') || url.includes('musics://') || url.includes('music://')) { +// CiderBase.LinkHandler(url) +// } +// }) +// +// app.on('second-instance', (_e, argv) => { +// console.warn(`[InstanceHandler][SecondInstanceHandler] Second Instance Started with args: [${argv.join(', ')}]`) +// +// // Checks if first instance is authorized and if second instance has protocol args +// argv.forEach((value) => { +// if (value.includes('ame://') || value.includes('itms://') || value.includes('itmss://') || value.includes('musics://') || value.includes('music://')) { +// console.warn(`[InstanceHandler][SecondInstanceHandler] Found Protocol!`) +// CiderBase.LinkHandler(value); +// } +// }) +// +// if (argv.includes("--force-quit")) { +// console.warn('[InstanceHandler][SecondInstanceHandler] Force Quit found. Quitting App.'); +// app.isQuiting = true +// app.quit() +// } else if (app.win && !app.cfg.get('advanced.allowMultipleInstances')) { // If a Second Instance has Been Started +// console.warn('[InstanceHandler][SecondInstanceHandler] Showing window.'); +// app.win.show() +// app.win.focus() +// } +// }) +// +// if (!app.requestSingleInstanceLock() && !app.cfg.get('advanced.allowMultipleInstances')) { +// console.warn("[InstanceHandler] Existing Instance is Blocking Second Instance."); +// app.quit(); +// app.isQuiting = true +// } +//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map new file mode 100644 index 00000000..2d2ac767 --- /dev/null +++ b/build/index.js.map @@ -0,0 +1 @@ +{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/main/index.ts"],"names":[],"mappings":";;AAAA,OAAO,CAAC,kBAAkB,CAAC,CAAC;AAE5B,kCAAkC;AAClC,kCAAkC;AAElC,uCAA8C;AAC9C,6BAA6B;AAE7B,SAAS,YAAY;IACjB,6BAA6B;IAC7B,MAAM,UAAU,GAAG,IAAI,wBAAa,CAAC;QACjC,MAAM,EAAE,GAAG;QACX,cAAc,EAAE;YACZ,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,YAAY,CAAC;SAC9C;QACD,KAAK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ACR,KAAK;AACL,EAAE;AACF,0EAA0E;AAC1E,0HAA0H;AAC1H,KAAK;AACL,EAAE;AACF,wCAAwC;AACxC,4FAA4F;AAC5F,iBAAiB;AACjB,KAAK;AACL,EAAE;AACF,4BAA4B;AAC5B,sCAAsC;AACtC,gGAAgG;AAChG,8FAA8F;AAC9F,+FAA+F;AAC/F,gGAAgG;AAChG,iGAAiG;AACjG,gGAAgG;AAChG,QAAQ;AACR,WAAW;AACX,qEAAqE;AACrE,mEAAmE;AACnE,qEAAqE;AACrE,uEAAuE;AACvE,wEAAwE;AACxE,uEAAuE;AACvE,IAAI;AACJ,EAAE;AACF,uCAAuC;AACvC,6BAA6B;AAC7B,oJAAoJ;AACpJ,qCAAqC;AACrC,QAAQ;AACR,KAAK;AACL,EAAE;AACF,4CAA4C;AAC5C,uHAAuH;AACvH,EAAE;AACF,yFAAyF;AACzF,gCAAgC;AAChC,kKAAkK;AAClK,uFAAuF;AACvF,4CAA4C;AAC5C,YAAY;AACZ,SAAS;AACT,EAAE;AACF,2CAA2C;AAC3C,oGAAoG;AACpG,+BAA+B;AAC/B,qBAAqB;AACrB,wHAAwH;AACxH,oFAAoF;AACpF,yBAAyB;AACzB,0BAA0B;AAC1B,QAAQ;AACR,KAAK;AACL,EAAE;AACF,6FAA6F;AAC7F,wFAAwF;AACxF,kBAAkB;AAClB,2BAA2B;AAC3B,IAAI"} \ No newline at end of file diff --git a/package.json b/package.json index a45419e1..83eebac8 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "version": "1.0.0", "description": "A new look into listening and enjoying music in style and performance.", "license": "MIT", + "main": "./build/index.js", "author": "Cider Collective (https://cider.sh)", "repository": "https://github.com/ciderapp/Cider.git", "bugs": { @@ -13,10 +14,12 @@ "homepage": "https://cider.sh/", "buildResources": "resources", "scripts": { - "init": "yarn install --force", - "start": "electron . --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", + "build": "tsc", + "init": "install --force", + "watch": "tsc --watch", + "start": "npm run build && electron ./build/index.js --enable-accelerated-mjpeg-decode --enable-accelerated-video --disable-gpu-driver-bug-workarounds --ignore-gpu-blacklist --enable-native-gpu-memory-buffers", "pack": "electron-builder --dir", - "dist": "electron-builder", + "dist": "npm run build && electron-builder", "msft": "electron-builder -c msft-package.json", "postinstall": "electron-builder install-app-deps" }, @@ -25,19 +28,18 @@ "discord-rpc": "^4.0.1", "ejs": "^3.1.6", "electron-acrylic-window": "^0.5.11", - "electron-log": "^4.4.3", + "electron-log": "^4.4.4", "electron-store": "^8.0.1", "electron-updater": "^4.6.1", "electron-window-state": "^5.0.3", + "es6-promise": "^4.2.8", "express": "^4.17.2", "get-port": "^5.1.1", "lastfmapi": "^0.1.1", "mpris-service": "^2.1.2", - "react": "^17.0.2", - "react-dom": "^17.0.2", "source-map-support": "^0.5.21", "v8-compile-cache": "^2.3.0", - "ws": "^8.3.0", + "ws": "^8.4.0", "xml2js": "^0.4.23", "youtube-search-without-api-key": "^1.0.7" }, @@ -46,6 +48,7 @@ "electron-builder": "^22.14.5", "electron-webpack": "^2.8.2", "musickit-typescript": "^1.2.4", + "typescript": "^4.5.4", "vue-devtools": "^5.1.4", "webpack": "~5.65.0" }, @@ -93,16 +96,12 @@ ], "extends": null, "files": [ - "**/*", - "./src/**/*", + "./build/**/*", "./resources/icons/icon.*" ], "linux": { "target": [ - "AppImage", - "deb", - "snap", - "rpm" + "AppImage" ], "synopsis": "A new look into listening and enjoying music in style and performance. ", "category": "AudioVideo", @@ -124,7 +123,8 @@ "icon": "resources/icons/icon.ico" }, "directories": { - "buildResources": "." + "buildResources": ".", + "output": "dist" }, "mac": { "icon": "./resources/icons/icon.icns", diff --git a/index.js b/src/main/index.ts similarity index 90% rename from index.js rename to src/main/index.ts index 06d85e73..435f39be 100644 --- a/index.js +++ b/src/main/index.ts @@ -1,16 +1,19 @@ require('v8-compile-cache'); -const { app } = require('electron'), - {resolve} = require("path"), - CiderBase = require ('./src/main/cider-base'); + +// import { app } from 'electron'; +// import { resolve } from 'path'; + +import { app, BrowserWindow } from "electron"; +import * as path from "path"; + // Analytics for debugging fun yeah. -const ElectronSentry = require("@sentry/electron"); -ElectronSentry.init({ dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214" }); - -// const {Init} = require("./src/main/cider-base"); -// Init() -CiderBase.Init().catch(() => {}) - +// const ElectronSentry = require("@sentry/electron"); +// ElectronSentry.init({ dsn: "https://68c422bfaaf44dea880b86aad5a820d2@o954055.ingest.sentry.io/6112214" }); +// +// // const {Init} = require("./src/main/cider-base"); +// // Init() +// /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * App Event Handlers * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ @@ -24,7 +27,7 @@ app.on('ready', () => { require('vue-devtools').install() } - CiderBase.Start() + // CiderBase.Start() }); app.on('before-quit', () => { @@ -101,8 +104,4 @@ if (!app.requestSingleInstanceLock() && !app.cfg.get('advanced.allowMultipleInst console.warn("[InstanceHandler] Existing Instance is Blocking Second Instance."); app.quit(); app.isQuiting = true -} - - - - \ No newline at end of file +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 00000000..a4db4c0d --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,17 @@ +{ + "compilerOptions": { + "target": "es6", + "module": "commonjs", + "noImplicitAny": true, + "strict": true, + "sourceMap": true, + "outDir": "./build", + "baseUrl": ".", + "paths": { + "*": ["node_modules/*"] + } + }, + "include": [ + "src/**/*" + ] +} \ No newline at end of file