Skip to content
This repository has been archived by the owner on Apr 29, 2023. It is now read-only.

Feat Vue3 and Typescript #78

Open
wants to merge 65 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
2651c14
Halfway done with the upgrade
stefnotch Jul 20, 2022
c074ebf
CRLF to LF
stefnotch Jul 20, 2022
9727371
Add missing stuff
stefnotch Jul 20, 2022
7d33ad3
Typescript go brr
stefnotch Jul 20, 2022
27c642c
More modernizing
stefnotch Jul 20, 2022
21fcb7d
Minor tweaks
stefnotch Jul 20, 2022
491dd7c
Funky flags
stefnotch Jul 20, 2022
ac3c027
More fixes
stefnotch Jul 20, 2022
ec3b4bf
Fix electron builder mistakes
stefnotch Jul 20, 2022
174668a
Figured out why env variables were cursed
stefnotch Jul 20, 2022
1233a7c
Fix build
stefnotch Jul 21, 2022
03485cf
Improve build type checking
stefnotch Jul 21, 2022
28ed818
Improve builds
stefnotch Jul 21, 2022
adf534e
Fix queue
stefnotch Jul 21, 2022
e203fce
Minor tweaks
stefnotch Jul 21, 2022
6f7a04d
Try out protobuf stuff
stefnotch Jul 21, 2022
755502d
Shift .proto Ids
stefnotch Jul 22, 2022
dd04712
Remove required .proto fileds
stefnotch Jul 22, 2022
dbad750
Protobuf Typescript WIP
stefnotch Jul 22, 2022
80a2678
Back to protobufjs
stefnotch Jul 22, 2022
06e2a8b
Trying out types
stefnotch Jul 22, 2022
b2b11b2
Sleek JSON doesn't work, so we're back
stefnotch Jul 23, 2022
84e93ed
Add old messages.proto
stefnotch Jul 23, 2022
309af29
Improve room creation
stefnotch Jul 23, 2022
fb261f9
Improve message handler type
stefnotch Jul 23, 2022
bcc46b0
Refactoring
stefnotch Jul 24, 2022
ce878a0
Refactor flags
stefnotch Jul 24, 2022
9aa9463
Fix death flag
stefnotch Jul 24, 2022
2a40c65
Fix room joining
stefnotch Jul 24, 2022
3ed423a
Fix stupid config mistake
stefnotch Jul 24, 2022
4696000
Minor polishing
stefnotch Jul 24, 2022
9e7125b
Minor tweaks
stefnotch Jul 25, 2022
ca1dec1
Update config
stefnotch Jul 26, 2022
ff4ff79
Maybe lowdb
stefnotch Jul 27, 2022
dd4f4df
Try out sqlite
stefnotch Jul 27, 2022
a5b772e
Try to async load sqlite
stefnotch Jul 27, 2022
5f1c2c2
Use database for game path
stefnotch Jul 27, 2022
287320d
Refactors
stefnotch Jul 27, 2022
9a4a4c3
Refactor
stefnotch Jul 27, 2022
2d1d4b1
Minor tweak
stefnotch Jul 27, 2022
ffb2847
Stuff
stefnotch Jul 27, 2022
b4057c0
I am debating the sanity of this
stefnotch Jul 28, 2022
f4f9b7e
Start experimenting with game saving implementation
stefnotch Jul 28, 2022
42d5435
Try out lowdb again
stefnotch Jul 28, 2022
2d2e8ee
Use lowdb
stefnotch Jul 28, 2022
58fba08
Better JSON serializing
stefnotch Jul 28, 2022
f03eda4
Prevent illegal imports
stefnotch Jul 28, 2022
6ed1d09
Move IPC stuff around
stefnotch Jul 28, 2022
998a8bd
Refactor gamemode a bit
stefnotch Jul 28, 2022
ce3e130
Start with game saving
stefnotch Jul 29, 2022
72124b2
Implement gold saving
stefnotch Jul 29, 2022
4a7b330
Save game flags
stefnotch Jul 29, 2022
9479cbd
Save the bank
stefnotch Jul 29, 2022
cb09c19
Fix gitattributes
stefnotch Jul 29, 2022
5e02704
Loading the bank
stefnotch Jul 29, 2022
9f52c62
Fix wrong type
stefnotch Jul 29, 2022
affdb77
Fix flags bug
stefnotch Jul 29, 2022
4110f03
Disgusting room flags loading workaround
stefnotch Jul 29, 2022
bd8e6c3
Fix build
stefnotch Jul 29, 2022
965323a
Update contributing guide
stefnotch Jul 29, 2022
bd3d90d
More contributing guide stuff
stefnotch Jul 29, 2022
2a3e7e2
Add todo comments
stefnotch Jul 29, 2022
d3ef915
Add more Typescript types
stefnotch Jul 30, 2022
adaec1b
Bump dependencies
stefnotch Jul 30, 2022
144c742
Fix bank sending
stefnotch Aug 2, 2022
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: 0 additions & 3 deletions .browserslistrc

This file was deleted.

2 changes: 2 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
VITE_APP_HOSTNAME=noita-together.unicast.link
VITE_APP_WS_PORT=6969
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I probably shouldn't commit the .env file?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, those are the renamed env variables

27 changes: 18 additions & 9 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,26 @@
module.exports = {
root: true,
env: {
node: true
es2021: true,
node: true,
browser: false,
},
'extends': [
'plugin:vue/essential',
'eslint:recommended'
extends: [
"eslint:recommended",
/** @see https://github.com/typescript-eslint/typescript-eslint/tree/master/packages/eslint-plugin#recommended-configs */
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 2020
ecmaVersion: 12,
sourceType: "module",
},
plugins: ["@typescript-eslint"],
ignorePatterns: ["node_modules/**", "**/dist/**"],
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off'
}
}
"no-console": process.env.NODE_ENV === "production" ? "warn" : "off",
"no-debugger": process.env.NODE_ENV === "production" ? "warn" : "off",
"@typescript-eslint/no-explicit-any": "off",
"linebreak-style": "off",
},
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that there's a second .eslintrc.js file in the src folder.

2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Use LF everywhere
* text eol=lf
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotta have those sane line endings. The Windows style "carriage return" line endings are weird.

5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
/node_modules
/dist

/vite-plugin-electron.log

# local env files
.env.local
Expand All @@ -15,12 +16,12 @@ pnpm-debug.log*

# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

#Electron-builder output
/dist_electron
/dist_electron
/release
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"Vue.volar",
"Vue.vscode-typescript-vue-plugin"
]
}
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those are the currently recommended Visual Studio Code plugins for working with Vue.
The old one, Vetur, isn't recommended anymore.

39 changes: 39 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Contributing


master branch: Electron app
mod branch: Noita together mod
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Look, we got a bit of documentation!



## Directory

```diff
+ ├─┬ electron
+ │ ├─┬ main
+ │ │ └── index.ts entry of Electron-main
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

background.js turned into index.ts

+ │ └─┬ preload
+ │ └── index.ts entry of Electron-preload
├─┬ src
│ └── main.ts entry of Electron-renderer
├── index.html
├── package.json
└── vite.config.ts
```

## 🚨 `dependencies` vs `devDependencies`

**Put Node.js packages in `dependencies`**

**e.g.** `electron-store` `sqlite3` `serilaport` `mongodb` ...others

**Put Web packages in `devDependencies`**

**e.g.** `vue` `vue-router` `vuex` `pinia` `element-plus` `ant-design-vue` `axios` ...others

See more 👉 [dependencies vs devDependencies](https://github.com/electron-vite/vite-plugin-electron-renderer#dependencies-vs-devdependencies)

## 🚨 Node.js ESM packages

**e.g.** `node-fetch` `execa` `got` ...

[👉 Using Node.js ESM packages in Electron-Renderer](https://github.com/electron-vite/vite-plugin-electron-renderer#-nodejs-esm-packages)
Binary file removed build/icons/icon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions electron-builder.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
if (process.env.VITE_APP_VERSION === undefined) {
const now = new Date();
process.env.VITE_APP_VERSION = `${now.getUTCFullYear() -
2000}.${now.getUTCMonth() + 1}.${now.getUTCDate()}-${now.getUTCHours() *
60 +
now.getUTCMinutes()}`;
}

/**
* @type {import('electron-builder').Configuration}
* @see https://www.electron.build/configuration/configuration
*/
const config = {
appId: "NoitaTogether",
asar: true,
nodeIntegration: true,
externals: ["keytar"],
productName: "Noita Together",
win: {
target: [
{
target: "nsis",
arch: ["x64"],
},
],
requestedExecutionLevel: "requireAdministrator", //eugh
artifactName: "${productName}_${version}.${ext}",
},
nsis: {
perMachine: true,
oneClick: false,
allowToChangeInstallationDirectory: true,
},
directories: {
output: "release/${version}",
},
files: ["dist"],
extraMetadata: {
version: process.env.VITE_APP_VERSION,
},
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Chances are that I subtly changed the config while upgrading. I guess this stuff would have to be tested.


module.exports = config;
8 changes: 8 additions & 0 deletions electron/electron-env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

declare namespace NodeJS {
interface ProcessEnv {
NODE_ENV: 'development' | 'production'
readonly VITE_DEV_SERVER_HOST: string
readonly VITE_DEV_SERVER_PORT: string
}
}
6 changes: 6 additions & 0 deletions electron/main/appEvent.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { webContents } from "electron";
export const appEvent = (event, data) => {
webContents.getAllWebContents().forEach((content) => {
content.send(event, data);
});
};
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The files like appEvent.js have been moved.

Loading