From 393ed5a2105ed674e71a354564a8cf274c7b9200 Mon Sep 17 00:00:00 2001 From: Isaac Grynsztein Date: Thu, 20 Feb 2020 18:35:09 -0500 Subject: [PATCH] added skeleton code for future electron.js support added font swap to google font call simplified polyfills updated backend package.json info --- angular.json | 51 ++++++++++++++++++++++++++++++++++++++++++++ backend/package.json | 8 +++---- main.js | 41 +++++++++++++++++++++++++++++++++++ package.json | 5 ++++- src/index.html | 2 +- src/polyfills.ts | 4 ++-- 6 files changed, 103 insertions(+), 8 deletions(-) create mode 100644 main.js diff --git a/angular.json b/angular.json index 5cee9cb2..bb5d905b 100644 --- a/angular.json +++ b/angular.json @@ -65,6 +65,57 @@ "browserTarget": "youtube-dl-material:build" } }, + "serve-electron": { + "builder": "@angular-guru/electron-builder:dev-server", + "options": { + "browserTarget": "youtube-dl-material:build" + }, + "configurations": { + "production": { + "browserTarget": "youtube-dl-material:build:production" + } + } + }, + "electron": { + "builder": "@angular-guru/electron-builder:build", + "options": { + "outputPath": "dist", + "index": "src/index.html", + "main": "main.js", + "tsConfig": "src/tsconfig.app.json", + "polyfills": "src/polyfills.ts", + "assets": [ + "src/assets", + "src/favicon.ico", + "src/backend/audio", + "src/backend/video", + "src/backend" + ], + "styles": [ + "src/styles.scss" + ], + "scripts": [] + }, + "configurations": { + "production": { + "optimization": true, + "outputHashing": "all", + "sourceMap": false, + "extractCss": true, + "namedChunks": false, + "aot": true, + "extractLicenses": true, + "vendorChunk": false, + "buildOptimizer": true, + "fileReplacements": [ + { + "replace": "src/environments/environment.ts", + "with": "src/environments/environment.prod.ts" + } + ] + } + } + }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { diff --git a/backend/package.json b/backend/package.json index 7a54114e..be334093 100644 --- a/backend/package.json +++ b/backend/package.json @@ -1,21 +1,21 @@ { "name": "backend", "version": "1.0.0", - "description": "backend for hda", + "description": "backend for YoutubeDL-Material", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/Tzahi12345/hda-backend.git" + "url": "" }, "author": "Isaac Grynsztein", "license": "MIT", "bugs": { - "url": "https://github.com/Tzahi12345/hda-backend/issues" + "url": "" }, - "homepage": "https://github.com/Tzahi12345/hda-backend#readme", + "homepage": "", "dependencies": { "archiver": "^3.1.1", "async": "^3.1.0", diff --git a/main.js b/main.js new file mode 100644 index 00000000..3daecc29 --- /dev/null +++ b/main.js @@ -0,0 +1,41 @@ +const { app, BrowserWindow } = require('electron'); +const path = require('path'); +const url = require('url'); + +let win; + +function createWindow() { + win = new BrowserWindow({ width: 800, height: 600 }); + + // load the dist folder from Angular + win.loadURL( + url.format({ + pathname: path.join(__dirname, `/dist/index.html`), + protocol: 'file:', + slashes: true + }) + ); + + // The following is optional and will open the DevTools: + // win.webContents.openDevTools() + + win.on('closed', () => { + win = null; + }); +} + +app.on('ready', createWindow); + +// on macOS, closing the window doesn't quit the app +app.on('window-all-closed', () => { + if (process.platform !== 'darwin') { + app.quit(); + } +}); + +// initialize the app's main window +app.on('activate', () => { + if (win === null) { + createWindow(); + } +}); \ No newline at end of file diff --git a/package.json b/package.json index 023b897d..9270eb08 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,8 @@ "build": "ng build", "test": "ng test", "lint": "ng lint", - "e2e": "ng e2e" + "e2e": "ng e2e", + "electron": "ng build --base-href ./ && electron ." }, "private": true, "dependencies": { @@ -33,6 +34,7 @@ "rxjs-compat": "^6.0.0-rc.0", "tslib": "^1.10.0", "videogular2": "^7.0.1", + "web-animations-js": "^2.3.2", "zone.js": "~0.9.1" }, "devDependencies": { @@ -45,6 +47,7 @@ "@types/jasmine": "2.5.45", "@types/node": "~6.0.60", "codelyzer": "^5.0.1", + "electron": "^8.0.1", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", diff --git a/src/index.html b/src/index.html index dcab2f65..74a83f42 100644 --- a/src/index.html +++ b/src/index.html @@ -7,7 +7,7 @@ - + diff --git a/src/polyfills.ts b/src/polyfills.ts index 8dbf0988..019cf949 100644 --- a/src/polyfills.ts +++ b/src/polyfills.ts @@ -42,11 +42,11 @@ /** Evergreen browsers require these. **/ -import 'core-js/es6/reflect'; +// import 'core-js/es6/reflect'; /** ALL Firefox browsers require the following to support `@angular/animation`. **/ -// import 'web-animations-js'; // Run `npm install --save web-animations-js`. +import 'web-animations-js'; // Run `npm install --save web-animations-js`.