pear-mobile 3.0.0 → 4.0.1

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.
Files changed (3) hide show
  1. package/README.md +3 -5
  2. package/index.js +2 -3
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -20,9 +20,7 @@ This boilerplate is MVP and Experimental.
20
20
  const PearRuntime = require('pear-mobile')
21
21
  const { version, upgrade, productName, name } = require('./package.json')
22
22
 
23
- const app = productName ?? name
24
-
25
- const runtime = new PearRuntime({ version, upgrade, app })
23
+ const runtime = new PearRuntime({ version, upgrade, name: productName })
26
24
  runtime.updater.on('updated', async () => {
27
25
  await runtime.updater.applyUpdate()
28
26
  conosle.log('restart for update')
@@ -52,8 +50,8 @@ Create a runtime. `opts` may include:
52
50
 
53
51
  - **`dir`** Directory to store data (e.g. app data dir). Defaults to `/Documents`.
54
52
  - **`upgrade`** – (required) Pear link for OTA updates (e.g. from `package.json` `upgrade` field).
55
- - **`app`** (required) The package.json prductName or name of the app. required for `applyUpdate()` to swap in the new build.
56
- - **`name`** - The package.json prductName or name of the app.
53
+ - **`name`** - (required) The package.json prductName of the app.
54
+ - **`app`** The path to the local OTA react-native bundle as booted from native code. (defaults to [pear-runtime-react-native](https://github.com/holepunchto/pear-runtime-react-native) default)
57
55
  - **`version`** – Current app version (e.g. from `package.json`); used for update checks.
58
56
  - **`updates`** – Set to `false` to disable P2P OTA updates.
59
57
  - **`storage`** – Saves the app storage path.
package/index.js CHANGED
@@ -7,16 +7,15 @@ const fs = require('bare-fs')
7
7
  module.exports = class PearRuntime extends ReadyResouce {
8
8
  constructor(opts = {}) {
9
9
  super()
10
- opts.name = opts.name || opts.app
11
- if (!opts.name) throw new Error('need to pass name or app')
12
10
  if (!opts.dir) opts.dir = dir.persistent()
13
11
 
14
12
  this.dir = opts.dir
15
13
  this.storage = opts.storage || path.join(this.dir, 'app-storage')
16
14
 
17
- const appPath = path.join(opts.dir, 'pear-runtime', 'ota')
15
+ const appPath = opts.app || path.join(opts.dir, 'pear-runtime', 'ota')
18
16
  if (!fs.existsSync(appPath)) fs.mkdirSync(appPath, { recursive: true, force: true })
19
17
  this.updater = new PearRuntimeUpdater({ ...opts, app: appPath })
18
+ this.updater.on('error', (err) => this.emit('error', err))
20
19
  }
21
20
 
22
21
  async _open() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-mobile",
3
- "version": "3.0.0",
3
+ "version": "4.0.1",
4
4
  "description": "Embeddable Pear runtime for mobile applications",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -41,7 +41,7 @@
41
41
  "bare-fs": "^4.5.5",
42
42
  "bare-path": "^3.0.0",
43
43
  "bare-storage": "^1.0.1",
44
- "pear-runtime-updater": "^1.0.0",
44
+ "pear-runtime-updater": "^2.0.0",
45
45
  "ready-resource": "^1.2.0"
46
46
  }
47
47
  }