pear-runtime-react-native 0.0.0 → 1.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 +11 -11
  2. package/index.js +0 -57
  3. package/package.json +2 -3
package/README.md CHANGED
@@ -8,7 +8,9 @@ npm install pear-runtime-react-native react-native-bare-kit
8
8
 
9
9
  Requires `react-native-bare-kit` in your project.
10
10
 
11
- ---
11
+ ## MVP - EXPERIMENTAL
12
+
13
+ This boilerplate is MVP and Experimental.
12
14
 
13
15
  ## Usage
14
16
 
@@ -66,24 +68,22 @@ npm install @react-native/metro-config --save-dev
66
68
  From the project root (entry file must match your app, e.g. `index.js`):
67
69
 
68
70
  ```sh
69
- npx react-native bundle --platform ios --dev false --entry-file index.js --bundle-output dist/app.bundle --assets-dest dist/assets
70
- npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output dist/app.bundle --assets-dest dist/assets
71
+ npx react-native bundle --platform ios --dev false --entry-file index.js --bundle-output dist/by-arch/<host-arch>/app/app.bundle --assets-dest dist/by-arch/<host-arch>/app
72
+ npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output dist/by-arch/<host-arch>/app/app.bundle --assets-dest dist/by-arch/<host-arch>/app
71
73
  cp -f package.json dist/package.json
72
74
  ```
73
75
 
74
76
  Then stage and seed with `pear` as in your OTA flow.
75
77
 
76
- ---
77
-
78
78
  ## API
79
79
 
80
- - **`new PearRuntime()`** — Create runtime. `runtime.dir` is the app storage path.
81
- - **`runtime.on(event, callback)`** / **`off`** / **`once`** — Event shim.
82
- - **`runtime.run(filename, bundle, argv)`** — Start worklet; returns IPC duplex.
83
- - **`runtime.ready()`** / **`runtime.close()`** — Promise; no-op in react-native (API compatibility).
84
- - **`runtime.applyUpdate()`** — Promise; no-op in react-native (API compatibility).
80
+ #### `const pear = PearRuntime()`
85
81
 
86
- ---
82
+ Create a pear runtime (currently doesnt do anything on its own).
83
+
84
+ #### `IPC <stream.Duplex> = pear.run(filename, bundle, argv)`
85
+
86
+ Start a Bare worklet. returns IPC duplex stream.
87
87
 
88
88
  ## License
89
89
 
package/index.js CHANGED
@@ -1,66 +1,9 @@
1
1
  const { Worklet } = require('react-native-bare-kit')
2
- const RNFS = require('react-native-fs')
3
2
 
4
3
  module.exports = class PearRuntime {
5
- constructor() {
6
- this.dir = RNFS.DocumentDirectoryPath
7
-
8
- this._listeners = Object.create(null)
9
- this._calledReady = null
10
-
11
- this.ready().catch(noop)
12
- }
13
-
14
- ready() {
15
- if (this._calledReady) return this._calledReady
16
- this._calledReady = this._open()
17
- return this._calledReady
18
- }
19
-
20
- async _open() {}
21
-
22
- async close() {}
23
-
24
- on(event, callback) {
25
- if (!this._listeners[event]) this._listeners[event] = []
26
- this._listeners[event].push(callback)
27
- return this
28
- }
29
-
30
- off(event, callback) {
31
- if (!this._listeners[event]) return this
32
- if (callback) {
33
- this._listeners[event] = this._listeners[event].filter((fn) => fn !== callback)
34
- } else {
35
- this._listeners[event] = []
36
- }
37
- return this
38
- }
39
-
40
- once(event, fn) {
41
- const wrap = (...args) => {
42
- this.off(event, wrap)
43
- fn(...args)
44
- }
45
- return this.on(event, wrap)
46
- }
47
-
48
- emit(event, ...args) {
49
- const list = this._listeners[event]
50
- if (!list) return this
51
- for (const fn of list) fn(...args)
52
- return this
53
- }
54
-
55
4
  run(filename, bundle, argv) {
56
5
  const worklet = new Worklet()
57
6
  worklet.start(filename, bundle, argv)
58
7
  return worklet.IPC
59
8
  }
60
-
61
- applyUpdate() {
62
- return Promise.resolve()
63
- }
64
9
  }
65
-
66
- function noop() {}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pear-runtime-react-native",
3
- "version": "0.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Enables OTA updates with pear-runtime in react-native mobile apps",
5
5
  "main": "index.js",
6
6
  "exports": {
@@ -42,8 +42,7 @@
42
42
  "prettier-config-holepunch": "^2.0.0"
43
43
  },
44
44
  "peerDependencies": {
45
- "react-native-bare-kit": "*",
46
- "react-native-fs": "*"
45
+ "react-native-bare-kit": "*"
47
46
  },
48
47
  "peerDependenciesMeta": {
49
48
  "expo": {