mrousavy / nitro

🔥 Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI
https://nitro.margelo.com
MIT License
643 stars 22 forks source link

RN Windows Support? #168

Open gmacmaster opened 1 month ago

gmacmaster commented 1 month ago

I see mention on iOS and Android in the doc but no mention of RNW.

Is there a way to get this working on windows?

mrousavy commented 1 month ago

Yes, everything is cross-platform so it does work on Windows.

The only thing that we need to change is to get the turbomodule/ autolinked - which is just a single module that acts as an entry point for Nitro.

Nitro only needs reference to the jsi::Runtime and a CallInvoker - that's it.

mrousavy commented 1 month ago

To add support to another platform, you just need to call margelo::nitro::install(...) in a Runtime. This will install global.NitroModulesProxy into the Runtime's global.

https://github.com/mrousavy/nitro/blob/c0ae25bef6710894c1314f714638b38ca650c66b/packages/react-native-nitro-modules/cpp/entrypoint/InstallNitro.hpp#L16-L29

cc @shirakaba

shirakaba commented 1 month ago

Here is my writeup of how to write a react-native-windows "attributed" native module (which can be installed as either a NativeModule or TurboModule) that installs a JSI HostObject on the JS global.

I'd help out, but I don't have even a spare half-hour from now until mid-November 🫠

Nitro only needs reference to the jsi::Runtime and a CallInvoker - that's it.

Here is my writeup of how to get access to callinvoker using the above approach.

mrousavy commented 1 month ago

This is really helpful, thanks Jamie!!

Windows support in Nitro is unfortunately also lower on my priority list for now because of a lot of other things (including VisionCamera stuff), so I don't think I can implement this anytime soon.

If anyone wants to tackle this, I can take time to review PRs and release it though!