Skip to content

Commit a850820

Browse files
committed
Add documentation
1 parent 8b791b2 commit a850820

File tree

4 files changed

+61
-0
lines changed

4 files changed

+61
-0
lines changed

README.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,52 @@
1414
1515
## How does this work?
1616

17+
> [!NOTE]
18+
> This library is currently dependent on a custom version of Hermes and therefore has a very limited range of supported React Native versions.
19+
> Once the [PR adding Node-API support to Hermes](https://github.com/facebook/hermes/pull/1377) merges, we expect this restriction to be lifted.
20+
21+
> [!NOTE]
22+
> This library is currently only implemented for iOS, we want to add support for Android next and eventually React Native for Windows and macOS too.
23+
1724
See the document on ["how it works"](./docs/HOW_IT_WORKS.md) for a detailed description of what it's like to write native modules using this package.
25+
26+
## Packages
27+
28+
This mono-repository hosts the development of a few packages:
29+
30+
### `packages/react-native-node-api-modules`
31+
32+
Responsible for adding Node-API support to your React Native application:
33+
34+
- Declares a Podspec which downloads a special version of Hermes, with Node-API support,
35+
- instructing React Native's Hermes Podspecs to compile from this custom source-code.
36+
- patching React Native's JSI copy, with the updates introduced by our special version of Hermes.
37+
- we expect this to eventually be removed, as Node-API support gets merged into Hermes upstream.
38+
- Automatically discovers and adds Node-API binaries, matching the [the prebuilt binary specification](./docs/PREBUILDS.md)
39+
- This is driven by the platform specific build tools (through the Podspec on iOS and eventually Gradle on Android)
40+
- Implements a TurboModule with a `requireNodeAddon` function responsible for
41+
- Loading dynamic libraries
42+
- Node-API module registration and (per `jsi::Runtime`) initialization.
43+
- Provides ways of transforming `require("./addon.node")` and `require("bindings")("addon")` calls into `requireNodeAddon` calls.
44+
45+
Note: We'll sometimes refer to this as the "host package", as it can be seen as a host of Node-API modules in React Native apps.
46+
47+
### `packages/react-native-node-api-cmake`
48+
49+
A wrapper around CMake making it easier to produce [prebuilt binaries](./docs/PREBUILDS.md) targeting iOS and Android matching the [the prebuilt binary specification](./docs/PREBUILDS.md).
50+
51+
Serves the same purpose as `cmake-js` does for the Node.js community and could potentially be upstreamed into `cmake-js` eventually.
52+
53+
### `packages/gyp-to-cmake`
54+
55+
A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `react-native-node-api-cmake` to build from.
56+
57+
### `packages/node-addon-examples`
58+
59+
A wrapper around the examples in the [nodejs/node-addon-examples](https://github.com/nodejs/node-addon-examples) repo, using `gyp-to-cmake` and `react-native-node-api-cmake` to prepare prebuilds and scaffolding for loading the addons.
60+
61+
The main purpose is to use these as tests to verify the implementation. We choose to use this as our first signal for compliance, over the [js-native-api tests in the Node.js project](https://github.com/nodejs/node/tree/main/test/js-native-api), because the examples depends much less on Node.js built-in runtime APIs.
62+
63+
### `apps/test-app`
64+
65+
A test app using `react-native-test-app` to exercise the implementation of

packages/gyp-to-cmake/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# `gyp-to-cmake`
2+
3+
A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `react-native-node-api-cmake` to build from.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `react-native-node-addon-examples`
2+
3+
A wrapper around the examples in the [nodejs/node-addon-examples](https://github.com/nodejs/node-addon-examples) repo, using `gyp-to-cmake` and `react-native-node-api-cmake` to prepare prebuilds and scaffolding for loading the addons.
4+
5+
The main purpose is to use these as tests to verify the implementation. We choose to use this as our first signal for compliance, over the [js-native-api tests in the Node.js project](https://github.com/nodejs/node/tree/main/test/js-native-api), because the examples depends much less on Node.js built-in runtime APIs.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# `react-native-node-api-cmake`
2+
3+
A wrapper around CMake making it easier to produce [prebuilt binaries](./docs/PREBUILDS.md) targeting iOS and Android matching the [the prebuilt binary specification](./docs/PREBUILDS.md).
4+
5+
Serves the same purpose as `cmake-js` does for the Node.js community and could potentially be upstreamed into `cmake-js` eventually.

0 commit comments

Comments
 (0)