Repository navigation
refactor(nitro): port the 28 specs and C++ to Nitro Modules v1 - #1108
Merged
Merged
Conversation
Bump nitrogen, nitro-core and react-native-nitro-modules to 1.0.0-alpha.nightly.138.g43e09c161101, rewrite nitro.json for the bare environment, add the #nitro/* imports map, port all 28 specs to decorated declare classes (statics for stateless members, zero-arg constructors for stateful classes), regenerate with nitrogen v1, and replace every createHybridObject call site with `new X()` or static calls. Configure bob and Metro babel for the decorators parser and the example tsconfig for package imports. Native code (cpp/, Android, iOS) is not ported in this commit and will not compile until phases 2-4 of #1102 land. TypeScript, lint, format, bob build and Jest pass.
…ules v1 Add scripts/check-nitro-v1-compile.sh (iOS simulator and Android NDK syntax-only compile of the package C++ against Nitro v1). Port ToNativeArrayBuffer helpers, KeyObjectData, HybridKeyObjectHandle (raw SLH-DSA import via an extended Class), and the static modules Argon2, Certificate, Hkdf, Pbkdf2, Prime, Random, Scrypt, TurboShake, RsaCipher and Utils. Stateful modules follow in Phase 3.
… Modules v1 Port HybridCipher and its subclasses, HybridCipherFactory, Hash, Hmac, Kmac, Blake3, SignHandle, VerifyHandle and X509Certificate to the v1 ArrayBuffer value type, no-argument HybridObject constructors, and static members for the stateless methods. Keypair modules follow in Phase 3b.
react-native-mmkv 4.3.2 ships Nitro Modules 0.x generated code and cannot compile against Nitro Modules v1. Nothing in the example uses it. With it gone, the example's Android build succeeds on Nitro Modules v1.
- Capture shared_cast self in the DH, DSA, EC and RSA generateKeyPair async lambdas, matching Ed/ML-DSA, so a disposed or collected object is never written from the worker. - Make the compile check also require every TU to report ok. - Restore import type for KeyObjectHandle in utils/types. - Pin the nitro-core and react-native-nitro-modules peers to the exact Nitro Modules v1 nightly the generated bindings target. - Record the known next-branch breakage owned by #1101 and #1103.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is the first PR into
next(RNQC 2.0). It ports RNQC's 28 Nitro specs (30 HybridObjects) to Nitro Modules v1 (margelo/nitro@43e09c1, npm1.0.0-alpha.nightly.138.g43e09c161101), regenerates them with nitrogen v1 using"environment": "bare", and ports the C++ hybrid objects to the new headers and types. Following decision 4 from #1100, stateless members become statics and stateful classes get constructors.nextwas created frommainat 5f9560e.Changes
nitrogen,nitro-coreandreact-native-nitro-modulesare pinned to the v1 nightly. Thenitro-coreandreact-native-nitro-modulespeers are optional and pinned to that exact nightly, following decision 7 from Nitro Modules v1: research breaking changes and React Native support #1100.nitro.jsonis rewritten for v1, withenvironment: bareand noautolinkingblock.package.jsongains the#nitro/*imports map.declare classspecs that import fromnitro-core. The generated output undernitrogen/generatedis fully regenerated, and the oldios/and flatshared/c++layout is gone.createHybridObjectcalls (65 in the package, 1 in the example) becomenew X()or static calls. The lazy singletons for static-only modules are removed. JS reaches the raw JSI methods (Utils.stringToBuffer/bufferToString,KeyObjectHandle.importSlhDsaRawPrivateKey) throughin/typeoftype guards, with no casts.ArrayBufferis now a value type. TheToNativeArrayBufferhelpers deep-copy withArrayBuffer::copyand neverasOwning(), so JS can't mutate bytes that native code is reading.cleanse,secureZero,memzero) are unchanged: 33 sites before and after.dataOrEmpty()guards the OpenSSL and libsodium calls that would otherwise get a null pointer for empty buffers.Promise<T>is returned by value, and async lambdas capture owned data. The DH, DSA, EC, Ed and RSAgenerateKeyPairlambdas now holdshared_castself rather than barethis.Classthat overridesgetHybridClass().cpp-adapter.cpp(registerAllNatives()) and anitro-core-config.cmakeshim (from Nitro Modules v1: research breaking changes and React Native support #1100's spike).react-native-mmkv. Nothing used it, and its Nitro 0.x generated code doesn't compile against v1.scripts/check-nitro-v1-compile.shis new. It runs aclang++ -std=c++20 -fsyntax-onlypass over every hand-written, generated and ncrypto TU for the iOS simulator and the Android NDK.Testing
All runs were on macOS.
scripts/check-nitro-v1-compile.sh, run at f7c7ca4, passed 108/108 TUs onarm64-apple-ios16.0-simulatorand 108/108 onaarch64-linux-android26. A run withSODIUM_ENABLED=1at 4f5aa8b also passed 108/108 on both targets. As a negative control, an unported TU fails the check.cd example && bun run build:android(arm64-v8a, at 4668d3a) reported BUILD SUCCESSFUL.app-debug.apkcontainslibQuickCrypto.soandlibNitroModules.so, andllvm-nm -D --defined-onlyshows no exportedERR_*,EVP_*,SSL_*orOPENSSL_*symbols.OPENSSL_ROOT_DIR=/opt/homebrew/opt/openssl@3.6 scripts/check-ncrypto-openssl-deprecations.shexited 0 at 4f5aa8b. ncrypto is unchanged in this PR.bun tsc,bun lint,bun format,bun --filter="react-native-quick-crypto" prepareandbun run circularpassed at 435b2de.cd packages/react-native-quick-crypto && bun run testpassed 19 tests in 3 suites at 435b2de.bun tscandbun lintpassed again at f7c7ca4.nitrogen/generatedexactly.agentscm/local-validationgate covers PRs intomainonly, so it doesn't apply to this PR intonext. No mobile E2E ran, so there are no screenshots.Delivery
Merging into
nextdelivers nothing to npm or to consumers.nextis an integration branch for RNQC 2.0 (#1105).Not verified
These gaps are deliberate. The scope split was agreed for #1102, and each item has an owner:
pod installfails onnext, becauseQuickCrypto.podspecstill loads the deletednitrogen/generated/ios/QuickCrypto+autolinking.rb. Owner: Native packaging for Nitro Modules v1: SwiftPM/CocoaPods, Android CMake, OpenSSL, libsodium, blake3 #1103.nitro-corethrows until an RN entry importsreact-native-nitro-modulesfirst. None of the ported C++, including the raw-method exposure and empty-buffer round-trips, has run yet. Owners: Make RNQC usable without React Native (single package, Nitro Modules v1 bare + RN layer) #1101, E2E qualification for Nitro Modules v1: React Native app plus a bare-host smoke test #1104."react-native": "src/index"need the decorators parser. Make RNQC usable without React Native (single package, Nitro Modules v1 bare + RN layer) #1101 should point the RN entry at built output and then drop the example'sparserOpts.react-nativepeer: still*, although Nitro Modules v1 needs RN 0.88+. Owner: Make RNQC usable without React Native (single package, Nitro Modules v1 bare + RN layer) #1101 or Release RNQC 2.0 (on Nitro Modules v1) from the next branch #1105.Closes #1102
🤖 Generated with Claude Code