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

React-Native support #38

Open
RangerMauve opened this issue Jan 20, 2020 · 8 comments
Open

React-Native support #38

RangerMauve opened this issue Jan 20, 2020 · 8 comments
Labels
enhancement New feature or request

Comments

@RangerMauve
Copy link
Owner

Make a wrapper over the SDK using nodejs-mobile-react-native and provide it to React-Native apps.

@RangerMauve RangerMauve added the enhancement New feature or request label Jan 20, 2020
@fmsouza
Copy link

fmsouza commented Apr 30, 2020

Won't that push the entire node_modules into the app build? I've tried a similar alternative to run a full IPFS node on a React-Native app and in the end the app had about to 500MB. This is not something I'd call ideal...

Would it be possible to just pull a compiled version of the code or something like that into nodejs-mobile-react-native directory somehow?

Edit: typo

@RangerMauve
Copy link
Owner Author

I'm not sure actually. It might be possible to browserify the bundle and just include the binaries in the folder. I wonder if there are tools that do this already?

There's also an effort to make it work with regular react-native: https://github.com/cliqz/dat-react-native/ If they can get decent performance out of it then nodejs-mobile wouldn't be needed.

@okdistribute
Copy link
Contributor

okdistribute commented Apr 30, 2020

Yes, react-native out of the box would be ideal. However, we have a working app that runs hypercore, networking, crypto, leveldb in nodejs-mobile, it's pretty small actually given it's bundling node, the APK is 89MB. https://github.com/digidem/mapeo-mobile

It takes a bit of effort to make sure it works well in the background, but this is mostly app logic not too different from programming in electron

@LeslieOA
Copy link

LeslieOA commented Aug 11, 2020

Hello all.
Not sure if the following would help, but I'm attempting this at the moment using nodejs-mobile-react-native.

To hopefully answer @fmsouza question and confirm @RangerMauve's suggestion:

I've found moving the node_modules folder outside of the nodejs-project into it's parent nodejs-assets works (as node will still resolve a package one level up).

My webpack.config.js output's to ~/nodejs-assets/nodejs-project/main.js. Folder structure is as follows:

.
+-- nodejs-assets
|   +-- node_modules
|   +-- nodejs-project
|   |   +-- main.js 
|   +-- src
|   |   +-- index.js
|   +-- package.json
|   +-- webpack.config.js

Only issue is nodejs-mobile doesn't currently support WebAssembly on iOS (ChakraCore) so DatSDKs version of sodium won't run.

Making attempts this week irrespective.

@RangerMauve
Copy link
Owner Author

@martinheidegger and I are currently working on making sure sodium-javascript works in RN.

We're setting up a continuous integration testing suite that'll run it on RN and then we'll be fixing bugs.

@RangerMauve
Copy link
Owner Author

Actually, @LeslieOA would you be down for chatting more about how we could collaborate on pushing this RN stuff forward? My email is ranger@mauve.moe

@LeslieOA
Copy link

Actually, @LeslieOA would you be down for chatting more about how we could collaborate on pushing this RN stuff forward? My email is ranger@mauve.moe

Emailed 🙂

@RangerMauve
Copy link
Owner Author

Now that we have hyperspace support in the SDK it might make sense to use nodejs-mobile to spin up a hyperspace instance on the native side and use just the client portion for hyper-sdk in the react-native thread.

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

4 participants