pear-mobile 0.0.3 → 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -4
- package/index.js +2 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -10,6 +10,10 @@ This module integrates Pear into React-Native-based Mobile applications.
|
|
|
10
10
|
|
|
11
11
|
See [pear-runtime](https://github.com/holepunchto/pear-runtime) for Pear's embeddable runtime module for Desktop Devices.
|
|
12
12
|
|
|
13
|
+
## MVP - EXPERIMENTAL
|
|
14
|
+
|
|
15
|
+
This boilerplate is MVP and Experimental.
|
|
16
|
+
|
|
13
17
|
## Usage
|
|
14
18
|
|
|
15
19
|
```js
|
|
@@ -48,9 +52,9 @@ Inherits from [pear-runtime-updater]{https://www.github.com/holepunchto/pear-run
|
|
|
48
52
|
|
|
49
53
|
Create a runtime. `opts` may include:
|
|
50
54
|
|
|
51
|
-
- **`dir`** (required)
|
|
55
|
+
- **`dir`** (required) Directory to store data (e.g. app data dir).
|
|
56
|
+
- **`upgrade`** – (required) Pear link for OTA updates (e.g. from `package.json` `upgrade` field).
|
|
52
57
|
- **`version`** – Current app version (e.g. from `package.json`); used for update checks.
|
|
53
|
-
- **`upgrade`** – Pear link for OTA updates (e.g. from `package.json` `upgrade` field).
|
|
54
58
|
- **`app`** – Path to the native boot bundle override; required for `applyUpdate()` to swap in the new build. Defaults to `path/to/Documents/pear-runtime/upgrades`
|
|
55
59
|
- **`updates`** – Set to `false` to disable P2P OTA updates.
|
|
56
60
|
- **`storage`** – Saves the app storage path.
|
|
@@ -59,7 +63,27 @@ Create a runtime. `opts` may include:
|
|
|
59
63
|
|
|
60
64
|
Suggested storage folder for app storage.
|
|
61
65
|
|
|
62
|
-
#### `
|
|
66
|
+
#### `pear.storage`
|
|
67
|
+
|
|
68
|
+
Suggested storage folder for app storage.
|
|
69
|
+
|
|
70
|
+
#### `pear.on('updating')`
|
|
71
|
+
|
|
72
|
+
Emitted when an update is in progress
|
|
73
|
+
|
|
74
|
+
#### `updater.on('updating-delta', data)`
|
|
75
|
+
|
|
76
|
+
Emitted with progress data while mirroring the update.
|
|
77
|
+
|
|
78
|
+
#### `pear.on('updated')`
|
|
79
|
+
|
|
80
|
+
Emitted when an update is done
|
|
81
|
+
|
|
82
|
+
#### `await pear.applyUpdate()`
|
|
83
|
+
|
|
84
|
+
Apply the update. Only valid post `updated`. On next app restart the new update is in effect.
|
|
85
|
+
|
|
86
|
+
#### `await pear.close()`
|
|
63
87
|
|
|
64
88
|
Shut it down. You should do this when closing your app for best performance.
|
|
65
89
|
|
|
@@ -75,7 +99,7 @@ First allocate a pear link if you haven't using [`pear`](https://github.com/hole
|
|
|
75
99
|
pear touch
|
|
76
100
|
```
|
|
77
101
|
|
|
78
|
-
Store this link in the `package.json` `upgrade` field of a project.
|
|
102
|
+
Store this link in the `package.json` `upgrade` field of a project.
|
|
79
103
|
|
|
80
104
|
bundle your JS frontend. Take the distributable (e.g react-native bundle and assets) produced and make a deployment folder with the following structure:
|
|
81
105
|
|
package/index.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
const PearRuntimeUpdater = require('pear-runtime-updater')
|
|
2
2
|
const path = require('bare-path')
|
|
3
3
|
const fs = require('bare-fs')
|
|
4
|
+
const dir = require('bare-storage')
|
|
4
5
|
|
|
5
6
|
module.exports = class PearRuntime extends PearRuntimeUpdater {
|
|
6
7
|
constructor(opts = {}) {
|
|
8
|
+
if (!opts.dir) opts.dir = dir.persistent()
|
|
7
9
|
const appPath = opts.app || path.join(opts.dir, 'pear-runtime', 'upgrade')
|
|
8
10
|
if (!fs.existsSync(appPath)) fs.mkdirSync(appPath, { recursive: true, force: true })
|
|
9
11
|
if (fs.existsSync(path.join(appPath, 'package.json'))) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pear-mobile",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Embeddable Pear runtime for mobile applications",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"exports": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"bare-fs": "^4.5.4",
|
|
42
42
|
"bare-path": "^3.0.0",
|
|
43
|
-
"
|
|
43
|
+
"bare-storage": "^1.0.1",
|
|
44
|
+
"pear-runtime-updater": "^0.0.11"
|
|
44
45
|
}
|
|
45
46
|
}
|