kenan238 / reblessed

A high-level terminal interface library for node.js.
MIT License
80 stars 9 forks source link

Typescriptify and refactor codebase #20

Closed zyriab closed 1 year ago

zyriab commented 1 year ago

[Work in progress] - Opening a draft so you can follow the changes as they come.

Note: we need to come up with a strategy as to not have an enormous PR. I'll see how I could refactor little by little and open small PRs that make sense!

Translating the codebase to TS and also refactoring to a more modern JS approach, using new features since the time the original code was written (classes, spread operators, ESM, etc...)

It's the way I write TS, might not be to your liking, I'm open to suggestions. Also, I tried to keep the original implementations ideas when I could (like using classes to replace the old school way of doing it used by OP) and I usually only change the actual implementations of methods or function when I think I've found a more elegant way or when a "new" feature can be used (e.g. helpers.merge using spread operator), it's possible that it will bug or that we will loose performance, will need proper testing.

I'm pretty busy so I don't know when that'll be mergeable, feel free to work on this PR yourself if you'd like. I'm planning on rewriting the files in the base directory lib and then attack the widgets, probably.

Also we will need to rework the tests at some point.

I took the liberty to update the copyright mention by changing the GH URL, blessed to reblessed and kept the original copyright with updated dates + mention of the original repo and author

zyriab commented 1 year ago

After rewriting part of the libs and the event + node widgets, I think the code is too convoluted and old school for this to be realistically doable by one person on their free time. I don't wan't to spend the little free time I got on dirty ass JS when my full-time TS job is boring enough :D

I think the best thing to do would be to either write good .d.ts files or rewrite and redesign the entire library, from scratch.

Writing the .d.ts will be quite challenging because the OP did not choose the variable names wisely and neither did he respected some coding and design practices that would have made this codebase maintainable and easy to discover (is that why he abandoned the project?)

If you are down to work seriously on a new TUI lib in TS from the ground up feel free to contact me about it but I'm not continuing on this PR.