rustwasm / wasm-bindgen

Facilitating high-level interactions between Wasm modules and JavaScript
https://rustwasm.github.io/docs/wasm-bindgen/
Apache License 2.0
7.81k stars 1.08k forks source link

distinguish between `MediaStreamTrack` clone, and rust Clone::clone #4182

Open deep-gaurav opened 1 month ago

deep-gaurav commented 1 month ago

Motivation

So I was working with WebRTC Media Stream Track and was cloning with with .clone() thinking it'll do shallow clone just like how all other web-sys api does shallow clone, but MediaStreamTrack has a clone method in js too that does deep clone which is what is invoked here. It becomes very hard to debug unless you know this. maybe we can mark it somehow?

Proposed Solution

Not exactly sure what can be done but maybe rename deep clone?

Alternatives

We can also just do some linting for it?

Additional Context

NA

daxpedda commented 1 month ago

This could be easily added to the list of Rust keywords, but unfortunately it requires much more plumbing to generate duplicate methods to avoid a breaking change.

I'm happy to look over a PR, which can also deprecate the old methods.

deep-gaurav commented 1 month ago

Unfortunately I dont think I've enough knowledge of how web-sys/wasm_bindgen works internally to make PR. If you can point me somewhere to getstarted on learning it, I would be willing to look into it.

daxpedda commented 1 month ago

If you can point me somewhere to getstarted on learning it, I would be willing to look into it.

I don't think we have any documentation on the internal code architecture that would help with this. To get started you would just have to dig into the code.