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

Migrate to x #328

Merged
merged 19 commits into from
Dec 31, 2023
Merged
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
11 changes: 11 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: ["eslint:recommended", "plugin:@typescript-eslint/recommended", "plugin:react-hooks/recommended"],
ignorePatterns: ["dist", ".eslintrc.cjs"],
parser: "@typescript-eslint/parser",
plugins: ["react-refresh"],
rules: {
"react-refresh/only-export-components": ["warn", { allowConstantExport: true }],
},
};
34 changes: 0 additions & 34 deletions .eslintrc.js

This file was deleted.

8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -59,7 +59,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -119,7 +119,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:

strategy:
matrix:
node-version: [18.x]
node-version: [20.x]

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -119,3 +119,5 @@ dataScripts/src/mapsToObj/gen
dataScripts/src/out

cypress/screenshots/

.DS_Store
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@ dataScripts/src/mapsToObj/gen
public
.vscode
src/services/SeedInfo/noita_random/*.js
src/services/SeedInfo/infoHandler/InfoProviders/*/*.mjs
src/services/SeedInfo/infoHandler/InfoProviders/*/*.d.ts
1 change: 1 addition & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 20.10.0
6 changes: 3 additions & 3 deletions .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
"name": "Linux",
"includePath": [
"${workspaceFolder}/**",
"~/.emscripten_cache/**"
"~/builds/emsdk/upstream/emscripten/cache/**"
],
"defines": [],
"compilerPath": "/usr/bin/gcc",
"cStandard": "c17",
"cppStandard": "c++20",
"intelliSenseMode": "linux-gcc-x64"
"intelliSenseMode": "linux-gcc-arm64"
}
],
"version": 4
}
}
6 changes: 5 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"files.associations": {
"*.mdx": "mdx",
"iostream": "cpp",
"__locale": "cpp",
"functional": "cpp",
Expand Down Expand Up @@ -86,7 +87,10 @@
"variant": "cpp",
"fstream": "cpp",
"span": "cpp",
"sstream": "cpp"
"sstream": "cpp",
"charconv": "cpp",
"iomanip": "cpp",
"format": "cpp"
},
"terminal.integrated.env.windows": {
"PATH": "${env:PATH};${workspaceFolder}\\node_modules\\.bin;${env:LOCALAPPDATA}\\Programs\\emsdk\\upstream\\emscripten"
Expand Down
40 changes: 8 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Current features include:

- The machine should have node installed (ideally v18.6+) and npm.
- Follow to <https://www.noitool.com/?profile=true> and link your patreon account. Under your patreon username, there will now be an id like `6456aff2478c4f8f91701018`
- Install `chokidar` (`npm install -g chokidar-cli`)

### Installing and connecting

Expand Down Expand Up @@ -50,13 +51,13 @@ git checkout master # for https://www.noitool.com
# git checkout develop # for https://dev.noitool.com
npm install --frozen-lockfile
npm run console-build
npm run console-search --userId 6456aff2478c4f8f91701018
npm run console-search --userId <your id>
```

console-search args (or env vars):

- `--url` `NOITOOL_URL`: default <https://www.noitool.com/>. Change to <https://dev.noitool.com/> for the dev build
- `--cores` `NOITOOL_CORES`: default `os.cpus()`. The amount of threads to use.
- `--cores` `NOITOOL_CORES`: default `os.cpus()`. The amount of cores to use.
- `--userId` `NOITOOL_USER_ID`: The user to connect as.
- `--exit` `NOITOOL_EXIT` default `false`. Add if you want the worker to exit if there are no more jobs.
- `--minRunTime` `NOITOOL_MIN_RUN_TIME` default `0`. This minimum amount of time (in seconds) that the worker will run for. If there are no more jobs, it will exit after this time. A value of 0 means that this is disabled.
Expand All @@ -70,7 +71,7 @@ Many parts of the critical core game functions that are needed to generate every
The c++ code is then compiled to wasm and is run in web workers (and partly in the main thread).
The performance improvements are 20-fold by transferring seed functions (like randoms and lc & ap recipes) from a typescript implementation to c++, even with the call overhead from worker -> wasm code.

For map generation, [wang tiles](https://github.com/nothings/stb/blob/master/stb_herringbone_wang_tile.h) are used. In lua/xml code, **A**RGB color formats are used for color targeting. In browsers, in general, RGB**A** is used. The transformed colors (in data json) use RGB**A** to homogenize color format.
In Noita, for map generation, [wang tiles](https://github.com/nothings/stb/blob/master/stb_herringbone_wang_tile.h) are used. In lua/xml code, **A**RGB color formats are used for color targeting. In browsers, in general, RGB**A** is used. The transformed colors (in data json) use RGB**A** to homogenize color format.

Credits to the developers of similar tools:
The code for finding LC and AP values was transferred from [noita_unicorn](https://github.com/SaphireLattice/noita_unicorn)'s `Program.cs` from c# to c++.
Expand All @@ -81,7 +82,6 @@ Also, I took inspiration from [cr4xy](https://cr4xy.dev/noita/) for extra featur
Prerequisites:

- [emscripten](https://emscripten.org/docs/getting_started/downloads.html) is installed
- `npm i -g google-closure-compiler`
- Node

After extracting noita wak, run
Expand All @@ -104,34 +104,10 @@ For emscripten, some edits need to be done to enable the closure compiler:

I recommend using the git repo to install emsdk. Install the latest version.

After, there are a small amount of changes that might need to be done:

- /usr/share/emscripten/tools/building.py

Here, go to line ~888
Verify that this is there:

```py
def get_closure_compiler():
# First check if the user configured a specific CLOSURE_COMPILER in thier settings
if config.CLOSURE_COMPILER:
return config.CLOSURE_COMPILER
```

- ~/.emscripten

Add the closure compiler path to the config.

```py
CLOSURE_COMPILER = ["<path to prefix>/bin/google-closure-compiler"]
```

To get the prefix, run:
Installation (after emscripten): `npm i`

```sh
npm config get prefix
```
When running `npm run dev` a build script will listen to changes in `.cpp` files and rebuild the wasm files.

Installation (after emscripten): `npm i`
For vscode to work with the c++ files, install the [c++ extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.cpptools).

Running: `npm run dev`
Then, go to `C/C++: Edit configurations (UI)` and add `<emscripten installation path>/upstream/emscripten/cache/**` to `Include path` so that vscode can find the emscripten headers.
37 changes: 32 additions & 5 deletions consoleBuild.js → consoleBuild.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,14 @@ const path = require("path");
// 2
// )
// );
if (!fs.existsSync("console-build")) {
fs.mkdirSync("console-build");
}

const mkDir = dir => {
if (!fs.existsSync(dir)) {
fs.mkdirSync(dir);
}
};

["console-build", "console-build/workers", "console-build/noita_random"].forEach(mkDir);

const pkg = require(path.resolve("./package.json"));

Expand All @@ -45,9 +50,10 @@ require("esbuild")
"./src/services/SeedInfo/infoHandler/index.ts",
"./src/consoleSearch.ts",
"./src/workers/seedSearcher.worker.node.ts",
"./src/services/imageActions/nodeImageActions.ts",
],
bundle: true,
loader: { ".wasm": "file", ".node": "copy", ".json": "copy" },
loader: { ".wasm": "file", ".node": "copy" },
platform: "node",
metafile: true,
sourcemap: true,
Expand All @@ -64,7 +70,7 @@ require("esbuild")
.then(() => {
fs.copyFileSync(
path.resolve(__dirname, "search.package.json"),
path.resolve(__dirname, "console-build", "package.json")
path.resolve(__dirname, "console-build", "package.json"),
);

{
Expand All @@ -85,4 +91,25 @@ require("esbuild")
result = result.replaceAll(`__dirname`, `import.meta.url`);
fs.writeFileSync(fixFile, result);
}

{
// Need to figure out how to correctly fix URL requires with esbuild
const fixFile = path.resolve(__dirname, "console-build", "workers/seedSearcher.worker.node.js");
let f = fs.readFileSync(fixFile, "utf8");
let result = f.replace("./nodeImageActions", "../services/imageActions/nodeImageActions.js");
fs.writeFileSync(fixFile, result);
}

{
fs.copyFileSync(
path.resolve(__dirname, "src/services/SeedInfo/noita_random/noita_random.wasm"),
path.resolve(__dirname, "console-build", "noita_random/noita_random.wasm"),
);
}
{
fs.copyFileSync(
path.resolve(__dirname, "src/services/SeedInfo/infoHandler/InfoProviders/Alchemy/Alchemy.wasm"),
path.resolve(__dirname, "console-build", "workers/Alchemy.wasm"),
);
}
});
83 changes: 0 additions & 83 deletions craco.config.js

This file was deleted.

Loading
Loading