RangerMauve / hyper-sdk

Make your own hyper apps!
https://www.youtube.com/watch?v=HyHk4aImd_I&list=PL7sG5SCUNyeYx8wnfMOUpsh7rM_g0w_cu&index=20
MIT License
290 stars 46 forks source link

React-Native support #38

Open RangerMauve opened 4 years ago

RangerMauve commented 4 years ago

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

fmsouza commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

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 commented 3 years ago

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.