-
Notifications
You must be signed in to change notification settings - Fork 28
Feat Vue3 and Typescript #78
base: master
Are you sure you want to change the base?
Conversation
Update Vue code More vue upgrading Upgrade Hm Stuff So many tweaks Somewhat okay
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another thing you'll notice: Everything has been formatted with Prettier.
@@ -0,0 +1,2 @@ | |||
VITE_APP_HOSTNAME=noita-together.unicast.link | |||
VITE_APP_WS_PORT=6969 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
"@typescript-eslint/no-explicit-any": "off", | ||
"linebreak-style": "off", | ||
}, | ||
}; |
There was a problem hiding this comment.
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.
.gitattributes
Outdated
@@ -0,0 +1,2 @@ | |||
# Use LF everywhere | |||
* text eol=lf |
There was a problem hiding this comment.
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.
"Vue.volar", | ||
"Vue.vscode-typescript-vue-plugin" | ||
] | ||
} |
There was a problem hiding this comment.
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.
CONTRIBUTING.md
Outdated
|
||
|
||
master branch: Electron app | ||
mod branch: Noita together mod |
There was a problem hiding this comment.
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!
|
||
const version = ref(""); | ||
ipcRenderer.invoke("get-version").then((v) => (version.value = v)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, and beforeMount
just isn't needed anymore. You just slap whatever you want to do right in the code and done.
src/components/vRoomFlags.vue
Outdated
function randomizeSeed() { | ||
const seed = Math.floor(Math.random() * 4294967295) + 1; | ||
payload.value.world.sync_world_seed.value = seed; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The hack here has been replaced with something nicer
<div class="info-wrapper" v-if="user"> | ||
<!-- TODO show personal alert for user --> | ||
<Popper :hover="true" :interactive="true" class="info"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of manually doing tooltips, I just used that library.
}; | ||
}; | ||
|
||
const useStore = defineStore("store", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The store now looks way more like those new Vue components do.
- The state is just a
reactive
(andref
s can also be used) - Getters are
computed()
- Mutations are plain old functions, and are an obsolete concept
- Actions are plain old functions
|
||
function commit(type: keyof typeof mutations, payload) { | ||
return mutations[type](payload); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This commit
function and the one below only exists so that I didn't have to refactor quite as much. Eventually it can be removed.
keytar has been removed from externals?
Am about to have fun
Required fields are not allowed in proto3.
required bool locked = 7; | ||
} | ||
syntax = "proto3"; | ||
package NT; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What has changed in the protobuf file?
Well, first I had to move the syntax statement to the first line, so that it would get parsed at all.
Then, I had to shift nearly every single identifier by 1, so that nothing starts with zero.
And then I removed every single required
, since proto3 apparently doesn't support those anymore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes have been moved to a messages-updated.proto
file. ^
to this monstrosity
Not sure if I like this yet
One thing about the current design that I find odd is that the frontend |
Another tidbit that should probably be implemented: A loaded successfully message. |
i appreciate the effort put into this, but i'd rather keep on the versions of tooling i'm familiar with so I can continue maintaining this project. could you pull the feature changes out into a separate PR that uses the current versions of tooling? |
@soler91 Sure, I can do that. Though, I'll point out that the Typescript part of the tooling does let one catch a lot of mistakes. (See: Discord) The protobuf part is also pretty cursed at the moment, I'd love it if you could take a look at that eventually. The Vue composition API is mainly in there, because it works slightly better with Typescript, and admittedly due to personal preferences. I could change that part back to the options API. I can replace Pinia with Vuex again, shouldn't make much of a difference. Replacing Webpack with Vite, upgrading Electron builder, etc. should all be rather unnoticeable changes. |
For posterity, there are a few bugfixes in this PR as well Function not being called due to typoI found another cursed little bug that has evaded detection so far. noita-together/public/messages.proto Line 62 in 1583ecf
This is probably a typo. And that leads to Line 385 in 1583ecf
Modifying the default flagsThe room flags code sometimes just returns the default flags noita-together/src/store/index.js Lines 242 to 255 in 5fb4d5a
This can actually be observed: https://discord.com/channels/813249109208334386/813254974447419402/999373131904978965
And also, it modifies the object returned by a Vue computed. This seems questionable to say the least. noita-together/src/components/vRoomFlags.vue Line 119 in 5fb4d5a
Double escapingThe double escaping is probably really hard to observe, especially since the game doesn't aggressively throw errors. Line 162 in 5fb4d5a
Anyways, what happens there is:
const evt = JSON.stringify(obj)
if (!this.client) {
//console.log("[Game] Pushed code to queue.")
this.queue.push(evt)
return
} ...
Invalid protobuf fileThe canonical protobuf implementation doesn't accept the protobuf file.
noita-together/public/messages.proto Line 2 in 5fb4d5a
I'm guessing it's actually a proto2 file right now, since proto3 has other differences such as And many of the field numbers start with zero, which doesn't seem to be legal either
|
Anyways, I'll leave this pull request open indefinitely, but I wouldn't expect this to get merged anytime soon (or ever). |
(Oh neat, protobuf-ts is closer to being nice to use https://github.com/timostamm/protobuf-ts . They fixed one pretty big issue with the whole |
(Interesting, there is this ORM https://github.com/drizzle-team/drizzle-orm ) |
This is what the Vue 3 upgrade would look like.
Big changes that you'll probably notice
CONTRIBUTING.md
.proto
file which is actually compatible with protobuf 3. Shoutout to CyberChef for making this somewhat easy. I think it might be worthwhile to fix all the protobuf stuff at some point.electron/ipc.ts
and some more stuff
Surprisingly not big changes
One thing that I didn't touch, but am curious about: Should we use
style scoped
? https://vue-loader.vuejs.org/guide/scoped-css.html