-
-
Notifications
You must be signed in to change notification settings - Fork 229
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
refactor!: better cross runtime support #97
Conversation
removes node-forge and uuid in favor of Web APIs
To aid with #93 I will make all my changes in TypeScript instead. This is the first step into making that happen. Used: https://github.com/wessberg/cjstoesm
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 now realize that this is going to cause massive merge conflicts with #93, but how bad could it be 😅
Bring this PR up to speed with #93
Maybe we could work on a custom implementation of EventEmitter? It seems quite simple and would probably be better compared to the verbosity & weirdness of the EventTarget API. |
Haha there's already a quite big conflict due to 68cb841 (which was an inevitable change as we had lots of dead code laying around). I guess we could help but unfortunately he's working on a branch outside of the project. |
this is untested! should remove idb as dependecy.
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.
How about this for EventEmitter? Best of both worlds haha
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.
Awesome!
Initial TS support for parsers as per #93 This adds several type safety checks to the parser which'll help to ensure valid data is returned by the parser.
Bring more in line with the existing implementations & make less verbose
I was overcomplicating things, this is much simpler and compatible with the existing JS API
Again, this also does some work for #93
I'm going quite out of the scope of this PR by doing so much TS conversion too, but I cannot write my new changes in TS without then also converting some of the other parts of the project to TS too. |
At this point this probably supersedes @MasterOfBob777's PR. |
There's no way I'm rewriting all the parsers to TS in this PR though, so there's still a lot of work to be done if we want the entire codebase to be TS, for now I've enabled allowJS in the tsconfig |
Wow! This is very cool! As @Wykerd mentioned I do think my PR has its place, but I think it is probably best to wait until this PR is completed to avoid merge conflict hell. |
I think Ex: //...
// Triggers the auth event and asks the user to authorize the authentication.
await yt.session.signIn(undefined);
// This will return true even though authorization hasn't been granted yet.
// In fact, this should not be printed at all since the auth flow hasn't finished and any InnerTube call will inevitably fail.
console.log(yt.session.logged_in); |
It does not, it only waits until the first auth event is fired with the login code |
Should I make it wait instead? Probably makes more sense if it does. |
Yup, not doing so would probably cause some confusion. |
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.
Just a few small comments I had. Nothing that seem like a huge issue, or a glaring bug, but since this a large PR I most definitely missed something, and frankly I don't have a large amount of experience with the library.
This also splits the 'auth' event up into 3 distinct events: - 'auth' -> fired on success - 'auth-pending' -> fired when pending authentication - 'auth-error' -> fired when an error occurred
I do think there will be some small bugs that slipped through the cracks here and there, especially in the JS code. They should be easy to find once the project is completely migrated to TS. |
Whoops assigned this to myself accidentally 🤣 |
remove @param annotations without descriptions
As suggested by @MasterOfBob777
I think this PR is ready to be merged now. Mind giving it a look @LuanRT ? |
This should be
|
I don't see any other major bug, so merging now. Thanks @Wykerd! |
Description
This builds on efforts of #91 and intends to make the library work on browsers and Deno (possibly CFWorkers) by replacing as much dependencies as possible with equivalent Web APIs available on all platforms.
This is a major change which will break event and stream APIs as these are to be replaced by their Web API equivalents.
Type of change
Changes:
EDIT: will not support Bun.js at this time, too experimental at this moment.