Skip to content

Commit

Permalink
$$$ update $$$
Browse files Browse the repository at this point in the history
  • Loading branch information
darekf77 committed Apr 6, 2024
1 parent d2369ea commit 27c21a5
Show file tree
Hide file tree
Showing 4 changed files with 104 additions and 100 deletions.
31 changes: 16 additions & 15 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"name": "Launch Server standalone",
"program": "${workspaceFolder}/run.js",
"args": [
"port=4507",
"port=4506",
"--ENVoverride=%7B%0A%20%20%20%20%22clientProjectName%22%3A%20%22static-columns%22%0A%7D "
],
"runtimeArgs": [
Expand All @@ -18,19 +18,20 @@
]
},
{
"name": "Debugger with ng serve",
"type": "chrome",
"name": "Start electron app debug",
"type": "node",
"request": "launch",
"preLaunchTask": "Ng Serve",
"postDebugTask": "terminateall",
"sourceMaps": true,
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*",
"/./*": "${webRoot}/*",
"/tmp-src/*": "${webRoot}/*",
"/*": "*",
"/./~/*": "${webRoot}/node_modules/*"
"protocol": "inspector",
"cwd": "${workspaceFolder}",
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron",
"trace": "verbose",
"runtimeArgs": [
"--serve",
".",
"--remote-debugging-port=9876"
],
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
}
},
{
Expand All @@ -45,10 +46,10 @@
],
"compounds": [
{
"name": "Debug backend/frontend",
"name": "Debug Server + Electron App",
"configurations": [
"Launch Server standalone",
"Debugger with ng serve"
"Start electron app debug"
]
}
]
Expand Down
26 changes: 14 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"includeNodeModules": false,
"cliBuildNoDts": false,
"cliBuildObscure": false,
"cliBuildIncludeNodeModules": false
"cliBuildIncludeNodeModules": false,
"cliBuildUglify": false
},
"smartContainerTarget": "",
"type": "isomorphic-lib",
Expand Down Expand Up @@ -209,7 +210,7 @@
"firedev-storage": "~16.5.14",
"firedev-type-sql": "~16.5.14",
"firedev-typeorm": "~16.5.16",
"firedev-ui": "~16.5.14",
"firedev-ui": "~16.5.15",
"fkill": "6.1.0",
"font-awesome": "4.7.0",
"form-data": "4.0.0",
Expand Down Expand Up @@ -241,7 +242,7 @@
"joi": "17.9.2",
"jscodeshift": "0.6.3",
"json-stringify-safe": "5.0.1",
"json10": "~16.5.13",
"json10": "~16.5.14",
"json10-writer": "~16.5.22",
"json5": "2.2.1",
"json5-writer": "0.2.0",
Expand All @@ -251,7 +252,7 @@
"localforage": "1.10.0",
"lockfile": "1.0.4",
"lodash": "4.17.20",
"lodash-walk-object": "~16.5.13",
"lodash-walk-object": "~16.5.14",
"lowdb": "1.0.0",
"magic-renamer": "~16.5.15",
"material-design-icons": "3.0.1",
Expand All @@ -260,14 +261,14 @@
"mkdirp": "0.5.1",
"mocha": "10.2.0",
"moment": "2.29.3",
"morphi": "~16.5.13",
"morphi": "~16.5.14",
"ng-for-track-by-property": "16.0.1",
"ng-in-viewport": "15.0.2",
"ng-lock": "16.0.1",
"ng-packagr": "16.0.1",
"ng-talkback": "~16.5.14",
"ng-talkback": "~16.5.15",
"ng2-logger": "~16.5.24",
"ng2-rest": "~16.5.13",
"ng2-rest": "~16.5.14",
"ngx-ace-wrapper": "14.0.0",
"ngx-editor": "15.3.0",
"ngx-highlightjs": "9.0.0",
Expand All @@ -280,7 +281,7 @@
"ngx-scrolltop": "6.0.0",
"ngx-store": "3.1.1",
"ngx-typed-js": "2.1.1",
"node-cli-tester": "~16.5.14",
"node-cli-tester": "~16.5.15",
"node-localstorage": "2.1.6",
"node-notifier": "6.0.0",
"node-polyfill-webpack-plugin": "2.0.1",
Expand All @@ -307,7 +308,7 @@
"q": "1.5.1",
"rallax.js": "2.0.4",
"randomcolor": "0.5.3",
"record-replay-req-res-scenario": "~16.5.14",
"record-replay-req-res-scenario": "~16.5.15",
"reflect-metadata": "0.1.10",
"rimraf": "2.6.2",
"rxjs": "~7.8.0",
Expand All @@ -326,7 +327,7 @@
"systeminformation": "3.45.7",
"task.js": "0.1.5",
"threads": "1.7.0",
"tnp-cli": "~16.5.13",
"tnp-cli": "~16.5.15",
"tnp-config": "~16.5.33",
"tnp-core": "~16.6.29",
"tnp-db": "~16.5.15",
Expand All @@ -346,9 +347,10 @@
"uuid": "8.3.2",
"validator": "9.2.0",
"video.js": "8.3.0",
"vpn-split": "~16.5.15",
"vpn-split": "~16.5.18",
"watch": "1.0.2",
"yup": "1.1.1",
"zone.js": "~0.13.0"
}
},
"main": "dist/app.electron.js"
}
1 change: 1 addition & 0 deletions package.json_tnp.json5
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
'cliBuildNoDts': false,
'cliBuildObscure': false,
'cliBuildIncludeNodeModules': false,
'cliBuildUglify': false,
},

'smartContainerTarget': '',
Expand Down
146 changes: 73 additions & 73 deletions src/app.electron.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

import { CLIENT_DEV_NORMAL_APP_PORT, CLIENT_DEV_WEBSQL_APP_PORT } from './app.hosts';
import {
path,
//#region @backend
fse
//#endregion
path,
//#region @backend
fse
//#endregion
} from 'tnp-core';
//#region @backend
import { app, BrowserWindow, screen } from 'electron';
Expand All @@ -16,82 +16,82 @@ const websql = args.some(val => val === '--websql');

function createWindow(): BrowserWindow {

const size = screen.getPrimaryDisplay().workAreaSize;

// Create the browser window.
win = new BrowserWindow({
x: 0,
y: 0,
// autoHideMenuBar: true,
width: size.width / 2,
height: size.height / 2,
webPreferences: {
nodeIntegration: true,
allowRunningInsecureContent: (serve),
contextIsolation: false,
},
});
const size = screen.getPrimaryDisplay().workAreaSize;

// Create the browser window.
win = new BrowserWindow({
x: 0,
y: 0,
autoHideMenuBar: true,
width: size.width / 2,
height: size.height / 2,
webPreferences: {
nodeIntegration: true,
allowRunningInsecureContent: (serve),
contextIsolation: false,
},
});

if (serve) {
const debug = require('electron-debug');
debug();

require('electron-reloader')(module);
win.loadURL('http://localhost:' + (websql ? CLIENT_DEV_WEBSQL_APP_PORT : CLIENT_DEV_NORMAL_APP_PORT));
} else {
// Path when running electron executable
let pathIndex = './index.html';

if (fse.existsSync(path.join(__dirname, '../dist/index.html'))) {
// Path when running electron in local folder
pathIndex = '../dist/index.html';
}

if (serve) {
const debug = require('electron-debug');
debug();
const url = new URL(path.join('file:', __dirname, pathIndex));
win.loadURL(url.href);
}

require('electron-reloader')(module);
win.loadURL('http://localhost:' + (websql ? CLIENT_DEV_WEBSQL_APP_PORT : CLIENT_DEV_NORMAL_APP_PORT));
} else {
// Path when running electron executable
let pathIndex = './index.html';
// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store window
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
});

if (fse.existsSync(path.join(__dirname, '../dist/index.html'))) {
// Path when running electron in local folder
pathIndex = '../dist/index.html';
}
return win;
}

const url = new URL(path.join('file:', __dirname, pathIndex));
win.loadURL(url.href);
}
async function startElectron() {
try {
// 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.
// Added 400 ms to fix the black background issue while using transparent window. More detais at https://github.com/electron/electron/issues/15947
app.on('ready', () => setTimeout(createWindow, 400));

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

// Emitted when the window is closed.
win.on('closed', () => {
// Dereference the window object, usually you would store window
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
win = null;
app.on('activate', () => {
// On OS X 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 (win === null) {
createWindow();
}
});

return win;
} catch (e) {
// Catch Error
// throw e;
}

async function startElectron() {
try {
// 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.
// Added 400 ms to fix the black background issue while using transparent window. More detais at https://github.com/electron/electron/issues/15947
app.on('ready', () => setTimeout(createWindow, 400));

// Quit when all windows are closed.
app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit();
}
});

app.on('activate', () => {
// On OS X 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 (win === null) {
createWindow();
}
});

} catch (e) {
// Catch Error
// throw e;
}
}

export default startElectron;
//#endregion
startElectron();
//#endregion

0 comments on commit 27c21a5

Please sign in to comment.