pear-mobile
v4.2.2
Published
Embeddable Pear runtime for mobile applications
Downloads
855
Readme
pear-mobile
Embeddable Pear runtime for mobile applications. Provides storage path and bare workers via worklets.
npm install pear-mobileThis module integrates Pear into React-Native-based Mobile applications.
See pear-runtime for Pear's embeddable runtime module for Desktop Devices.
MVP - EXPERIMENTAL
This boilerplate is MVP and Experimental.
Usage
const PearRuntime = require('pear-mobile')
const { version, upgrade, productName, name } = require('./package.json')
const runtime = new PearRuntime({ version, upgrade, name: productName })
runtime.updater.on('updated', async () => {
await runtime.updater.applyUpdate()
conosle.log('restart for update')
})Quick Starts
Expo
git clone https://github.com/holepunchto/hello-pear-react-nativeFor end-to-end instructions from building to deploying with Pear see hello-pear-react-native README.md.
Features
- Peer-to-Peer Over-the-Air (P2P OTA) updates (via pear-runtime-updater)
- Application storage management
API
const pear = new PearRuntime(opts)
Create a runtime. opts may include:
dirDirectory to store data (e.g. app data dir). Defaults to/Documents.upgrade– (required) Pear link for OTA updates (e.g. frompackage.jsonupgradefield).name- (required) The package.json prductName of the app.store- (optional) pass a Corestore to be used for updates. If passedswarmmust also be passed. Thestoreshould be replicated over theswarm.swarm- (optional) pass a Hyperswarm to be used for swarming updates. If passedstoremust also be passed. Thestoreshould be replicated over theswarm.app– (optional) The path to the local OTA react-native bundle as booted from native code. (defaults to pear-runtime-react-native default)version– (optional) Current app version (i.e. frompackage.json); used for update checks.updates– (optional) Set tofalseto disable P2P OTA updates.storage– (optional) Saves the app storage path.
pear.storage
Suggested storage folder for app storage.
pear.updater
Instance of pear-runtime-updater
await pear.ready()
Awaits the open of the updater (p2p connections, drive open ...)
await pear.close()
Shut it down. You should do this when closing your app for best performance.
Making updates
VERY EXPERIMENTAL, MOST DEFINITELY WILL CHANGE.
Update listening and apply logic lives in pear-runtime-updater.
First allocate a pear link if you haven't using pear:
pear touchStore this link in the package.json upgrade field of a project.
bundle your JS frontend. Take the distributable (e.g react-native bundle and assets) produced and make a deployment folder with the following structure:
/package.json
/by-arch
/[...platform-arch]
/appNow go to this folder and stage this onto the link with pear stage
pear stage {link-from-touch}Now seed it. Any build out there on a lower version will trigger the update flow.
LICENSE
Apache-2.0
