Skip to content

Commit

Permalink
Merge pull request #55 from cardano-scaling/react-refactor
Browse files Browse the repository at this point in the history
React refactor
  • Loading branch information
Quantumplation authored Oct 28, 2024
2 parents 90b8566 + 27cebf1 commit 147f523
Show file tree
Hide file tree
Showing 157 changed files with 4,376 additions and 7,346 deletions.
1 change: 1 addition & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
npx lint-staged
4 changes: 4 additions & 0 deletions .lintstagedrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"*/**/*.{js,jsx,ts,tsx}": ["eslint --fix", "eslint"],
"*/**/*.{json,css,md}": ["prettier --write"]
}
80 changes: 40 additions & 40 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# Hydra Doom
# React + TypeScript + Vite

Experiment of running Doom using a [Cardano Hydra head](https://github.com/cardano-scaling/hydra).
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.

## Manual startup
Currently, two official plugins are available:

This is using a forked version of [doom-wasm](https://github.com/cardano-scaling/doom-wasm), make sure to build it first and copy or symlink the build results:
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react/README.md) uses [Babel](https://babeljs.io/) for Fast Refresh
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh

``` shell
cp ../doom-wasm/src/websockets-doom.js assets/websockets-doom.js
cp ../doom-wasm/src/websockets-doom.wasm assets/websockets-doom.wasm
cp ../doom-wasm/src/websockets-doom.wasm.map assets/websockets-doom.wasm.map
```

Also, you need to copy the shareware version of [doom1.wad](https://doomwiki.org/wiki/DOOM1.WAD) to `./assets`:

```shell
curl https://distro.ibiblio.org/slitaz/sources/packages/d/doom1.wad -o assets/doom1.wad
```

The application requires connection to a [hydra-control-plane](https://github.com/cardano-scaling/hydra-control-plane) which provides managed Hydra head instances provided as `SERVER_URL` in the `.env` file.

Then to build & run:

```shell
npm install
npm start
```
## Expanding the ESLint configuration

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

There is a way to start all required processes using `nix` and `process-compose`:
- Configure the top-level `parserOptions` property like this:

``` shell
nix run
```js
export default tseslint.config({
languageOptions: {
// other options...
parserOptions: {
project: ['./tsconfig.node.json', './tsconfig.app.json'],
tsconfigRootDir: import.meta.dirname,
},
},
})
```

## Persistent sessions

If we want to keep using the same key and remote node configuration between runs, set the `PERSISTENT_SESSION=true` variable in the `.env` file before starting the dev web server.



### Local Development

To run the project locally (using the POO integration), you need to set a `CABINET_KEY` in the `.env` file. For example:

```sh
CABIENT_KEY=A610911D628D5475EFFBA5E80ED09D1260B49E6935C40E4195C4D4AA17963CBF
- Replace `tseslint.configs.recommended` to `tseslint.configs.recommendedTypeChecked` or `tseslint.configs.strictTypeChecked`
- Optionally add `...tseslint.configs.stylisticTypeChecked`
- Install [eslint-plugin-react](https://github.com/jsx-eslint/eslint-plugin-react) and update the config:

```js
// eslint.config.js
import react from 'eslint-plugin-react'

export default tseslint.config({
// Set the react version
settings: { react: { version: '18.3' } },
plugins: {
// Add the react plugin
react,
},
rules: {
// other rules...
// Enable its recommended rules
...react.configs.recommended.rules,
...react.configs['jsx-runtime'].rules,
},
})
```
Binary file removed assets/images/background-2.jpg
Binary file not shown.
Binary file removed assets/images/background.jpg
Binary file not shown.
Binary file removed assets/images/bg-0-5x.jpg
Binary file not shown.
Binary file removed assets/images/bg-1-0x.jpg
Binary file not shown.
Binary file removed assets/images/connect-wallet-button.png
Binary file not shown.
Binary file removed assets/images/doom-guy-1-0x.png
Binary file not shown.
Binary file removed assets/images/favicon.ico
Binary file not shown.
Binary file removed assets/images/favicon.png
Binary file not shown.
Binary file removed assets/images/hydra-text-1-0x.png
Binary file not shown.
Binary file removed assets/images/hydra_outline_small.png
Binary file not shown.
Binary file removed assets/images/logo.png
Binary file not shown.
Binary file removed assets/images/monster.jpg
Binary file not shown.
Binary file removed assets/images/play-doom-button.png
Binary file not shown.
Binary file removed assets/images/social-image-twitter.png
Binary file not shown.
Binary file removed assets/images/social-image.png
Binary file not shown.
1 change: 0 additions & 1 deletion assets/websockets-doom.wasm.map

This file was deleted.

36 changes: 36 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
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 eslintConfigPrettier from "eslint-config-prettier";
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";

export default tseslint.config(
{ ignores: ["dist"] },
{
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
eslintPluginPrettierRecommended,
],
files: ["**/*.{ts,tsx}"],
languageOptions: {
ecmaVersion: 2020,
globals: globals.browser,
},
plugins: {
"react-hooks": reactHooks,
"react-refresh": reactRefresh,
},
rules: {
...reactHooks.configs.recommended.rules,
...eslintConfigPrettier.rules,
"react-refresh/only-export-components": [
"warn",
{ allowConstantExport: true },
],
"@typescript-eslint/no-explicit-any": "off",
},
}
);
Binary file removed holding-page/assets/fonts/VT323-Regular.ttf
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed holding-page/assets/fonts/pixelifysans-bold.ttf
Binary file not shown.
Binary file removed holding-page/assets/images/bg-0-5x.jpg
Binary file not shown.
Binary file removed holding-page/assets/images/bg-1-0x.jpg
Binary file not shown.
Binary file removed holding-page/assets/images/bg-1-5x.jpg
Binary file not shown.
Binary file removed holding-page/assets/images/bg.webp
Binary file not shown.
Binary file removed holding-page/assets/images/doom-guy-1-0x.png
Binary file not shown.
Binary file removed holding-page/assets/images/doom-guy-1-5x.png
Binary file not shown.
Binary file removed holding-page/assets/images/favicon.png
Binary file not shown.
Binary file removed holding-page/assets/images/hydra-logo-2-0x.png
Binary file not shown.
Binary file removed holding-page/assets/images/hydra-text-1-0x.png
Binary file not shown.
Binary file removed holding-page/assets/images/hydra-text-1-5x.png
Binary file not shown.
Binary file removed holding-page/assets/images/social-image-twitter.png
Binary file not shown.
Binary file removed holding-page/assets/images/social-image.png
Binary file not shown.
Loading

0 comments on commit 147f523

Please sign in to comment.