Skip to content

Commit

Permalink
feat: add electron version for Linux
Browse files Browse the repository at this point in the history
add electron frontend using tauri-invoke-http
remove old incomplete dev-only electron version
  • Loading branch information
MichaelMakesGames committed Dec 9, 2024
1 parent 2b573df commit 76362fb
Show file tree
Hide file tree
Showing 149 changed files with 10,934 additions and 7,219 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/debug-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'ubuntu-22.04'
args: '-c src-tauri/tauri.electron-build.conf.json'
- platform: 'windows-latest'
args: ''

Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ jobs:
args: '--target x86_64-apple-darwin'
- platform: 'ubuntu-22.04'
args: ''
- platform: 'ubuntu-22.04'
args: '-c src-tauri/tauri.electron-build.conf.json'
- platform: 'windows-latest'
args: ''

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ node_modules
/out
/build
/.svelte-kit
/.vite
/package
.env
.env.*
Expand Down
10 changes: 1 addition & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,4 @@ Other interface icons from [Heroicons](https://heroicons.com), licensed under th

## Electron

There is an Electron version available for local development. Some changes to the package.json are required. You can run `electron-on.sh` to make those changes, then run `npm run dev`. When you are finished, run `electron-off.sh` to revert the changes to package.json.

This exists mostly for debugging in Chromium. The release builds all use Tauri. Currently, the Electron version lacks the following features:

- loading data (localization, emblems, colors) from Stellaris mods
- loading non-English Stellaris localization
- translator mode
- (temporarily) country emblems
- production builds
For Linux, there is a version of the app which uses Electron instead of WebkitGTK for the frontend. To run that version, run `npm run dev:electron`. This will not work for other operating systems.
4 changes: 0 additions & 4 deletions electron-off.sh

This file was deleted.

4 changes: 0 additions & 4 deletions electron-on.sh

This file was deleted.

14 changes: 0 additions & 14 deletions electron.vite.config.ts

This file was deleted.

3 changes: 2 additions & 1 deletion eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const extraFileExtensions = ['.svelte'];

/** @type {import('eslint').Linter.Config[]} */
export default [
{ ignores: ['.vite/**'] },
{ files: ['**/*.{ts}'] },
{ languageOptions: { globals: { ...globals.browser, ...globals.node } } },
pluginJs.configs.recommended,
Expand All @@ -28,7 +29,7 @@ export default [
// svelte
...eslintPluginSvelte.configs['flat/recommended'],
{
files: ['**/*.svelte'],
files: ['src/**/*.svelte'],
languageOptions: {
parserOptions: {
extraFileExtensions,
Expand Down
32 changes: 32 additions & 0 deletions forge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { VitePlugin } from '@electron-forge/plugin-vite';
import type { ForgeConfig } from '@electron-forge/shared-types';

const config: ForgeConfig = {
rebuildConfig: {},
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: 'src/electron/main.ts',
config: 'vite.electron-main.config.ts',
target: 'main',
},
{
entry: 'src/electron/preload.cjs',
config: 'vite.electron-preload.config.ts',
target: 'preload',
},
],
renderer: [
{
name: 'main_window',
config: 'vite.config.ts',
},
],
}),
],
};

export default config;
2 changes: 1 addition & 1 deletion src/renderer/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<!-- https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP -->
<meta
http-equiv="Content-Security-Policy"
content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' https://*.github.com https://discord.gg ipc://*"
content="default-src 'self'; script-src 'self' 'wasm-unsafe-eval'; style-src 'self' 'unsafe-inline'; img-src 'self' data: blob:; connect-src 'self' https://*.github.com https://discord.gg ipc://* http://localhost:*"
/>
</head>

Expand Down
4 changes: 2 additions & 2 deletions knip.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"$schema": "https://unpkg.com/knip@5/schema.json",
"entry": ["src/main/index.ts", "src/preload/index.ts", "src/renderer/src/main.ts"],
"entry": ["src/main.ts", "src/electron/main.ts", "src/electron/preload.cjs"],
"project": [
"*/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx}",
"src/**/*.{js,cjs,mjs,jsx,ts,cts,mts,tsx,svelte}"
],
"ignore": ["electron.vite.config.ts", "svelte.config.mjs"]
"ignoreDependencies": ["@electron-forge/cli", "@electron-forge/plugin-vite"]
}
Loading

0 comments on commit 76362fb

Please sign in to comment.