diff --git a/.github/workflows/build-android-release.yml b/.github/workflows/build-android-release.yml index 0a8b3fea7..2fb7ce5dc 100644 --- a/.github/workflows/build-android-release.yml +++ b/.github/workflows/build-android-release.yml @@ -17,9 +17,6 @@ jobs: - name: Install npm dependencies (bun) run: bun install - - name: Install npm dependencies in example/ (bun) - working-directory: example - run: bun install - name: Setup JDK 17 uses: actions/setup-java@v5 @@ -32,8 +29,9 @@ jobs: run: sed -i "s/minSdkVersion = 24/minSdkVersion = 26/g" example/android/build.gradle - name: Run Gradle Build for example/android/ - working-directory: example - run: bun run build:android-release + working-directory: example/android + run: | + ./gradlew clean :app:assembleRelease --no-daemon --no-build-cache - name: Upload APK to Release uses: actions/upload-release-asset@v1 diff --git a/.github/workflows/build-ios-release.yml b/.github/workflows/build-ios-release.yml index 27647598b..271464ff8 100644 --- a/.github/workflows/build-ios-release.yml +++ b/.github/workflows/build-ios-release.yml @@ -17,9 +17,6 @@ jobs: - name: Install npm dependencies (bun) run: bun install - - name: Install npm dependencies in example/ (bun) - working-directory: example - run: bun install - name: Setup Ruby (bundle) uses: ruby/setup-ruby@v1 @@ -30,14 +27,6 @@ jobs: - name: Select Xcode 26.2 run: sudo xcode-select -s "/Applications/Xcode_26.2.app/Contents/Developer" - - - name: Restore Pods cache - uses: actions/cache@v5 - with: - path: example/ios/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }} - restore-keys: | - ${{ runner.os }}-pods- - name: Install Pods working-directory: example run: bun pods @@ -55,6 +44,7 @@ jobs: -configuration Release \ -destination 'generic/platform=iOS Simulator' \ -showBuildTimingSummary \ + clean \ build \ CODE_SIGNING_ALLOWED=NO | xcbeautify --renderer github-actions diff --git a/.github/workflows/build-ios.yml b/.github/workflows/build-ios.yml index b4413a256..12b06b88d 100644 --- a/.github/workflows/build-ios.yml +++ b/.github/workflows/build-ios.yml @@ -38,6 +38,8 @@ on: env: USE_CCACHE: 1 + XCODE_VERSION: '26.2' + IOS_SIMULATOR_DESTINATION: 'platform=iOS Simulator,name=iPhone 17 Pro' jobs: build: @@ -65,7 +67,7 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: max-size: 1.5G - key: ${{ runner.os }}-${{ matrix.use_frameworks }}-ccache-example-ios + key: ${{ runner.os }}-${{ runner.arch }}-xcode${{ env.XCODE_VERSION }}-${{ matrix.use_frameworks }}-ccache-example-ios create-symlink: true - name: Setup ccache behavior run: | @@ -81,16 +83,16 @@ jobs: bundler-cache: true working-directory: example - - name: Select Xcode 26.2 - run: sudo xcode-select -s "/Applications/Xcode_26.2.app/Contents/Developer" + - name: Select Xcode ${{ env.XCODE_VERSION }} + run: sudo xcode-select -s "/Applications/Xcode_${{ env.XCODE_VERSION }}.app/Contents/Developer" - name: Restore Pods cache uses: actions/cache@v5 with: path: example/ios/Pods - key: ${{ runner.os }}-${{ matrix.use_frameworks }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }} + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.use_frameworks }}-pods-${{ hashFiles('bun.lock', 'example/Gemfile.lock', 'example/ios/Podfile.lock') }} restore-keys: | - ${{ runner.os }}-${{ matrix.use_frameworks }}-pods- + ${{ runner.os }}-${{ runner.arch }}-${{ matrix.use_frameworks }}-pods- - name: Install Pods working-directory: example run: bun pods @@ -99,9 +101,9 @@ jobs: uses: actions/cache@v5 with: path: example/ios/build - key: ${{ runner.os }}-${{ matrix.use_frameworks }}-dd-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock', '**/package.json', '**/bun.lockb') }}-xcode26.2 + key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.use_frameworks }}-xcode${{ env.XCODE_VERSION }}-dd-${{ hashFiles('bun.lock', 'example/Gemfile.lock', 'example/ios/Podfile.lock') }} restore-keys: | - ${{ runner.os }}-${{ matrix.use_frameworks }}-dd- + ${{ runner.os }}-${{ runner.arch }}-${{ matrix.use_frameworks }}-xcode${{ env.XCODE_VERSION }}-dd- - name: Build App working-directory: example/ios @@ -114,7 +116,7 @@ jobs: -scheme NitroExample \ -sdk iphonesimulator \ -configuration Debug \ - -destination 'platform=iOS Simulator,name=iPhone 17 Pro' \ + -destination '${{ env.IOS_SIMULATOR_DESTINATION }}' \ -showBuildTimingSummary \ ONLY_ACTIVE_ARCH=YES \ build \ diff --git a/.github/workflows/harness-android.yml b/.github/workflows/harness-android.yml index 06d60d060..efc738eed 100644 --- a/.github/workflows/harness-android.yml +++ b/.github/workflows/harness-android.yml @@ -44,6 +44,7 @@ on: - "packages/react-native-nitro-test-external/android/**" - "packages/react-native-nitro-modules/cpp/**" - "packages/react-native-nitro-modules/android/**" + - "packages/react-native-nitro-modules/src/**" - "**/bun.lock" - "**/react-native.config.js" - "**/nitro.json" @@ -61,6 +62,7 @@ on: - "packages/react-native-nitro-test-external/android/**" - "packages/react-native-nitro-modules/cpp/**" - "packages/react-native-nitro-modules/android/**" + - "packages/react-native-nitro-modules/src/**" - "**/bun.lock" - "**/react-native.config.js" - "**/nitro.json" diff --git a/.github/workflows/harness-ios.yml b/.github/workflows/harness-ios.yml index 51699b921..f29cc4a8d 100644 --- a/.github/workflows/harness-ios.yml +++ b/.github/workflows/harness-ios.yml @@ -36,6 +36,7 @@ on: - "packages/react-native-nitro-test-external/ios/**" - "packages/react-native-nitro-modules/cpp/**" - "packages/react-native-nitro-modules/ios/**" + - "packages/react-native-nitro-modules/src/**" - "**/Podfile.lock" - "**/*.podspec" - "**/react-native.config.js" @@ -54,6 +55,7 @@ on: - "packages/react-native-nitro-test-external/ios/**" - "packages/react-native-nitro-modules/cpp/**" - "packages/react-native-nitro-modules/ios/**" + - "packages/react-native-nitro-modules/src/**" - "**/Podfile.lock" - "**/*.podspec" - "**/react-native.config.js" @@ -87,7 +89,7 @@ jobs: uses: hendrikmuhs/ccache-action@v1.2 with: max-size: 1.5G - key: ${{ runner.os }}-ccache-example-ios + key: ${{ runner.os }}-${{ runner.arch }}-xcode${{ env.XCODE_VERSION }}-ccache-example-ios create-symlink: true - name: Setup ccache behavior run: | @@ -110,9 +112,9 @@ jobs: uses: actions/cache@v5 with: path: example/ios/Pods - key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock') }} + key: ${{ runner.os }}-${{ runner.arch }}-pods-${{ hashFiles('bun.lock', 'example/Gemfile.lock', 'example/ios/Podfile.lock') }} restore-keys: | - ${{ runner.os }}-pods- + ${{ runner.os }}-${{ runner.arch }}-pods- - name: Install Pods working-directory: example run: bun pods @@ -121,9 +123,9 @@ jobs: uses: actions/cache@v5 with: path: example/ios/build - key: ${{ runner.os }}-dd-${{ hashFiles('**/Podfile.lock', '**/Gemfile.lock', '**/package.json', '**/bun.lockb') }}-xcode26.2 + key: ${{ runner.os }}-${{ runner.arch }}-xcode${{ env.XCODE_VERSION }}-dd-${{ hashFiles('bun.lock', 'example/Gemfile.lock', 'example/ios/Podfile.lock') }} restore-keys: | - ${{ runner.os }}-dd- + ${{ runner.os }}-${{ runner.arch }}-xcode${{ env.XCODE_VERSION }}-dd- - name: Build iOS app working-directory: example/ios diff --git a/.github/workflows/lint-typescript.yml b/.github/workflows/lint-typescript.yml index 351d9bdc6..a5a0fc89e 100644 --- a/.github/workflows/lint-typescript.yml +++ b/.github/workflows/lint-typescript.yml @@ -1,9 +1,7 @@ name: Lint TypeScript permissions: - checks: write contents: read - pull-requests: read on: push: @@ -38,16 +36,12 @@ jobs: steps: - uses: actions/checkout@v6 - uses: oven-sh/setup-bun@v2 - - uses: reviewdog/action-setup@v1 - name: Install npm dependencies (bun) run: bun install - name: Run TypeScript (tsc) - run: | - bun typecheck | reviewdog -name="tsc" -efm="%f(%l,%c): error TS%n: %m" -reporter="github-pr-review" -filter-mode="nofilter" -fail-on-error -tee - env: - REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: bun typecheck lint: name: Lint TypeScript (eslint, prettier) @@ -55,7 +49,6 @@ jobs: steps: - uses: actions/checkout@v6 - uses: oven-sh/setup-bun@v2 - - uses: reviewdog/action-setup@v1 - name: Install npm dependencies (bun) run: bun install diff --git a/README.md b/README.md index 0655b2b67..2fca66aed 100644 --- a/README.md +++ b/README.md @@ -87,7 +87,7 @@ We build fast and beautiful apps. Contact us at [margelo.com](https://margelo.co ## Contributing -See the [contributing guide](https://nitro.margelo.com/docs/contributing) to learn how to contribute to the repository and the development workflow. +See the [contributing guide](https://nitro.margelo.com/docs/resources/contributing) to learn how to contribute to the repository and the development workflow. ## License diff --git a/bun.lock b/bun.lock index 19165e682..0f008b68c 100644 --- a/bun.lock +++ b/bun.lock @@ -43,7 +43,7 @@ "prism-react-renderer": "^2.3.0", "react": "19.1.0", "react-dom": "19.1.0", - "satori": "^0.24.1", + "satori": "^0.25.0", "sharp": "^0.34.5", }, "devDependencies": { @@ -56,7 +56,7 @@ }, "example": { "name": "react-native-nitro-example", - "version": "0.35.0", + "version": "0.35.1", "dependencies": { "@react-native-segmented-control/segmented-control": "^2.5.7", "@react-navigation/bottom-tabs": "^7.4.5", @@ -92,11 +92,11 @@ }, "packages/nitrogen": { "name": "nitrogen", - "version": "0.35.0", + "version": "0.35.1", "bin": "./lib/index.js", "dependencies": { "chalk": "^5.3.0", - "react-native-nitro-modules": "^0.35.0", + "react-native-nitro-modules": "^0.35.1", "ts-morph": "^27.0.0", "yargs": "^18.0.0", "zod": "^4.0.5", @@ -107,7 +107,7 @@ }, "packages/react-native-nitro-modules": { "name": "react-native-nitro-modules", - "version": "0.35.0", + "version": "0.35.1", "devDependencies": { "@types/jest": "*", "@types/react": "*", @@ -124,7 +124,7 @@ }, "packages/react-native-nitro-test": { "name": "react-native-nitro-test", - "version": "0.35.0", + "version": "0.35.1", "devDependencies": { "@types/jest": "*", "@types/react": "*", @@ -144,7 +144,7 @@ }, "packages/react-native-nitro-test-external": { "name": "react-native-nitro-test-external", - "version": "0.35.0", + "version": "0.35.1", "devDependencies": { "@react-native/eslint-config": "0.83.0", "@types/jest": "^29.5.12", @@ -3573,7 +3573,7 @@ "safer-buffer": ["safer-buffer@2.1.2", "", {}, "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg=="], - "satori": ["satori@0.24.1", "", { "dependencies": { "@shuding/opentype.js": "1.4.0-beta.0", "css-background-parser": "^0.1.0", "css-box-shadow": "1.0.0-3", "css-gradient-parser": "^0.0.17", "css-to-react-native": "^3.0.0", "emoji-regex-xs": "^2.0.1", "escape-html": "^1.0.3", "linebreak": "^1.1.0", "parse-css-color": "^0.2.1", "postcss-value-parser": "^4.2.0", "yoga-layout": "^3.2.1" } }, "sha512-Lqj26wYdMjGR1AE/cwYkcpAFdf1EG0y0amitwu1+JnwCIrGd7cOI+Olap6ASeeOI58wydF0sfs8JET61XM0j/Q=="], + "satori": ["satori@0.25.0", "", { "dependencies": { "@shuding/opentype.js": "1.4.0-beta.0", "css-background-parser": "^0.1.0", "css-box-shadow": "1.0.0-3", "css-gradient-parser": "^0.0.17", "css-to-react-native": "^3.0.0", "emoji-regex-xs": "^2.0.1", "escape-html": "^1.0.3", "linebreak": "^1.1.0", "parse-css-color": "^0.2.1", "postcss-value-parser": "^4.2.0", "yoga-layout": "^3.2.1" } }, "sha512-utINfLxrYrmSnLvxFT4ZwgwWa8KOjrz7ans32V5wItgHVmzESl/9i33nE38uG0miycab8hUqQtDlOpqrIpB/iw=="], "sax": ["sax@1.4.1", "", {}, "sha512-+aWOz7yVScEGoKNd4PA10LZ8sk0A/z5+nXQG5giUO5rprX9jgYsTdov9qCchZiPIZezbZH+jRut8nPodFAX4Jg=="], diff --git a/docs/docs/hybrid-objects.md b/docs/docs/concepts/hybrid-objects.md similarity index 100% rename from docs/docs/hybrid-objects.md rename to docs/docs/concepts/hybrid-objects.md diff --git a/docs/docs/hybrid-views.md b/docs/docs/concepts/hybrid-views.md similarity index 87% rename from docs/docs/hybrid-views.md rename to docs/docs/concepts/hybrid-views.md index 7bc532ff9..80d18b4c3 100644 --- a/docs/docs/hybrid-views.md +++ b/docs/docs/concepts/hybrid-views.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Hybrid Views A **Hybrid View** is just a [**Hybrid Object**](hybrid-objects) that can also be rendered. @@ -81,8 +78,8 @@ function App() { } ``` -> Note: If you're wondering about the `callback(...)` syntax, see ["Callbacks have to be wrapped"](view-components#callbacks-have-to-be-wrapped). +> Note: If you're wondering about the `callback(...)` syntax, see ["Callbacks have to be wrapped"](../guides/view-components#callbacks-have-to-be-wrapped). ## Full Guides -Check out the [View Components](view-components) section for a full guide on Hybrid Views. +Check out the [View Components](../guides/view-components) section for a full guide on Hybrid Views. diff --git a/docs/docs/nitro-modules.md b/docs/docs/concepts/nitro-modules.md similarity index 100% rename from docs/docs/nitro-modules.md rename to docs/docs/concepts/nitro-modules.md diff --git a/docs/docs/nitrogen.md b/docs/docs/concepts/nitrogen.md similarity index 96% rename from docs/docs/nitrogen.md rename to docs/docs/concepts/nitrogen.md index 9559bd9c1..e7aacd925 100644 --- a/docs/docs/nitrogen.md +++ b/docs/docs/concepts/nitrogen.md @@ -257,8 +257,14 @@ In your `nitro.json`, register `HybridMath` in the `"autolinking"` section: ... "autolinking": { "Math": { - "swift": "HybridMath", - "kotlin": "HybridMath" + "ios": { + "language": "swift", + "implementationClassName": "HybridMath" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridMath" + } } } } @@ -270,7 +276,10 @@ In your `nitro.json`, register `HybridMath` in the `"autolinking"` section: ... "autolinking": { "Math": { - "cpp": "HybridMath" + "all": { + "language": "c++", + "implementationClassName": "HybridMath" + } } } } diff --git a/docs/docs/configuration-nitro-json.md b/docs/docs/getting-started/configuration-nitro-json.md similarity index 93% rename from docs/docs/configuration-nitro-json.md rename to docs/docs/getting-started/configuration-nitro-json.md index 1f4a50d2d..d75c70674 100644 --- a/docs/docs/configuration-nitro-json.md +++ b/docs/docs/getting-started/configuration-nitro-json.md @@ -3,7 +3,7 @@ # Configuration (`nitro.json`) -[Nitrogen](nitrogen) requires a `nitro.json` file to be configured at the root of each [Nitro Module](nitro-modules). +[Nitrogen](../concepts/nitrogen) requires a `nitro.json` file to be configured at the root of each [Nitro Module](../concepts/nitro-modules). ```json { @@ -133,7 +133,7 @@ Nitro will load this library at runtime using `System.loadLibrary`. ## `autolinking` -Contains configuration for all [Hybrid Objects](hybrid-objects) that should be autolinked by Nitrogen. +Contains configuration for all [Hybrid Objects](../concepts/hybrid-objects) that should be autolinked by Nitrogen. All Hybrid Objects specified here must follow these requirements: @@ -152,7 +152,10 @@ Nitrogen will then generate the following code: { "autolinking": { "Math": { - "cpp": "HybridMath" + "all": { + "language": "c++", + "implementationClassName": "HybridMath" + } } } } diff --git a/docs/docs/how-to-build-a-nitro-module.md b/docs/docs/getting-started/how-to-build-a-nitro-module.md similarity index 81% rename from docs/docs/how-to-build-a-nitro-module.md rename to docs/docs/getting-started/how-to-build-a-nitro-module.md index a812a1849..c275e23c5 100644 --- a/docs/docs/how-to-build-a-nitro-module.md +++ b/docs/docs/getting-started/how-to-build-a-nitro-module.md @@ -8,14 +8,14 @@ import TabItem from '@theme/TabItem'; # How to build a Nitro Module -A [Nitro Module](nitro-modules) is essentially just a react-native library that depends on react-native-nitro-modules and exposes one or more [Hybrid Objects](hybrid-objects). -It can either just use react-native-nitro-modules directly from C++, or use [Nitrogen](nitrogen) to generate bindings from TypeScript to native - in this case you can even use Swift and Kotlin. +A [Nitro Module](../concepts/nitro-modules) is essentially just a react-native library that depends on react-native-nitro-modules and exposes one or more [Hybrid Objects](../concepts/hybrid-objects). +It can either just use react-native-nitro-modules directly from C++, or use [Nitrogen](../concepts/nitrogen) to generate bindings from TypeScript to native - in this case you can even use Swift and Kotlin. This is a quick guide to build a Nitro Module from start to finish: ## 1. Create a Nitro Module -First, you need to create a [Nitro Module](nitro-modules) - either by bootstrapping a template using [nitrogen](nitrogen), [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob) or [create-nitro-module](https://github.com/patrickkabwe/create-nitro-module) - or by manually adding Nitro to your existing library/app. +First, you need to create a [Nitro Module](../concepts/nitro-modules) - either by bootstrapping a template using [nitrogen](../concepts/nitrogen), [react-native-builder-bob](https://github.com/callstack/react-native-builder-bob) or [create-nitro-module](https://github.com/patrickkabwe/create-nitro-module) - or by manually adding Nitro to your existing library/app. @@ -43,7 +43,7 @@ First, you need to create a [Nitro Module](nitro-modules) - either by bootstrapp npm install nitrogen --save-dev ``` - Then, you need to decide if you want to use Nitro's C++ library directly, or use [nitrogen](nitrogen) to generate specs: + Then, you need to decide if you want to use Nitro's C++ library directly, or use [nitrogen](../concepts/nitrogen) to generate specs: @@ -115,7 +115,7 @@ First, you need to create a [Nitro Module](nitro-modules) - either by bootstrapp - If you don't plan on using Nitrogen at all - and instead write your [Hybrid Objects](hybrid-objects) manually using C++, you do not need to set up any autolinking files since you will be responsible for exposing your Hybrid Objects to JS. + If you don't plan on using Nitrogen at all - and instead write your [Hybrid Objects](../concepts/hybrid-objects) manually using C++, you do not need to set up any autolinking files since you will be responsible for exposing your Hybrid Objects to JS. @@ -124,7 +124,7 @@ First, you need to create a [Nitro Module](nitro-modules) - either by bootstrapp ## 2. Create Hybrid Object specs -To actually use Nitro, you need to create [Hybrid Objects](hybrid-objects) - either by using Nitro's code-generator CLI “[Nitrogen](nitrogen)”, or by just manually extending the `HybridObject` base class in C++. +To actually use Nitro, you need to create [Hybrid Objects](../concepts/hybrid-objects) - either by using Nitro's code-generator CLI “[Nitrogen](../concepts/nitrogen)”, or by just manually extending the `HybridObject` base class in C++. @@ -162,7 +162,7 @@ To actually use Nitro, you need to create [Hybrid Objects](hybrid-objects) - eit ### 2.2. Run nitrogen - After writing specs, re-generate the generated code by running [nitrogen](nitrogen): + After writing specs, re-generate the generated code by running [nitrogen](../concepts/nitrogen): ```sh npx nitrogen @@ -244,7 +244,7 @@ To actually use Nitro, you need to create [Hybrid Objects](hybrid-objects) - eit - To create new [Hybrid Objects](hybrid-objects) manually, you simply create a new C++ class that meets the following requirements: + To create new [Hybrid Objects](../concepts/hybrid-objects) manually, you simply create a new C++ class that meets the following requirements: 1. It **public**-inherits from `HybridObject` 2. It calls the `HybridObject` constructor with its name @@ -289,12 +289,12 @@ To actually use Nitro, you need to create [Hybrid Objects](hybrid-objects) - eit Each Hybrid Object you want to be able to construct from JS has to be registered in Nitro's [`HybridObjectRegistry`](https://github.com/mrousavy/nitro/blob/main/packages/react-native-nitro-modules/cpp/registry/HybridObjectRegistry.hpp). If you don't want to register this Hybrid Object, you can skip this part - you will still be able to create it from another Hybrid Object's function (e.g. using the Factory-pattern). -You can either use [Nitrogen](nitrogen) to automatically generate bindings for your [Hybrid Object](hybrid-objects)'s constructor, or manually register them using the C++ API for `HybridObjectRegistry`: +You can either use [Nitrogen](../concepts/nitrogen) to automatically generate bindings for your [Hybrid Object](../concepts/hybrid-objects)'s constructor, or manually register them using the C++ API for `HybridObjectRegistry`: - In your [`nitro.json` config](configuration-nitro-json), you can connect the name of the [Hybrid Object](hybrid-objects) (`"Math"`) with the name of the native C++/Swift/Kotlin class that you used to implement the spec (`HybridMath`) using the `autolinking` section: + In your [`nitro.json` config](configuration-nitro-json), you can connect the name of the [Hybrid Object](../concepts/hybrid-objects) (`"Math"`) with the name of the native C++/Swift/Kotlin class that you used to implement the spec (`HybridMath`) using the `autolinking` section: @@ -305,14 +305,27 @@ You can either use [Nitrogen](nitrogen) to automatically generate bindings for y // diff-add "Math": { // diff-add - "swift": "HybridMath" + "ios": { + // diff-add + "language": "swift", + // diff-add + "implementationClassName": "HybridMath" + // diff-add + }, // diff-add - "kotlin": "HybridMath" + "android": { + // diff-add + "language": "kotlin", + // diff-add + "implementationClassName": "HybridMath" + // diff-add + } // diff-add } } } ``` + ```json title="nitro.json" @@ -322,8 +335,14 @@ You can either use [Nitrogen](nitrogen) to automatically generate bindings for y // diff-add "Math": { // diff-add - "cpp": "HybridMath" - // diff-add + "all": { + // diff-add + "language": "c++", + // diff-add + "implementationClassName": "HybridMath" + // diff-add + } + // diff-add } } } @@ -331,7 +350,7 @@ You can either use [Nitrogen](nitrogen) to automatically generate bindings for y - Now, just run [Nitrogen](nitrogen) again to generate the native bindings: + Now, just run [Nitrogen](../concepts/nitrogen) again to generate the native bindings: ```sh npx nitrogen diff --git a/docs/docs/minimum-requirements.md b/docs/docs/getting-started/minimum-requirements.md similarity index 100% rename from docs/docs/minimum-requirements.md rename to docs/docs/getting-started/minimum-requirements.md diff --git a/docs/docs/what-is-nitro.md b/docs/docs/getting-started/what-is-nitro.md similarity index 91% rename from docs/docs/what-is-nitro.md rename to docs/docs/getting-started/what-is-nitro.md index d91c1bae7..f3c201045 100644 --- a/docs/docs/what-is-nitro.md +++ b/docs/docs/getting-started/what-is-nitro.md @@ -8,9 +8,9 @@ Simply put, a JS object can be implemented in C++, Swift or Kotlin instead of JS While Nitro's primary environment is React Native, it also works in any other environment that uses JSI. -- A [**Nitro Module**](nitro-modules) is a library built with Nitro. It contains one or more **Hybrid Objects**. -- A [**Hybrid Object**](hybrid-objects) is a native object in Nitro, implemented in either C++, Swift or Kotlin. -- [**Nitrogen**](nitrogen) is an optional code-generator library authors can use to generate native bindings from a TypeScript interface. +- A [**Nitro Module**](../concepts/nitro-modules) is a library built with Nitro. It contains one or more **Hybrid Objects**. +- A [**Hybrid Object**](../concepts/hybrid-objects) is a native object in Nitro, implemented in either C++, Swift or Kotlin. +- [**Nitrogen**](../concepts/nitrogen) is an optional code-generator library authors can use to generate native bindings from a TypeScript interface.
@@ -92,7 +92,7 @@ Hybrid Objects in Nitro are built on top of `jsi::NativeState`, which is more ef ## Type Safety -Nitro Modules are **type-safe** and **null-safe**. By using Nitro's code-generator, [nitrogen](nitrogen), TypeScript specs are the single source of truth as generated native interfaces have to exactly represent the declared types. +Nitro Modules are **type-safe** and **null-safe**. By using Nitro's code-generator, [nitrogen](../concepts/nitrogen), TypeScript specs are the single source of truth as generated native interfaces have to exactly represent the declared types. If a function declares a `number`, you can only implement it on the native side as a `Double`, otherwise the app will not compile.
diff --git a/docs/docs/guides/android-context.md b/docs/docs/guides/android-context.md new file mode 100644 index 000000000..ecbd45551 --- /dev/null +++ b/docs/docs/guides/android-context.md @@ -0,0 +1,37 @@ +--- +--- + +# Android `Context` + +Many Android APIs require a [`Context`](https://developer.android.com/reference/android/content/Context) object, which allows access to application-specific resources and classes, as well as calls to hardware APIs. + +## Using `Context` in a `HybridObject` + +Unlike in TurboModules, a [Hybrid Object](../concepts/hybrid-objects) does not receive a [`Context`](https://developer.android.com/reference/android/content/Context) via its constructor, as that would make it non-portable. +Instead, Nitro exposes the current `ReactApplicationContext` via the static [`NitroModules.applicationContext`](https://github.com/mrousavy/nitro/blob/fb1102ca7657665aad3011d7556fcd06f3cc796d/packages/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/NitroModules.kt#L68-L72) getter, which you can access in your [Hybrid Object](../concepts/hybrid-objects) if needed: + +```kotlin +class HybridClipboard: HybridClipboardSpec() { + private val clipboard: ClipboardManager + + init { + // highlight-next-line + val context = NitroModules.applicationContext ?: throw Error("No Context available!") + clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager + } +} +``` + +## Using `Context` in a `HybridView` + +Unlike in a [Hybrid Object](../concepts/hybrid-objects), a [Hybrid View](../concepts/hybrid-views) is platform-specific and always needs a [`Context`](https://developer.android.com/reference/android/content/Context) - e.g. to create Android `View`s. +Therefore all `HybridView`s receive [`Context`](https://developer.android.com/reference/android/content/Context) as a constructor argument: + +```kotlin +class HybridCameraView( + // highlight-next-line + private val context: ThemedReactContext +): HybridCameraViewSpec() { + override val view: View = View(context) +} +``` diff --git a/docs/docs/entry-point.md b/docs/docs/guides/entry-point.md similarity index 96% rename from docs/docs/entry-point.md rename to docs/docs/guides/entry-point.md index c68d70c1a..3b5710626 100644 --- a/docs/docs/entry-point.md +++ b/docs/docs/guides/entry-point.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Entry Point Nitro is built on top of JSI - while the primary target is React Native, Nitro even works on any other target that provides JSI. diff --git a/docs/docs/errors.md b/docs/docs/guides/errors.md similarity index 95% rename from docs/docs/errors.md rename to docs/docs/guides/errors.md index 39b0209a3..b256774ff 100644 --- a/docs/docs/errors.md +++ b/docs/docs/guides/errors.md @@ -6,7 +6,7 @@ import TabItem from '@theme/TabItem'; # Errors -Every method in a [Hybrid Object](hybrid-objects) can throw an error using the language-default error throwing feature: +Every method in a [Hybrid Object](../concepts/hybrid-objects) can throw an error using the language-default error throwing feature: diff --git a/docs/docs/performance-tips.md b/docs/docs/guides/performance-tips.md similarity index 86% rename from docs/docs/performance-tips.md rename to docs/docs/guides/performance-tips.md index f00b48f5b..2568d8992 100644 --- a/docs/docs/performance-tips.md +++ b/docs/docs/guides/performance-tips.md @@ -15,7 +15,7 @@ Any dynamic types require runtime type checking, and cannot be optimized as good ### Untyped Maps -An [untyped map](types/untyped-maps) (`AnyMap`) is not only untyped, but also in-efficient. If you can, avoid untyped maps: +An [untyped map](../types/untyped-maps) (`AnyMap`) is not only untyped, but also in-efficient. If you can, avoid untyped maps:
@@ -49,7 +49,7 @@ In this case, it might make sense to use `ArrayBuffer` or `string`, and parse th ### Variants -[Variants](types/variants) (`A | B`) are dynamic types. Each time you pass a variant to native, Nitro has to check its type at runtime - is it `A` or `B`? +[Variants](../types/variants) (`A | B`) are dynamic types. Each time you pass a variant to native, Nitro has to check its type at runtime - is it `A` or `B`? Those type-checks are very efficient so this is considered a micro-optimization, but if you can, avoid variants like so:
@@ -119,7 +119,7 @@ interface GoodDatabase By default, every function in Nitro is fully synchronous. If your function takes long to execute, the JS Thread can not do any other work in the meantime. -In such cases, mark your function asynchronous by returning a [`Promise`](types/promises), which you can then use to run the heavy processing code on a different thread: +In such cases, mark your function asynchronous by returning a [`Promise`](../types/promises), which you can then use to run the heavy processing code on a different thread:
@@ -148,10 +148,10 @@ Keep in mind that switching to a different Thread on the native side introduces ## Use `ArrayBuffer` for large data -For large data sets, conventional [arrays](types/arrays) are in-efficient as each value has to be copied individually. -In contrast to conventional arrays, [Array Buffers](types/array-buffers) are zero-copy, meaning native memory can be directly shared to JS without copying the data. +For large data sets, conventional [arrays](../types/arrays) are in-efficient as each value has to be copied individually. +In contrast to conventional arrays, [Array Buffers](../types/array-buffers) are zero-copy, meaning native memory can be directly shared to JS without copying the data. -For example, to return a large list of numbers we could use [array buffers](types/array-buffers) (`Float64Array`) instead of [arrays](types/arrays): +For example, to return a large list of numbers we could use [array buffers](../types/array-buffers) (`Float64Array`) instead of [arrays](../types/arrays):
@@ -178,7 +178,7 @@ interface GoodDatabase ## Use Hybrid Objects to implement proxy-results -If a function returns a large amount of data to JS, but only a sub-set of that data is used, we can implement it as a [Hybrid Object](types/hybrid-objects) instead of a [struct](types/custom-structs). +If a function returns a large amount of data to JS, but only a sub-set of that data is used, we can implement it as a [Hybrid Object](../types/hybrid-objects) instead of a [struct](../types/custom-structs). This way data will be accessed lazily, and all the data that the user does not access will never be converted to JS, which means Nitro has to do less work: @@ -226,7 +226,7 @@ const row = data.findRowWithName("Marc") The **Bad** example is significantly slower than **Good**, because Nitro has to convert **all rows** to JS, and there could be thousands of rows - even if we only use the row with the `name` "Marc". -The **Good** example is significantly faster than **Bad** because the result of `getAllData()` is a [Hybrid Object](types/hybrid-objects), and all the thousands of rows do not have to be converted to JS at all, instead they are simply held in native memory. The function `findRowWithName(...)` iterates through the list on the native side and finds the matching row - only this single row will then have to be converted to JS. +The **Good** example is significantly faster than **Bad** because the result of `getAllData()` is a [Hybrid Object](../types/hybrid-objects), and all the thousands of rows do not have to be converted to JS at all, instead they are simply held in native memory. The function `findRowWithName(...)` iterates through the list on the native side and finds the matching row - only this single row will then have to be converted to JS. ## Properly use `memorySize` diff --git a/docs/docs/running-example-app.md b/docs/docs/guides/running-example-app.md similarity index 93% rename from docs/docs/running-example-app.md rename to docs/docs/guides/running-example-app.md index 2e04000bb..0ed210bf8 100644 --- a/docs/docs/running-example-app.md +++ b/docs/docs/guides/running-example-app.md @@ -127,7 +127,7 @@ Then, simply clone (potentially also fork?) the Nitro repository and install its ### Reproducing bugs -In addition to `packages/nitrogen` ([nitrogen](nitrogen) CLI) and `packages/react-native-nitro-modules` ([Nitro Modules](nitro-modules) core), the nitro repository also contains two testing libraries; +In addition to `packages/nitrogen` ([nitrogen](../concepts/nitrogen) CLI) and `packages/react-native-nitro-modules` ([Nitro Modules](../concepts/nitro-modules) core), the nitro repository also contains two testing libraries; - `packages/react-native-nitro-test`: Contains a lot of tests for C++/Swift/Kotlin Hybrid Objects, functions and types. - `packages/react-native-nitro-test-external`: Contains a Hybrid Object that is used in `react-native-nitro-test` to test cross-library-imports. @@ -142,7 +142,7 @@ Every time you change a Nitro spec in one of those two test libraries, you can s bun specs ``` -This runs [nitrogen](nitrogen) for both test libraries. You might need to reinstall pods if any iOS files changed; +This runs [nitrogen](../concepts/nitrogen) for both test libraries. You might need to reinstall pods if any iOS files changed; ```sh bun example pods diff --git a/docs/docs/sync-vs-async.md b/docs/docs/guides/sync-vs-async.md similarity index 96% rename from docs/docs/sync-vs-async.md rename to docs/docs/guides/sync-vs-async.md index 9cafa9866..0ca3c5c0c 100644 --- a/docs/docs/sync-vs-async.md +++ b/docs/docs/guides/sync-vs-async.md @@ -6,7 +6,7 @@ import TabItem from '@theme/TabItem'; # Sync vs Async -By default, every method on a [Hybrid Object](hybrid-objects) is synchronous and runs on the JS Thread. +By default, every method on a [Hybrid Object](../concepts/hybrid-objects) is synchronous and runs on the JS Thread. This means, as long as your native method is executing, the JS Thread is blocked and can not do any other work (like state updates or view changes). ## Light Methods diff --git a/docs/docs/troubleshooting.md b/docs/docs/guides/troubleshooting.md similarity index 97% rename from docs/docs/troubleshooting.md rename to docs/docs/guides/troubleshooting.md index 116d1e090..a5952371e 100644 --- a/docs/docs/troubleshooting.md +++ b/docs/docs/guides/troubleshooting.md @@ -10,7 +10,7 @@ This guide helps you troubleshoot issues in Nitro and should give you enough con ## Minimum requirements -First, make sure you meet the [minimum requirements](minimum-requirements) for Nitro. +First, make sure you meet the [minimum requirements](../getting-started/minimum-requirements) for Nitro. ## Ask for help diff --git a/docs/docs/view-components.md b/docs/docs/guides/view-components.md similarity index 97% rename from docs/docs/view-components.md rename to docs/docs/guides/view-components.md index 7bd2aad14..278036285 100644 --- a/docs/docs/view-components.md +++ b/docs/docs/guides/view-components.md @@ -35,7 +35,7 @@ export type CameraView = HybridView ### 2. Code Generation -Then, run [nitrogen](nitrogen): +Then, run [nitrogen](../concepts/nitrogen): @@ -60,7 +60,7 @@ Then, run [nitrogen](nitrogen): -This will create a C++ ShadowNode, with an iOS (Swift) and Android (Kotlin) interface, just like any other [Hybrid Object](hybrid-objects). +This will create a C++ ShadowNode, with an iOS (Swift) and Android (Kotlin) interface, just like any other [Hybrid Object](../concepts/hybrid-objects). Additionally, a view config (`CameraViewConfig.json`) will be generated - this is required by Fabric. ### 3. Implementation @@ -218,9 +218,9 @@ To batch prop changes, you can override `beforeUpdate()` and `afterUpdate()` in ```kotlin title="HybridCameraView.kt" - class HybridCameraView: HybridCameraViewSpec() { + class HybridCameraView(context: ThemedReactContext): HybridCameraViewSpec() { // View - override val view: View = View(NitroModules.applicationContext) + override val view: View = View(context) override fun beforeUpdate() { } override fun afterUpdate() { } diff --git a/docs/docs/worklets.md b/docs/docs/guides/worklets.md similarity index 90% rename from docs/docs/worklets.md rename to docs/docs/guides/worklets.md index 957aa6043..da64c151e 100644 --- a/docs/docs/worklets.md +++ b/docs/docs/guides/worklets.md @@ -6,10 +6,10 @@ import TabItem from '@theme/TabItem'; # Worklets/Threading -Nitro itself is fully runtime-agnostic, which means every [Hybrid Object](hybrid-objects) can be used from any JS Runtime or Worklet Context. +Nitro itself is fully runtime-agnostic, which means every [Hybrid Object](../concepts/hybrid-objects) can be used from any JS Runtime or Worklet Context. This allows the caller to call into native Nitro Modules from libraries like [react-native-worklets-core](https://github.com/margelo/react-native-worklets-core), or [react-native-reanimated](https://github.com/software-mansion/react-native-reanimated). -You can use a Nitro [Hybrid Object](hybrid-objects) on the default React JS context, on the UI context, or on any other background worklet context. +You can use a Nitro [Hybrid Object](../concepts/hybrid-objects) on the default React JS context, on the UI context, or on any other background worklet context. @@ -69,7 +69,7 @@ Your `runSync` and `runAsync` implementations must run the given `function` on t ## Boxing -A [Hybrid Object](hybrid-objects) is a JS object with `jsi::NativeState` and a prototype chain. +A [Hybrid Object](../concepts/hybrid-objects) is a JS object with `jsi::NativeState` and a prototype chain. If you need to interop with legacy APIs or APIs that can't deal with `jsi::NativeState` yet, you can _box_ the Hybrid Object into a `jsi::HostObject`: ```ts diff --git a/docs/docs/awesome-nitro-modules.md b/docs/docs/resources/awesome-nitro-modules.md similarity index 100% rename from docs/docs/awesome-nitro-modules.md rename to docs/docs/resources/awesome-nitro-modules.md diff --git a/docs/docs/comparison.md b/docs/docs/resources/comparison.md similarity index 100% rename from docs/docs/comparison.md rename to docs/docs/resources/comparison.md diff --git a/docs/docs/contributing.md b/docs/docs/resources/contributing.md similarity index 100% rename from docs/docs/contributing.md rename to docs/docs/resources/contributing.md diff --git a/docs/docs/for-library-users.md b/docs/docs/resources/for-library-users.md similarity index 100% rename from docs/docs/for-library-users.md rename to docs/docs/resources/for-library-users.md diff --git a/docs/docs/types/custom-enums.md b/docs/docs/types/custom-enums.md index 423b019b9..bcb3d4519 100644 --- a/docs/docs/types/custom-enums.md +++ b/docs/docs/types/custom-enums.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Custom Enums (`A | B`) There's two different types of enums - [enums](#typescript-enums) and [unions](#typescript-union). diff --git a/docs/docs/types/custom-structs.md b/docs/docs/types/custom-structs.md index 3cc2f2110..b4c3d95d6 100644 --- a/docs/docs/types/custom-structs.md +++ b/docs/docs/types/custom-structs.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Custom Structs (`interface`) Any custom `interface` or `type` that does **not** extend `HybridObject` will be represented as a fully type-safe `struct` in C++/Swift/Kotlin. Simply define the type in your `.nitro.ts` spec: diff --git a/docs/docs/types/raw-jsi-value.md b/docs/docs/types/raw-jsi-value.md index cfcceb425..3fc7db2eb 100644 --- a/docs/docs/types/raw-jsi-value.md +++ b/docs/docs/types/raw-jsi-value.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Raw `jsi::Value` / `jsi::Runtime` Even though Nitro supports virually any type in JS, there are certain use-cases where you might want to use a `jsi::Value` or `jsi::Runtime` directly - and Nitro provides an escape hatch for this. diff --git a/docs/docs/types/typing-system.md b/docs/docs/types/typing-system.md index 75e731be4..ad2884a3a 100644 --- a/docs/docs/types/typing-system.md +++ b/docs/docs/types/typing-system.md @@ -1,9 +1,6 @@ --- --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; - # Nitro's Typing System Nitro uses an extensible typing system to efficiently convert between JS and C++ types - **statically defined** and fully **type-safe** and **null-safe at compile-time**. @@ -40,7 +37,7 @@ On the JS side (TypeScript), type- and null-safety is enforced via TypeScript - ## Nitrogen -[Nitrogen](../nitrogen) ensures that TypeScript definitions are always in sync with native type definitions. +[Nitrogen](../concepts/nitrogen) ensures that TypeScript definitions are always in sync with native type definitions. You can also use Nitro without nitrogen, in this case TypeScript definitions have to be written manually. ## Supported Types diff --git a/docs/docusaurus.config.ts b/docs/docusaurus.config.ts index 754e5ec42..a7e69c476 100644 --- a/docs/docusaurus.config.ts +++ b/docs/docusaurus.config.ts @@ -55,20 +55,27 @@ const config: Config = { plugins: [ [ 'vercel-analytics', - { }, + {}, ], [ 'docusaurus-plugin-llms', { generateLLMsTxt: true, generateLLMsFullTxt: true, + generateMarkdownFiles: true, + preserveDirectoryStructure: true, + excludeImports: true, includeOrder: [ - 'what-is-nitro.md', - 'nitro-modules.md', - 'hybrid-objects.md', - 'hybrid-views.md', - 'nitrogen.md', - 'how-to-build-a-nitro-module.md', + 'getting-started/what-is-nitro.md', + 'concepts/nitro-modules.md', + 'concepts/hybrid-objects.md', + 'concepts/hybrid-views.md', + 'concepts/nitrogen.md', + 'types/typing-system.md', + 'getting-started/minimum-requirements.md', + 'getting-started/how-to-build-a-nitro-module.md', + 'getting-started/configuration-nitro-json.md', + // ... then the remaining pages in whatever order ] }, ], @@ -131,7 +138,7 @@ const config: Config = { }, { type: 'doc', - docId: 'for-library-users', + docId: 'resources/for-library-users', position: 'right', label: 'Installation', }, diff --git a/docs/package.json b/docs/package.json index e276383f9..f3dd4e569 100644 --- a/docs/package.json +++ b/docs/package.json @@ -28,7 +28,7 @@ "prism-react-renderer": "^2.3.0", "react": "19.1.0", "react-dom": "19.1.0", - "satori": "^0.24.1", + "satori": "^0.25.0", "sharp": "^0.34.5" }, "devDependencies": { diff --git a/docs/sidebars.ts b/docs/sidebars.ts index 626ec24c6..3f401134b 100644 --- a/docs/sidebars.ts +++ b/docs/sidebars.ts @@ -1,4 +1,4 @@ -import type {SidebarsConfig} from '@docusaurus/plugin-content-docs'; +import type { SidebarsConfig } from '@docusaurus/plugin-content-docs'; /** * Creating a sidebar enables you to: @@ -16,34 +16,35 @@ const sidebars: SidebarsConfig = { type: 'category', label: 'Getting started', items: [ - 'what-is-nitro', - 'how-to-build-a-nitro-module', - 'configuration-nitro-json', - 'minimum-requirements', + 'getting-started/what-is-nitro', + 'getting-started/how-to-build-a-nitro-module', + 'getting-started/configuration-nitro-json', + 'getting-started/minimum-requirements', ] }, { type: 'category', label: 'Concepts', items: [ - 'nitro-modules', - 'hybrid-objects', - 'hybrid-views', - 'nitrogen', + 'concepts/nitro-modules', + 'concepts/hybrid-objects', + 'concepts/hybrid-views', + 'concepts/nitrogen', ] }, { type: 'category', label: 'Guides', items: [ - 'errors', - 'performance-tips', - 'worklets', - 'entry-point', - 'sync-vs-async', - 'view-components', - 'troubleshooting', - 'running-example-app', + 'guides/errors', + 'guides/performance-tips', + 'guides/worklets', + 'guides/android-context', + 'guides/entry-point', + 'guides/sync-vs-async', + 'guides/view-components', + 'guides/troubleshooting', + 'guides/running-example-app', ] }, { @@ -75,10 +76,10 @@ const sidebars: SidebarsConfig = { type: 'category', label: 'Resources', items: [ - 'awesome-nitro-modules', - 'comparison', - 'for-library-users', - 'contributing', + 'resources/awesome-nitro-modules', + 'resources/comparison', + 'resources/for-library-users', + 'resources/contributing', ] }, ], diff --git a/docs/src/pages/index.tsx b/docs/src/pages/index.tsx index a9652928b..0db98715d 100644 --- a/docs/src/pages/index.tsx +++ b/docs/src/pages/index.tsx @@ -28,7 +28,7 @@ function HomepageHeader() { />

{siteConfig.tagline}

- + Get Started
diff --git a/docs/static/nitro.schema.json b/docs/static/nitro.schema.json index 64c1c5739..993c25f6c 100644 --- a/docs/static/nitro.schema.json +++ b/docs/static/nitro.schema.json @@ -62,26 +62,105 @@ "type": "object", "oneOf": [ { + "required": [ + "all" + ], "properties": { - "cpp": { - "type": "string" + "all": { + "type": "object", + "required": [ + "language", + "implementationClassName" + ], + "properties": { + "language": { + "type": "string", + "enum": [ + "c++" + ] + }, + "implementationClassName": { + "type": "string" + } + }, + "additionalProperties": false } }, - "additionalProperties": false, - "required": [ - "cpp" - ] + "additionalProperties": false }, { + "type": "object", + "not": { + "required": [ + "all" + ] + }, + "minProperties": 1, "properties": { - "swift": { - "type": "string" + "ios": { + "type": "object", + "required": [ + "language", + "implementationClassName" + ], + "properties": { + "language": { + "type": "string", + "enum": [ + "c++", + "swift" + ] + }, + "implementationClassName": { + "type": "string" + } + }, + "additionalProperties": false }, - "kotlin": { - "type": "string" + "android": { + "type": "object", + "required": [ + "language", + "implementationClassName" + ], + "properties": { + "language": { + "type": "string", + "enum": [ + "c++", + "kotlin" + ] + }, + "implementationClassName": { + "type": "string" + } + }, + "additionalProperties": false + } + }, + "patternProperties": { + "^(?!all$|ios$|android$).+$": { + "type": "object", + "required": [ + "language", + "implementationClassName" + ], + "properties": { + "language": { + "type": "string", + "enum": [ + "c++", + "swift", + "kotlin" + ] + }, + "implementationClassName": { + "type": "string" + } + }, + "additionalProperties": false } }, - "minProperties": 1, "additionalProperties": false } ] diff --git a/docs/vercel.json b/docs/vercel.json index bd6fd8faa..4bc44825f 100644 --- a/docs/vercel.json +++ b/docs/vercel.json @@ -1,3 +1,25 @@ { - "cleanUrls": true + "cleanUrls": true, + "redirects": [ + { + "source": "/docs/:slug(hybrid-objects|hybrid-views|nitro-modules|nitrogen)", + "destination": "/docs/concepts/:slug", + "permanent": true + }, + { + "source": "/docs/:slug(configuration-nitro-json|how-to-build-a-nitro-module|minimum-requirements|what-is-nitro)", + "destination": "/docs/getting-started/:slug", + "permanent": true + }, + { + "source": "/docs/:slug(entry-point|errors|performance-tips|running-example-app|sync-vs-async|troubleshooting|view-components|worklets)", + "destination": "/docs/guides/:slug", + "permanent": true + }, + { + "source": "/docs/:slug(awesome-nitro-modules|comparison|contributing|for-library-users)", + "destination": "/docs/resources/:slug", + "permanent": true + } + ] } diff --git a/example/ios/Podfile.lock b/example/ios/Podfile.lock index 6747d1f9a..57a5200a1 100644 --- a/example/ios/Podfile.lock +++ b/example/ios/Podfile.lock @@ -3,7 +3,7 @@ PODS: - hermes-engine (0.14.0): - hermes-engine/Pre-built (= 0.14.0) - hermes-engine/Pre-built (0.14.0) - - NitroModules (0.35.0): + - NitroModules (0.35.1): - hermes-engine - RCTRequired - RCTTypeSafety @@ -26,7 +26,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - NitroTest (0.35.0): + - NitroTest (0.35.1): - hermes-engine - NitroModules - NitroTestExternal @@ -51,7 +51,7 @@ PODS: - ReactCommon/turbomodule/core - ReactNativeDependencies - Yoga - - NitroTestExternal (0.35.0): + - NitroTestExternal (0.35.1): - hermes-engine - NitroModules - RCTRequired @@ -2217,10 +2217,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: FBLazyVector: 7c1d69992204c5ec452eeefa4a24b0ff311709c8 - hermes-engine: 16e781d7fca74c8bb3ca59b99527d9633ee9ee36 - NitroModules: 056dbee64d5ca10237fe9fec9856431c3b13f24a - NitroTest: 22fc4f9430e42903ecb3feb063484e04c416aba8 - NitroTestExternal: ab0e3a7614541921ba6b6e8d80a1a8c5028b8f3a + hermes-engine: b69aade2dcf59e8c2203c748ca79c7fa4c875053 + NitroModules: 86196902a7d0d270f06fe68e39f3a779978ab6ca + NitroTest: 9592e0d7828caf2628984725de23476946917f57 + NitroTestExternal: 92f847976cae501fe61c9eb4285428746d7c6918 RCTDeprecation: dbbb85eae640e3b43cc16462d0476b00ca5959ae RCTRequired: 7047b18af29a76069818fd3fa0f4df423483abab RCTSwiftUI: 5928f7ca7e9e2f1a82d85d4c79ea3065137ad81c @@ -2229,7 +2229,7 @@ SPEC CHECKSUMS: React: f6f8fc5c01e77349cdfaf49102bcb928ac31d8ed React-callinvoker: 3e62a849bda1522c6422309c02f5dc3210bc5359 React-Core: 0b765bc7c2b83dff178c2b03ed8a0390df26f18c - React-Core-prebuilt: 88810feb58457484bff17e9e91a15453407d745a + React-Core-prebuilt: 1ed3b91c7035f715bf741f1b8a2c87e94d126d38 React-CoreModules: 55b932564ba696301cb683a86385be6a6f137e57 React-cxxreact: 5bfb95256fde56cc0f9ce425f38cfaa085e71ad2 React-debug: f9dda2791d3ebe2078bc6102641edab77917efb7 @@ -2292,7 +2292,7 @@ SPEC CHECKSUMS: ReactAppDependencyProvider: 23e2bca1661f8781e55fcc05a151fc1df97bc1fb ReactCodegen: c049d7e966ed24be56d8e21cb1b8880316975e76 ReactCommon: 89ccc6cb100ca5a0303b46483037ef8f3e06e2e0 - ReactNativeDependencies: 1a7e3c3ffa57533d8118dd9bc01790ffa9e02a3b + ReactNativeDependencies: 69de62c8a59d21e7b6af8bdfb62b61e798f65351 RNScreens: dd61bc3a3e6f6901ad833efa411917d44827cf51 Yoga: 21f482cbc18b56cdc477cd3a0c5b8c2c83ac27ce diff --git a/example/package.json b/example/package.json index ddb9de054..333e26a7f 100644 --- a/example/package.json +++ b/example/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nitro-example", - "version": "0.35.0", + "version": "0.35.1", "private": true, "scripts": { "start": "react-native start --client-logs", diff --git a/example/src/logPrototypeChain.ts b/example/src/logPrototypeChain.ts index 8d44886a2..09b7295c6 100644 --- a/example/src/logPrototypeChain.ts +++ b/example/src/logPrototypeChain.ts @@ -1,10 +1,12 @@ -import type { HybridObject } from 'react-native-nitro-modules' +import type { HybridObject, PlatformSpec } from 'react-native-nitro-modules' function dim(string: string): string { return `\x1b[2m${string}\x1b[0m` } -export function logPrototypeChain(type: HybridObject): void { +export function logPrototypeChain( + type: HybridObject +): void { console.log(`Prototype chain of ${type.name}:`) let object = type let indentation = ' ' diff --git a/package.json b/package.json index a975349df..c0a3d7fca 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "react-native-nitro", "packageManager": "bun@1.3.6", "private": true, - "version": "0.35.0", + "version": "0.35.1", "repository": "https://github.com/mrousavy/nitro.git", "author": "Marc Rousavy (https://github.com/mrousavy)", "workspaces": [ diff --git a/packages/nitrogen/README.md b/packages/nitrogen/README.md index 519e4060b..bfb84df3e 100644 --- a/packages/nitrogen/README.md +++ b/packages/nitrogen/README.md @@ -25,4 +25,4 @@ npx nitrogen ## Usage -See the [Nitrogen documentation](https://nitro.margelo.com/docs/nitrogen) for more information. +See the [Nitrogen documentation](https://nitro.margelo.com/docs/concepts/nitrogen) for more information. diff --git a/packages/nitrogen/package.json b/packages/nitrogen/package.json index 6e4927c8b..669f1261c 100644 --- a/packages/nitrogen/package.json +++ b/packages/nitrogen/package.json @@ -1,6 +1,6 @@ { "name": "nitrogen", - "version": "0.35.0", + "version": "0.35.1", "description": "The code-generator for react-native-nitro-modules.", "main": "lib/index", "types": "lib/index.d.ts", @@ -35,7 +35,7 @@ }, "dependencies": { "chalk": "^5.3.0", - "react-native-nitro-modules": "^0.35.0", + "react-native-nitro-modules": "^0.35.1", "ts-morph": "^27.0.0", "yargs": "^18.0.0", "zod": "^4.0.5" diff --git a/packages/nitrogen/src/autolinking/android/createHybridObjectInitializer.ts b/packages/nitrogen/src/autolinking/android/createHybridObjectInitializer.ts index 5dc208878..a053b25c4 100644 --- a/packages/nitrogen/src/autolinking/android/createHybridObjectInitializer.ts +++ b/packages/nitrogen/src/autolinking/android/createHybridObjectInitializer.ts @@ -28,27 +28,39 @@ export function createHybridObjectIntializer(): SourceFile[] { const cppRegistrations: string[] = [] const cppDefinitions: string[] = [] for (const hybridObjectName of Object.keys(autolinkedHybridObjects)) { - const config = autolinkedHybridObjects[hybridObjectName] - - if (config?.cpp != null) { - // Autolink a C++ HybridObject! - const { cppCode, requiredImports } = createCppHybridObjectRegistration({ - hybridObjectName: hybridObjectName, - cppClassName: config.cpp, - }) - cppHybridObjectImports.push(...requiredImports) - cppRegistrations.push(cppCode) + const implementation = + NitroConfig.current.getAndroidAutolinkedImplementation(hybridObjectName) + if (implementation == null) { + continue } - if (config?.kotlin != null) { - // Autolink a Kotlin HybridObject through JNI/C++! - const { cppCode, cppDefinition, requiredImports } = - createJNIHybridObjectRegistration({ + + switch (implementation.language) { + case 'c++': { + // Autolink a C++ HybridObject! + const { cppCode, requiredImports } = createCppHybridObjectRegistration({ hybridObjectName: hybridObjectName, - jniClassName: config.kotlin, + cppClassName: implementation.implementationClassName, }) - cppHybridObjectImports.push(...requiredImports) - cppDefinitions.push(cppDefinition) - cppRegistrations.push(cppCode) + cppHybridObjectImports.push(...requiredImports) + cppRegistrations.push(cppCode) + break + } + case 'kotlin': { + // Autolink a Kotlin HybridObject through JNI/C++! + const { cppCode, cppDefinition, requiredImports } = + createJNIHybridObjectRegistration({ + hybridObjectName: hybridObjectName, + jniClassName: implementation.implementationClassName, + }) + cppHybridObjectImports.push(...requiredImports) + cppDefinitions.push(cppDefinition) + cppRegistrations.push(cppCode) + break + } + default: + throw new Error( + `The HybridObject "${hybridObjectName}" cannot be autolinked on Android - Language "${implementation.language}" is not supported on Android!` + ) } } diff --git a/packages/nitrogen/src/autolinking/ios/createHybridObjectInitializer.ts b/packages/nitrogen/src/autolinking/ios/createHybridObjectInitializer.ts index a34749cbb..3b3233631 100644 --- a/packages/nitrogen/src/autolinking/ios/createHybridObjectInitializer.ts +++ b/packages/nitrogen/src/autolinking/ios/createHybridObjectInitializer.ts @@ -23,28 +23,40 @@ export function createHybridObjectIntializer(): [ObjcFile, SwiftFile] | [] { const cppImports: SourceImport[] = [] let containsSwiftObjects = false for (const hybridObjectName of Object.keys(autolinkedHybridObjects)) { - const config = autolinkedHybridObjects[hybridObjectName] - - if (config?.cpp != null) { - // Autolink a C++ HybridObject! - const { cppCode, requiredImports } = createCppHybridObjectRegistration({ - hybridObjectName: hybridObjectName, - cppClassName: config.cpp, - }) - cppImports.push(...requiredImports) - cppRegistrations.push(cppCode) + const implementation = + NitroConfig.current.getIosAutolinkedImplementation(hybridObjectName) + if (implementation == null) { + continue } - if (config?.swift != null) { - // Autolink a Swift HybridObject! - containsSwiftObjects = true - const { cppCode, requiredImports, swiftRegistrationMethods } = - createSwiftHybridObjectRegistration({ + + switch (implementation.language) { + case 'c++': { + // Autolink a C++ HybridObject! + const { cppCode, requiredImports } = createCppHybridObjectRegistration({ hybridObjectName: hybridObjectName, - swiftClassName: config.swift, + cppClassName: implementation.implementationClassName, }) - cppImports.push(...requiredImports) - cppRegistrations.push(cppCode) - swiftRegistrations.push(swiftRegistrationMethods) + cppImports.push(...requiredImports) + cppRegistrations.push(cppCode) + break + } + case 'swift': { + // Autolink a Swift HybridObject! + containsSwiftObjects = true + const { cppCode, requiredImports, swiftRegistrationMethods } = + createSwiftHybridObjectRegistration({ + hybridObjectName: hybridObjectName, + swiftClassName: implementation.implementationClassName, + }) + cppImports.push(...requiredImports) + cppRegistrations.push(cppCode) + swiftRegistrations.push(swiftRegistrationMethods) + break + } + default: + throw new Error( + `The HybridObject "${hybridObjectName}" cannot be autolinked on iOS - Language "${implementation.language}" is not supported on iOS!` + ) } } diff --git a/packages/nitrogen/src/config/NitroConfig.ts b/packages/nitrogen/src/config/NitroConfig.ts index f23a005c3..658d2eee2 100644 --- a/packages/nitrogen/src/config/NitroConfig.ts +++ b/packages/nitrogen/src/config/NitroConfig.ts @@ -1,6 +1,11 @@ import chalk from 'chalk' import { readUserConfig } from './getConfig.js' -import type { NitroUserConfig } from './NitroUserConfig.js' +import type { + AutolinkingAndroidImplementation, + AutolinkingIOSImplementation, + AutolinkingPlatformImplementation, + NitroUserConfig, +} from './NitroUserConfig.js' const CXX_BASE_NAMESPACE = ['margelo', 'nitro'] const ANDROID_BASE_NAMESPACE = ['com', 'margelo', 'nitro'] @@ -109,6 +114,49 @@ export class NitroConfig { return this.config.autolinking } + getPlatformAutolinkedImplementation( + hybridObjectName: string, + platform: string + ): AutolinkingPlatformImplementation | undefined { + const objectConfig = this.config.autolinking[hybridObjectName] + if (objectConfig == null) { + return undefined + } + + // "all" applies to every platform and should automatically include + // future platforms without having to expand explicit key lists here. + if (objectConfig.all != null) { + return objectConfig.all + } + return objectConfig[platform] + } + + getIosAutolinkedImplementation( + hybridObjectName: string + ): AutolinkingIOSImplementation | undefined { + const objectConfig = this.config.autolinking[hybridObjectName] + if (objectConfig == null) { + return undefined + } + if (objectConfig.all != null) { + return objectConfig.all + } + return objectConfig.ios + } + + getAndroidAutolinkedImplementation( + hybridObjectName: string + ): AutolinkingAndroidImplementation | undefined { + const objectConfig = this.config.autolinking[hybridObjectName] + if (objectConfig == null) { + return undefined + } + if (objectConfig.all != null) { + return objectConfig.all + } + return objectConfig.android + } + /** * Get the paths that will be ignored when loading the TypeScript project. * In most cases, this just contains `node_modules/`. diff --git a/packages/nitrogen/src/config/NitroUserConfig.ts b/packages/nitrogen/src/config/NitroUserConfig.ts index c2591a7be..a82b8e74c 100644 --- a/packages/nitrogen/src/config/NitroUserConfig.ts +++ b/packages/nitrogen/src/config/NitroUserConfig.ts @@ -9,6 +9,137 @@ const isReservedKeywordError = { message: `This value is reserved and cannot be used!`, } +const autolinkingLanguageSchema = z.enum(['c++', 'swift', 'kotlin']) + +const autolinkingAllImplementationSchema = z.object({ + language: z.literal('c++'), + implementationClassName: z.string(), +}) + +const autolinkingIOSImplementationSchema = z.object({ + language: z.enum(['c++', 'swift']), + implementationClassName: z.string(), +}) + +const autolinkingAndroidImplementationSchema = z.object({ + language: z.enum(['c++', 'kotlin']), + implementationClassName: z.string(), +}) + +const autolinkingPlatformImplementationSchema = z.object({ + language: autolinkingLanguageSchema, + implementationClassName: z.string(), +}) + +const autolinkingModernHybridObjectSchema = z + .object({ + all: autolinkingAllImplementationSchema.optional(), + ios: autolinkingIOSImplementationSchema.optional(), + android: autolinkingAndroidImplementationSchema.optional(), + }) + .catchall(autolinkingPlatformImplementationSchema) + .superRefine((value, ctx) => { + const hasAll = value.all != null + const platformCount = Object.keys(value).filter( + (key) => key !== 'all' + ).length + + if (hasAll && platformCount > 0) { + ctx.addIssue({ + code: 'custom', + message: '"all" cannot be combined with platform-specific entries.', + }) + } + + if (!hasAll && platformCount === 0) { + ctx.addIssue({ + code: 'custom', + message: + 'Each autolinking entry must declare either "all" or at least one platform.', + }) + } + }) + +const autolinkingLegacyHybridObjectSchema = z + .object({ + cpp: z.string().optional(), + swift: z.string().optional(), + kotlin: z.string().optional(), + }) + .strict() + .superRefine((value, ctx) => { + const hasCpp = value.cpp != null + const hasSwift = value.swift != null + const hasKotlin = value.kotlin != null + + if (!hasCpp && !hasSwift && !hasKotlin) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Each autolinking entry must declare at least one implementation.', + }) + } + + if (hasCpp && (hasSwift || hasKotlin)) { + ctx.addIssue({ + code: z.ZodIssueCode.custom, + message: + 'Legacy autolinking entries cannot mix "cpp" with "swift"/"kotlin".', + }) + } + }) + +function normalizeLegacyAutolinkingHybridObject( + value: z.infer +): z.infer { + if (value.cpp != null) { + return { + all: { + language: 'c++', + implementationClassName: value.cpp, + }, + } + } + + const normalized: z.infer = {} + if (value.swift != null) { + normalized.ios = { + language: 'swift', + implementationClassName: value.swift, + } + } + if (value.kotlin != null) { + normalized.android = { + language: 'kotlin', + implementationClassName: value.kotlin, + } + } + return normalized +} + +const autolinkingHybridObjectSchema = z.union([ + autolinkingModernHybridObjectSchema, + autolinkingLegacyHybridObjectSchema.transform( + normalizeLegacyAutolinkingHybridObject + ), +]) + +export type AutolinkingAllImplementation = z.infer< + typeof autolinkingAllImplementationSchema +> +export type AutolinkingIOSImplementation = z.infer< + typeof autolinkingIOSImplementationSchema +> +export type AutolinkingAndroidImplementation = z.infer< + typeof autolinkingAndroidImplementationSchema +> +export type AutolinkingPlatformImplementation = z.infer< + typeof autolinkingPlatformImplementationSchema +> +export type AutolinkingHybridObject = z.infer< + typeof autolinkingHybridObjectSchema +> + export const NitroUserConfigSchema = z.object({ /** * Represents the C++ namespace of the module that will be generated. @@ -74,17 +205,10 @@ export const NitroUserConfigSchema = z.object({ * Configures the code that gets generated for autolinking (registering) * Hybrid Object constructors. * - * Each class listed here needs to have a default constructor/initializer that takes - * zero arguments. + * Each class listed here needs to have a default constructor/initializer + * that takes zero arguments. */ - autolinking: z.record( - z.string(), - z.object({ - cpp: z.string().optional(), - swift: z.string().optional(), - kotlin: z.string().optional(), - }) - ), + autolinking: z.record(z.string(), autolinkingHybridObjectSchema), /** * A list of paths relative to the project directory that should be ignored by nitrogen. * Nitrogen will not look for `.nitro.ts` files in these directories. diff --git a/packages/nitrogen/src/config/getConfig.ts b/packages/nitrogen/src/config/getConfig.ts index 7fa133bf7..6ef0fd244 100644 --- a/packages/nitrogen/src/config/getConfig.ts +++ b/packages/nitrogen/src/config/getConfig.ts @@ -6,6 +6,43 @@ import { } from './NitroUserConfig.js' import chalk from 'chalk' +function isObject(value: unknown): value is Record { + return typeof value === 'object' && value != null && !Array.isArray(value) +} + +function getLegacyAutolinkingEntries(config: unknown): string[] { + if (!isObject(config)) return [] + + const autolinking = config.autolinking + if (!isObject(autolinking)) return [] + + const entries: string[] = [] + for (const [hybridObjectName, entry] of Object.entries(autolinking)) { + if (!isObject(entry)) continue + + const hasLegacySyntax = + 'cpp' in entry || 'swift' in entry || 'kotlin' in entry + if (hasLegacySyntax) { + entries.push(hybridObjectName) + } + } + + return entries +} + +// TODO: Remove this once users have migrated to new `nitro.json` +function logLegacyAutolinkingDeprecation(config: unknown): void { + const legacyEntries = getLegacyAutolinkingEntries(config) + if (legacyEntries.length === 0) return + + console.warn( + chalk.yellow( + `Warning: nitro.json uses deprecated autolinking syntax ("cpp"/"swift"/"kotlin") for [${legacyEntries.join(', ')}]. ` + + `Use "all"/"ios"/"android" entries with { language, implementationClassName } instead.` + ) + ) +} + function readFile(configPath: string): string { try { return fs.readFileSync(configPath, 'utf8') @@ -58,6 +95,7 @@ function parseConfig(json: string): NitroUserConfig { } try { + logLegacyAutolinkingDeprecation(object) return NitroUserConfigSchema.parse(object) } catch (error) { if (error instanceof ZodError) { diff --git a/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts b/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts index f220fc5c3..7332d6131 100644 --- a/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts +++ b/packages/nitrogen/src/syntax/kotlin/FbjniHybridObject.ts @@ -103,11 +103,11 @@ namespace ${cxxNamespace} { class ${name.JHybridTSpec}: public virtual ${name.HybridTSpec}, public virtual ${cppBaseClass} { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniClassDescriptor};"; std::shared_ptr<${name.JHybridTSpec}> get${name.JHybridTSpec}(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "L${cxxPartJniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${cxxPartJniClassDescriptor};"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts b/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts index 739567cf0..74a162cc7 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinCxxBridgedType.ts @@ -66,7 +66,13 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> { return false } - getRequiredImports(language: Language): SourceImport[] { + getRequiredImports( + language: Language, + visited: Set = new Set() + ): SourceImport[] { + if (visited.has(this.type)) return [] + visited.add(this.type) + const imports = this.type.getRequiredImports(language) if (language === 'c++') { @@ -179,19 +185,17 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> { // Recursively look into referenced types (e.g. the `T` of a `optional`, or `T` of a `T[]`) const referencedTypes = getReferencedTypes(this.type) - referencedTypes.forEach((t) => { - if (t === this.type) { - // break a recursion - we already know this type - return - } + for (const t of referencedTypes) { const bridged = new KotlinCxxBridgedType(t) - imports.push(...bridged.getRequiredImports(language)) - }) + imports.push(...bridged.getRequiredImports(language, visited)) + } return imports } - getExtraFiles(): SourceFile[] { + getExtraFiles(visited: Set = new Set()): SourceFile[] { + if (visited.has(this.type)) return [] + visited.add(this.type) const files: SourceFile[] = [] switch (this.type.kind) { @@ -219,14 +223,10 @@ export class KotlinCxxBridgedType implements BridgedType<'kotlin', 'c++'> { // Recursively look into referenced types (e.g. the `T` of a `optional`, or `T` of a `T[]`) const referencedTypes = getReferencedTypes(this.type) - referencedTypes.forEach((t) => { - if (t === this.type) { - // break a recursion - we already know this type - return - } + for (const t of referencedTypes) { const bridged = new KotlinCxxBridgedType(t) - files.push(...bridged.getExtraFiles()) - }) + files.push(...bridged.getExtraFiles(visited)) + } return files } diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts b/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts index f95a9094c..eda201998 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinEnum.ts @@ -53,7 +53,7 @@ namespace ${cxxNamespace} { */ struct J${enumType.enumName} final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniClassDescriptor};"; public: /** diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts b/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts index 80d22babf..a540b6b14 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinFunction.ts @@ -201,7 +201,7 @@ namespace ${cxxNamespace} { */ struct J${name}: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "L${jniInterfaceDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniInterfaceDescriptor};"; public: /** @@ -236,7 +236,7 @@ namespace ${cxxNamespace} { } public: - static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniClassDescriptor};"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", J${name}_cxx::invoke_cxx)}); } diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts index 2e19ed792..d6b7fee75 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinHybridObjectRegistration.ts @@ -40,9 +40,9 @@ export function createJNIHybridObjectRegistration({ ], cppDefinition: ` struct ${JHybridTSpec}Impl: public jni::JavaClass<${JHybridTSpec}Impl, ${JHybridTSpec}::JavaPart> { - static auto constexpr kJavaDescriptor = "L${jniNamespace};"; + static constexpr auto kJavaDescriptor = "L${jniNamespace};"; static std::shared_ptr<${JHybridTSpec}> create() { - static auto constructorFn = javaClassStatic()->getConstructor<${JHybridTSpec}Impl::javaobject()>(); + static const auto constructorFn = javaClassStatic()->getConstructor<${JHybridTSpec}Impl::javaobject()>(); jni::local_ref<${JHybridTSpec}::JavaPart> javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->get${JHybridTSpec}(); } diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts b/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts index 6ef5f8f1c..c358f827f 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinStruct.ts @@ -117,7 +117,7 @@ namespace ${cxxNamespace} { */ struct J${structType.structName} final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniClassDescriptor};"; public: /** diff --git a/packages/nitrogen/src/syntax/kotlin/KotlinVariant.ts b/packages/nitrogen/src/syntax/kotlin/KotlinVariant.ts index b366a7833..b3ad8d6f1 100644 --- a/packages/nitrogen/src/syntax/kotlin/KotlinVariant.ts +++ b/packages/nitrogen/src/syntax/kotlin/KotlinVariant.ts @@ -145,7 +145,7 @@ if (isInstanceOf(${namespace}::${innerName}::javaClassStatic())) { return ` class ${innerName} final: public jni::JavaClass<${innerName}, J${kotlinName}> { public: - static auto constexpr kJavaDescriptor = "L${descriptor};"; + static constexpr auto kJavaDescriptor = "L${descriptor};"; [[nodiscard]] ${bridge.asJniReferenceType('local')} getValue() const { static const auto field = javaClassStatic()->getField<${bridge.getTypeCode('c++')}>("value"); @@ -180,7 +180,7 @@ namespace ${cxxNamespace} { */ class J${kotlinName}: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "L${jniClassDescriptor};"; + static constexpr auto kJavaDescriptor = "L${jniClassDescriptor};"; ${indent(cppCreateFuncs.join('\n'), ' ')} diff --git a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts index 6a18739b9..bb28038e2 100644 --- a/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts +++ b/packages/nitrogen/src/syntax/swift/SwiftHybridObjectBridge.ts @@ -69,6 +69,11 @@ public final func maybePrepareForRecycle() { guard let recyclable = __implementation as? any RecyclableView else { return } recyclable.prepareForRecycle() } +`.trim(), + ` +public final func onDropView() { + __implementation.onDropView() +} `.trim() ) } diff --git a/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts b/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts index 1721f73a5..a27718115 100644 --- a/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts +++ b/packages/nitrogen/src/views/kotlin/KotlinHybridViewManager.ts @@ -28,13 +28,15 @@ export function createKotlinHybridViewManager( descriptorClassName, } = getViewComponentNames(spec) const stateUpdaterName = `${stateClassName}Updater` - const autolinking = spec.config.getAutolinkedHybridObjects() - const viewImplementation = autolinking[spec.name]?.kotlin - if (viewImplementation == null) { + const implementation = spec.config.getAndroidAutolinkedImplementation( + spec.name + ) + if (implementation?.language !== 'kotlin') { throw new Error( - `Cannot create Kotlin HybridView ViewManager for ${spec.name} - it is not autolinked in nitro.json!` + `Cannot create Kotlin HybridView ViewManager for ${spec.name} - it must be autolinked with a Kotlin Android implementation in nitro.json!` ) } + const viewImplementation = implementation.implementationClassName const viewManagerCode = ` ${createFileMetadataString(`${manager}.kt`)} @@ -73,7 +75,7 @@ public class ${manager}: SimpleViewManager() { } override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? { - val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation} + val hybridView = getHybridView(view) ?: throw Error("Couldn't find view $view in local views table!") // 1. Update each prop individually @@ -85,9 +87,15 @@ public class ${manager}: SimpleViewManager() { return super.updateState(view, props, stateWrapper) } + override fun onDropViewInstance(view: View) { + val hybridView = getHybridView(view) + hybridView?.onDropView() + return super.onDropViewInstance(view) + } + protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? { super.prepareToRecycleView(reactContext, view) - val hybridView = view.getTag(associated_hybrid_view_tag) as? ${viewImplementation} + val hybridView = getHybridView(view) ?: return null @Suppress("USELESS_IS_CHECK") @@ -101,6 +109,10 @@ public class ${manager}: SimpleViewManager() { return null } } + + private fun getHybridView(view: View): ${viewImplementation}? { + return view.getTag(associated_hybrid_view_tag) as? ${viewImplementation} + } } `.trim() diff --git a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts index 29e9c9b38..21797d34a 100644 --- a/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts +++ b/packages/nitrogen/src/views/swift/SwiftHybridViewManager.ts @@ -28,11 +28,10 @@ export function createSwiftHybridViewManager( ) const { component, descriptorClassName, propsClassName } = getViewComponentNames(spec) - const autolinking = spec.config.getAutolinkedHybridObjects() - const viewImplementation = autolinking[spec.name]?.swift - if (viewImplementation == null) { + const implementation = spec.config.getIosAutolinkedImplementation(spec.name) + if (implementation?.language !== 'swift') { throw new Error( - `Cannot create Swift HybridView ViewManager for ${spec.name} - it is not autolinked in nitro.json!` + `Cannot create Swift HybridView ViewManager for ${spec.name} - it must be autolinked with a Swift iOS implementation in nitro.json!` ) } @@ -151,6 +150,12 @@ using namespace ${namespace}::views; swiftPart.maybePrepareForRecycle(); } +- (void)invalidate { + ${swiftNamespace}::${HybridTSpecCxx}& swiftPart = _hybridView->getSwiftPart(); + swiftPart.onDropView(); + [super invalidate]; +} + @end ` diff --git a/packages/react-native-nitro-modules/android/build.gradle b/packages/react-native-nitro-modules/android/build.gradle index bd6d6e384..368fc7d2c 100644 --- a/packages/react-native-nitro-modules/android/build.gradle +++ b/packages/react-native-nitro-modules/android/build.gradle @@ -7,7 +7,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:9.0.1" + classpath "com.android.tools.build:gradle:9.1.0" } } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyMap.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyMap.hpp index 9b352dc5e..d6688f02c 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyMap.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyMap.hpp @@ -20,7 +20,7 @@ using namespace facebook; */ class JAnyMap final : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/AnyMap;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/AnyMap;"; public: /** diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyValue.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyValue.hpp index 7faac1207..f946c6588 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyValue.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JAnyValue.hpp @@ -19,7 +19,7 @@ using namespace facebook; */ class JAnyValue final : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/AnyValue;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/AnyValue;"; /** * Represents an `Array` diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp index c250c0c52..2e77def94 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JArrayBuffer.hpp @@ -27,7 +27,7 @@ using namespace facebook; */ class JArrayBuffer final : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/ArrayBuffer;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/ArrayBuffer;"; public: /** diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.cpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.cpp index bc730fb71..6b870211a 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.cpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.cpp @@ -14,7 +14,7 @@ namespace margelo::nitro { using namespace facebook; std::shared_ptr JHybridObject::JavaPart::getJHybridObject() { - static auto method = javaClassStatic()->getMethod("getCxxPart"); + static const auto method = javaClassStatic()->getMethod("getCxxPart"); jni::local_ref cxxPart = method(self()); std::shared_ptr hybridObject = cxxPart->cthis()->getOrCreateHybridObject(); return hybridObject; @@ -23,7 +23,7 @@ std::shared_ptr JHybridObject::JavaPart::getJHybridObject() { JHybridObject::CxxPart::CxxPart(jni::alias_ref cxxJavaPart) : _cxxJavaPart(jni::make_global(cxxJavaPart)) {} jni::local_ref JHybridObject::CxxPart::getJavaPart() { - static auto javaPartField = javaClassStatic()->getField("javaPart"); + static const auto javaPartField = javaClassStatic()->getField("javaPart"); return _cxxJavaPart->getFieldValue(javaPartField); } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.hpp index 6cf247f39..f37828030 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JHybridObject.hpp @@ -22,11 +22,11 @@ using namespace facebook; class JHybridObject : public virtual HybridObject { public: struct JavaPart : jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObject;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObject;"; std::shared_ptr getJHybridObject(); }; struct CxxPart : jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObject$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObject$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref cxxJavaPart); static void registerNatives(); explicit CxxPart(jni::alias_ref cxxJavaPart); diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/core/JPromise.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/core/JPromise.hpp index 4ece34486..8f3aea407 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/core/JPromise.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/core/JPromise.hpp @@ -17,7 +17,7 @@ namespace margelo::nitro { using namespace facebook; struct JOnResolvedCallback : public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/Promise$OnResolvedCallback;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/Promise$OnResolvedCallback;"; void onResolved(const jni::alias_ref& result) const { static const auto method = javaClassLocal()->getMethod)>("onResolved"); method(self(), result); @@ -25,7 +25,7 @@ struct JOnResolvedCallback : public jni::JavaClass { }; struct JOnRejectedCallback : public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/Promise$OnRejectedCallback;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/Promise$OnRejectedCallback;"; void onRejected(const jni::alias_ref& error) const { static const auto method = javaClassLocal()->getMethod)>("onRejected"); method(self(), error); @@ -37,7 +37,7 @@ struct JOnRejectedCallback : public jni::JavaClass { */ class JPromise final : public jni::HybridClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/Promise;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/core/Promise;"; using ResultType = jni::global_ref; using ErrorType = jni::global_ref; using OnResolvedFunc = std::function)>; diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectInitializer.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectInitializer.hpp index d26f100ce..96e9e265e 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectInitializer.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/registry/JHybridObjectInitializer.hpp @@ -23,7 +23,7 @@ struct JHybridObjectInitializer : public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/NitroModules;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/NitroModules;"; private: explicit JNitroModules() = default; @@ -26,7 +26,7 @@ class JNitroModules final : public jni::HybridClass { void install(jlong runtimePointer, jni::alias_ref callInvokerHolder); private: - static auto constexpr TAG = "NitroModules"; + static constexpr auto TAG = "NitroModules"; using HybridBase::HybridBase; friend HybridBase; diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JHardwareBufferUtils.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JHardwareBufferUtils.hpp index 36c28d83f..2648c1ba4 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JHardwareBufferUtils.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JHardwareBufferUtils.hpp @@ -16,7 +16,7 @@ using namespace facebook; class JHardwareBufferUtils final : public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/utils/HardwareBufferUtils;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/utils/HardwareBufferUtils;"; public: static size_t getHardwareBufferSize(AHardwareBuffer* hardwareBuffer); diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JNativeRunnable.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JNativeRunnable.hpp index ef1b4536a..ca36da2d6 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JNativeRunnable.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JNativeRunnable.hpp @@ -19,7 +19,7 @@ class JNativeRunnable : public jni::HybridClass { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/utils/NativeRunnable;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/utils/NativeRunnable;"; static void registerNatives() { registerHybrid({makeNativeMethod("run", JNativeRunnable::run)}); } diff --git a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JThreadUtils.hpp b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JThreadUtils.hpp index 7f91d9d17..e38e83c13 100644 --- a/packages/react-native-nitro-modules/android/src/main/cpp/utils/JThreadUtils.hpp +++ b/packages/react-native-nitro-modules/android/src/main/cpp/utils/JThreadUtils.hpp @@ -16,22 +16,22 @@ using namespace facebook; // Bridged to Java class JThreadUtils : public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/utils/ThreadUtils;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/utils/ThreadUtils;"; static jni::local_ref getCurrentThreadName() { - static auto method = javaClassStatic()->getStaticMethod()>("getCurrentThreadName"); + static const auto method = javaClassStatic()->getStaticMethod()>("getCurrentThreadName"); return method(javaClassStatic()); } static void setCurrentThreadName(jni::alias_ref name) { - static auto method = javaClassStatic()->getStaticMethod)>("setCurrentThreadName"); + static const auto method = javaClassStatic()->getStaticMethod)>("setCurrentThreadName"); method(javaClassStatic(), name); } static jboolean isOnUIThread() { - static auto method = javaClassStatic()->getStaticMethod("isOnUIThread"); + static const auto method = javaClassStatic()->getStaticMethod("isOnUIThread"); return method(javaClassStatic()); } static void runOnUIThread(jni::alias_ref runnable) { - static auto method = javaClassStatic()->getStaticMethod)>("runOnUIThread"); + static const auto method = javaClassStatic()->getStaticMethod)>("runOnUIThread"); method(javaClassStatic(), runnable); } }; diff --git a/packages/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/views/HybridView.kt b/packages/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/views/HybridView.kt index 23cf52948..655d32a6a 100644 --- a/packages/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/views/HybridView.kt +++ b/packages/react-native-nitro-modules/android/src/main/java/com/margelo/nitro/views/HybridView.kt @@ -25,4 +25,12 @@ abstract class HybridView : HybridObject() { * React props are updated in a single batch/transaction. */ open fun afterUpdate() { /* noop */ } + + /** + * Called when the [HybridView] is about + * to be dropped and unmounted. + * This is a good place to clean up view-related + * resources. + */ + open fun onDropView() { /* noop */ } } diff --git a/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp b/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp index d28ca4065..d99a45c91 100644 --- a/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp +++ b/packages/react-native-nitro-modules/cpp/utils/NitroDefines.hpp @@ -9,7 +9,7 @@ #define NitroDefines_h // Sets the version of the native Nitro core library -#define NITRO_VERSION "0.35.0" +#define NITRO_VERSION "0.35.1" // Sets whether to use debug or optimized production build flags #ifdef DEBUG diff --git a/packages/react-native-nitro-modules/ios/views/HybridView.swift b/packages/react-native-nitro-modules/ios/views/HybridView.swift index 061e70637..94a422e00 100644 --- a/packages/react-native-nitro-modules/ios/views/HybridView.swift +++ b/packages/react-native-nitro-modules/ios/views/HybridView.swift @@ -29,11 +29,20 @@ * React props are updated in a single batch/transaction. */ func afterUpdate() + + /** + * Called when the `HybridView` is about + * to be dropped and unmounted. + * This is a good place to clean up view-related + * resources. + */ + func onDropView() } extension HybridView { public func beforeUpdate() { /* noop */ } public func afterUpdate() { /* noop */ } + public func onDropView() { /* noop */ } } extension HybridView { diff --git a/packages/react-native-nitro-modules/package.json b/packages/react-native-nitro-modules/package.json index 88b1e5626..8f6604c6c 100644 --- a/packages/react-native-nitro-modules/package.json +++ b/packages/react-native-nitro-modules/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nitro-modules", - "version": "0.35.0", + "version": "0.35.1", "description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.", "main": "lib/commonjs/index", "module": "lib/module/index", diff --git a/packages/react-native-nitro-modules/src/turbomodule/NativeNitroModules.ts b/packages/react-native-nitro-modules/src/turbomodule/NativeNitroModules.ts index a5e1a1bc5..0cba768fb 100644 --- a/packages/react-native-nitro-modules/src/turbomodule/NativeNitroModules.ts +++ b/packages/react-native-nitro-modules/src/turbomodule/NativeNitroModules.ts @@ -12,33 +12,53 @@ interface Spec extends TurboModule { install(): string | undefined } -// 1. Get (and initialize) the TurboModule -let turboModule: Spec | undefined -try { - turboModule = TurboModuleRegistry.getEnforcing('NitroModules') -} catch (e) { - throw new ModuleNotFoundError(e) -} +const jsVersion = require('react-native-nitro-modules/package.json').version -// 2. Install Dispatcher and install `NitroModulesProxy` into the Runtime's `global` -const errorMessage = turboModule.install() -if (errorMessage != null) { - throw new Error(`Failed to install Nitro: ${errorMessage}`) +function getInstalledNitro(): NitroModulesProxy | undefined { + // @ts-expect-error + return global.NitroModulesProxy as NitroModulesProxy | undefined } -// 3. Find `NitroModulesProxy` in `global` -// @ts-expect-error -export const NitroModules = global.NitroModulesProxy as NitroModulesProxy -if (NitroModules == null) { - const cause = new Error( - 'NitroModules was installed, but `global.NitroModulesProxy` was null!' - ) - throw new ModuleNotFoundError(cause) +let nitroModules = getInstalledNitro() + +// Reuse the existing proxy when the same JS runtime evaluates Nitro again, +// such as when react-native-harness loads a dedicated test bundle. +if (nitroModules != null) { + if (nitroModules.version !== jsVersion) { + throw new Error( + `Nitro was installed twice: once with native version ${nitroModules.version} and once with JS version ${jsVersion}. ` + + 'This usually means react-native-nitro-modules exists multiple times in node_modules (e.g. in monorepos or double-linked setups).' + ) + } +} else { + // 1. Get (and initialize) the TurboModule + let turboModule: Spec | undefined + try { + turboModule = TurboModuleRegistry.getEnforcing('NitroModules') + } catch (e) { + throw new ModuleNotFoundError(e) + } + + // 2. Install Dispatcher and install `NitroModulesProxy` into the Runtime's `global` + const errorMessage = turboModule.install() + if (errorMessage != null) { + throw new Error(`Failed to install Nitro: ${errorMessage}`) + } + + // 3. Find `NitroModulesProxy` in `global` + nitroModules = getInstalledNitro() + if (nitroModules == null) { + const cause = new Error( + 'NitroModules was installed, but `global.NitroModulesProxy` was null!' + ) + throw new ModuleNotFoundError(cause) + } } +export const NitroModules = nitroModules as NitroModulesProxy + // Double-check native version if (__DEV__) { - const jsVersion = require('react-native-nitro-modules/package.json').version if (jsVersion !== NitroModules.version) { console.warn( `The native Nitro Modules core runtime version is ${NitroModules.version}, but the JS code is using version ${jsVersion}. ` + diff --git a/packages/react-native-nitro-modules/src/views/getHostComponent.ts b/packages/react-native-nitro-modules/src/views/getHostComponent.ts index eeb34809e..b01cc4d58 100644 --- a/packages/react-native-nitro-modules/src/views/getHostComponent.ts +++ b/packages/react-native-nitro-modules/src/views/getHostComponent.ts @@ -54,7 +54,7 @@ interface DefaultHybridViewProps { * } * ``` * @note If you're wondering about the `callback(...)` syntax, see - * ["Callbacks have to be wrapped"](https://nitro.margelo.com/docs/view-components#callbacks-have-to-be-wrapped). + * ["Callbacks have to be wrapped"](https://nitro.margelo.com/docs/guides/view-components#callbacks-have-to-be-wrapped). */ hybridRef?: (ref: RefType) => void } @@ -66,7 +66,7 @@ interface DefaultHybridViewProps { * because RN converts them to booleans (`true`). As a workaround, * Nitro requires you to wrap each function using `callback(...)`, * which bypasses React Native's conversion. - * Please see the [Callbacks have to be wrapped](https://nitro.margelo.com/docs/view-components#callbacks-have-to-be-wrapped) section for more information. + * Please see the [Callbacks have to be wrapped](https://nitro.margelo.com/docs/guides/view-components#callbacks-have-to-be-wrapped) section for more information. * * @type {Object} NitroViewWrappedCallback * @property {T} f - The wrapped callback function diff --git a/packages/react-native-nitro-test-external/android/build.gradle b/packages/react-native-nitro-test-external/android/build.gradle index 390e0acc6..ec0cf9d64 100644 --- a/packages/react-native-nitro-test-external/android/build.gradle +++ b/packages/react-native-nitro-test-external/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:9.0.1" + classpath "com.android.tools.build:gradle:9.1.0" } } diff --git a/packages/react-native-nitro-test-external/nitro.json b/packages/react-native-nitro-test-external/nitro.json index 851fb0c9d..62fe81c40 100644 --- a/packages/react-native-nitro-test-external/nitro.json +++ b/packages/react-native-nitro-test-external/nitro.json @@ -10,8 +10,14 @@ }, "autolinking": { "SomeExternalObject": { - "kotlin": "HybridSomeExternalObject", - "swift": "HybridSomeExternalObject" + "ios": { + "language": "swift", + "implementationClassName": "HybridSomeExternalObject" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridSomeExternalObject" + } } }, "ignorePaths": [ diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp index 4bf1450e0..53a6a8167 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/NitroTestExternalOnLoad.cpp @@ -27,9 +27,9 @@ int initialize(JavaVM* vm) { } struct JHybridSomeExternalObjectSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObject;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObject;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridSomeExternalObjectSpec(); } diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp index ede518285..30645703b 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JHybridSomeExternalObjectSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test::external { class JHybridSomeExternalObjectSpec: public virtual HybridSomeExternalObjectSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObjectSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObjectSpec;"; std::shared_ptr getJHybridSomeExternalObjectSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObjectSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/HybridSomeExternalObjectSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp index 8c65053b4..bc648c6b9 100644 --- a/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp +++ b/packages/react-native-nitro-test-external/nitrogen/generated/android/c++/JOptionalPrimitivesHolder.hpp @@ -21,7 +21,7 @@ namespace margelo::nitro::test::external { */ struct JOptionalPrimitivesHolder final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/external/OptionalPrimitivesHolder;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/external/OptionalPrimitivesHolder;"; public: /** diff --git a/packages/react-native-nitro-test-external/package.json b/packages/react-native-nitro-test-external/package.json index cef4980eb..ed6d41e68 100644 --- a/packages/react-native-nitro-test-external/package.json +++ b/packages/react-native-nitro-test-external/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nitro-test-external", - "version": "0.35.0", + "version": "0.35.1", "description": "react-native-nitro-test-external", "main": "lib/index", "module": "lib/index", diff --git a/packages/react-native-nitro-test/android/build.gradle b/packages/react-native-nitro-test/android/build.gradle index cdaef3ecb..83e6955a4 100644 --- a/packages/react-native-nitro-test/android/build.gradle +++ b/packages/react-native-nitro-test/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:9.0.1" + classpath "com.android.tools.build:gradle:9.1.0" } } diff --git a/packages/react-native-nitro-test/android/src/main/java/com/margelo/nitro/test/HybridRecyclableTestView.kt b/packages/react-native-nitro-test/android/src/main/java/com/margelo/nitro/test/HybridRecyclableTestView.kt index 43525c6c4..64a955f48 100644 --- a/packages/react-native-nitro-test/android/src/main/java/com/margelo/nitro/test/HybridRecyclableTestView.kt +++ b/packages/react-native-nitro-test/android/src/main/java/com/margelo/nitro/test/HybridRecyclableTestView.kt @@ -1,6 +1,7 @@ package com.margelo.nitro.test import android.graphics.Color +import android.util.Log import android.view.View import androidx.annotation.Keep import com.facebook.proguard.annotations.DoNotStrip @@ -27,6 +28,10 @@ class HybridRecyclableTestView( } } + override fun onDropView() { + Log.i(TAG, "View dropped!") + } + // Recycling conformance override fun prepareForRecycle() { view.setBackgroundColor(Color.YELLOW) diff --git a/packages/react-native-nitro-test/ios/HybridRecyclableTestView.swift b/packages/react-native-nitro-test/ios/HybridRecyclableTestView.swift index 2d97420ae..f11a57b2d 100644 --- a/packages/react-native-nitro-test/ios/HybridRecyclableTestView.swift +++ b/packages/react-native-nitro-test/ios/HybridRecyclableTestView.swift @@ -22,6 +22,10 @@ class HybridRecyclableTestView: HybridRecyclableTestViewSpec, RecyclableView { } } + func onDropView() { + print("View dropped!") + } + // Recycling conformance func prepareForRecycle() { view.backgroundColor = .yellow diff --git a/packages/react-native-nitro-test/nitro.json b/packages/react-native-nitro-test/nitro.json index e51730954..b3a180b75 100644 --- a/packages/react-native-nitro-test/nitro.json +++ b/packages/react-native-nitro-test/nitro.json @@ -10,31 +10,70 @@ }, "autolinking": { "TestObjectCpp": { - "cpp": "HybridTestObjectCpp" + "all": { + "language": "c++", + "implementationClassName": "HybridTestObjectCpp" + } }, "TestObjectSwiftKotlin": { - "swift": "HybridTestObjectSwift", - "kotlin": "HybridTestObjectKotlin" + "ios": { + "language": "swift", + "implementationClassName": "HybridTestObjectSwift" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridTestObjectKotlin" + } }, "Base": { - "swift": "HybridBase", - "kotlin": "HybridBase" + "ios": { + "language": "swift", + "implementationClassName": "HybridBase" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridBase" + } }, "Child": { - "swift": "HybridChild", - "kotlin": "HybridChild" + "ios": { + "language": "swift", + "implementationClassName": "HybridChild" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridChild" + } }, "PlatformObject": { - "swift": "HybridPlatformObject", - "kotlin": "HybridPlatformObject" + "ios": { + "language": "swift", + "implementationClassName": "HybridPlatformObject" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridPlatformObject" + } }, "TestView": { - "swift": "HybridTestView", - "kotlin": "HybridTestView" + "ios": { + "language": "swift", + "implementationClassName": "HybridTestView" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridTestView" + } }, "RecyclableTestView": { - "swift": "HybridRecyclableTestView", - "kotlin": "HybridRecyclableTestView" + "ios": { + "language": "swift", + "implementationClassName": "HybridRecyclableTestView" + }, + "android": { + "language": "kotlin", + "implementationClassName": "HybridRecyclableTestView" + } } }, "ignorePaths": [ diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp index ede73dfbc..5ebdab53b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/NitroTestOnLoad.cpp @@ -48,49 +48,49 @@ int initialize(JavaVM* vm) { } struct JHybridTestObjectSwiftKotlinSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectKotlin;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectKotlin;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridTestObjectSwiftKotlinSpec(); } }; struct JHybridBaseSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBase;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBase;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridBaseSpec(); } }; struct JHybridChildSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChild;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChild;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridChildSpec(); } }; struct JHybridPlatformObjectSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObject;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObject;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridPlatformObjectSpec(); } }; struct JHybridTestViewSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestView;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestView;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridTestViewSpec(); } }; struct JHybridRecyclableTestViewSpecImpl: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestView;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestView;"; static std::shared_ptr create() { - static auto constructorFn = javaClassStatic()->getConstructor(); + static const auto constructorFn = javaClassStatic()->getConstructor(); jni::local_ref javaPart = javaClassStatic()->newObject(constructorFn); return javaPart->getJHybridRecyclableTestViewSpec(); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp index 6c21ad0d9..25678e164 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCar.hpp @@ -29,7 +29,7 @@ namespace margelo::nitro::test { */ struct JCar final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Car;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Car;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp index 4bcac7145..1995f592a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JColorScheme.hpp @@ -19,7 +19,7 @@ namespace margelo::nitro::test { */ struct JColorScheme final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/ColorScheme;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/ColorScheme;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp index 316d48923..adcd72700 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JCoreTypesVariant.hpp @@ -37,7 +37,7 @@ namespace margelo::nitro::test { */ class JCoreTypesVariant: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -93,7 +93,7 @@ namespace margelo::nitro::test { namespace JCoreTypesVariant_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -103,7 +103,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -113,7 +113,7 @@ namespace margelo::nitro::test { class Third final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Third;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Third;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -123,7 +123,7 @@ namespace margelo::nitro::test { class Fourth final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Fourth;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Fourth;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -133,7 +133,7 @@ namespace margelo::nitro::test { class Fifth final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Fifth;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Fifth;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -143,7 +143,7 @@ namespace margelo::nitro::test { class Sixth final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Sixth;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/CoreTypesVariant$Sixth;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp index 8601cbd86..aa59aea18 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JExternalObjectStruct.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ struct JExternalObjectStruct final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/ExternalObjectStruct;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/ExternalObjectStruct;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_double.hpp index 4e1aba3ed..264b70542 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_double.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ struct JFunc_double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_double;"; public: /** @@ -61,7 +61,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_double_cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_double_cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_double_cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp index fa39add4c..a6d07ddcc 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_double__.hpp @@ -25,7 +25,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_Promise_double__: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_double__;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_double__;"; public: /** @@ -85,7 +85,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_double___cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_double___cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_double___cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp index 97adf6179..10fef4206 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____.hpp @@ -25,7 +25,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double____: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double____;"; public: /** @@ -107,7 +107,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_double_____cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp index 1a898cb37..1533b7f36 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____.hpp @@ -27,7 +27,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer_____;"; public: /** @@ -109,7 +109,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_std__shared_ptr_ArrayBuffer______cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____.hpp index e25c26dd9..1c8dcffee 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void____: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_void____;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_void____;"; public: /** @@ -107,7 +107,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_void_____cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__shared_ptr_Promise_void_____cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__shared_ptr_Promise_void_____cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp index 87bec75c3..318f1caab 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_Promise_std__string__.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_Promise_std__string__: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__string__;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__string__;"; public: /** @@ -86,7 +86,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__string___cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_Promise_std__string___cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_Promise_std__string___cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp index 13cde3971..9a1754da9 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec_;"; public: /** @@ -64,7 +64,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec__cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec__cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_std__shared_ptr_margelo__nitro__test__external__HybridSomeExternalObjectSpec__cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void.hpp index 4ff8e76c9..388fc6105 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ struct JFunc_void: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void;"; public: /** @@ -59,7 +59,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_double.hpp index 3d75fa0da..a65f50942 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_double.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ struct JFunc_void_double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_double;"; public: /** @@ -59,7 +59,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_double_cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_double_cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_double_cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp index 4316e051a..4a7068854 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__exception_ptr.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ struct JFunc_void_std__exception_ptr: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__exception_ptr;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__exception_ptr;"; public: /** @@ -60,7 +60,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__exception_ptr_cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__exception_ptr_cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__exception_ptr_cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp index d743fb431..0c2d72cbe 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__optional_double_.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ struct JFunc_void_std__optional_double_: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__optional_double_;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__optional_double_;"; public: /** @@ -60,7 +60,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__optional_double__cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__optional_double__cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__optional_double__cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__string.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__string.hpp index ac3ea3928..4fbd31c02 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__string.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ struct JFunc_void_std__string: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__string;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__string;"; public: /** @@ -60,7 +60,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__string_cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__string_cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__string_cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp index 01c5f03f3..36c3045d5 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JFunc_void_std__vector_Powertrain_.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JFunc_void_std__vector_Powertrain_: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__vector_Powertrain_;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__vector_Powertrain_;"; public: /** @@ -80,7 +80,7 @@ namespace margelo::nitro::test { } public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__vector_Powertrain__cxx;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Func_void_std__vector_Powertrain__cxx;"; static void registerNatives() { registerHybrid({makeNativeMethod("invoke_cxx", JFunc_void_std__vector_Powertrain__cxx::invoke_cxx)}); } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp index 59da67d17..18bdcf92c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridBaseSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test { class JHybridBaseSpec: public virtual HybridBaseSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBaseSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBaseSpec;"; std::shared_ptr getJHybridBaseSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBaseSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridBaseSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp index 7a4980640..7ae265342 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridChildSpec.hpp @@ -22,11 +22,11 @@ namespace margelo::nitro::test { class JHybridChildSpec: public virtual HybridChildSpec, public virtual JHybridBaseSpec { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChildSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChildSpec;"; std::shared_ptr getJHybridChildSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChildSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridChildSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp index 83735f024..0caca67fa 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridPlatformObjectSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test { class JHybridPlatformObjectSpec: public virtual HybridPlatformObjectSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObjectSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObjectSpec;"; std::shared_ptr getJHybridPlatformObjectSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObjectSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridPlatformObjectSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp index 3cd2cfc0f..0683c6250 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridRecyclableTestViewSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test { class JHybridRecyclableTestViewSpec: public virtual HybridRecyclableTestViewSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestViewSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestViewSpec;"; std::shared_ptr getJHybridRecyclableTestViewSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestViewSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridRecyclableTestViewSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp index 8b0d3313c..1c3e75bd7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestObjectSwiftKotlinSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test { class JHybridTestObjectSwiftKotlinSpec: public virtual HybridTestObjectSwiftKotlinSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec;"; std::shared_ptr getJHybridTestObjectSwiftKotlinSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestObjectSwiftKotlinSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp index 52f554f15..715471554 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JHybridTestViewSpec.hpp @@ -21,11 +21,11 @@ namespace margelo::nitro::test { class JHybridTestViewSpec: public virtual HybridTestViewSpec, public virtual JHybridObject { public: struct JavaPart: public jni::JavaClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestViewSpec;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestViewSpec;"; std::shared_ptr getJHybridTestViewSpec(); }; struct CxxPart: public jni::HybridClass { - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestViewSpec$CxxPart;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/HybridTestViewSpec$CxxPart;"; static jni::local_ref initHybrid(jni::alias_ref jThis); static void registerNatives(); using HybridBase::HybridBase; diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp index 457e79c0b..3dc4e3811 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JJsStyleStruct.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ struct JJsStyleStruct final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/JsStyleStruct;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/JsStyleStruct;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp index 40600054a..7f0d644be 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JMapWrapper.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ struct JMapWrapper final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/MapWrapper;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/MapWrapper;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp index 9e75bf18f..e763f29f8 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JNamedVariant.hpp @@ -31,7 +31,7 @@ namespace margelo::nitro::test { */ class JNamedVariant: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -56,7 +56,7 @@ namespace margelo::nitro::test { namespace JNamedVariant_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -66,7 +66,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/NamedVariant$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp index 8aad2ea75..45fb9f184 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOldEnum.hpp @@ -19,7 +19,7 @@ namespace margelo::nitro::test { */ struct JOldEnum final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/OldEnum;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/OldEnum;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp index 72b9d9e23..83279d7eb 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalCallback.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JOptionalCallback final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/OptionalCallback;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/OptionalCallback;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp index 3b93fbb40..f3454348e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JOptionalWrapper.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ struct JOptionalWrapper final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/OptionalWrapper;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/OptionalWrapper;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp index 24021722b..62d26c796 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPartialPerson.hpp @@ -22,7 +22,7 @@ namespace margelo::nitro::test { */ struct JPartialPerson final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/PartialPerson;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/PartialPerson;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp index 17085354c..adc2b46db 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPerson.hpp @@ -21,7 +21,7 @@ namespace margelo::nitro::test { */ struct JPerson final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Person;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Person;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp index 68a84ec08..b30e1c998 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JPowertrain.hpp @@ -19,7 +19,7 @@ namespace margelo::nitro::test { */ struct JPowertrain final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Powertrain;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Powertrain;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp index 3ad945644..8879c7184 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JSecondMapWrapper.hpp @@ -22,7 +22,7 @@ namespace margelo::nitro::test { */ struct JSecondMapWrapper final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/SecondMapWrapper;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/SecondMapWrapper;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp index 25f9428f7..edcee2d49 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JStringOrExternal.hpp @@ -25,7 +25,7 @@ namespace margelo::nitro::test { */ class JStringOrExternal: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -50,7 +50,7 @@ namespace margelo::nitro::test { namespace JStringOrExternal_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -60,7 +60,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/StringOrExternal$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_Double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_Double.hpp index 0c7fac8d0..54d67ce8b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_Double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_Double.hpp @@ -21,7 +21,7 @@ namespace margelo::nitro::test { */ class JVariant_Boolean_Double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double;"; static jni::local_ref create_0(jboolean value) { static const auto method = javaClassStatic()->getStaticMethod("create"); @@ -46,7 +46,7 @@ namespace margelo::nitro::test { namespace JVariant_Boolean_Double_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double$First;"; [[nodiscard]] jboolean getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -56,7 +56,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_Double$Second;"; [[nodiscard]] double getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_DoubleArray_Array_String__String_Double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_DoubleArray_Array_String__String_Double.hpp index fa808ee7f..4e22b6620 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_DoubleArray_Array_String__String_Double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_DoubleArray_Array_String__String_Double.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ class JVariant_Boolean_DoubleArray_Array_String__String_Double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double;"; static jni::local_ref create_0(jboolean value) { static const auto method = javaClassStatic()->getStaticMethod("create"); @@ -77,7 +77,7 @@ namespace margelo::nitro::test { namespace JVariant_Boolean_DoubleArray_Array_String__String_Double_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$First;"; [[nodiscard]] jboolean getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -87,7 +87,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -97,7 +97,7 @@ namespace margelo::nitro::test { class Third final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Third;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Third;"; [[nodiscard]] jni::local_ref> getValue() const { static const auto field = javaClassStatic()->getField>("value"); @@ -107,7 +107,7 @@ namespace margelo::nitro::test { class Fourth final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Fourth;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Fourth;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -117,7 +117,7 @@ namespace margelo::nitro::test { class Fifth final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Fifth;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_DoubleArray_Array_String__String_Double$Fifth;"; [[nodiscard]] double getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp index 548115742..9e33352f2 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_OldEnum.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ class JVariant_Boolean_OldEnum: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum;"; static jni::local_ref create_0(jboolean value) { static const auto method = javaClassStatic()->getStaticMethod("create"); @@ -48,7 +48,7 @@ namespace margelo::nitro::test { namespace JVariant_Boolean_OldEnum_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum$First;"; [[nodiscard]] jboolean getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -58,7 +58,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_OldEnum$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp index 785b1051e..eca8f9e97 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Boolean_WeirdNumbersEnum.hpp @@ -23,7 +23,7 @@ namespace margelo::nitro::test { */ class JVariant_Boolean_WeirdNumbersEnum: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum;"; static jni::local_ref create_0(jboolean value) { static const auto method = javaClassStatic()->getStaticMethod("create"); @@ -48,7 +48,7 @@ namespace margelo::nitro::test { namespace JVariant_Boolean_WeirdNumbersEnum_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum$First;"; [[nodiscard]] jboolean getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -58,7 +58,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Boolean_WeirdNumbersEnum$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp index 648499fcf..40c6e67c2 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_Car_Person.hpp @@ -31,7 +31,7 @@ namespace margelo::nitro::test { */ class JVariant_Car_Person: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -56,7 +56,7 @@ namespace margelo::nitro::test { namespace JVariant_Car_Person_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -66,7 +66,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_Car_Person$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp index 23e9f951d..56fdb1a12 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridBaseSpec_OptionalWrapper.hpp @@ -30,7 +30,7 @@ namespace margelo::nitro::test { */ class JVariant_HybridBaseSpec_OptionalWrapper: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -55,7 +55,7 @@ namespace margelo::nitro::test { namespace JVariant_HybridBaseSpec_OptionalWrapper_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -65,7 +65,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridBaseSpec_OptionalWrapper$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp index cd5559767..171390827 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_HybridTestObjectSwiftKotlinSpec_Person.hpp @@ -27,7 +27,7 @@ namespace margelo::nitro::test { */ class JVariant_HybridTestObjectSwiftKotlinSpec_Person: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -52,7 +52,7 @@ namespace margelo::nitro::test { namespace JVariant_HybridTestObjectSwiftKotlinSpec_Person_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -62,7 +62,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_HybridTestObjectSwiftKotlinSpec_Person$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_NullType_String.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_NullType_String.hpp index 4944e8a8e..22a7923b4 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_NullType_String.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_NullType_String.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ class JVariant_NullType_String: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -49,7 +49,7 @@ namespace margelo::nitro::test { namespace JVariant_NullType_String_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -59,7 +59,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_NullType_String$Second;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_String_Double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_String_Double.hpp index a9439cbae..47a70c2f7 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_String_Double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_String_Double.hpp @@ -22,7 +22,7 @@ namespace margelo::nitro::test { */ class JVariant_String_Double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -47,7 +47,7 @@ namespace margelo::nitro::test { namespace JVariant_String_Double_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -57,7 +57,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_String_Double$Second;"; [[nodiscard]] double getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_______Unit_Double.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_______Unit_Double.hpp index baa82abfd..7110ee90c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_______Unit_Double.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JVariant_______Unit_Double.hpp @@ -24,7 +24,7 @@ namespace margelo::nitro::test { */ class JVariant_______Unit_Double: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double;"; static jni::local_ref create_0(jni::alias_ref value) { static const auto method = javaClassStatic()->getStaticMethod)>("create"); @@ -49,7 +49,7 @@ namespace margelo::nitro::test { namespace JVariant_______Unit_Double_impl { class First final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double$First;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double$First;"; [[nodiscard]] jni::local_ref getValue() const { static const auto field = javaClassStatic()->getField("value"); @@ -59,7 +59,7 @@ namespace margelo::nitro::test { class Second final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double$Second;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/Variant_______Unit_Double$Second;"; [[nodiscard]] double getValue() const { static const auto field = javaClassStatic()->getField("value"); diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp index 661c2a47f..c3ca0c92c 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWeirdNumbersEnum.hpp @@ -19,7 +19,7 @@ namespace margelo::nitro::test { */ struct JWeirdNumbersEnum final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/WeirdNumbersEnum;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/WeirdNumbersEnum;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp index e3b707ef3..d8d8af27f 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp +++ b/packages/react-native-nitro-test/nitrogen/generated/android/c++/JWrappedJsStruct.hpp @@ -26,7 +26,7 @@ namespace margelo::nitro::test { */ struct JWrappedJsStruct final: public jni::JavaClass { public: - static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/test/WrappedJsStruct;"; + static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/test/WrappedJsStruct;"; public: /** diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt index 19b59924a..c325e51a5 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridRecyclableTestViewManager.kt @@ -39,7 +39,7 @@ public class HybridRecyclableTestViewManager: SimpleViewManager() { } override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? { - val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridRecyclableTestView + val hybridView = getHybridView(view) ?: throw Error("Couldn't find view $view in local views table!") // 1. Update each prop individually @@ -51,9 +51,15 @@ public class HybridRecyclableTestViewManager: SimpleViewManager() { return super.updateState(view, props, stateWrapper) } + override fun onDropViewInstance(view: View) { + val hybridView = getHybridView(view) + hybridView?.onDropView() + return super.onDropViewInstance(view) + } + protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? { super.prepareToRecycleView(reactContext, view) - val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridRecyclableTestView + val hybridView = getHybridView(view) ?: return null @Suppress("USELESS_IS_CHECK") @@ -67,4 +73,8 @@ public class HybridRecyclableTestViewManager: SimpleViewManager() { return null } } + + private fun getHybridView(view: View): HybridRecyclableTestView? { + return view.getTag(associated_hybrid_view_tag) as? HybridRecyclableTestView + } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt index a157d5dcc..6ee9d802a 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt +++ b/packages/react-native-nitro-test/nitrogen/generated/android/kotlin/com/margelo/nitro/test/views/HybridTestViewManager.kt @@ -39,7 +39,7 @@ public class HybridTestViewManager: SimpleViewManager() { } override fun updateState(view: View, props: ReactStylesDiffMap, stateWrapper: StateWrapper): Any? { - val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridTestView + val hybridView = getHybridView(view) ?: throw Error("Couldn't find view $view in local views table!") // 1. Update each prop individually @@ -51,9 +51,15 @@ public class HybridTestViewManager: SimpleViewManager() { return super.updateState(view, props, stateWrapper) } + override fun onDropViewInstance(view: View) { + val hybridView = getHybridView(view) + hybridView?.onDropView() + return super.onDropViewInstance(view) + } + protected override fun prepareToRecycleView(reactContext: ThemedReactContext, view: View): View? { super.prepareToRecycleView(reactContext, view) - val hybridView = view.getTag(associated_hybrid_view_tag) as? HybridTestView + val hybridView = getHybridView(view) ?: return null @Suppress("USELESS_IS_CHECK") @@ -67,4 +73,8 @@ public class HybridTestViewManager: SimpleViewManager() { return null } } + + private fun getHybridView(view: View): HybridTestView? { + return view.getTag(associated_hybrid_view_tag) as? HybridTestView + } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm index 7bc1bfcbd..84b842a86 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridRecyclableTestViewComponent.mm @@ -104,4 +104,10 @@ - (void)prepareForRecycle { swiftPart.maybePrepareForRecycle(); } +- (void)invalidate { + NitroTest::HybridRecyclableTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + swiftPart.onDropView(); + [super invalidate]; +} + @end diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm index c9c9bb445..95446a263 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/c++/views/HybridTestViewComponent.mm @@ -119,4 +119,10 @@ - (void)prepareForRecycle { swiftPart.maybePrepareForRecycle(); } +- (void)invalidate { + NitroTest::HybridTestViewSpec_cxx& swiftPart = _hybridView->getSwiftPart(); + swiftPart.onDropView(); + [super invalidate]; +} + @end diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec_cxx.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec_cxx.swift index f50bfc4b8..f09e1f75b 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec_cxx.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridRecyclableTestViewSpec_cxx.swift @@ -149,4 +149,8 @@ open class HybridRecyclableTestViewSpec_cxx { guard let recyclable = __implementation as? any RecyclableView else { return } recyclable.prepareForRecycle() } + + public final func onDropView() { + __implementation.onDropView() + } } diff --git a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift index 7038fe6d0..4c0b9731e 100644 --- a/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift +++ b/packages/react-native-nitro-test/nitrogen/generated/ios/swift/HybridTestViewSpec_cxx.swift @@ -201,4 +201,8 @@ open class HybridTestViewSpec_cxx { guard let recyclable = __implementation as? any RecyclableView else { return } recyclable.prepareForRecycle() } + + public final func onDropView() { + __implementation.onDropView() + } } diff --git a/packages/react-native-nitro-test/package.json b/packages/react-native-nitro-test/package.json index 6d82a1506..c2ced8440 100644 --- a/packages/react-native-nitro-test/package.json +++ b/packages/react-native-nitro-test/package.json @@ -1,6 +1,6 @@ { "name": "react-native-nitro-test", - "version": "0.35.0", + "version": "0.35.1", "description": "A testing playground library for Nitro Modules.", "main": "lib/index", "module": "lib/index", diff --git a/packages/template/android/build.gradle b/packages/template/android/build.gradle index 1b3e10773..9eca4d37f 100644 --- a/packages/template/android/build.gradle +++ b/packages/template/android/build.gradle @@ -5,7 +5,7 @@ buildscript { } dependencies { - classpath "com.android.tools.build:gradle:9.0.1" + classpath "com.android.tools.build:gradle:9.1.0" } }