mirror of
https://github.com/colanode/colanode.git
synced 2025-12-16 11:47:47 +01:00
Inception
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
.idea
|
||||||
|
.DS_Store
|
||||||
16
desktop/.eslintrc.json
Normal file
16
desktop/.eslintrc.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"env": {
|
||||||
|
"browser": true,
|
||||||
|
"es6": true,
|
||||||
|
"node": true
|
||||||
|
},
|
||||||
|
"extends": [
|
||||||
|
"eslint:recommended",
|
||||||
|
"plugin:@typescript-eslint/eslint-recommended",
|
||||||
|
"plugin:@typescript-eslint/recommended",
|
||||||
|
"plugin:import/recommended",
|
||||||
|
"plugin:import/electron",
|
||||||
|
"plugin:import/typescript"
|
||||||
|
],
|
||||||
|
"parser": "@typescript-eslint/parser"
|
||||||
|
}
|
||||||
94
desktop/.gitignore
vendored
Normal file
94
desktop/.gitignore
vendored
Normal file
@@ -0,0 +1,94 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# nuxt.js build output
|
||||||
|
.nuxt
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# Webpack
|
||||||
|
.webpack/
|
||||||
|
|
||||||
|
# Vite
|
||||||
|
.vite/
|
||||||
|
|
||||||
|
# Electron-Forge
|
||||||
|
out/
|
||||||
|
|
||||||
|
dist/
|
||||||
52
desktop/forge.config.ts
Normal file
52
desktop/forge.config.ts
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import type { ForgeConfig } from '@electron-forge/shared-types';
|
||||||
|
import { MakerSquirrel } from '@electron-forge/maker-squirrel';
|
||||||
|
import { MakerZIP } from '@electron-forge/maker-zip';
|
||||||
|
import { MakerDeb } from '@electron-forge/maker-deb';
|
||||||
|
import { MakerRpm } from '@electron-forge/maker-rpm';
|
||||||
|
import { VitePlugin } from '@electron-forge/plugin-vite';
|
||||||
|
import { FusesPlugin } from '@electron-forge/plugin-fuses';
|
||||||
|
import { FuseV1Options, FuseVersion } from '@electron/fuses';
|
||||||
|
|
||||||
|
const config: ForgeConfig = {
|
||||||
|
packagerConfig: {
|
||||||
|
asar: true,
|
||||||
|
},
|
||||||
|
rebuildConfig: {},
|
||||||
|
makers: [new MakerSquirrel({}), new MakerZIP({}, ['darwin']), new MakerRpm({}), new MakerDeb({})],
|
||||||
|
plugins: [
|
||||||
|
new VitePlugin({
|
||||||
|
// `build` can specify multiple entry builds, which can be Main process, Preload scripts, Worker process, etc.
|
||||||
|
// If you are familiar with Vite configuration, it will look really familiar.
|
||||||
|
build: [
|
||||||
|
{
|
||||||
|
// `entry` is just an alias for `build.lib.entry` in the corresponding file of `config`.
|
||||||
|
entry: 'src/main.ts',
|
||||||
|
config: 'vite.main.config.ts',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
entry: 'src/preload.ts',
|
||||||
|
config: 'vite.preload.config.ts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
renderer: [
|
||||||
|
{
|
||||||
|
name: 'main_window',
|
||||||
|
config: 'vite.renderer.config.ts',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}),
|
||||||
|
// Fuses are used to enable/disable various Electron functionality
|
||||||
|
// at package time, before code signing the application
|
||||||
|
new FusesPlugin({
|
||||||
|
version: FuseVersion.V1,
|
||||||
|
[FuseV1Options.RunAsNode]: false,
|
||||||
|
[FuseV1Options.EnableCookieEncryption]: true,
|
||||||
|
[FuseV1Options.EnableNodeOptionsEnvironmentVariable]: false,
|
||||||
|
[FuseV1Options.EnableNodeCliInspectArguments]: false,
|
||||||
|
[FuseV1Options.EnableEmbeddedAsarIntegrityValidation]: true,
|
||||||
|
[FuseV1Options.OnlyLoadAppFromAsar]: true,
|
||||||
|
}),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
export default config;
|
||||||
31
desktop/forge.env.d.ts
vendored
Normal file
31
desktop/forge.env.d.ts
vendored
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
export {}; // Make this a module
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
// This allows TypeScript to pick up the magic constants that's auto-generated by Forge's Vite
|
||||||
|
// plugin that tells the Electron app where to look for the Vite-bundled app code (depending on
|
||||||
|
// whether you're running in development or production).
|
||||||
|
const MAIN_WINDOW_VITE_DEV_SERVER_URL: string;
|
||||||
|
const MAIN_WINDOW_VITE_NAME: string;
|
||||||
|
|
||||||
|
namespace NodeJS {
|
||||||
|
interface Process {
|
||||||
|
// Used for hot reload after preload scripts.
|
||||||
|
viteDevServers: Record<string, import('vite').ViteDevServer>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
type VitePluginConfig = ConstructorParameters<typeof import('@electron-forge/plugin-vite').VitePlugin>[0];
|
||||||
|
|
||||||
|
interface VitePluginRuntimeKeys {
|
||||||
|
VITE_DEV_SERVER_URL: `${string}_VITE_DEV_SERVER_URL`;
|
||||||
|
VITE_NAME: `${string}_VITE_NAME`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module 'vite' {
|
||||||
|
interface ConfigEnv<K extends keyof VitePluginConfig = keyof VitePluginConfig> {
|
||||||
|
root: string;
|
||||||
|
forgeConfig: VitePluginConfig;
|
||||||
|
forgeConfigSelf: VitePluginConfig[K][number];
|
||||||
|
}
|
||||||
|
}
|
||||||
10
desktop/index.html
Normal file
10
desktop/index.html
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Neuron</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<script type="module" src="/src/renderer.ts"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
10061
desktop/package-lock.json
generated
Normal file
10061
desktop/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
46
desktop/package.json
Normal file
46
desktop/package.json
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
"name": "neuron-desktop",
|
||||||
|
"productName": "neuron-desktop",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "Neuron Desktop",
|
||||||
|
"main": ".vite/build/main.js",
|
||||||
|
"scripts": {
|
||||||
|
"start": "electron-forge start",
|
||||||
|
"package": "electron-forge package",
|
||||||
|
"make": "electron-forge make",
|
||||||
|
"publish": "electron-forge publish",
|
||||||
|
"lint": "eslint --ext .ts,.tsx ."
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@electron-forge/cli": "^7.4.0",
|
||||||
|
"@electron-forge/maker-deb": "^7.4.0",
|
||||||
|
"@electron-forge/maker-rpm": "^7.4.0",
|
||||||
|
"@electron-forge/maker-squirrel": "^7.4.0",
|
||||||
|
"@electron-forge/maker-zip": "^7.4.0",
|
||||||
|
"@electron-forge/plugin-auto-unpack-natives": "^7.4.0",
|
||||||
|
"@electron-forge/plugin-fuses": "^7.4.0",
|
||||||
|
"@electron-forge/plugin-vite": "^7.4.0",
|
||||||
|
"@electron/fuses": "^1.8.0",
|
||||||
|
"@types/react": "^18.3.3",
|
||||||
|
"@types/react-dom": "^18.3.0",
|
||||||
|
"@typescript-eslint/eslint-plugin": "^5.62.0",
|
||||||
|
"@typescript-eslint/parser": "^5.62.0",
|
||||||
|
"electron": "31.3.0",
|
||||||
|
"eslint": "^8.57.0",
|
||||||
|
"eslint-plugin-import": "^2.29.1",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"typescript": "~4.5.4",
|
||||||
|
"vite": "^5.3.5"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": {
|
||||||
|
"name": "Hakan Shehu",
|
||||||
|
"email": "hakan@neuronapp.io"
|
||||||
|
},
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"electron-squirrel-startup": "^1.0.1",
|
||||||
|
"react": "^18.3.1",
|
||||||
|
"react-dom": "^18.3.1"
|
||||||
|
}
|
||||||
|
}
|
||||||
5
desktop/src/components/app.tsx
Normal file
5
desktop/src/components/app.tsx
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import React from "react";
|
||||||
|
import { createRoot } from 'react-dom/client';
|
||||||
|
|
||||||
|
const root = createRoot(document.body);
|
||||||
|
root.render(<h2>Hello from React!</h2>);
|
||||||
53
desktop/src/main.ts
Normal file
53
desktop/src/main.ts
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
import { app, BrowserWindow } from 'electron';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
// Handle creating/removing shortcuts on Windows when installing/uninstalling.
|
||||||
|
if (require('electron-squirrel-startup')) {
|
||||||
|
app.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
const createWindow = () => {
|
||||||
|
// Create the browser window.
|
||||||
|
const mainWindow = new BrowserWindow({
|
||||||
|
width: 800,
|
||||||
|
height: 600,
|
||||||
|
webPreferences: {
|
||||||
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
// and load the index.html of the app.
|
||||||
|
if (MAIN_WINDOW_VITE_DEV_SERVER_URL) {
|
||||||
|
mainWindow.loadURL(MAIN_WINDOW_VITE_DEV_SERVER_URL);
|
||||||
|
} else {
|
||||||
|
mainWindow.loadFile(path.join(__dirname, `../renderer/${MAIN_WINDOW_VITE_NAME}/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.
|
||||||
|
app.on('ready', 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.
|
||||||
|
app.on('window-all-closed', () => {
|
||||||
|
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 (BrowserWindow.getAllWindows().length === 0) {
|
||||||
|
createWindow();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// In this file you can include the rest of your app's specific main process
|
||||||
|
// code. You can also put them in separate files and import them here.
|
||||||
2
desktop/src/preload.ts
Normal file
2
desktop/src/preload.ts
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
// See the Electron documentation for details on how to use preload scripts:
|
||||||
|
// https://www.electronjs.org/docs/latest/tutorial/process-model#preload-scripts
|
||||||
32
desktop/src/renderer.ts
Normal file
32
desktop/src/renderer.ts
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/**
|
||||||
|
* This file will automatically be loaded by vite and run in the "renderer" context.
|
||||||
|
* To learn more about the differences between the "main" and the "renderer" context in
|
||||||
|
* Electron, visit:
|
||||||
|
*
|
||||||
|
* https://electronjs.org/docs/tutorial/application-architecture#main-and-renderer-processes
|
||||||
|
*
|
||||||
|
* By default, Node.js integration in this file is disabled. When enabling Node.js integration
|
||||||
|
* in a renderer process, please be aware of potential security implications. You can read
|
||||||
|
* more about security risks here:
|
||||||
|
*
|
||||||
|
* https://electronjs.org/docs/tutorial/security
|
||||||
|
*
|
||||||
|
* To enable Node.js integration in this file, open up `main.ts` and enable the `nodeIntegration`
|
||||||
|
* flag:
|
||||||
|
*
|
||||||
|
* ```
|
||||||
|
* // Create the browser window.
|
||||||
|
* mainWindow = new BrowserWindow({
|
||||||
|
* width: 800,
|
||||||
|
* height: 600,
|
||||||
|
* webPreferences: {
|
||||||
|
* nodeIntegration: true
|
||||||
|
* }
|
||||||
|
* });
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
|
||||||
|
import './styles/index.css';
|
||||||
|
import './components/app'
|
||||||
|
|
||||||
|
console.log('👋 This message is being logged by "renderer.ts", included via Vite');
|
||||||
7
desktop/src/styles/index.css
Normal file
7
desktop/src/styles/index.css
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica,
|
||||||
|
Arial, sans-serif;
|
||||||
|
margin: auto;
|
||||||
|
max-width: 38rem;
|
||||||
|
padding: 2rem;
|
||||||
|
}
|
||||||
16
desktop/tsconfig.json
Normal file
16
desktop/tsconfig.json
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ESNext",
|
||||||
|
"module": "commonjs",
|
||||||
|
"allowJs": true,
|
||||||
|
"skipLibCheck": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"sourceMap": true,
|
||||||
|
"baseUrl": ".",
|
||||||
|
"outDir": "dist",
|
||||||
|
"moduleResolution": "node",
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"jsx": "react"
|
||||||
|
}
|
||||||
|
}
|
||||||
93
desktop/vite.base.config.ts
Normal file
93
desktop/vite.base.config.ts
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import { builtinModules } from 'node:module';
|
||||||
|
import type { AddressInfo } from 'node:net';
|
||||||
|
import type { ConfigEnv, Plugin, UserConfig } from 'vite';
|
||||||
|
import pkg from './package.json';
|
||||||
|
|
||||||
|
export const builtins = ['electron', ...builtinModules.map((m) => [m, `node:${m}`]).flat()];
|
||||||
|
|
||||||
|
export const external = [...builtins, ...Object.keys('dependencies' in pkg ? (pkg.dependencies as Record<string, unknown>) : {})];
|
||||||
|
|
||||||
|
export function getBuildConfig(env: ConfigEnv<'build'>): UserConfig {
|
||||||
|
const { root, mode, command } = env;
|
||||||
|
|
||||||
|
return {
|
||||||
|
root,
|
||||||
|
mode,
|
||||||
|
build: {
|
||||||
|
// Prevent multiple builds from interfering with each other.
|
||||||
|
emptyOutDir: false,
|
||||||
|
// 🚧 Multiple builds may conflict.
|
||||||
|
outDir: '.vite/build',
|
||||||
|
watch: command === 'serve' ? {} : null,
|
||||||
|
minify: command === 'build',
|
||||||
|
},
|
||||||
|
clearScreen: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getDefineKeys(names: string[]) {
|
||||||
|
const define: { [name: string]: VitePluginRuntimeKeys } = {};
|
||||||
|
|
||||||
|
return names.reduce((acc, name) => {
|
||||||
|
const NAME = name.toUpperCase();
|
||||||
|
const keys: VitePluginRuntimeKeys = {
|
||||||
|
VITE_DEV_SERVER_URL: `${NAME}_VITE_DEV_SERVER_URL`,
|
||||||
|
VITE_NAME: `${NAME}_VITE_NAME`,
|
||||||
|
};
|
||||||
|
|
||||||
|
return { ...acc, [name]: keys };
|
||||||
|
}, define);
|
||||||
|
}
|
||||||
|
|
||||||
|
export function getBuildDefine(env: ConfigEnv<'build'>) {
|
||||||
|
const { command, forgeConfig } = env;
|
||||||
|
const names = forgeConfig.renderer.filter(({ name }) => name != null).map(({ name }) => name!);
|
||||||
|
const defineKeys = getDefineKeys(names);
|
||||||
|
const define = Object.entries(defineKeys).reduce((acc, [name, keys]) => {
|
||||||
|
const { VITE_DEV_SERVER_URL, VITE_NAME } = keys;
|
||||||
|
const def = {
|
||||||
|
[VITE_DEV_SERVER_URL]: command === 'serve' ? JSON.stringify(process.env[VITE_DEV_SERVER_URL]) : undefined,
|
||||||
|
[VITE_NAME]: JSON.stringify(name),
|
||||||
|
};
|
||||||
|
return { ...acc, ...def };
|
||||||
|
}, {} as Record<string, any>);
|
||||||
|
|
||||||
|
return define;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pluginExposeRenderer(name: string): Plugin {
|
||||||
|
const { VITE_DEV_SERVER_URL } = getDefineKeys([name])[name];
|
||||||
|
|
||||||
|
return {
|
||||||
|
name: '@electron-forge/plugin-vite:expose-renderer',
|
||||||
|
configureServer(server) {
|
||||||
|
process.viteDevServers ??= {};
|
||||||
|
// Expose server for preload scripts hot reload.
|
||||||
|
process.viteDevServers[name] = server;
|
||||||
|
|
||||||
|
server.httpServer?.once('listening', () => {
|
||||||
|
const addressInfo = server.httpServer!.address() as AddressInfo;
|
||||||
|
// Expose env constant for main process use.
|
||||||
|
process.env[VITE_DEV_SERVER_URL] = `http://localhost:${addressInfo?.port}`;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
export function pluginHotRestart(command: 'reload' | 'restart'): Plugin {
|
||||||
|
return {
|
||||||
|
name: '@electron-forge/plugin-vite:hot-restart',
|
||||||
|
closeBundle() {
|
||||||
|
if (command === 'reload') {
|
||||||
|
for (const server of Object.values(process.viteDevServers)) {
|
||||||
|
// Preload scripts hot reload.
|
||||||
|
server.ws.send({ type: 'full-reload' });
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Main process hot restart.
|
||||||
|
// https://github.com/electron/forge/blob/v7.2.0/packages/api/core/src/api/start.ts#L216-L223
|
||||||
|
process.stdin.emit('data', 'rs');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
30
desktop/vite.main.config.ts
Normal file
30
desktop/vite.main.config.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import type { ConfigEnv, UserConfig } from 'vite';
|
||||||
|
import { defineConfig, mergeConfig } from 'vite';
|
||||||
|
import { getBuildConfig, getBuildDefine, external, pluginHotRestart } from './vite.base.config';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig((env) => {
|
||||||
|
const forgeEnv = env as ConfigEnv<'build'>;
|
||||||
|
const { forgeConfigSelf } = forgeEnv;
|
||||||
|
const define = getBuildDefine(forgeEnv);
|
||||||
|
const config: UserConfig = {
|
||||||
|
build: {
|
||||||
|
lib: {
|
||||||
|
entry: forgeConfigSelf.entry!,
|
||||||
|
fileName: () => '[name].js',
|
||||||
|
formats: ['cjs'],
|
||||||
|
},
|
||||||
|
rollupOptions: {
|
||||||
|
external,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [pluginHotRestart('restart')],
|
||||||
|
define,
|
||||||
|
resolve: {
|
||||||
|
// Load the Node.js entry.
|
||||||
|
mainFields: ['module', 'jsnext:main', 'jsnext'],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
return mergeConfig(getBuildConfig(forgeEnv), config);
|
||||||
|
});
|
||||||
29
desktop/vite.preload.config.ts
Normal file
29
desktop/vite.preload.config.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import type { ConfigEnv, UserConfig } from 'vite';
|
||||||
|
import { defineConfig, mergeConfig } from 'vite';
|
||||||
|
import { getBuildConfig, external, pluginHotRestart } from './vite.base.config';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig((env) => {
|
||||||
|
const forgeEnv = env as ConfigEnv<'build'>;
|
||||||
|
const { forgeConfigSelf } = forgeEnv;
|
||||||
|
const config: UserConfig = {
|
||||||
|
build: {
|
||||||
|
rollupOptions: {
|
||||||
|
external,
|
||||||
|
// Preload scripts may contain Web assets, so use the `build.rollupOptions.input` instead `build.lib.entry`.
|
||||||
|
input: forgeConfigSelf.entry!,
|
||||||
|
output: {
|
||||||
|
format: 'cjs',
|
||||||
|
// It should not be split chunks.
|
||||||
|
inlineDynamicImports: true,
|
||||||
|
entryFileNames: '[name].js',
|
||||||
|
chunkFileNames: '[name].js',
|
||||||
|
assetFileNames: '[name].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
plugins: [pluginHotRestart('reload')],
|
||||||
|
};
|
||||||
|
|
||||||
|
return mergeConfig(getBuildConfig(forgeEnv), config);
|
||||||
|
});
|
||||||
24
desktop/vite.renderer.config.ts
Normal file
24
desktop/vite.renderer.config.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import type { ConfigEnv, UserConfig } from 'vite';
|
||||||
|
import { defineConfig } from 'vite';
|
||||||
|
import { pluginExposeRenderer } from './vite.base.config';
|
||||||
|
|
||||||
|
// https://vitejs.dev/config
|
||||||
|
export default defineConfig((env) => {
|
||||||
|
const forgeEnv = env as ConfigEnv<'renderer'>;
|
||||||
|
const { root, mode, forgeConfigSelf } = forgeEnv;
|
||||||
|
const name = forgeConfigSelf.name ?? '';
|
||||||
|
|
||||||
|
return {
|
||||||
|
root,
|
||||||
|
mode,
|
||||||
|
base: './',
|
||||||
|
build: {
|
||||||
|
outDir: `.vite/renderer/${name}`,
|
||||||
|
},
|
||||||
|
plugins: [pluginExposeRenderer(name)],
|
||||||
|
resolve: {
|
||||||
|
preserveSymlinks: true,
|
||||||
|
},
|
||||||
|
clearScreen: false,
|
||||||
|
} as UserConfig;
|
||||||
|
});
|
||||||
129
server/.gitignore
vendored
Normal file
129
server/.gitignore
vendored
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
.pnpm-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# Snowpack dependency directory (https://snowpack.dev/)
|
||||||
|
web_modules/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Optional stylelint cache
|
||||||
|
.stylelintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variable files
|
||||||
|
.env
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
|
.env.local
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
.parcel-cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
out
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# vuepress v2.x temp and cache directory
|
||||||
|
.temp
|
||||||
|
|
||||||
|
# Docusaurus cache and generated files
|
||||||
|
.docusaurus
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# yarn v2
|
||||||
|
.yarn/cache
|
||||||
|
.yarn/unplugged
|
||||||
|
.yarn/build-state.yml
|
||||||
|
.yarn/install-state.gz
|
||||||
|
.pnp.*
|
||||||
1457
server/package-lock.json
generated
Normal file
1457
server/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
24
server/package.json
Normal file
24
server/package.json
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
{
|
||||||
|
"name": "neuron-server",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"main": "src/index.ts",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc",
|
||||||
|
"start": "node dist/index.js",
|
||||||
|
"dev": "nodemon --watch src --exec ts-node src/index.ts"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"description": "",
|
||||||
|
"devDependencies": {
|
||||||
|
"@types/express": "^4.17.21",
|
||||||
|
"@types/node": "^22.0.0",
|
||||||
|
"nodemon": "^3.1.4",
|
||||||
|
"ts-node": "^10.9.2",
|
||||||
|
"typescript": "^5.5.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"express": "^4.19.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
12
server/src/index.ts
Normal file
12
server/src/index.ts
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
import express, { Request, Response } from 'express';
|
||||||
|
|
||||||
|
const app = express();
|
||||||
|
const port = 3000;
|
||||||
|
|
||||||
|
app.get('/', (req: Request, res: Response) => {
|
||||||
|
res.send('Hello World!');
|
||||||
|
});
|
||||||
|
|
||||||
|
app.listen(port, () => {
|
||||||
|
console.log(`Server is running at http://localhost:${port}`);
|
||||||
|
});
|
||||||
10
server/tsconfig.json
Normal file
10
server/tsconfig.json
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "ES6",
|
||||||
|
"module": "commonjs",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"rootDir": "./src",
|
||||||
|
"strict": true,
|
||||||
|
"esModuleInterop": true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user