Skip to content

Commit

Permalink
feat: boostrap runtime inside electron client
Browse files Browse the repository at this point in the history
  • Loading branch information
Yukaii committed Apr 23, 2023
1 parent 79cfead commit fb29964
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
1 change: 1 addition & 0 deletions apps/electron-client/package.json
Expand Up @@ -18,6 +18,7 @@
"start": "electron-forge start"
},
"dependencies": {
"@blastlauncher/runtime": "workspace:*",
"electron-squirrel-startup": "^1.0.0"
},
"devDependencies": {
Expand Down
22 changes: 20 additions & 2 deletions apps/electron-client/src/index.ts
@@ -1,4 +1,4 @@
import { app, BrowserWindow } from "electron";
import { app, BrowserWindow, utilityProcess } from "electron";

import installExtension, { REACT_DEVELOPER_TOOLS } from "electron-devtools-installer";
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Webpack
Expand Down Expand Up @@ -38,10 +38,28 @@ const createWindow = (): void => {
mainWindow.webContents.openDevTools();
};


let runtimeProcess: any;

const startRuntime = (): void => {
const modulePath = require.resolve('@blastlauncher/runtime/dist/run.js')
runtimeProcess = utilityProcess.fork(modulePath)
}

const stopRuntime = (): void => {
runtimeProcess.kill()
}

const onReady = (): void => {
startRuntime();

createWindow();
};

// 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.
app.on("ready", createWindow);
app.on("ready", onReady);

// 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
Expand Down
2 changes: 1 addition & 1 deletion ecosystem.config.js
Expand Up @@ -2,7 +2,7 @@ module.exports = {
apps: [
{
name: 'runtime',
script: "pnpm run start-runtime:dev",
script: "pnpm run watch-runtime",
},
{
name: 'client',
Expand Down
2 changes: 2 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fb29964

Please sign in to comment.