From f5b3f373857a16f030785036dbc4c46e93fb6651 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 10:27:39 +0200 Subject: [PATCH 1/6] Rename cmake package --- .../{react-native-node-api-cmake => cmake-rn}/README.md | 0 .../bin/cmake-rn.js} | 0 .../{react-native-node-api-cmake => cmake-rn}/package.json | 6 +++--- .../src/android.ts | 0 .../{react-native-node-api-cmake => cmake-rn}/src/apple.ts | 0 .../{react-native-node-api-cmake => cmake-rn}/src/cli.ts | 0 .../src/headers.ts | 0 .../{react-native-node-api-cmake => cmake-rn}/src/run.ts | 0 .../src/weak-node-api.ts | 0 .../{react-native-node-api-cmake => cmake-rn}/tsconfig.json | 0 10 files changed, 3 insertions(+), 3 deletions(-) rename packages/{react-native-node-api-cmake => cmake-rn}/README.md (100%) rename packages/{react-native-node-api-cmake/bin/react-native-node-api-cmake.js => cmake-rn/bin/cmake-rn.js} (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/package.json (81%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/android.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/apple.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/cli.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/headers.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/run.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/src/weak-node-api.ts (100%) rename packages/{react-native-node-api-cmake => cmake-rn}/tsconfig.json (100%) diff --git a/packages/react-native-node-api-cmake/README.md b/packages/cmake-rn/README.md similarity index 100% rename from packages/react-native-node-api-cmake/README.md rename to packages/cmake-rn/README.md diff --git a/packages/react-native-node-api-cmake/bin/react-native-node-api-cmake.js b/packages/cmake-rn/bin/cmake-rn.js similarity index 100% rename from packages/react-native-node-api-cmake/bin/react-native-node-api-cmake.js rename to packages/cmake-rn/bin/cmake-rn.js diff --git a/packages/react-native-node-api-cmake/package.json b/packages/cmake-rn/package.json similarity index 81% rename from packages/react-native-node-api-cmake/package.json rename to packages/cmake-rn/package.json index ff0803d8..fb2a1452 100644 --- a/packages/react-native-node-api-cmake/package.json +++ b/packages/cmake-rn/package.json @@ -1,16 +1,16 @@ { - "name": "react-native-node-api-cmake", + "name": "cmake-rn", "version": "0.1.0", "description": "Build React Native Node API modules with CMake", "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", "repository": { "type": "git", "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", - "directory": "packages/react-native-node-api-cmake" + "directory": "packages/cmake-rn" }, "type": "module", "bin": { - "react-native-node-api-cmake": "./bin/react-native-node-api-cmake.js" + "cmake-rn": "./bin/cmake-rn.js" }, "files": [ "bin", diff --git a/packages/react-native-node-api-cmake/src/android.ts b/packages/cmake-rn/src/android.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/android.ts rename to packages/cmake-rn/src/android.ts diff --git a/packages/react-native-node-api-cmake/src/apple.ts b/packages/cmake-rn/src/apple.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/apple.ts rename to packages/cmake-rn/src/apple.ts diff --git a/packages/react-native-node-api-cmake/src/cli.ts b/packages/cmake-rn/src/cli.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/cli.ts rename to packages/cmake-rn/src/cli.ts diff --git a/packages/react-native-node-api-cmake/src/headers.ts b/packages/cmake-rn/src/headers.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/headers.ts rename to packages/cmake-rn/src/headers.ts diff --git a/packages/react-native-node-api-cmake/src/run.ts b/packages/cmake-rn/src/run.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/run.ts rename to packages/cmake-rn/src/run.ts diff --git a/packages/react-native-node-api-cmake/src/weak-node-api.ts b/packages/cmake-rn/src/weak-node-api.ts similarity index 100% rename from packages/react-native-node-api-cmake/src/weak-node-api.ts rename to packages/cmake-rn/src/weak-node-api.ts diff --git a/packages/react-native-node-api-cmake/tsconfig.json b/packages/cmake-rn/tsconfig.json similarity index 100% rename from packages/react-native-node-api-cmake/tsconfig.json rename to packages/cmake-rn/tsconfig.json From ad5a18e970b7133bbf5a968736669f010ba2b949 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 10:32:01 +0200 Subject: [PATCH 2/6] Update references to "react-native-node-api-cmake" --- .github/workflows/check.yml | 6 +- README.md | 7 +- package-lock.json | 217 ++++++++++-------- package.json | 2 +- packages/cmake-rn/README.md | 2 +- packages/cmake-rn/src/cli.ts | 2 +- packages/gyp-to-cmake/README.md | 2 +- packages/node-addon-examples/README.md | 2 +- packages/node-addon-examples/package.json | 2 +- .../scripts/build-examples.mts | 6 +- .../package.json | 4 +- tsconfig.json | 2 +- 12 files changed, 136 insertions(+), 118 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index bc9a8dbc..c31787e7 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,7 +28,7 @@ jobs: node-version: lts/jod - run: npm ci - run: npm run build - - run: npm test --workspace gyp-to-cmake --workspace react-native-node-api-cmake --workspace react-native-node-api-modules + - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api-modules test-windows: name: Run tests on Windows runs-on: windows-latest @@ -39,7 +39,7 @@ jobs: node-version: lts/jod - run: npm ci - run: npm run build - - run: npm test --workspace gyp-to-cmake --workspace react-native-node-api-cmake --workspace react-native-node-api-modules + - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api-modules test-macos: name: Run tests which requires MacOS @@ -56,7 +56,7 @@ jobs: distribution: "temurin" - name: Setup Android SDK uses: android-actions/setup-android@v3 - # Version here should match the one in React Native template and packages/react-native-node-api-cmake/src/cli.ts + # Version here should match the one in React Native template and packages/cmake-rn/src/cli.ts - run: sdkmanager --install "ndk;27.1.12297006" - run: npm ci - run: npm run build diff --git a/README.md b/README.md index b6f0eff4..85c56dee 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -

@@ -49,7 +48,7 @@ Responsible for adding Node-API support to your React Native application: 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. -### `packages/react-native-node-api-cmake` +### `packages/cmake-rn` 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). @@ -57,11 +56,11 @@ Serves the same purpose as `cmake-js` does for the Node.js community and could p ### `packages/gyp-to-cmake` -A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `react-native-node-api-cmake` to build from. +A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `cmake-rn` to build from. ### `packages/node-addon-examples` -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. +A wrapper around the examples in the [nodejs/node-addon-examples](https://github.com/nodejs/node-addon-examples) repo, using `gyp-to-cmake` and `cmake-rn` to prepare prebuilds and scaffolding for loading the addons. 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. diff --git a/package-lock.json b/package-lock.json index 2e0d0769..ebcc19f9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6473,6 +6473,10 @@ "node": ">= 10.0.0" } }, + "node_modules/cmake-rn": { + "resolved": "packages/cmake-rn", + "link": true + }, "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", @@ -10053,10 +10057,6 @@ "resolved": "packages/node-addon-examples", "link": true }, - "node_modules/react-native-node-api-cmake": { - "resolved": "packages/react-native-node-api-cmake", - "link": true - }, "node_modules/react-native-node-api-modules": { "resolved": "packages/react-native-node-api-modules", "link": true @@ -11560,28 +11560,25 @@ "url": "https://github.com/sponsors/colinhacks" } }, - "packages/ferric": { - "name": "ferric-cli", + "packages/cmake-rn": { "version": "0.1.0", "dependencies": { "@commander-js/extra-typings": "^13.1.0", - "@napi-rs/cli": "3.0.0-alpha.80", "bufout": "^0.3.1", "chalk": "^5.4.1", + "cmake-js": "^7.3.1", "commander": "^13.1.0", "ora": "^8.2.0" }, "bin": { - "ferric": "bin/ferric.js" - } - }, - "packages/ferric-example": { - "version": "0.1.0", - "devDependencies": { - "ferric-cli": "^0.1.0" + "cmake-rn": "bin/cmake-rn.js" + }, + "peerDependencies": { + "node-addon-api": "^8.3.1", + "node-api-headers": "^1.5.0" } }, - "packages/ferric/node_modules/@commander-js/extra-typings": { + "packages/cmake-rn/node_modules/@commander-js/extra-typings": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-13.1.0.tgz", "integrity": "sha512-q5P52BYb1hwVWE6dtID7VvuJWrlfbCv4klj7BjUUOqMz4jbSZD4C9fJ9lRjL2jnBGTg+gDDlaXN51rkWcLk4fg==", @@ -11590,7 +11587,7 @@ "commander": "~13.1.0" } }, - "packages/ferric/node_modules/ansi-regex": { + "packages/cmake-rn/node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", @@ -11602,7 +11599,7 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "packages/ferric/node_modules/chalk": { + "packages/cmake-rn/node_modules/chalk": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", @@ -11614,7 +11611,7 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "packages/ferric/node_modules/cli-cursor": { + "packages/cmake-rn/node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", @@ -11629,7 +11626,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/commander": { + "packages/cmake-rn/node_modules/commander": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", @@ -11638,13 +11635,13 @@ "node": ">=18" } }, - "packages/ferric/node_modules/emoji-regex": { + "packages/cmake-rn/node_modules/emoji-regex": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "license": "MIT" }, - "packages/ferric/node_modules/is-interactive": { + "packages/cmake-rn/node_modules/is-interactive": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", @@ -11656,7 +11653,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/is-unicode-supported": { + "packages/cmake-rn/node_modules/is-unicode-supported": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", @@ -11668,7 +11665,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/log-symbols": { + "packages/cmake-rn/node_modules/log-symbols": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", @@ -11684,7 +11681,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/log-symbols/node_modules/is-unicode-supported": { + "packages/cmake-rn/node_modules/log-symbols/node_modules/is-unicode-supported": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", @@ -11696,7 +11693,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/onetime": { + "packages/cmake-rn/node_modules/onetime": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", @@ -11711,7 +11708,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/ora": { + "packages/cmake-rn/node_modules/ora": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", @@ -11734,7 +11731,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/restore-cursor": { + "packages/cmake-rn/node_modules/restore-cursor": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", @@ -11750,7 +11747,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/signal-exit": { + "packages/cmake-rn/node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", @@ -11762,7 +11759,7 @@ "url": "https://github.com/sponsors/isaacs" } }, - "packages/ferric/node_modules/string-width": { + "packages/cmake-rn/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", @@ -11779,7 +11776,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/ferric/node_modules/strip-ansi": { + "packages/cmake-rn/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", @@ -11794,71 +11791,28 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "packages/gyp-to-cmake": { - "version": "0.1.0", - "dependencies": { - "@commander-js/extra-typings": "^13.1.0", - "commander": "^13.1.0", - "gyp-parser": "^1.0.4" - }, - "bin": { - "gyp-to-cmake": "bin/gyp-to-cmake.js" - } - }, - "packages/gyp-to-cmake/node_modules/@commander-js/extra-typings": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-13.1.0.tgz", - "integrity": "sha512-q5P52BYb1hwVWE6dtID7VvuJWrlfbCv4klj7BjUUOqMz4jbSZD4C9fJ9lRjL2jnBGTg+gDDlaXN51rkWcLk4fg==", - "license": "MIT", - "peerDependencies": { - "commander": "~13.1.0" - } - }, - "packages/gyp-to-cmake/node_modules/commander": { - "version": "13.1.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", - "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", - "license": "MIT", - "engines": { - "node": ">=18" - } - }, - "packages/node-addon-examples": { - "name": "react-native-node-addon-examples", - "devDependencies": { - "gyp-to-cmake": "*", - "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", - "react-native-node-api-cmake": "*", - "read-pkg": "^9.0.1" - } - }, - "packages/node-addon-examples-tests": { - "extraneous": true, - "devDependencies": { - "gyp-to-cmake": "*", - "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", - "react-native-node-api-cmake": "*" - } - }, - "packages/react-native-node-api-cmake": { + "packages/ferric": { + "name": "ferric-cli", "version": "0.1.0", "dependencies": { "@commander-js/extra-typings": "^13.1.0", + "@napi-rs/cli": "3.0.0-alpha.80", "bufout": "^0.3.1", "chalk": "^5.4.1", - "cmake-js": "^7.3.1", "commander": "^13.1.0", "ora": "^8.2.0" }, "bin": { - "react-native-node-api-cmake": "bin/react-native-node-api-cmake.js" - }, - "peerDependencies": { - "node-addon-api": "^8.3.1", - "node-api-headers": "^1.5.0" + "ferric": "bin/ferric.js" } }, - "packages/react-native-node-api-cmake/node_modules/@commander-js/extra-typings": { + "packages/ferric-example": { + "version": "0.1.0", + "devDependencies": { + "ferric-cli": "^0.1.0" + } + }, + "packages/ferric/node_modules/@commander-js/extra-typings": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-13.1.0.tgz", "integrity": "sha512-q5P52BYb1hwVWE6dtID7VvuJWrlfbCv4klj7BjUUOqMz4jbSZD4C9fJ9lRjL2jnBGTg+gDDlaXN51rkWcLk4fg==", @@ -11867,7 +11821,7 @@ "commander": "~13.1.0" } }, - "packages/react-native-node-api-cmake/node_modules/ansi-regex": { + "packages/ferric/node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", @@ -11879,7 +11833,7 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "packages/react-native-node-api-cmake/node_modules/chalk": { + "packages/ferric/node_modules/chalk": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", @@ -11891,7 +11845,7 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "packages/react-native-node-api-cmake/node_modules/cli-cursor": { + "packages/ferric/node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", @@ -11906,7 +11860,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/commander": { + "packages/ferric/node_modules/commander": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", @@ -11915,13 +11869,13 @@ "node": ">=18" } }, - "packages/react-native-node-api-cmake/node_modules/emoji-regex": { + "packages/ferric/node_modules/emoji-regex": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "license": "MIT" }, - "packages/react-native-node-api-cmake/node_modules/is-interactive": { + "packages/ferric/node_modules/is-interactive": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", @@ -11933,7 +11887,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/is-unicode-supported": { + "packages/ferric/node_modules/is-unicode-supported": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", @@ -11945,7 +11899,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/log-symbols": { + "packages/ferric/node_modules/log-symbols": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", @@ -11961,7 +11915,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/log-symbols/node_modules/is-unicode-supported": { + "packages/ferric/node_modules/log-symbols/node_modules/is-unicode-supported": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", @@ -11973,7 +11927,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/onetime": { + "packages/ferric/node_modules/onetime": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", @@ -11988,7 +11942,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/ora": { + "packages/ferric/node_modules/ora": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", @@ -12011,7 +11965,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/restore-cursor": { + "packages/ferric/node_modules/restore-cursor": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", @@ -12027,7 +11981,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/signal-exit": { + "packages/ferric/node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", @@ -12039,7 +11993,7 @@ "url": "https://github.com/sponsors/isaacs" } }, - "packages/react-native-node-api-cmake/node_modules/string-width": { + "packages/ferric/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", @@ -12056,7 +12010,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-cmake/node_modules/strip-ansi": { + "packages/ferric/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", @@ -12071,6 +12025,71 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, + "packages/gyp-to-cmake": { + "version": "0.1.0", + "dependencies": { + "@commander-js/extra-typings": "^13.1.0", + "commander": "^13.1.0", + "gyp-parser": "^1.0.4" + }, + "bin": { + "gyp-to-cmake": "bin/gyp-to-cmake.js" + } + }, + "packages/gyp-to-cmake/node_modules/@commander-js/extra-typings": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-13.1.0.tgz", + "integrity": "sha512-q5P52BYb1hwVWE6dtID7VvuJWrlfbCv4klj7BjUUOqMz4jbSZD4C9fJ9lRjL2jnBGTg+gDDlaXN51rkWcLk4fg==", + "license": "MIT", + "peerDependencies": { + "commander": "~13.1.0" + } + }, + "packages/gyp-to-cmake/node_modules/commander": { + "version": "13.1.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", + "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", + "license": "MIT", + "engines": { + "node": ">=18" + } + }, + "packages/node-addon-examples": { + "name": "react-native-node-addon-examples", + "devDependencies": { + "cmake-rn": "*", + "gyp-to-cmake": "*", + "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", + "read-pkg": "^9.0.1" + } + }, + "packages/node-addon-examples-tests": { + "extraneous": true, + "devDependencies": { + "gyp-to-cmake": "*", + "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", + "react-native-node-api-cmake": "*" + } + }, + "packages/react-native-node-api-cmake": { + "version": "0.1.0", + "extraneous": true, + "dependencies": { + "@commander-js/extra-typings": "^13.1.0", + "bufout": "^0.3.1", + "chalk": "^5.4.1", + "cmake-js": "^7.3.1", + "commander": "^13.1.0", + "ora": "^8.2.0" + }, + "bin": { + "react-native-node-api-cmake": "bin/react-native-node-api-cmake.js" + }, + "peerDependencies": { + "node-addon-api": "^8.3.1", + "node-api-headers": "^1.5.0" + } + }, "packages/react-native-node-api-modules": { "version": "0.1.0", "license": "MIT", diff --git a/package.json b/package.json index 13093305..45876537 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "clean": "tsc --build --clean", "dev": "tsc --build --watch", "lint": "eslint .", - "test": "npm run test --workspace react-native-node-api-modules --workspace react-native-node-api-cmake --workspace gyp-to-cmake --workspace node-addon-examples" + "test": "npm run test --workspace react-native-node-api-modules --workspace cmake-rn --workspace gyp-to-cmake --workspace node-addon-examples" }, "author": { "name": "Callstack", diff --git a/packages/cmake-rn/README.md b/packages/cmake-rn/README.md index 6d10fb4f..1f37f269 100644 --- a/packages/cmake-rn/README.md +++ b/packages/cmake-rn/README.md @@ -1,4 +1,4 @@ -# `react-native-node-api-cmake` +# `cmake-rn` 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). diff --git a/packages/cmake-rn/src/cli.ts b/packages/cmake-rn/src/cli.ts index 4465366c..5b90fece 100644 --- a/packages/cmake-rn/src/cli.ts +++ b/packages/cmake-rn/src/cli.ts @@ -96,7 +96,7 @@ const xcframeworkExtensionOption = new Option( "Don't rename the xcframework to .apple.node" ).default(false); -export const program = new Command("react-native-node-api-cmake") +export const program = new Command("cmake-rn") .description("Build React Native Node API modules with CMake") .addOption(sourcePathOption) .addOption(configurationOption) diff --git a/packages/gyp-to-cmake/README.md b/packages/gyp-to-cmake/README.md index 91a8f911..cbb554bd 100644 --- a/packages/gyp-to-cmake/README.md +++ b/packages/gyp-to-cmake/README.md @@ -1,3 +1,3 @@ # `gyp-to-cmake` -A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `react-native-node-api-cmake` to build from. +A tool to transform `binding.gyp` files into `CMakeLists.txt` files, intended for `cmake-js` or `cmake-rn` to build from. diff --git a/packages/node-addon-examples/README.md b/packages/node-addon-examples/README.md index 2f818659..11439dee 100644 --- a/packages/node-addon-examples/README.md +++ b/packages/node-addon-examples/README.md @@ -1,5 +1,5 @@ # `react-native-node-addon-examples` -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. +A wrapper around the examples in the [nodejs/node-addon-examples](https://github.com/nodejs/node-addon-examples) repo, using `gyp-to-cmake` and `cmake-rn` to prepare prebuilds and scaffolding for loading the addons. 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. diff --git a/packages/node-addon-examples/package.json b/packages/node-addon-examples/package.json index e39654eb..467f66e8 100644 --- a/packages/node-addon-examples/package.json +++ b/packages/node-addon-examples/package.json @@ -16,9 +16,9 @@ "test": "npm run copy-and-build && npm run verify" }, "devDependencies": { + "cmake-rn": "*", "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", "gyp-to-cmake": "*", - "react-native-node-api-cmake": "*", "read-pkg": "^9.0.1" } } diff --git a/packages/node-addon-examples/scripts/build-examples.mts b/packages/node-addon-examples/scripts/build-examples.mts index 1a5ed30b..f43f446f 100644 --- a/packages/node-addon-examples/scripts/build-examples.mts +++ b/packages/node-addon-examples/scripts/build-examples.mts @@ -5,10 +5,10 @@ import { findCMakeProjects } from "./cmake-projects.mjs"; const projectDirectories = findCMakeProjects(); for (const projectDirectory of projectDirectories) { - console.log(`Running "react-native-node-api-cmake" in ${projectDirectory}`); + console.log(`Running "cmake-rn" in ${projectDirectory}`); execSync( - "react-native-node-api-cmake --android --apple", - // "react-native-node-api-cmake --triplet aarch64-linux-android --triplet arm64-apple-ios-sim", + "cmake-rn --android --apple", + // "cmake-rn --triplet aarch64-linux-android --triplet arm64-apple-ios-sim", { cwd: projectDirectory, stdio: "inherit", diff --git a/packages/react-native-node-api-modules/package.json b/packages/react-native-node-api-modules/package.json index 836f960a..5638d9e6 100644 --- a/packages/react-native-node-api-modules/package.json +++ b/packages/react-native-node-api-modules/package.json @@ -6,7 +6,7 @@ "repository": { "type": "git", "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", - "directory": "packages/react-native-node-api-cmake" + "directory": "packages/react-native-node-api-modules" }, "main": "dist/react-native/index.js", "type": "commonjs", @@ -43,7 +43,7 @@ "copy-node-api-headers": "tsx scripts/copy-node-api-headers.ts", "generate-weak-node-api": "tsx scripts/generate-weak-node-api.ts", "generate-weak-node-api-injector": "tsx scripts/generate-weak-node-api-injector.ts", - "build-weak-node-api": "npm run generate-weak-node-api && react-native-node-api-cmake --android --apple --no-auto-link --no-weak-node-api-linkage --xcframework-extension --source ./weak-node-api", + "build-weak-node-api": "npm run generate-weak-node-api && cmake-rn --android --apple --no-auto-link --no-weak-node-api-linkage --xcframework-extension --source ./weak-node-api", "test": "tsx --test src/node/**/*.test.ts src/node/*.test.ts" }, "keywords": [ diff --git a/tsconfig.json b/tsconfig.json index 8bf7d5f4..66aec613 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,7 +3,7 @@ "references": [ { "path": "./packages/react-native-node-api-modules/tsconfig.json" }, { "path": "./packages/gyp-to-cmake/tsconfig.json" }, - { "path": "./packages/react-native-node-api-cmake/tsconfig.json" }, + { "path": "./packages/cmake-rn/tsconfig.json" }, { "path": "./packages/ferric/tsconfig.json" } ] } From 9444dd02a1cb02b69a9c0c963f8648d7d1ff1e3a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 10:35:23 +0200 Subject: [PATCH 3/6] Rename "react-native-node-api-modules" to "react-native-node-api" --- packages/{react-native-node-api-modules => host}/.gitignore | 0 packages/{react-native-node-api-modules => host}/README.md | 0 .../android/CMakeLists.txt | 0 .../android/build.gradle | 0 .../android/gradle.properties | 0 .../android/src/main/AndroidManifest.xml | 0 .../android/src/main/AndroidManifestNew.xml | 0 .../android/src/main/cpp/OnLoad.cpp | 0 .../com/callstack/node_api_modules/NodeApiModulesPackage.kt | 0 .../{react-native-node-api-modules => host}/babel-plugin.js | 0 .../bin/react-native-node-api-modules.mjs | 0 .../cpp/AddonLoaders.hpp | 0 .../cpp/CxxNodeApiHostModule.cpp | 0 .../cpp/CxxNodeApiHostModule.hpp | 0 .../{react-native-node-api-modules => host}/cpp/Logger.cpp | 0 .../{react-native-node-api-modules => host}/cpp/Logger.hpp | 0 .../cpp/WeakNodeApiInjector.hpp | 0 .../ios/NodeApiHostModuleProvider.mm | 0 .../{react-native-node-api-modules => host}/package.json | 6 +++--- .../react-native-node-api-modules.podspec | 0 .../react-native.config.js | 0 .../scripts/copy-node-api-headers.ts | 0 .../scripts/generate-weak-node-api-injector.ts | 0 .../scripts/generate-weak-node-api.ts | 0 .../scripts/node-api-functions.ts | 0 .../scripts/patch-hermes.rb | 0 .../src/node/babel-plugin/index.ts | 0 .../src/node/babel-plugin/plugin.test.ts | 0 .../src/node/babel-plugin/plugin.ts | 0 .../src/node/cli/android.ts | 0 .../src/node/cli/apple.ts | 0 .../src/node/cli/hermes.ts | 0 .../src/node/cli/link-modules.ts | 0 .../src/node/cli/options.ts | 0 .../src/node/cli/program.ts | 0 .../src/node/cli/run.ts | 0 .../src/node/duplicates.ts | 0 .../src/node/index.ts | 0 .../src/node/path-utils.test.ts | 0 .../src/node/path-utils.ts | 0 .../src/node/prebuilds/android.ts | 0 .../src/node/prebuilds/apple.ts | 0 .../src/node/prebuilds/triplets.ts | 0 .../src/node/test-utils.ts | 0 .../src/react-native/NativeNodeApiHost.ts | 0 .../src/react-native/index.ts | 0 .../{react-native-node-api-modules => host}/tsconfig.json | 0 .../tsconfig.node-scripts.json | 0 .../tsconfig.node-tests.json | 0 .../tsconfig.node.json | 0 .../tsconfig.react-native.json | 0 .../types/node-api-headers/index.d.ts | 0 .../weak-node-api/CMakeLists.txt | 0 53 files changed, 3 insertions(+), 3 deletions(-) rename packages/{react-native-node-api-modules => host}/.gitignore (100%) rename packages/{react-native-node-api-modules => host}/README.md (100%) rename packages/{react-native-node-api-modules => host}/android/CMakeLists.txt (100%) rename packages/{react-native-node-api-modules => host}/android/build.gradle (100%) rename packages/{react-native-node-api-modules => host}/android/gradle.properties (100%) rename packages/{react-native-node-api-modules => host}/android/src/main/AndroidManifest.xml (100%) rename packages/{react-native-node-api-modules => host}/android/src/main/AndroidManifestNew.xml (100%) rename packages/{react-native-node-api-modules => host}/android/src/main/cpp/OnLoad.cpp (100%) rename packages/{react-native-node-api-modules => host}/android/src/main/java/com/callstack/node_api_modules/NodeApiModulesPackage.kt (100%) rename packages/{react-native-node-api-modules => host}/babel-plugin.js (100%) rename packages/{react-native-node-api-modules => host}/bin/react-native-node-api-modules.mjs (100%) rename packages/{react-native-node-api-modules => host}/cpp/AddonLoaders.hpp (100%) rename packages/{react-native-node-api-modules => host}/cpp/CxxNodeApiHostModule.cpp (100%) rename packages/{react-native-node-api-modules => host}/cpp/CxxNodeApiHostModule.hpp (100%) rename packages/{react-native-node-api-modules => host}/cpp/Logger.cpp (100%) rename packages/{react-native-node-api-modules => host}/cpp/Logger.hpp (100%) rename packages/{react-native-node-api-modules => host}/cpp/WeakNodeApiInjector.hpp (100%) rename packages/{react-native-node-api-modules => host}/ios/NodeApiHostModuleProvider.mm (100%) rename packages/{react-native-node-api-modules => host}/package.json (93%) rename packages/{react-native-node-api-modules => host}/react-native-node-api-modules.podspec (100%) rename packages/{react-native-node-api-modules => host}/react-native.config.js (100%) rename packages/{react-native-node-api-modules => host}/scripts/copy-node-api-headers.ts (100%) rename packages/{react-native-node-api-modules => host}/scripts/generate-weak-node-api-injector.ts (100%) rename packages/{react-native-node-api-modules => host}/scripts/generate-weak-node-api.ts (100%) rename packages/{react-native-node-api-modules => host}/scripts/node-api-functions.ts (100%) rename packages/{react-native-node-api-modules => host}/scripts/patch-hermes.rb (100%) rename packages/{react-native-node-api-modules => host}/src/node/babel-plugin/index.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/babel-plugin/plugin.test.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/babel-plugin/plugin.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/android.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/apple.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/hermes.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/link-modules.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/options.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/program.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/cli/run.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/duplicates.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/index.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/path-utils.test.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/path-utils.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/prebuilds/android.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/prebuilds/apple.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/prebuilds/triplets.ts (100%) rename packages/{react-native-node-api-modules => host}/src/node/test-utils.ts (100%) rename packages/{react-native-node-api-modules => host}/src/react-native/NativeNodeApiHost.ts (100%) rename packages/{react-native-node-api-modules => host}/src/react-native/index.ts (100%) rename packages/{react-native-node-api-modules => host}/tsconfig.json (100%) rename packages/{react-native-node-api-modules => host}/tsconfig.node-scripts.json (100%) rename packages/{react-native-node-api-modules => host}/tsconfig.node-tests.json (100%) rename packages/{react-native-node-api-modules => host}/tsconfig.node.json (100%) rename packages/{react-native-node-api-modules => host}/tsconfig.react-native.json (100%) rename packages/{react-native-node-api-modules => host}/types/node-api-headers/index.d.ts (100%) rename packages/{react-native-node-api-modules => host}/weak-node-api/CMakeLists.txt (100%) diff --git a/packages/react-native-node-api-modules/.gitignore b/packages/host/.gitignore similarity index 100% rename from packages/react-native-node-api-modules/.gitignore rename to packages/host/.gitignore diff --git a/packages/react-native-node-api-modules/README.md b/packages/host/README.md similarity index 100% rename from packages/react-native-node-api-modules/README.md rename to packages/host/README.md diff --git a/packages/react-native-node-api-modules/android/CMakeLists.txt b/packages/host/android/CMakeLists.txt similarity index 100% rename from packages/react-native-node-api-modules/android/CMakeLists.txt rename to packages/host/android/CMakeLists.txt diff --git a/packages/react-native-node-api-modules/android/build.gradle b/packages/host/android/build.gradle similarity index 100% rename from packages/react-native-node-api-modules/android/build.gradle rename to packages/host/android/build.gradle diff --git a/packages/react-native-node-api-modules/android/gradle.properties b/packages/host/android/gradle.properties similarity index 100% rename from packages/react-native-node-api-modules/android/gradle.properties rename to packages/host/android/gradle.properties diff --git a/packages/react-native-node-api-modules/android/src/main/AndroidManifest.xml b/packages/host/android/src/main/AndroidManifest.xml similarity index 100% rename from packages/react-native-node-api-modules/android/src/main/AndroidManifest.xml rename to packages/host/android/src/main/AndroidManifest.xml diff --git a/packages/react-native-node-api-modules/android/src/main/AndroidManifestNew.xml b/packages/host/android/src/main/AndroidManifestNew.xml similarity index 100% rename from packages/react-native-node-api-modules/android/src/main/AndroidManifestNew.xml rename to packages/host/android/src/main/AndroidManifestNew.xml diff --git a/packages/react-native-node-api-modules/android/src/main/cpp/OnLoad.cpp b/packages/host/android/src/main/cpp/OnLoad.cpp similarity index 100% rename from packages/react-native-node-api-modules/android/src/main/cpp/OnLoad.cpp rename to packages/host/android/src/main/cpp/OnLoad.cpp diff --git a/packages/react-native-node-api-modules/android/src/main/java/com/callstack/node_api_modules/NodeApiModulesPackage.kt b/packages/host/android/src/main/java/com/callstack/node_api_modules/NodeApiModulesPackage.kt similarity index 100% rename from packages/react-native-node-api-modules/android/src/main/java/com/callstack/node_api_modules/NodeApiModulesPackage.kt rename to packages/host/android/src/main/java/com/callstack/node_api_modules/NodeApiModulesPackage.kt diff --git a/packages/react-native-node-api-modules/babel-plugin.js b/packages/host/babel-plugin.js similarity index 100% rename from packages/react-native-node-api-modules/babel-plugin.js rename to packages/host/babel-plugin.js diff --git a/packages/react-native-node-api-modules/bin/react-native-node-api-modules.mjs b/packages/host/bin/react-native-node-api-modules.mjs similarity index 100% rename from packages/react-native-node-api-modules/bin/react-native-node-api-modules.mjs rename to packages/host/bin/react-native-node-api-modules.mjs diff --git a/packages/react-native-node-api-modules/cpp/AddonLoaders.hpp b/packages/host/cpp/AddonLoaders.hpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/AddonLoaders.hpp rename to packages/host/cpp/AddonLoaders.hpp diff --git a/packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.cpp b/packages/host/cpp/CxxNodeApiHostModule.cpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.cpp rename to packages/host/cpp/CxxNodeApiHostModule.cpp diff --git a/packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.hpp b/packages/host/cpp/CxxNodeApiHostModule.hpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/CxxNodeApiHostModule.hpp rename to packages/host/cpp/CxxNodeApiHostModule.hpp diff --git a/packages/react-native-node-api-modules/cpp/Logger.cpp b/packages/host/cpp/Logger.cpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/Logger.cpp rename to packages/host/cpp/Logger.cpp diff --git a/packages/react-native-node-api-modules/cpp/Logger.hpp b/packages/host/cpp/Logger.hpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/Logger.hpp rename to packages/host/cpp/Logger.hpp diff --git a/packages/react-native-node-api-modules/cpp/WeakNodeApiInjector.hpp b/packages/host/cpp/WeakNodeApiInjector.hpp similarity index 100% rename from packages/react-native-node-api-modules/cpp/WeakNodeApiInjector.hpp rename to packages/host/cpp/WeakNodeApiInjector.hpp diff --git a/packages/react-native-node-api-modules/ios/NodeApiHostModuleProvider.mm b/packages/host/ios/NodeApiHostModuleProvider.mm similarity index 100% rename from packages/react-native-node-api-modules/ios/NodeApiHostModuleProvider.mm rename to packages/host/ios/NodeApiHostModuleProvider.mm diff --git a/packages/react-native-node-api-modules/package.json b/packages/host/package.json similarity index 93% rename from packages/react-native-node-api-modules/package.json rename to packages/host/package.json index 5638d9e6..90677295 100644 --- a/packages/react-native-node-api-modules/package.json +++ b/packages/host/package.json @@ -1,17 +1,17 @@ { - "name": "react-native-node-api-modules", + "name": "react-native-node-api", "version": "0.1.0", "description": "Node-API Modules for React Native", "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", "repository": { "type": "git", "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", - "directory": "packages/react-native-node-api-modules" + "directory": "packages/react-native-node-api" }, "main": "dist/react-native/index.js", "type": "commonjs", "bin": { - "react-native-node-api-modules": "./bin/react-native-node-api-modules.mjs" + "react-native-node-api": "./bin/react-native-node-api.mjs" }, "exports": { ".": { diff --git a/packages/react-native-node-api-modules/react-native-node-api-modules.podspec b/packages/host/react-native-node-api-modules.podspec similarity index 100% rename from packages/react-native-node-api-modules/react-native-node-api-modules.podspec rename to packages/host/react-native-node-api-modules.podspec diff --git a/packages/react-native-node-api-modules/react-native.config.js b/packages/host/react-native.config.js similarity index 100% rename from packages/react-native-node-api-modules/react-native.config.js rename to packages/host/react-native.config.js diff --git a/packages/react-native-node-api-modules/scripts/copy-node-api-headers.ts b/packages/host/scripts/copy-node-api-headers.ts similarity index 100% rename from packages/react-native-node-api-modules/scripts/copy-node-api-headers.ts rename to packages/host/scripts/copy-node-api-headers.ts diff --git a/packages/react-native-node-api-modules/scripts/generate-weak-node-api-injector.ts b/packages/host/scripts/generate-weak-node-api-injector.ts similarity index 100% rename from packages/react-native-node-api-modules/scripts/generate-weak-node-api-injector.ts rename to packages/host/scripts/generate-weak-node-api-injector.ts diff --git a/packages/react-native-node-api-modules/scripts/generate-weak-node-api.ts b/packages/host/scripts/generate-weak-node-api.ts similarity index 100% rename from packages/react-native-node-api-modules/scripts/generate-weak-node-api.ts rename to packages/host/scripts/generate-weak-node-api.ts diff --git a/packages/react-native-node-api-modules/scripts/node-api-functions.ts b/packages/host/scripts/node-api-functions.ts similarity index 100% rename from packages/react-native-node-api-modules/scripts/node-api-functions.ts rename to packages/host/scripts/node-api-functions.ts diff --git a/packages/react-native-node-api-modules/scripts/patch-hermes.rb b/packages/host/scripts/patch-hermes.rb similarity index 100% rename from packages/react-native-node-api-modules/scripts/patch-hermes.rb rename to packages/host/scripts/patch-hermes.rb diff --git a/packages/react-native-node-api-modules/src/node/babel-plugin/index.ts b/packages/host/src/node/babel-plugin/index.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/babel-plugin/index.ts rename to packages/host/src/node/babel-plugin/index.ts diff --git a/packages/react-native-node-api-modules/src/node/babel-plugin/plugin.test.ts b/packages/host/src/node/babel-plugin/plugin.test.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/babel-plugin/plugin.test.ts rename to packages/host/src/node/babel-plugin/plugin.test.ts diff --git a/packages/react-native-node-api-modules/src/node/babel-plugin/plugin.ts b/packages/host/src/node/babel-plugin/plugin.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/babel-plugin/plugin.ts rename to packages/host/src/node/babel-plugin/plugin.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/android.ts b/packages/host/src/node/cli/android.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/android.ts rename to packages/host/src/node/cli/android.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/apple.ts b/packages/host/src/node/cli/apple.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/apple.ts rename to packages/host/src/node/cli/apple.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/hermes.ts b/packages/host/src/node/cli/hermes.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/hermes.ts rename to packages/host/src/node/cli/hermes.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/link-modules.ts b/packages/host/src/node/cli/link-modules.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/link-modules.ts rename to packages/host/src/node/cli/link-modules.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/options.ts b/packages/host/src/node/cli/options.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/options.ts rename to packages/host/src/node/cli/options.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/program.ts b/packages/host/src/node/cli/program.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/program.ts rename to packages/host/src/node/cli/program.ts diff --git a/packages/react-native-node-api-modules/src/node/cli/run.ts b/packages/host/src/node/cli/run.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/cli/run.ts rename to packages/host/src/node/cli/run.ts diff --git a/packages/react-native-node-api-modules/src/node/duplicates.ts b/packages/host/src/node/duplicates.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/duplicates.ts rename to packages/host/src/node/duplicates.ts diff --git a/packages/react-native-node-api-modules/src/node/index.ts b/packages/host/src/node/index.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/index.ts rename to packages/host/src/node/index.ts diff --git a/packages/react-native-node-api-modules/src/node/path-utils.test.ts b/packages/host/src/node/path-utils.test.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/path-utils.test.ts rename to packages/host/src/node/path-utils.test.ts diff --git a/packages/react-native-node-api-modules/src/node/path-utils.ts b/packages/host/src/node/path-utils.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/path-utils.ts rename to packages/host/src/node/path-utils.ts diff --git a/packages/react-native-node-api-modules/src/node/prebuilds/android.ts b/packages/host/src/node/prebuilds/android.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/prebuilds/android.ts rename to packages/host/src/node/prebuilds/android.ts diff --git a/packages/react-native-node-api-modules/src/node/prebuilds/apple.ts b/packages/host/src/node/prebuilds/apple.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/prebuilds/apple.ts rename to packages/host/src/node/prebuilds/apple.ts diff --git a/packages/react-native-node-api-modules/src/node/prebuilds/triplets.ts b/packages/host/src/node/prebuilds/triplets.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/prebuilds/triplets.ts rename to packages/host/src/node/prebuilds/triplets.ts diff --git a/packages/react-native-node-api-modules/src/node/test-utils.ts b/packages/host/src/node/test-utils.ts similarity index 100% rename from packages/react-native-node-api-modules/src/node/test-utils.ts rename to packages/host/src/node/test-utils.ts diff --git a/packages/react-native-node-api-modules/src/react-native/NativeNodeApiHost.ts b/packages/host/src/react-native/NativeNodeApiHost.ts similarity index 100% rename from packages/react-native-node-api-modules/src/react-native/NativeNodeApiHost.ts rename to packages/host/src/react-native/NativeNodeApiHost.ts diff --git a/packages/react-native-node-api-modules/src/react-native/index.ts b/packages/host/src/react-native/index.ts similarity index 100% rename from packages/react-native-node-api-modules/src/react-native/index.ts rename to packages/host/src/react-native/index.ts diff --git a/packages/react-native-node-api-modules/tsconfig.json b/packages/host/tsconfig.json similarity index 100% rename from packages/react-native-node-api-modules/tsconfig.json rename to packages/host/tsconfig.json diff --git a/packages/react-native-node-api-modules/tsconfig.node-scripts.json b/packages/host/tsconfig.node-scripts.json similarity index 100% rename from packages/react-native-node-api-modules/tsconfig.node-scripts.json rename to packages/host/tsconfig.node-scripts.json diff --git a/packages/react-native-node-api-modules/tsconfig.node-tests.json b/packages/host/tsconfig.node-tests.json similarity index 100% rename from packages/react-native-node-api-modules/tsconfig.node-tests.json rename to packages/host/tsconfig.node-tests.json diff --git a/packages/react-native-node-api-modules/tsconfig.node.json b/packages/host/tsconfig.node.json similarity index 100% rename from packages/react-native-node-api-modules/tsconfig.node.json rename to packages/host/tsconfig.node.json diff --git a/packages/react-native-node-api-modules/tsconfig.react-native.json b/packages/host/tsconfig.react-native.json similarity index 100% rename from packages/react-native-node-api-modules/tsconfig.react-native.json rename to packages/host/tsconfig.react-native.json diff --git a/packages/react-native-node-api-modules/types/node-api-headers/index.d.ts b/packages/host/types/node-api-headers/index.d.ts similarity index 100% rename from packages/react-native-node-api-modules/types/node-api-headers/index.d.ts rename to packages/host/types/node-api-headers/index.d.ts diff --git a/packages/react-native-node-api-modules/weak-node-api/CMakeLists.txt b/packages/host/weak-node-api/CMakeLists.txt similarity index 100% rename from packages/react-native-node-api-modules/weak-node-api/CMakeLists.txt rename to packages/host/weak-node-api/CMakeLists.txt From 4f10e861bf0f57f51e125af750465278dee5af49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 12:34:37 +0200 Subject: [PATCH 4/6] Rename "react-native-node-api-modules" to "react-native-node-api" and move it to "packages/host" --- .github/workflows/check.yml | 10 +- README.md | 2 +- apps/test-app/.gitignore | 2 +- apps/test-app/App.tsx | 2 +- apps/test-app/babel.config.js | 4 +- apps/test-app/package.json | 2 +- apps/test-app/react-native.config.js | 2 +- docs/ANDROID.md | 2 +- docs/AUTO-LINKING.md | 6 +- docs/CLI.md | 2 +- docs/HOW-IT-WORKS.md | 12 +- docs/PREBUILDS.md | 4 +- docs/USAGE.md | 21 +- eslint.config.js | 12 +- package-lock.json | 188 ++++++++++-------- package.json | 6 +- packages/cmake-rn/package.json | 4 +- packages/cmake-rn/src/android.ts | 2 +- packages/cmake-rn/src/apple.ts | 2 +- packages/cmake-rn/src/cli.ts | 6 +- packages/cmake-rn/src/weak-node-api.ts | 4 +- packages/ferric-example/package.json | 4 +- packages/ferric/package.json | 4 +- packages/ferric/src/build.ts | 2 +- packages/ferric/src/cargo.ts | 2 +- packages/gyp-to-cmake/package.json | 4 +- packages/gyp-to-cmake/src/transformer.ts | 2 +- packages/host/android/CMakeLists.txt | 2 +- packages/host/android/build.gradle | 2 +- packages/host/cpp/CxxNodeApiHostModule.cpp | 4 +- packages/host/package.json | 6 +- .../react-native-node-api-modules.podspec | 2 +- .../generate-weak-node-api-injector.ts | 2 +- .../host/scripts/generate-weak-node-api.ts | 4 +- packages/host/scripts/patch-hermes.rb | 2 +- packages/host/src/node/babel-plugin/plugin.ts | 2 +- packages/host/src/node/cli/apple.ts | 2 +- packages/host/src/node/cli/program.ts | 2 +- packages/host/src/node/path-utils.ts | 14 +- packages/node-addon-examples/package.json | 4 +- tsconfig.json | 2 +- 41 files changed, 198 insertions(+), 165 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index c31787e7..2734b27b 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -28,7 +28,7 @@ jobs: node-version: lts/jod - run: npm ci - run: npm run build - - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api-modules + - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api test-windows: name: Run tests on Windows runs-on: windows-latest @@ -39,7 +39,7 @@ jobs: node-version: lts/jod - run: npm ci - run: npm run build - - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api-modules + - run: npm test --workspace gyp-to-cmake --workspace cmake-rn --workspace react-native-node-api test-macos: name: Run tests which requires MacOS @@ -60,7 +60,7 @@ jobs: - run: sdkmanager --install "ndk;27.1.12297006" - run: npm ci - run: npm run build - - run: npm run copy-node-api-headers --workspace react-native-node-api-modules - - run: npm run build-weak-node-api --workspace react-native-node-api-modules - - run: npm run generate-weak-node-api-injector --workspace react-native-node-api-modules + - run: npm run copy-node-api-headers --workspace react-native-node-api + - run: npm run build-weak-node-api --workspace react-native-node-api + - run: npm run generate-weak-node-api-injector --workspace react-native-node-api - run: npm test --workspace react-native-node-addon-examples diff --git a/README.md b/README.md index 85c56dee..141a766f 100644 --- a/README.md +++ b/README.md @@ -31,7 +31,7 @@ See the document on ["how it works"](./docs/HOW_IT_WORKS.md) for a detailed desc This mono-repository hosts the development of a few packages: -### `packages/react-native-node-api-modules` +### `packages/react-native-node-api` Responsible for adding Node-API support to your React Native application: diff --git a/apps/test-app/.gitignore b/apps/test-app/.gitignore index 4550bc8f..7e43539a 100644 --- a/apps/test-app/.gitignore +++ b/apps/test-app/.gitignore @@ -11,7 +11,7 @@ build/ local.properties msbuild.binlog -# Ignoring the Podfile.lock as the `react-native-node-api-modules` hash updates too frequently +# Ignoring the Podfile.lock as the `react-native-node-api` hash updates too frequently Podfile.lock hermes/ diff --git a/apps/test-app/App.tsx b/apps/test-app/App.tsx index 59125577..a1aad6be 100644 --- a/apps/test-app/App.tsx +++ b/apps/test-app/App.tsx @@ -3,7 +3,7 @@ import { StyleSheet, Text, View, Button } from "react-native"; /* eslint-disable @typescript-eslint/no-require-imports -- We're using require to defer crashes */ -// import { requireNodeAddon } from "react-native-node-api-modules"; +// import { requireNodeAddon } from "react-native-node-api"; import nodeAddonExamples from "react-native-node-addon-examples"; // import * as ferricExample from "ferric-example"; diff --git a/apps/test-app/babel.config.js b/apps/test-app/babel.config.js index f412b4d6..175e8359 100644 --- a/apps/test-app/babel.config.js +++ b/apps/test-app/babel.config.js @@ -1,5 +1,5 @@ module.exports = { presets: ['module:@react-native/babel-preset'], - // plugins: [['module:react-native-node-api-modules/babel-plugin', { stripPathSuffix: true }]], - plugins: ['module:react-native-node-api-modules/babel-plugin'], + // plugins: [['module:react-native-node-api/babel-plugin', { stripPathSuffix: true }]], + plugins: ['module:react-native-node-api/babel-plugin'], }; diff --git a/apps/test-app/package.json b/apps/test-app/package.json index ef798be8..9fd3df7c 100644 --- a/apps/test-app/package.json +++ b/apps/test-app/package.json @@ -25,7 +25,7 @@ "react": "19.0.0", "react-native": "0.79.1", "react-native-node-addon-examples": "*", - "react-native-node-api-modules": "*", + "react-native-node-api": "*", "react-native-test-app": "^4.3.3" } } diff --git a/apps/test-app/react-native.config.js b/apps/test-app/react-native.config.js index fd9a56d8..e15e25b5 100644 --- a/apps/test-app/react-native.config.js +++ b/apps/test-app/react-native.config.js @@ -12,7 +12,7 @@ const project = (() => { }, // windows: { // sourceDir: "windows", - // solutionFile: "windows/react-native-node-api-modules-example.sln", + // solutionFile: "windows/react-native-node-api-example.sln", // }, }); return { diff --git a/docs/ANDROID.md b/docs/ANDROID.md index 2ddca25f..d946cf29 100644 --- a/docs/ANDROID.md +++ b/docs/ANDROID.md @@ -5,7 +5,7 @@ Because we're using a version of Hermes patched with Node-API support, we need to build React Native from source. ``` -export REACT_NATIVE_OVERRIDE_HERMES_DIR=`npx react-native-node-api-modules vendor-hermes --silent` +export REACT_NATIVE_OVERRIDE_HERMES_DIR=`npx react-native-node-api vendor-hermes --silent` ``` ## Cleaning your React Native build folders diff --git a/docs/AUTO-LINKING.md b/docs/AUTO-LINKING.md index 5cfdb3fc..ed757f1e 100644 --- a/docs/AUTO-LINKING.md +++ b/docs/AUTO-LINKING.md @@ -1,6 +1,6 @@ # Auto-linking -The `react-native-node-api-modules` package (sometimes referred to as "the host package") has mechanisms to automatically find and link prebuilt binaries with Node-API modules. +The `react-native-node-api` package (sometimes referred to as "the host package") has mechanisms to automatically find and link prebuilt binaries with Node-API modules. When auto-linking, prebuilt binaries are copied (sometimes referred to as vendored) from dependencies of the app into the host package. As they're copied, they get renamed to avoid conflicts in naming as the library files across multiple dependency packages will be sharing a namespace when building the app. @@ -15,12 +15,12 @@ The name of the library when linked / copied into the host is based on two thing ## How do I link Node-API module libraries into my app? -Linking will run when you `pod install` and as part of building your app with Gradle as long as your app has a dependency on the `react-native-node-api-modules` package. +Linking will run when you `pod install` and as part of building your app with Gradle as long as your app has a dependency on the `react-native-node-api` package. You can also manually link by running the following in your app directory: ```bash -npx react-native-node-api-modules link --android --apple +npx react-native-node-api link --android --apple ``` > [!NOTE] diff --git a/docs/CLI.md b/docs/CLI.md index 96355027..9156480f 100644 --- a/docs/CLI.md +++ b/docs/CLI.md @@ -1,3 +1,3 @@ -# The `react-native-node-api-modules` command-line interface (CLI) +# The `react-native-node-api` command-line interface (CLI) diff --git a/docs/HOW-IT-WORKS.md b/docs/HOW-IT-WORKS.md index 8c1ffc0f..25b4123f 100644 --- a/docs/HOW-IT-WORKS.md +++ b/docs/HOW-IT-WORKS.md @@ -15,12 +15,12 @@ The library has a require call to a `.node` file, which would normally not have module.exports = require("./prebuild.node"); ``` -Since the app developer has added the `react-native-node-api-modules/babel-plugin` to their Babel configuration, the require statement gets transformed when the app is being bundled by Metro, into a `requireNodeAddon` call on our TurboModule. +Since the app developer has added the `react-native-node-api/babel-plugin` to their Babel configuration, the require statement gets transformed when the app is being bundled by Metro, into a `requireNodeAddon` call on our TurboModule. The generated code looks something like this: ```javascript -module.exports = require("react-native-node-api-modules").requireNodeAddon( +module.exports = require("react-native-node-api").requireNodeAddon( "calculator-lib--prebuild" ); ``` @@ -37,13 +37,13 @@ In Node.js dynamic libraries sharing names can be disambiguated based off their To work around this issue, we scan for and copy any library (including its entire xcframework structure with nested framework directories) from the dependency package into our host package when the app builds and reference these from its podspec (as vendored_frameworks). We use a special file in the xcframeworks containing Node-API modules. To avoid collisions we rename xcframework, framework and library files to a unique name, containing a hash. The hash is computed based off the package-name of the containing package and the relative path from the package root to the library file (with any platform specific file extensions replaced with the neutral ".node" extension). -## Transformed code calls into `react-native-node-api-modules`, loading the platform specific dynamic library +## Transformed code calls into `react-native-node-api`, loading the platform specific dynamic library The native implementation of `requireNodeAddon` is responsible for loading the dynamic library and allow the Node-API module to register its initialization function, either by exporting a `napi_register_module_v1` function or by calling the (deprecated) `napi_module_register` function. In any case the native code stores the initialization function in a data-structure. -## `react-native-node-api-modules` creates a `node_env` and initialize the Node-API module +## `react-native-node-api` creates a `node_env` and initialize the Node-API module The initialization function of a Node-API module expects a `node_env`, which we create by calling `createNodeApiEnv` on the `jsi::Runtime`. @@ -52,11 +52,11 @@ The initialization function of a Node-API module expects a `node_env`, which we An `exports` object is created for the Node-API module and both the `napi_env` and `exports` object is passed to the Node-API module's initialization function and the third party code is able to call the Node-API free functions: - The engine-specific functions (see [js_native_api.h](https://github.com/nodejs/node/blob/main/src/js_native_api.h)) are implemented by the `jsi::Runtime` (currently only Hermes supports this). -- The runtime-specific functions (see [node_api.h](https://github.com/nodejs/node/blob/main/src/node_api.h)) are implemented by `react-native-node-api-modules`. +- The runtime-specific functions (see [node_api.h](https://github.com/nodejs/node/blob/main/src/node_api.h)) are implemented by `react-native-node-api`. ## `my-app` regain control and call `add` -When the `exports` object is populated by `calculator-lib`'s Node-API module, control is returned to `react-native-node-api-modules` which returns the `exports` object to JavaScript, with the `add` function defined on it. +When the `exports` object is populated by `calculator-lib`'s Node-API module, control is returned to `react-native-node-api` which returns the `exports` object to JavaScript, with the `add` function defined on it. ```javascript import { add } from "calculator-lib"; diff --git a/docs/PREBUILDS.md b/docs/PREBUILDS.md index 4930ac91..5f057953 100644 --- a/docs/PREBUILDS.md +++ b/docs/PREBUILDS.md @@ -2,7 +2,7 @@ This document codifies the naming and directory structure of prebuilt binaries, expected by the auto-linking mechanism. -At the time of writing, our auto-linking host package (`react-native-node-api-modules`) support two kinds of prebuilds: +At the time of writing, our auto-linking host package (`react-native-node-api`) support two kinds of prebuilds: ## `*.android.node` (for Android) @@ -17,7 +17,7 @@ The name of all the `.so` library files: > [!NOTE] > The `SONAME` doesn't have to match and is not updated as the .so is copied into the host package. > This might cause trouble if you're trying to link with the library from other native code. -> We're tracking [#14](https://github.com/callstackincubator/react-native-node-api-modules/issues/14) to fix this 🤞 +> We're tracking [#14](https://github.com/callstackincubator/react-native-node-api/issues/14) to fix this 🤞 The directory must have a `react-native-node-api-module` file (the content doesn't matter), to signal that the directory is intended for auto-linking by the `react-native-node-api-module` package. diff --git a/docs/USAGE.md b/docs/USAGE.md index 841212ef..e09cf4d1 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -3,26 +3,27 @@ The purpose of this document is to explain how Node-API modules are supported all the way from an app loading a library package to the library's native code returning a JavaScript value to from a function call. For the purpose of the explanation, we'll introduce a two fictitious packages: + - `calculator-lib`: A package publishing a Node-API module. - `my-app`: An app depending on `calculator-lib`. ## Steps needed for the app developer ```bash -npm install --save calculator-lib react-native-node-api-modules +npm install --save calculator-lib react-native-node-api ``` -The app developer has to install both `calculator-lib` as well as `react-native-node-api-modules`. +The app developer has to install both `calculator-lib` as well as `react-native-node-api`. The reason for the latter is a current limitation of the React Native Community CLI which doesn't consider transitive dependencies when enumerating packages for auto-linking. > [!WARNING] -> It's important to match the exact version of the `react-native-node-api-modules` declared as peer dependency by `calculator-lib`. +> It's important to match the exact version of the `react-native-node-api` declared as peer dependency by `calculator-lib`. -For the app to resolve the Node-API dynamic library files, the app developer must update their Metro config to use a `resolveRequest` function exported from `react-native-node-api-modules`: +For the app to resolve the Node-API dynamic library files, the app developer must update their Metro config to use a `resolveRequest` function exported from `react-native-node-api`: ```javascript -const { getDefaultConfig, mergeConfig } = require('@react-native/metro-config'); -const nodeApi = require("react-native-node-api-modules/metro-config"); +const { getDefaultConfig, mergeConfig } = require("@react-native/metro-config"); +const nodeApi = require("react-native-node-api/metro-config"); module.exports = mergeConfig(getDefaultConfig(__dirname), { resolver: { resolveRequest: nodeApi.resolveRequest }, }); @@ -39,17 +40,17 @@ We will be implementing this `add` function. ## Steps needed for the author of the `calculator-lib` library -### Install `react-native-node-api-modules` as a dev-dependency and declare a peer dependency +### Install `react-native-node-api` as a dev-dependency and declare a peer dependency ```bash -npm install react-native-node-api-modules --save-dev --save-exact +npm install react-native-node-api --save-dev --save-exact ``` Update the package.json of your library to add a peer dependency on the package as well: ```bash # Update the command to use the exact version you installed as dev-dependency -npm pkg set peerDependencies.react-native-node-api-modules=1.2.3 +npm pkg set peerDependencies.react-native-node-api=1.2.3 ``` ### Implement native code @@ -123,7 +124,7 @@ NAPI_MODULE_INIT(/* napi_env env, napi_value exports */) { ### Build the prebuilt binaries ``` -npx react-native-node-api-modules build ./addon.c +npx react-native-node-api build ./addon.c ``` This is a shorthand command which generates a CMake project from the single source-file and prebuilds for both the Apple and Android platforms. See the [CLI documentation](./CLI.md) for more information on the options available and [documentation on prebuilds](./PREBUILDS.md) for the specifics on their format and structure. diff --git a/eslint.config.js b/eslint.config.js index 3a8f7a5f..360cbeaf 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -6,18 +6,20 @@ import eslint from '@eslint/js'; import tseslint from 'typescript-eslint'; export default tseslint.config( + globalIgnores([".nx/**"]), globalIgnores(["**/dist/**"]), globalIgnores(["apps/test-app/ios/**"]), - globalIgnores(["packages/react-native-node-api-modules/hermes/**"]), + globalIgnores(["packages/host/hermes/**"]), globalIgnores(["packages/node-addon-examples/examples/**"]), + globalIgnores(["packages/ferric-example/ferric_example.d.ts"]), eslint.configs.recommended, tseslint.configs.recommended, { files: [ "apps/test-app/*.js", "packages/node-addon-examples/*.js", - "packages/react-native-node-api-modules/babel-plugin.js", - "packages/react-native-node-api-modules/react-native.config.js" + "packages/host/babel-plugin.js", + "packages/host/react-native.config.js" ], languageOptions: { parserOptions: { @@ -35,8 +37,8 @@ export default tseslint.config( { files: [ "packages/gyp-to-cmake/bin/*.js", - "packages/react-native-node-api-modules/bin/*.mjs", - "packages/react-native-node-api-modules/scripts/*.mjs" + "packages/host/bin/*.mjs", + "packages/host/scripts/*.mjs" ], languageOptions: { globals: { diff --git a/package-lock.json b/package-lock.json index ebcc19f9..b4fda931 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,10 @@ { - "name": "react-native-node-api-modules-root", + "name": "react-native-node-api-root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "react-native-node-api-modules-root", + "name": "react-native-node-api-root", "license": "MIT", "workspaces": [ "apps/*", @@ -42,7 +42,7 @@ "react": "19.0.0", "react-native": "0.79.1", "react-native-node-addon-examples": "*", - "react-native-node-api-modules": "*", + "react-native-node-api": "*", "react-native-test-app": "^4.3.3" } }, @@ -10057,8 +10057,8 @@ "resolved": "packages/node-addon-examples", "link": true }, - "node_modules/react-native-node-api-modules": { - "resolved": "packages/react-native-node-api-modules", + "node_modules/react-native-node-api": { + "resolved": "packages/host", "link": true }, "node_modules/react-native-node-api-test-app": { @@ -12054,43 +12054,8 @@ "node": ">=18" } }, - "packages/node-addon-examples": { - "name": "react-native-node-addon-examples", - "devDependencies": { - "cmake-rn": "*", - "gyp-to-cmake": "*", - "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", - "read-pkg": "^9.0.1" - } - }, - "packages/node-addon-examples-tests": { - "extraneous": true, - "devDependencies": { - "gyp-to-cmake": "*", - "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", - "react-native-node-api-cmake": "*" - } - }, - "packages/react-native-node-api-cmake": { - "version": "0.1.0", - "extraneous": true, - "dependencies": { - "@commander-js/extra-typings": "^13.1.0", - "bufout": "^0.3.1", - "chalk": "^5.4.1", - "cmake-js": "^7.3.1", - "commander": "^13.1.0", - "ora": "^8.2.0" - }, - "bin": { - "react-native-node-api-cmake": "bin/react-native-node-api-cmake.js" - }, - "peerDependencies": { - "node-addon-api": "^8.3.1", - "node-api-headers": "^1.5.0" - } - }, - "packages/react-native-node-api-modules": { + "packages/host": { + "name": "react-native-node-api", "version": "0.1.0", "license": "MIT", "dependencies": { @@ -12103,7 +12068,7 @@ "read-pkg": "^9.0.1" }, "bin": { - "react-native-node-api-modules": "bin/react-native-node-api-modules.mjs" + "react-native-node-api": "bin/react-native-node-api.mjs" }, "devDependencies": { "@babel/core": "^7.26.10", @@ -12118,7 +12083,7 @@ "react-native": "0.79.1 || 0.79.2" } }, - "packages/react-native-node-api-modules/node_modules/@commander-js/extra-typings": { + "packages/host/node_modules/@commander-js/extra-typings": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/@commander-js/extra-typings/-/extra-typings-13.1.0.tgz", "integrity": "sha512-q5P52BYb1hwVWE6dtID7VvuJWrlfbCv4klj7BjUUOqMz4jbSZD4C9fJ9lRjL2jnBGTg+gDDlaXN51rkWcLk4fg==", @@ -12127,7 +12092,7 @@ "commander": "~13.1.0" } }, - "packages/react-native-node-api-modules/node_modules/ansi-regex": { + "packages/host/node_modules/ansi-regex": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", @@ -12139,7 +12104,7 @@ "url": "https://github.com/chalk/ansi-regex?sponsor=1" } }, - "packages/react-native-node-api-modules/node_modules/chalk": { + "packages/host/node_modules/chalk": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.4.1.tgz", "integrity": "sha512-zgVZuo2WcZgfUEmsn6eO3kINexW8RAE4maiQ8QNs8CtpPCSyMiYsULR3HQYkm3w8FIA3SberyMJMSldGsW+U3w==", @@ -12151,14 +12116,14 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "packages/react-native-node-api-modules/node_modules/ci-info": { + "packages/host/node_modules/ci-info": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-2.0.0.tgz", "integrity": "sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ==", "dev": true, "license": "MIT" }, - "packages/react-native-node-api-modules/node_modules/cli-cursor": { + "packages/host/node_modules/cli-cursor": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-5.0.0.tgz", "integrity": "sha512-aCj4O5wKyszjMmDT4tZj93kxyydN/K5zPWSCe6/0AV/AA1pqe5ZBIw0a2ZfPQV7lL5/yb5HsUreJ6UFAF1tEQw==", @@ -12173,7 +12138,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/commander": { + "packages/host/node_modules/commander": { "version": "13.1.0", "resolved": "https://registry.npmjs.org/commander/-/commander-13.1.0.tgz", "integrity": "sha512-/rFeCpNJQbhSZjGVwO9RFV3xPqbnERS8MmIQzCtD/zl6gpJuV/bMLuN92oG3F7d8oDEHHRrujSXNUr8fpjntKw==", @@ -12182,7 +12147,7 @@ "node": ">=18" } }, - "packages/react-native-node-api-modules/node_modules/debug": { + "packages/host/node_modules/debug": { "version": "2.6.9", "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", @@ -12192,13 +12157,13 @@ "ms": "2.0.0" } }, - "packages/react-native-node-api-modules/node_modules/emoji-regex": { + "packages/host/node_modules/emoji-regex": { "version": "10.4.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-10.4.0.tgz", "integrity": "sha512-EC+0oUMY1Rqm4O6LLrgjtYDvcVYTy7chDnM4Q7030tP4Kwj3u/pR6gP9ygnp2CJMK5Gq+9Q2oqmrFJAz01DXjw==", "license": "MIT" }, - "packages/react-native-node-api-modules/node_modules/is-interactive": { + "packages/host/node_modules/is-interactive": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-interactive/-/is-interactive-2.0.0.tgz", "integrity": "sha512-qP1vozQRI+BMOPcjFzrjXuQvdak2pHNUMZoeG2eRbiSqyvbEf/wQtEOTOX1guk6E3t36RkaqiSt8A/6YElNxLQ==", @@ -12210,7 +12175,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/is-unicode-supported": { + "packages/host/node_modules/is-unicode-supported": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-2.1.0.tgz", "integrity": "sha512-mE00Gnza5EEB3Ds0HfMyllZzbBrmLOX3vfWoj9A9PEnTfratQ/BcaJOuMhnkhjXvb2+FkY3VuHqtAGpTPmglFQ==", @@ -12222,7 +12187,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/log-symbols": { + "packages/host/node_modules/log-symbols": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-6.0.0.tgz", "integrity": "sha512-i24m8rpwhmPIS4zscNzK6MSEhk0DUWa/8iYQWxhffV8jkI4Phvs3F+quL5xvS0gdQR0FyTCMMH33Y78dDTzzIw==", @@ -12238,7 +12203,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/log-symbols/node_modules/is-unicode-supported": { + "packages/host/node_modules/log-symbols/node_modules/is-unicode-supported": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-1.3.0.tgz", "integrity": "sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==", @@ -12250,7 +12215,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/metro": { + "packages/host/node_modules/metro": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro/-/metro-0.81.1.tgz", "integrity": "sha512-fqRu4fg8ONW7VfqWFMGgKAcOuMzyoQah2azv9Y3VyFXAmG+AoTU6YIFWqAADESCGVWuWEIvxTJhMf3jxU6jwjA==", @@ -12305,7 +12270,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-babel-transformer": { + "packages/host/node_modules/metro-babel-transformer": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-babel-transformer/-/metro-babel-transformer-0.81.1.tgz", "integrity": "sha512-JECKDrQaUnDmj0x/Q/c8c5YwsatVx38Lu+BfCwX9fR8bWipAzkvJocBpq5rOAJRDXRgDcPv2VO4Q4nFYrpYNQg==", @@ -12321,7 +12286,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-cache": { + "packages/host/node_modules/metro-cache": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-cache/-/metro-cache-0.81.1.tgz", "integrity": "sha512-Uqcmn6sZ+Y0VJHM88VrG5xCvSeU7RnuvmjPmSOpEcyJJBe02QkfHL05MX2ZyGDTyZdbKCzaX0IijrTe4hN3F0Q==", @@ -12336,7 +12301,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-cache-key": { + "packages/host/node_modules/metro-cache-key": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-cache-key/-/metro-cache-key-0.81.1.tgz", "integrity": "sha512-5fDaHR1yTvpaQuwMAeEoZGsVyvjrkw9IFAS7WixSPvaNY5YfleqoJICPc6hbXFJjvwCCpwmIYFkjqzR/qJ6yqA==", @@ -12349,7 +12314,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-config": { + "packages/host/node_modules/metro-config": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-config/-/metro-config-0.81.1.tgz", "integrity": "sha512-VAAJmxsKIZ+Fz5/z1LVgxa32gE6+2TvrDSSx45g85WoX4EtLmdBGP3DSlpQW3DqFUfNHJCGwMLGXpJnxifd08g==", @@ -12369,7 +12334,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-core": { + "packages/host/node_modules/metro-core": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-core/-/metro-core-0.81.1.tgz", "integrity": "sha512-4d2/+02IYqOwJs4dmM0dC8hIZqTzgnx2nzN4GTCaXb3Dhtmi/SJ3v6744zZRnithhN4lxf8TTJSHnQV75M7SSA==", @@ -12384,7 +12349,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-file-map": { + "packages/host/node_modules/metro-file-map": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-file-map/-/metro-file-map-0.81.1.tgz", "integrity": "sha512-aY72H2ujmRfFxcsbyh83JgqFF+uQ4HFN1VhV2FmcfQG4s1bGKf2Vbkk+vtZ1+EswcBwDZFbkpvAjN49oqwGzAA==", @@ -12405,7 +12370,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-minify-terser": { + "packages/host/node_modules/metro-minify-terser": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-minify-terser/-/metro-minify-terser-0.81.1.tgz", "integrity": "sha512-p/Qz3NNh1nebSqMlxlUALAnESo6heQrnvgHtAuxufRPtKvghnVDq9hGGex8H7z7YYLsqe42PWdt4JxTA3mgkvg==", @@ -12419,7 +12384,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-resolver": { + "packages/host/node_modules/metro-resolver": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-resolver/-/metro-resolver-0.81.1.tgz", "integrity": "sha512-E61t6fxRoYRkl6Zo3iUfCKW4DYfum/bLjcejXBMt1y3I7LFkK84TCR/Rs9OAwsMCY/7GOPB4+CREYZOtCC7CNA==", @@ -12432,7 +12397,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-runtime": { + "packages/host/node_modules/metro-runtime": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-runtime/-/metro-runtime-0.81.1.tgz", "integrity": "sha512-pqu5j5d01rjF85V/K8SDDJ0NR3dRp6bE3z5bKVVb5O2Rx0nbR9KreUxYALQCRCcQHaYySqCg5fYbGKBHC295YQ==", @@ -12446,7 +12411,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-source-map": { + "packages/host/node_modules/metro-source-map": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-source-map/-/metro-source-map-0.81.1.tgz", "integrity": "sha512-1i8ROpNNiga43F0ZixAXoFE/SS3RqcRDCCslpynb+ytym0VI7pkTH1woAN2HI9pczYtPrp3Nq0AjRpsuY35ieA==", @@ -12468,7 +12433,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-symbolicate": { + "packages/host/node_modules/metro-symbolicate": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-symbolicate/-/metro-symbolicate-0.81.1.tgz", "integrity": "sha512-Lgk0qjEigtFtsM7C0miXITbcV47E1ZYIfB+m/hCraihiwRWkNUQEPCWvqZmwXKSwVE5mXA0EzQtghAvQSjZDxw==", @@ -12489,7 +12454,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-transform-plugins": { + "packages/host/node_modules/metro-transform-plugins": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-transform-plugins/-/metro-transform-plugins-0.81.1.tgz", "integrity": "sha512-7L1lI44/CyjIoBaORhY9fVkoNe8hrzgxjSCQ/lQlcfrV31cZb7u0RGOQrKmUX7Bw4FpejrB70ArQ7Mse9mk7+Q==", @@ -12507,7 +12472,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro-transform-worker": { + "packages/host/node_modules/metro-transform-worker": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/metro-transform-worker/-/metro-transform-worker-0.81.1.tgz", "integrity": "sha512-M+2hVT3rEy5K7PBmGDgQNq3Zx53TjScOcO/CieyLnCRFtBGWZiSJ2+bLAXXOKyKa/y3bI3i0owxtyxuPGDwbZg==", @@ -12532,7 +12497,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/metro/node_modules/chalk": { + "packages/host/node_modules/metro/node_modules/chalk": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", @@ -12549,14 +12514,14 @@ "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "packages/react-native-node-api-modules/node_modules/ms": { + "packages/host/node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==", "dev": true, "license": "MIT" }, - "packages/react-native-node-api-modules/node_modules/ob1": { + "packages/host/node_modules/ob1": { "version": "0.81.1", "resolved": "https://registry.npmjs.org/ob1/-/ob1-0.81.1.tgz", "integrity": "sha512-1PEbvI+AFvOcgdNcO79FtDI1TUO8S3lhiKOyAiyWQF3sFDDKS+aw2/BZvGlArFnSmqckwOOB9chQuIX0/OahoQ==", @@ -12569,7 +12534,7 @@ "node": ">=18.18" } }, - "packages/react-native-node-api-modules/node_modules/onetime": { + "packages/host/node_modules/onetime": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/onetime/-/onetime-7.0.0.tgz", "integrity": "sha512-VXJjc87FScF88uafS3JllDgvAm+c/Slfz06lorj2uAY34rlUu0Nt+v8wreiImcrgAjjIHp1rXpTDlLOGw29WwQ==", @@ -12584,7 +12549,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/ora": { + "packages/host/node_modules/ora": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/ora/-/ora-8.2.0.tgz", "integrity": "sha512-weP+BZ8MVNnlCm8c0Qdc1WSWq4Qn7I+9CJGm7Qali6g44e/PUzbjNqJX5NJ9ljlNMosfJvg1fKEGILklK9cwnw==", @@ -12607,7 +12572,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/restore-cursor": { + "packages/host/node_modules/restore-cursor": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-5.1.0.tgz", "integrity": "sha512-oMA2dcrw6u0YfxJQXm342bFKX/E4sG9rbTzO9ptUcR/e8A33cHuvStiYOwH7fszkZlZ1z/ta9AAoPk2F4qIOHA==", @@ -12623,7 +12588,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/signal-exit": { + "packages/host/node_modules/signal-exit": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", @@ -12635,7 +12600,7 @@ "url": "https://github.com/sponsors/isaacs" } }, - "packages/react-native-node-api-modules/node_modules/string-width": { + "packages/host/node_modules/string-width": { "version": "7.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-7.2.0.tgz", "integrity": "sha512-tsaTIkKW9b4N+AEj+SVA+WhJzV7/zMhcSu78mLKWSk7cXMOSHsBKFWUs0fWwq8QyK3MgJBQRX6Gbi4kYbdvGkQ==", @@ -12652,7 +12617,7 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "packages/react-native-node-api-modules/node_modules/strip-ansi": { + "packages/host/node_modules/strip-ansi": { "version": "7.1.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", @@ -12667,7 +12632,7 @@ "url": "https://github.com/chalk/strip-ansi?sponsor=1" } }, - "packages/react-native-node-api-modules/node_modules/ws": { + "packages/host/node_modules/ws": { "version": "7.5.10", "resolved": "https://registry.npmjs.org/ws/-/ws-7.5.10.tgz", "integrity": "sha512-+dbF1tHwZpXcbOJdVOkzLDxZP1ailvSxM6ZweXTegylPny803bFhA+vqBYw4s31NSAk4S2Qz+AKXK9a4wkdjcQ==", @@ -12688,6 +12653,71 @@ "optional": true } } + }, + "packages/node-addon-examples": { + "name": "react-native-node-addon-examples", + "devDependencies": { + "cmake-rn": "*", + "gyp-to-cmake": "*", + "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", + "read-pkg": "^9.0.1" + } + }, + "packages/node-addon-examples-tests": { + "extraneous": true, + "devDependencies": { + "gyp-to-cmake": "*", + "node-addon-examples": "github:nodejs/node-addon-examples#4213d4c9d07996ae68629c67926251e117f8e52a", + "react-native-node-api-cmake": "*" + } + }, + "packages/react-native-node-api-cmake": { + "version": "0.1.0", + "extraneous": true, + "dependencies": { + "@commander-js/extra-typings": "^13.1.0", + "bufout": "^0.3.1", + "chalk": "^5.4.1", + "cmake-js": "^7.3.1", + "commander": "^13.1.0", + "ora": "^8.2.0" + }, + "bin": { + "react-native-node-api-cmake": "bin/react-native-node-api-cmake.js" + }, + "peerDependencies": { + "node-addon-api": "^8.3.1", + "node-api-headers": "^1.5.0" + } + }, + "packages/react-native-node-api-modules": { + "version": "0.1.0", + "extraneous": true, + "license": "MIT", + "dependencies": { + "@commander-js/extra-typings": "^13.1.0", + "bufout": "^0.3.1", + "chalk": "^5.4.1", + "commander": "^13.1.0", + "ora": "^8.2.0", + "pkg-dir": "^8.0.0", + "read-pkg": "^9.0.1" + }, + "bin": { + "react-native-node-api-modules": "bin/react-native-node-api-modules.mjs" + }, + "devDependencies": { + "@babel/core": "^7.26.10", + "@babel/types": "^7.27.0", + "fswin": "^3.24.829", + "metro-config": "0.81.1", + "node-api-headers": "^1.5.0", + "zod": "^3.24.3" + }, + "peerDependencies": { + "@babel/core": "^7.26.10", + "react-native": "0.79.1 || 0.79.2" + } } } } diff --git a/package.json b/package.json index 45876537..bb608792 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-native-node-api-modules-root", + "name": "react-native-node-api-root", "description": "Node-API Modules for React Native", "type": "module", "private": true, @@ -7,13 +7,13 @@ "apps/*", "packages/*" ], - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules#readme", + "homepage": "https://github.com/callstackincubator/react-native-node-api#readme", "scripts": { "build": "tsc --build", "clean": "tsc --build --clean", "dev": "tsc --build --watch", "lint": "eslint .", - "test": "npm run test --workspace react-native-node-api-modules --workspace cmake-rn --workspace gyp-to-cmake --workspace node-addon-examples" + "test": "npm run test --workspace react-native-node-api --workspace cmake-rn --workspace gyp-to-cmake --workspace node-addon-examples" }, "author": { "name": "Callstack", diff --git a/packages/cmake-rn/package.json b/packages/cmake-rn/package.json index fb2a1452..72903718 100644 --- a/packages/cmake-rn/package.json +++ b/packages/cmake-rn/package.json @@ -2,10 +2,10 @@ "name": "cmake-rn", "version": "0.1.0", "description": "Build React Native Node API modules with CMake", - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/cmake-rn" }, "type": "module", diff --git a/packages/cmake-rn/src/android.ts b/packages/cmake-rn/src/android.ts index 88f14877..dfe5a534 100644 --- a/packages/cmake-rn/src/android.ts +++ b/packages/cmake-rn/src/android.ts @@ -2,7 +2,7 @@ import assert from "node:assert/strict"; import fs from "node:fs"; import path from "node:path"; -import { AndroidTriplet } from "react-native-node-api-modules"; +import { AndroidTriplet } from "react-native-node-api"; export const DEFAULT_ANDROID_TRIPLETS = [ "aarch64-linux-android", diff --git a/packages/cmake-rn/src/apple.ts b/packages/cmake-rn/src/apple.ts index fb5a0811..da8a7ab4 100644 --- a/packages/cmake-rn/src/apple.ts +++ b/packages/cmake-rn/src/apple.ts @@ -1,6 +1,6 @@ import assert from "node:assert/strict"; -import { AppleTriplet, isAppleTriplet } from "react-native-node-api-modules"; +import { AppleTriplet, isAppleTriplet } from "react-native-node-api"; export const DEFAULT_APPLE_TRIPLETS = [ "arm64;x86_64-apple-darwin", diff --git a/packages/cmake-rn/src/cli.ts b/packages/cmake-rn/src/cli.ts index 5b90fece..bc03b705 100644 --- a/packages/cmake-rn/src/cli.ts +++ b/packages/cmake-rn/src/cli.ts @@ -30,7 +30,7 @@ import { createAppleFramework, createXCframework, determineXCFrameworkFilename, -} from "react-native-node-api-modules"; +} from "react-native-node-api"; // We're attaching a lot of listeners when spawning in parallel EventEmitter.defaultMaxListeners = 100; @@ -83,12 +83,12 @@ const ndkVersionOption = new Option( const noAutoLinkOption = new Option( "--no-auto-link", - "Don't mark the output as auto-linkable by react-native-node-api-modules" + "Don't mark the output as auto-linkable by react-native-node-api" ); const noWeakNodeApiLinkageOption = new Option( "--no-weak-node-api-linkage", - "Don't pass the path of the weak-node-api library from react-native-node-api-modules" + "Don't pass the path of the weak-node-api library from react-native-node-api" ); const xcframeworkExtensionOption = new Option( diff --git a/packages/cmake-rn/src/weak-node-api.ts b/packages/cmake-rn/src/weak-node-api.ts index 42d97507..4cf1982e 100644 --- a/packages/cmake-rn/src/weak-node-api.ts +++ b/packages/cmake-rn/src/weak-node-api.ts @@ -6,14 +6,14 @@ import { isAndroidTriplet, isAppleTriplet, SupportedTriplet, -} from "react-native-node-api-modules"; +} from "react-native-node-api"; import { ANDROID_ARCHITECTURES } from "./android.js"; import { getNodeAddonHeadersPath, getNodeApiHeadersPath } from "./headers.js"; export function getWeakNodeApiPath(triplet: SupportedTriplet): string { const { pathname } = new URL( - import.meta.resolve("react-native-node-api-modules/weak-node-api") + import.meta.resolve("react-native-node-api/weak-node-api") ); assert(fs.existsSync(pathname), "Weak Node API path does not exist"); if (isAppleTriplet(triplet)) { diff --git a/packages/ferric-example/package.json b/packages/ferric-example/package.json index 8d9ac9e9..73869b66 100644 --- a/packages/ferric-example/package.json +++ b/packages/ferric-example/package.json @@ -2,10 +2,10 @@ "name": "ferric-example", "private": true, "version": "0.1.0", - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/ferric-example" }, "main": "ferric_example.js", diff --git a/packages/ferric/package.json b/packages/ferric/package.json index 6759907e..bd89b0ae 100644 --- a/packages/ferric/package.json +++ b/packages/ferric/package.json @@ -2,10 +2,10 @@ "name": "ferric-cli", "version": "0.1.0", "description": "Rust Node-API Modules for React Native", - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/ferric" }, "type": "module", diff --git a/packages/ferric/src/build.ts b/packages/ferric/src/build.ts index d54ac713..799dcfdf 100644 --- a/packages/ferric/src/build.ts +++ b/packages/ferric/src/build.ts @@ -16,7 +16,7 @@ import { createUniversalAppleLibrary, determineLibraryBasename, prettyPath, -} from "react-native-node-api-modules"; +} from "react-native-node-api"; import { UsageError } from "./errors.js"; import { ensureCargo, build } from "./cargo.js"; diff --git a/packages/ferric/src/cargo.ts b/packages/ferric/src/cargo.ts index e227a849..79e6bc40 100644 --- a/packages/ferric/src/cargo.ts +++ b/packages/ferric/src/cargo.ts @@ -15,7 +15,7 @@ import { } from "./targets.js"; const WEAK_NODE_API_PATH = new URL( - import.meta.resolve("react-native-node-api-modules/weak-node-api") + import.meta.resolve("react-native-node-api/weak-node-api") ).pathname; const APPLE_XCFRAMEWORK_CHILDS_PER_TARGET: Record = { diff --git a/packages/gyp-to-cmake/package.json b/packages/gyp-to-cmake/package.json index e6c7564f..2c08ad45 100644 --- a/packages/gyp-to-cmake/package.json +++ b/packages/gyp-to-cmake/package.json @@ -3,10 +3,10 @@ "version": "0.1.0", "private": true, "description": "Convert binding.gyp files to CMakeLists.txt", - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/gyp-to-cmake" }, "type": "module", diff --git a/packages/gyp-to-cmake/src/transformer.ts b/packages/gyp-to-cmake/src/transformer.ts index aa1b5e6f..6a33c160 100644 --- a/packages/gyp-to-cmake/src/transformer.ts +++ b/packages/gyp-to-cmake/src/transformer.ts @@ -87,7 +87,7 @@ export function bindingGypToCmakeLists({ ); } - // Adding this post-amble from the template, although not used by react-native-node-api-modules + // Adding this post-amble from the template, although not used by react-native-node-api lines.push( "", "if(MSVC AND CMAKE_JS_NODELIB_DEF AND CMAKE_JS_NODELIB_TARGET)", diff --git a/packages/host/android/CMakeLists.txt b/packages/host/android/CMakeLists.txt index 6b4d2a5f..b913de7f 100644 --- a/packages/host/android/CMakeLists.txt +++ b/packages/host/android/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.13) -project(react-native-node-api-modules) +project(react-native-node-api) set(CMAKE_CXX_STANDARD 20) find_package(ReactAndroid REQUIRED CONFIG) diff --git a/packages/host/android/build.gradle b/packages/host/android/build.gradle index 5c04e7d3..df86c99a 100644 --- a/packages/host/android/build.gradle +++ b/packages/host/android/build.gradle @@ -143,7 +143,7 @@ task linkNodeApiModules { doLast { exec { // TODO: Support --strip-path-suffix - commandLine 'npx', 'react-native-node-api-modules', 'link', '--android', rootProject.rootDir.absolutePath + commandLine 'npx', 'react-native-node-api', 'link', '--android', rootProject.rootDir.absolutePath standardOutput = System.out errorOutput = System.err // Enable color output diff --git a/packages/host/cpp/CxxNodeApiHostModule.cpp b/packages/host/cpp/CxxNodeApiHostModule.cpp index af448026..727241cc 100644 --- a/packages/host/cpp/CxxNodeApiHostModule.cpp +++ b/packages/host/cpp/CxxNodeApiHostModule.cpp @@ -89,7 +89,7 @@ bool CxxNodeApiHostModule::loadNodeAddon(NodeAddon &addon, // TODO: Read "node_api_module_get_api_version_v1" to support the addon // declaring its Node-API version // @see - // https://github.com/callstackincubator/react-native-node-api-modules/issues/4 + // https://github.com/callstackincubator/react-native-node-api/issues/4 } else { log_debug("[%s] Failed to load library", libraryName.c_str()); } @@ -104,7 +104,7 @@ bool CxxNodeApiHostModule::initializeNodeModule(jsi::Runtime &rt, napi_status status = napi_ok; // TODO: Read the version from the addon // @see - // https://github.com/callstackincubator/react-native-node-api-modules/issues/4 + // https://github.com/callstackincubator/react-native-node-api/issues/4 napi_env env = reinterpret_cast(rt.createNodeApiEnv(8)); // Create the "exports" object diff --git a/packages/host/package.json b/packages/host/package.json index 90677295..ce8e8b08 100644 --- a/packages/host/package.json +++ b/packages/host/package.json @@ -1,11 +1,11 @@ { "name": "react-native-node-api", "version": "0.1.0", - "description": "Node-API Modules for React Native", - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "description": "Node-API for React Native", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/react-native-node-api" }, "main": "dist/react-native/index.js", diff --git a/packages/host/react-native-node-api-modules.podspec b/packages/host/react-native-node-api-modules.podspec index 618b4346..7592a3c1 100644 --- a/packages/host/react-native-node-api-modules.podspec +++ b/packages/host/react-native-node-api-modules.podspec @@ -27,7 +27,7 @@ Pod::Spec.new do |s| s.authors = package["author"] s.platforms = { :ios => min_ios_version_supported } - s.source = { :git => "https://github.com/callstackincubator/react-native-node-api-modules.git", :tag => "#{s.version}" } + s.source = { :git => "https://github.com/callstackincubator/react-native-node-api.git", :tag => "#{s.version}" } s.source_files = "ios/**/*.{h,m,mm}", "cpp/**/*.{hpp,cpp,c,h}", "weak-node-api/include/*.h", "weak-node-api/*.hpp" s.public_header_files = "weak-node-api/include/*.h" diff --git a/packages/host/scripts/generate-weak-node-api-injector.ts b/packages/host/scripts/generate-weak-node-api-injector.ts index 0d3a61a8..ff73b0ed 100644 --- a/packages/host/scripts/generate-weak-node-api-injector.ts +++ b/packages/host/scripts/generate-weak-node-api-injector.ts @@ -11,7 +11,7 @@ export const CPP_SOURCE_PATH = path.join(__dirname, "../cpp"); */ export function generateSource(functions: FunctionDecl[]) { return ` - // This file is generated by react-native-node-api-modules + // This file is generated by react-native-node-api #include #include #include diff --git a/packages/host/scripts/generate-weak-node-api.ts b/packages/host/scripts/generate-weak-node-api.ts index 27be13db..23a3c89d 100644 --- a/packages/host/scripts/generate-weak-node-api.ts +++ b/packages/host/scripts/generate-weak-node-api.ts @@ -11,7 +11,7 @@ export const WEAK_NODE_API_PATH = path.join(__dirname, "../weak-node-api"); */ export function generateHeader(functions: FunctionDecl[]) { return [ - "// This file is generated by react-native-node-api-modules", + "// This file is generated by react-native-node-api", "#include ", // Node-API "#include ", // fprintf() "#include ", // abort() @@ -34,7 +34,7 @@ export function generateHeader(functions: FunctionDecl[]) { */ export function generateSource(functions: FunctionDecl[]) { return [ - "// This file is generated by react-native-node-api-modules", + "// This file is generated by react-native-node-api", `#include "weak_node_api.hpp"`, // Generated header // Generate the struct of function pointers "WeakNodeApiHost g_host;", diff --git a/packages/host/scripts/patch-hermes.rb b/packages/host/scripts/patch-hermes.rb index 6e200250..2d986e4a 100644 --- a/packages/host/scripts/patch-hermes.rb +++ b/packages/host/scripts/patch-hermes.rb @@ -1,6 +1,6 @@ Pod::UI.warn "!!! PATCHING HERMES WITH NODE-API SUPPORT !!!" -VENDORED_HERMES_DIR ||= `npx react-native-node-api-modules vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip +VENDORED_HERMES_DIR ||= `npx react-native-node-api vendor-hermes --silent '#{Pod::Config.instance.installation_root}'`.strip if Dir.exist?(VENDORED_HERMES_DIR) Pod::UI.info "Hermes vendored into #{VENDORED_HERMES_DIR.inspect}" else diff --git a/packages/host/src/node/babel-plugin/plugin.ts b/packages/host/src/node/babel-plugin/plugin.ts index 2431af69..49733089 100644 --- a/packages/host/src/node/babel-plugin/plugin.ts +++ b/packages/host/src/node/babel-plugin/plugin.ts @@ -30,7 +30,7 @@ export function replaceWithRequireNodeAddon( t.callExpression( t.memberExpression( t.callExpression(t.identifier("require"), [ - t.stringLiteral("react-native-node-api-modules"), + t.stringLiteral("react-native-node-api"), ]), t.identifier("requireNodeAddon") ), diff --git a/packages/host/src/node/cli/apple.ts b/packages/host/src/node/cli/apple.ts index d7191bd1..5de453d6 100644 --- a/packages/host/src/node/cli/apple.ts +++ b/packages/host/src/node/cli/apple.ts @@ -45,7 +45,7 @@ export async function linkXcframework({ const newLibraryName = getLibraryName(modulePath, naming); const outputPath = getLinkedModuleOutputPath(platform, modulePath, naming); const tempPath = await fs.promises.mkdtemp( - path.join(os.tmpdir(), `react-native-node-api-modules-${newLibraryName}-`) + path.join(os.tmpdir(), `react-native-node-api-${newLibraryName}-`) ); try { if (incremental && fs.existsSync(outputPath)) { diff --git a/packages/host/src/node/cli/program.ts b/packages/host/src/node/cli/program.ts index 62c1ef27..963ca414 100644 --- a/packages/host/src/node/cli/program.ts +++ b/packages/host/src/node/cli/program.ts @@ -28,7 +28,7 @@ import { linkAndroidDir } from "./android"; // We're attaching a lot of listeners when spawning in parallel EventEmitter.defaultMaxListeners = 100; -export const program = new Command("react-native-node-api-modules").addCommand( +export const program = new Command("react-native-node-api").addCommand( vendorHermes ); diff --git a/packages/host/src/node/path-utils.ts b/packages/host/src/node/path-utils.ts index e09b31ac..ec93df86 100644 --- a/packages/host/src/node/path-utils.ts +++ b/packages/host/src/node/path-utils.ts @@ -45,13 +45,13 @@ export function isNodeApiModule(modulePath: string): boolean { if (!entries.includes(fileName)) { return false; } - + const filePath = path.join(dir, fileName); - + try { // First, check if file exists (works the same on all platforms) fs.accessSync(filePath, fs.constants.F_OK); - + // Then check if it's readable (behavior differs by platform) if (!isReadableSync(filePath)) { throw new Error(`Found an unreadable module ${fileName}`); @@ -237,7 +237,7 @@ export const MAGIC_FILENAME = "react-native-node-api-module"; * Default patterns to use when excluding paths from the search for Node-API modules. */ export const DEFAULT_EXCLUDE_PATTERNS = [ - /\/react-native-node-api-modules\//, + /\/react-native-node-api\//, /\/node_modules\//, /\/.git\//, ]; @@ -277,12 +277,12 @@ export function findNodeApiModulePaths( } const candidatePath = path.join(fromPath, suffix); // Normalize path separators for consistent pattern matching on all platforms - const normalizedSuffix = suffix.split(path.sep).join('/'); - + const normalizedSuffix = suffix.split(path.sep).join("/"); + if (excludePatterns.some((pattern) => pattern.test(normalizedSuffix))) { return []; } - + return fs .readdirSync(candidatePath, { withFileTypes: true }) .flatMap((file) => { diff --git a/packages/node-addon-examples/package.json b/packages/node-addon-examples/package.json index 467f66e8..ff0a16a2 100644 --- a/packages/node-addon-examples/package.json +++ b/packages/node-addon-examples/package.json @@ -1,10 +1,10 @@ { "name": "react-native-node-addon-examples", "private": true, - "homepage": "https://github.com/callstackincubator/react-native-node-api-modules", + "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { "type": "git", - "url": "git+https://github.com/callstackincubator/react-native-node-api-modules.git", + "url": "git+https://github.com/callstackincubator/react-native-node-api.git", "directory": "packages/node-addon-examples" }, "scripts": { diff --git a/tsconfig.json b/tsconfig.json index 66aec613..4b931432 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "files": [], "references": [ - { "path": "./packages/react-native-node-api-modules/tsconfig.json" }, + { "path": "./packages/host/tsconfig.json" }, { "path": "./packages/gyp-to-cmake/tsconfig.json" }, { "path": "./packages/cmake-rn/tsconfig.json" }, { "path": "./packages/ferric/tsconfig.json" } From e05b342594bcef322fae8b311ef9c8ebdfea82e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 12:37:09 +0200 Subject: [PATCH 5/6] Rename "react-native-node-addon-examples" to "@react-native-node-api/node-addon-examples" --- .github/workflows/check.yml | 2 +- packages/node-addon-examples/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml index 2734b27b..c9708b2e 100644 --- a/.github/workflows/check.yml +++ b/.github/workflows/check.yml @@ -63,4 +63,4 @@ jobs: - run: npm run copy-node-api-headers --workspace react-native-node-api - run: npm run build-weak-node-api --workspace react-native-node-api - run: npm run generate-weak-node-api-injector --workspace react-native-node-api - - run: npm test --workspace react-native-node-addon-examples + - run: npm test --workspace @react-native-node-api/node-addon-examples diff --git a/packages/node-addon-examples/package.json b/packages/node-addon-examples/package.json index ff0a16a2..1863b785 100644 --- a/packages/node-addon-examples/package.json +++ b/packages/node-addon-examples/package.json @@ -1,5 +1,5 @@ { - "name": "react-native-node-addon-examples", + "name": "@react-native-node-api/node-addon-examples", "private": true, "homepage": "https://github.com/callstackincubator/react-native-node-api", "repository": { From 3a75fd5c88c6429f6bf5ed2653b9bed19d1c79ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Wed, 11 Jun 2025 13:07:39 +0200 Subject: [PATCH 6/6] Rename root package --- package-lock.json | 10 +++++++--- package.json | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index b4fda931..b70ba5f0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,10 +1,10 @@ { - "name": "react-native-node-api-root", + "name": "@react-native-node-api/root", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "react-native-node-api-root", + "name": "@react-native-node-api/root", "license": "MIT", "workspaces": [ "apps/*", @@ -4780,6 +4780,10 @@ "node": "^12.20.0 || >=14" } }, + "node_modules/@react-native-node-api/node-addon-examples": { + "resolved": "packages/node-addon-examples", + "link": true + }, "node_modules/@react-native/assets-registry": { "version": "0.79.1", "resolved": "https://registry.npmjs.org/@react-native/assets-registry/-/assets-registry-0.79.1.tgz", @@ -12655,7 +12659,7 @@ } }, "packages/node-addon-examples": { - "name": "react-native-node-addon-examples", + "name": "@react-native-node-api/node-addon-examples", "devDependencies": { "cmake-rn": "*", "gyp-to-cmake": "*", diff --git a/package.json b/package.json index bb608792..20d7948a 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "react-native-node-api-root", + "name": "@react-native-node-api/root", "description": "Node-API Modules for React Native", "type": "module", "private": true,