Skip to content
Open
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 rusty-rays-desktop/.env-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# cross-env is used to conditionally set the SPA_SRC=vite to load react app from the vite server, otherwise use html

VITE_ENV=development
27 changes: 27 additions & 0 deletions rusty-rays-desktop/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
build
dist-ssr
*.local
.env
.env.*

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
1 change: 1 addition & 0 deletions rusty-rays-desktop/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
24.11
27 changes: 27 additions & 0 deletions rusty-rays-desktop/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules/
dist/
build/
dist-ssr/
*.local
.env
.env.*

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea/
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
3 changes: 3 additions & 0 deletions rusty-rays-desktop/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
73 changes: 73 additions & 0 deletions rusty-rays-desktop/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# React + TypeScript + Vite

This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

Currently, two official plugins are available:

- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

## React Compiler

The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).

## Expanding the ESLint configuration

If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:

```js
export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...

// Remove tseslint.configs.recommended and replace with this
tseslint.configs.recommendedTypeChecked,
// Alternatively, use this for stricter rules
tseslint.configs.strictTypeChecked,
// Optionally, add this for stylistic rules
tseslint.configs.stylisticTypeChecked,

// Other configs...
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.vite.renderer.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);
```

You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:

```js
// eslint.config.js
import reactX from 'eslint-plugin-react-x';
import reactDom from 'eslint-plugin-react-dom';

export default defineConfig([
globalIgnores(['dist']),
{
files: ['**/*.{ts,tsx}'],
extends: [
// Other configs...
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
languageOptions: {
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.vite.renderer.json'],
tsconfigRootDir: import.meta.dirname,
},
// other options...
},
},
]);
```
75 changes: 75 additions & 0 deletions rusty-rays-desktop/esbuild.run.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import esbuild from 'esbuild';
import { mkdir } from 'node:fs/promises';
import { builtinModules } from 'node:module';
import { resolve } from 'path';
import { fileURLToPath } from 'url';
import path from 'path';
import copy from 'esbuild-plugin-copy';

const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);

async function main() {
// Ensure dist directory exists
try {
await mkdir('build');
} catch {}

// Shared config for both main and preload builds
const sharedConfig = {
alias: {
'#': resolve(__dirname, 'src'),
},
platform: 'node',
format: 'esm', // Change to "cjs" if you prefer CJS output
target: 'es2023',
bundle: true,
sourcemap: true,
minify: false,
external: [
'electron',
...builtinModules.map((m) => `node:${m}`),
...builtinModules,
],
};

// Build main process
await esbuild.build({
...sharedConfig,
entryPoints: ['src/main.ts'],
outfile: 'build/index.js',
plugins: [
copy({
assets: {
from: [
resolve(
__dirname,
'node_modules',
'rusty-rays-napi-node',
'dist',
'bindings',
'*',
),
],
to: [resolve(__dirname, 'build/bindings')],
},
verbose: true,
}),
],
});

// Build preload script
await esbuild.build({
...sharedConfig,
entryPoints: ['src/preload.ts'],
outfile: 'build/preload.js',
});

console.log('Built main → build/index.js');
console.log('Built preload → build/preload.js');
}

main().catch((err) => {
console.error(err);
process.exit(1);
});
59 changes: 59 additions & 0 deletions rusty-rays-desktop/eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import js from '@eslint/js';
import globals from 'globals';
import reactHooks from 'eslint-plugin-react-hooks';
import reactRefresh from 'eslint-plugin-react-refresh';
import tseslint from 'typescript-eslint';
import reactX from 'eslint-plugin-react-x';
import reactDom from 'eslint-plugin-react-dom';
import { defineConfig, globalIgnores } from 'eslint/config';

export default defineConfig([
globalIgnores(['dist']),
{
rules: {
semi: ['error', 'always'],
quotes: ['error', 'single', { avoidEscape: true }],
'restrict-template-expressions': [
'error',
{
allowNumber: true
}
]
},
files: ['src/**/*.{ts,tsx}'],
extends: [
js.configs.recommended,
tseslint.configs.strictTypeChecked,
reactHooks.configs.flat.recommended,
reactRefresh.configs.vite,
// Enable lint rules for React
reactX.configs['recommended-typescript'],
// Enable lint rules for React DOM
reactDom.configs.recommended,
],
settings: {
'import/resolver': {
typescript: {
project: [
'./tsconfig.node.json',
'./tsconfig.vite.renderer.json',
'./tsconfig.electron.main.json',
],
alwaysTryTypes: true,
},
},
},
languageOptions: {
parserOptions: {
project: [
'./tsconfig.node.json',
'./tsconfig.vite.renderer.json',
'./tsconfig.electron.main.json',
],
tsconfigRootDir: import.meta.dirname,
},
ecmaVersion: 2023,
globals: globals.browser,
},
},
]);
Loading