Skip to content
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

RN Windows Support? #168

Open
gmacmaster opened this issue Oct 3, 2024 · 4 comments
Open

RN Windows Support? #168

gmacmaster opened this issue Oct 3, 2024 · 4 comments
Labels
enhancement New feature or request

Comments

@gmacmaster
Copy link

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 mrousavy added the enhancement New feature or request label Oct 4, 2024
@mrousavy
Copy link
Owner

mrousavy commented Oct 4, 2024

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
Copy link
Owner

mrousavy commented Oct 7, 2024

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.

/**
* Installs Nitro into the given JS `runtime`.
* This will create `global.NitroModulesProxy`, Nitro's entry-point,
* which can be used to create all registered HybridObjects from JS.
*
* Also registers the given `dispatcher` which allows using callbacks,
* and async code (Promises).
* The `dispatcher` needs to implement `runAsync`/`runSync` to run
* methods on whatever Thread can safely access `runtime`.
* In a non-thread-safe Runtime, it needs to be a single Thread (e.g.
* React's `CallInvoker`), but in a thread-safe Runtime it might just be
* an implementation that runs the method directly.
*/
void install(jsi::Runtime& runtime, std::shared_ptr<Dispatcher> dispatcher);

cc @shirakaba

@shirakaba
Copy link

shirakaba commented Oct 8, 2024

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
Copy link
Owner

mrousavy commented Oct 8, 2024

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants