Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP - DO NOT MERGE] - Electron app #125

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions apps/desktop-app/.babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-react"]
}
2 changes: 2 additions & 0 deletions apps/desktop-app/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
15 changes: 15 additions & 0 deletions apps/desktop-app/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = {
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest", // Allows the use of modern ECMAScript features
sourceType: "module", // Allows for the use of imports
},
extends: ["plugin:@typescript-eslint/recommended"], // Uses the linting rules from @typescript-eslint/eslint-plugin
env: {
node: true, // Enable Node.js global variables
},
rules: {
"@typescript-eslint/no-empty-function": "off",
"no-empty-function": "off",
}
};
2 changes: 2 additions & 0 deletions apps/desktop-app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules/
dist/
30 changes: 30 additions & 0 deletions apps/desktop-app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<script type="module">
// Note that you're importing it via import.meta.env
const GTM_ID = import.meta.env.VITE_GTM_ID;

// The rest of your GTM script goes here, with GTM_ID replaced with your actual ID.
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.src = "https://www.googletagmanager.com/gtm.js?id=" + i + dl;
f.parentNode.insertBefore(j, f);
})(window, document, "script", "dataLayer", GTM_ID);
</script>
<link href="/fonts.css" rel="stylesheet" />
<title>Miku.gg</title>
</head>
<body class="scrollbar">
<div id="root"></div>
<script type="module" src="/src/index.tsx"></script>
</body>
</html>
73 changes: 73 additions & 0 deletions apps/desktop-app/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
const http = require('http');
const { exec } = require('child_process');

const { app, BrowserWindow } = require('electron');

function createWindow() {
console.log('Starting Vite server...');
const serverProcess = exec('pnpm start', (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}

console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});

serverProcess.stdout.on('data', (data) => {
console.log(`stdout: ${data}`);
});

serverProcess.stderr.on('data', (data) => {
console.error(`stderr: ${data}`);
});

serverProcess.on('error', (error) => {
console.error(`exec error: ${error}`);
});

// Check if the server is running
const checkServer = setInterval(() => {
http
.get('http://localhost:8182/index.html', (res) => {
const { statusCode } = res;
console.log('Server is running...', statusCode, res.headers['content-type'], res.headers['content-length']);

if (statusCode === 200) {
clearInterval(checkServer);

const win = new BrowserWindow({
width: 1200,
height: 600,
webPreferences: {
contextIsolation: true,
webSecurity: false, // disable webSecurity
allowRunningInsecureContent: true, // allow running insecure content
},
});

win.loadURL('http://localhost:8182');
}
})
.on('error', (err) => {
console.log('Waiting for the server start...', err);
});
}, 2000);
}

app.whenReady().then(() => {
createWindow();

app.on('activate', () => {
if (BrowserWindow.getAllWindows().length === 0) {
createWindow();
}
});
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') {
app.quit();
}
});
137 changes: 137 additions & 0 deletions apps/desktop-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
{
"name": "@mikugg/desktop-app",
"version": "0.1.0",
"private": true,
"description": "",
"repository": {
"type": "git",
"url": "https://github.com/miku-gg/miku.git",
"directory": "apps/desktop-app"
},
"main": "main.js",
"types": "dist/index.d.ts",
"files": [
"dist/**/*"
],
"build": {
"appId": "com.mikugg.desktop",
"productName": "MikuGG",
"asar": true,
"files": [
"dist/**/*",
"build/**/*",
"node_modules/**/*",
"package.json",
"main.js"
],
"directories": {
"buildResources": "./public",
"output": "release/${version}"
},
"win": {
"target": [
{
"target": "nsis",
"arch": [
"x64"
]
}
],
"icon": "./public/logo.png"
},
"mac": {
"target": "dmg",
"icon": "./public/logo.png"
},
"linux": {
"target": "AppImage",
"icon": "./public/logo.png",
"category": "Utility"
}
},
"scripts": {
"build": "vite build",
"start": "vite --host",
"lint": "eslint . --ext .tsx",
"electron": "electron .",
"pack": "electron-builder --dir",
"dist": "electron-builder"
},
"devDependencies": {
"@babel/core": "^7.21.3",
"@babel/preset-env": "^7.20.2",
"@babel/preset-react": "^7.18.6",
"@babel/register": "^7.21.0",
"@originjs/vite-plugin-commonjs": "^1.0.3",
"@types/lodash.clonedeep": "^4.5.9",
"@types/lodash.debounce": "^4.0.9",
"@types/node": "^18.14.1",
"@types/react": "^18.2.45",
"@types/react-dom": "^18.2.18",
"@types/utf8": "^3.0.1",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vitejs/plugin-react": "^3.1.0",
"electron": "^16.0.0",
"eslint": "^8.32.0",
"fs": "0.0.1-security",
"path": "^0.12.7",
"react-dom": "^18.2.0",
"sass": "^1.59.3",
"ts-node": "^10.9.1",
"typescript": "^4.9.4",
"vite": "^4.0.0",
"electron-builder": "^24.13.3"
},
"dependencies": {
"@aws-crypto/crc32": "^4.0.0",
"@ipld/dag-pb": "^4.0.2",
"@mikugg/bot-utils": "workspace:^",
"@mikugg/guidance": "workspace:^",
"@mikugg/ui-kit": "workspace:^",
"@primer/octicons-react": "^17.12.0",
"@reactflow/node-resizer": "^2.2.9",
"@reduxjs/toolkit": "^2.0.1",
"@types/axios": "^0.14.0",
"@types/base-64": "^1.0.0",
"@types/polycrc": "^0.1.0",
"@types/prop-types": "^15.7.5",
"@types/uuid": "^9.0.1",
"axios": "^1.2.4",
"base-64": "^1.0.0",
"buffer": "^6.0.3",
"classnames": "^2.3.2",
"digest": "link:multiformats/hashes/digest",
"ipfs-only-hash": "^4.0.0",
"ipld-dag-pb": "^0.22.3",
"lodash.clonedeep": "^4.5.0",
"lodash.debounce": "^4.0.8",
"multiformats": "^11.0.2",
"png-chunk-text": "^1.0.0",
"png-chunks-extract": "^1.0.0",
"prop-types": "^15.8.1",
"query-string": "^8.1.0",
"react": "^18.2.0",
"react-icons": "^4.12.0",
"react-redux": "^9.0.4",
"react-toastify": "^9.1.1",
"reactflow": "^11.10.1",
"remove": "^0.1.5",
"utf8": "^3.0.0",
"uuid": "^9.0.0",
"vite-plugin-plain-text": "^1.4.2"
},
"gitHead": "fdedec3c8725dfd89c7062c0115ca23c1645f863",
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added apps/desktop-app/public/favicon.ico
Binary file not shown.
Loading
Loading