@onekeyfe/react-native-background-thread 3.0.162 → 3.0.163

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 (2) hide show
  1. package/README.md +54 -0
  2. package/package.json +6 -5
package/README.md ADDED
@@ -0,0 +1,54 @@
1
+ # @onekeyfe/react-native-background-thread
2
+
3
+ A separate JavaScript runtime and shared native bridge for OneKey React Native
4
+ applications on iOS and Android. The package exposes background runner startup,
5
+ segment evaluation and runtime restart, together with primitive shared storage
6
+ and inline RPC notifications.
7
+
8
+ ## Installation
9
+
10
+ ```sh
11
+ yarn add @onekeyfe/react-native-background-thread
12
+ ```
13
+
14
+ Install the application's iOS pods and rebuild the native application. Background
15
+ startup also requires the application's native host and background entry bundle;
16
+ this package does not create that entry or its module registry.
17
+
18
+ ## Usage
19
+
20
+ ```ts
21
+ import {
22
+ BackgroundThread,
23
+ getSharedStore,
24
+ } from '@onekeyfe/react-native-background-thread';
25
+
26
+ BackgroundThread.installSharedBridge();
27
+ const store = getSharedStore();
28
+ store?.set('worker.status', 'ready');
29
+ const status = store?.get('worker.status');
30
+ ```
31
+
32
+ `getSharedStore()` and `getSharedRPC()` can return `undefined` before the native
33
+ bridge has been installed in the calling runtime. Shared values are strings,
34
+ numbers or booleans; callers must serialize structured data themselves.
35
+
36
+ ## Runtime and bridge API
37
+
38
+ - `startBackgroundRunnerWithEntryURL(entryURL)` starts the background entry.
39
+ - `loadSegmentInBackground(segmentId, path)` evaluates a background segment.
40
+ - `restart('ui', reason)` restarts only the UI JavaScript runtime.
41
+ - `restart('all', reason)` restarts both JavaScript runtimes.
42
+ - SharedStore exposes `set`, `get`, `has`, `delete`, `keys`, `clear` and `size`.
43
+ - SharedRPC exposes `write`, `onWrite` and `registerReadinessKey`; notifications
44
+ include both the call ID and primitive payload, without a read-back operation.
45
+
46
+ An all-runtime restart preserves the iOS process but replaces the Android
47
+ process. Do not assume native singleton or service state survives on both
48
+ platforms. Bundle switches must restart both runtimes so their module tables
49
+ remain consistent. These differences and restart validation are documented in
50
+ [src/NativeBackgroundThread.ts](src/NativeBackgroundThread.ts).
51
+
52
+ ## License
53
+
54
+ MIT.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@onekeyfe/react-native-background-thread",
3
- "version": "3.0.162",
4
- "description": "react-native-background-thread",
3
+ "version": "3.0.163",
4
+ "description": "Background JavaScript runtime, shared storage and RPC bridge for OneKey",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",
7
7
  "exports": {
@@ -47,14 +47,15 @@
47
47
  ],
48
48
  "repository": {
49
49
  "type": "git",
50
- "url": "git+https://github.com/OneKeyHQ/app-modules/react-native-background-thread.git"
50
+ "url": "git+https://github.com/OneKeyHQ/app-modules.git",
51
+ "directory": "native-modules/react-native-background-thread"
51
52
  },
52
53
  "author": "@onekeyhq <huanming@onekey.so> (https://github.com/OneKeyHQ/app-modules)",
53
54
  "license": "MIT",
54
55
  "bugs": {
55
- "url": "https://github.com/OneKeyHQ/app-modules/react-native-background-thread/issues"
56
+ "url": "https://github.com/OneKeyHQ/app-modules/issues"
56
57
  },
57
- "homepage": "https://github.com/OneKeyHQ/app-modules/react-native-background-thread#readme",
58
+ "homepage": "https://github.com/OneKeyHQ/app-modules/tree/main/native-modules/react-native-background-thread#readme",
58
59
  "publishConfig": {
59
60
  "registry": "https://registry.npmjs.org/"
60
61
  },