Skip to content

Commit 4de93f4

Browse files
feat: bump nitro modules version (#4641)
1 parent fce0640 commit 4de93f4

File tree

109 files changed

+440
-340
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+440
-340
lines changed

README.md

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ The most battle-tested open-source video player component for React Native with
5151
### Requirements
5252

5353
- React Native 0.75 or higher
54-
- `react-native-nitro-modules` (>=0.24.0) - Please see [nitro requirements](https://nitro.margelo.com/docs/minimum-requirements)
54+
- `react-native-nitro-modules` (>=0.27.2) - Please see [nitro requirements](https://nitro.margelo.com/docs/minimum-requirements)
5555

5656
### Install
5757

58-
`react-native-video` requires `react-native-nitro-modules` (>=0.24.0) in your project.
58+
`react-native-video` requires `react-native-nitro-modules` (>=0.27.2) in your project.
5959
```bash
6060
npm install react-native-nitro-modules
6161
```
@@ -78,34 +78,7 @@ You can apply it using `patch-package`.
7878

7979
Without this patch you won't be able "recognize" errors, all will be thrown as unknown errors.
8080

81-
```diff
82-
diff --git a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
83-
index aefd987..c2e06fb 100644
84-
--- a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
85-
+++ b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
86-
@@ -23,6 +23,10 @@ struct JSIConverter;
87-
#include <string>
88-
#include <type_traits>
89-
90-
+#ifdef ANDROID
91-
+#include <fbjni/fbjni.h>
92-
+#endif
93-
+
94-
namespace margelo::nitro {
95-
96-
using namespace facebook;
97-
@@ -118,6 +122,10 @@ public:
98-
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
99-
std::string message = exception.what();
100-
throw jsi::JSError(runtime, funcName + ": " + message);
101-
+ } catch (const jni::JniException& exception) {
102-
+ std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
103-
+ std::string message = exception.what();
104-
+ throw jsi::JSError(runtime, funcName + ": " + message);
105-
#pragma clang diagnostic pop
106-
#endif
107-
} catch (...) {
108-
```
81+
see [installation guide](https://docs.thewidlarzgroup.com/react-native-video/docs/v7/installation#patch-for-react-native--080)
10982
</details>
11083

11184
### Usage

bun.lock

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@react-native-community/slider": "^4.5.6",
5757
"react": "18.3.1",
5858
"react-native": "^0.77.0",
59-
"react-native-nitro-modules": "^0.26.0",
59+
"react-native-nitro-modules": "^0.27.0",
6060
"react-native-video": "*",
6161
},
6262
"devDependencies": {
@@ -89,18 +89,18 @@
8989
"eslint": "^8.51.0",
9090
"eslint-config-prettier": "^9.0.0",
9191
"eslint-plugin-prettier": "^5.0.1",
92-
"nitro-codegen": ">=0.26.0",
92+
"nitro-codegen": "^0.27.0",
9393
"prettier": "^3.0.3",
9494
"react": "18.3.1",
9595
"react-native": "^0.77.0",
9696
"react-native-builder-bob": "^0.40.0",
97-
"react-native-nitro-modules": ">=0.26.0",
97+
"react-native-nitro-modules": "^0.27.0",
9898
"typescript": "^5.2.2",
9999
},
100100
"peerDependencies": {
101101
"react": "*",
102102
"react-native": "*",
103-
"react-native-nitro-modules": ">=0.25.0",
103+
"react-native-nitro-modules": ">=0.27.2",
104104
},
105105
},
106106
},
@@ -2597,7 +2597,7 @@
25972597

25982598
"new-github-release-url": ["[email protected]", "", { "dependencies": { "type-fest": "^2.5.1" } }, "sha512-NHDDGYudnvRutt/VhKFlX26IotXe1w0cmkDm6JGquh5bz/bDTw0LufSmH/GxTjEdpHEO+bVKFTwdrcGa/9XlKQ=="],
25992599

2600-
"nitro-codegen": ["nitro-codegen@0.26.2", "", { "dependencies": { "chalk": "^5.3.0", "react-native-nitro-modules": "^0.26.2", "ts-morph": "^25.0.0", "yargs": "^17.7.2", "zod": "^3.23.8" }, "bin": { "nitro-codegen": "lib/index.js" } }, "sha512-Z66PE0kzwrTdvyUMsq0eCv6IcEsv+tpkZovGcIat/UVJrcbbBNaScKuFRL07Qoh7idm4mErJiei6IRewJUDghA=="],
2600+
"nitro-codegen": ["nitro-codegen@0.27.2", "", { "dependencies": { "chalk": "^5.3.0", "react-native-nitro-modules": "^0.27.2", "ts-morph": "^25.0.0", "yargs": "^17.7.2", "zod": "^4.0.5" }, "bin": { "nitro-codegen": "lib/index.js" } }, "sha512-8s47CFGu2QYvqbKacmtpowgcj577fX60pxFiIDHyM0scT8u28thwAmy6ByskCySHiLFDO7OX6yVT+TrJHc6rQQ=="],
26012601

26022602
"no-case": ["[email protected]", "", { "dependencies": { "lower-case": "^2.0.2", "tslib": "^2.0.3" } }, "sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg=="],
26032603

@@ -2977,7 +2977,7 @@
29772977

29782978
"react-native-monorepo-config": ["[email protected]", "", { "dependencies": { "escape-string-regexp": "^5.0.0", "fast-glob": "^3.3.3" } }, "sha512-GLFYMEEcbltxZw7oUbbh/p0oXqA52lSirXt7o/N1qD6CFTvku84OVL6teeQ1Ef92pq+bepq4x0Qz+d6lapVbuQ=="],
29792979

2980-
"react-native-nitro-modules": ["react-native-nitro-modules@0.26.2", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-PvTUOryU/J1RDsPh1IvmAEDkYVVL32wCIYxkg6HsKgq+Dl+C8lth/MtW7cRZ+fJ0qW21NILbhBdhSXFzBx51fA=="],
2980+
"react-native-nitro-modules": ["react-native-nitro-modules@0.27.2", "", { "peerDependencies": { "react": "*", "react-native": "*" } }, "sha512-wHUs6m4e1MkhV7oPMNSZwCZcoaepLNfPScc+Pm9pwgtv26sTADXnu66MzyodSl6kO6TcTC1Pf+5VyQMgesx08w=="],
29812981

29822982
"react-native-video": ["react-native-video@workspace:packages/react-native-video"],
29832983

@@ -3579,7 +3579,7 @@
35793579

35803580
"yoctocolors-cjs": ["[email protected]", "", {}, "sha512-cYVsTjKl8b+FrnidjibDWskAv7UKOfcwaVZdp/it9n1s9fU3IkgDbhdIRKCW4JDsAlECJY0ytoVPT3sK6kideA=="],
35813581

3582-
"zod": ["zod@3.24.2", "", {}, "sha512-lY7CDW43ECgW9u1TcT3IoXHflywfVqDYze4waEz812jR/bZ8FHDsl7pFQoSZTz5N+2NqRXs8GBwnAwo3ZNxqhQ=="],
3582+
"zod": ["zod@4.0.14", "", {}, "sha512-nGFJTnJN6cM2v9kXL+SOBq3AtjQby3Mv5ySGFof5UGRHrRioSJ5iG680cYNjE/yWk671nROcpPj4hAS8nyLhSw=="],
35833583

35843584
"zwitch": ["[email protected]", "", {}, "sha512-V50KMwwzqJV0NpZIZFwfOD5/lyny3WlSzRiXgA0G7VUnRlqttta1L6UQIHzd6EuBY/cHGfwTIck7w1yH6Q5zUw=="],
35853585

docs/docs/installation.md

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ React Native Video is a library that allows you to play various kind of videos i
1414

1515
### Minimal Package Requirements
1616
- `react-native` `0.75.0` or higher
17-
- `react-native-nitro-modules` `0.26.0` or higher
17+
- `react-native-nitro-modules` `0.27.2` or higher
1818

1919
## Installation
2020

@@ -51,6 +51,57 @@ npx react-native run-ios # run on iOS
5151
npx react-native run-android # run on Android
5252
```
5353

54+
## Patch for react-native < 0.80
55+
56+
`react-native` < 0.80 have bug that prevents to properly handle errors by nitro modules on Android.
57+
We highly recommend to apply bellow patch for `react-native-nitro-modules` to fix this issue.
58+
You can apply it using `patch-package`.
59+
60+
:::warning
61+
Without this patch you won't be able "recognize" errors, all will be thrown as unknown errors.
62+
:::
63+
64+
<details>
65+
<summary>For `react-native-nitro-modules` 0.27.X or higher</summary>
66+
67+
```diff
68+
diff --git a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
69+
index efcea05..ffad3f2 100644
70+
--- a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
71+
+++ b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
72+
@@ -23,6 +23,10 @@ struct JSIConverter;
73+
#include <string>
74+
#include <type_traits>
75+
76+
+#ifdef ANDROID
77+
+#include <fbjni/fbjni.h>
78+
+#endif
79+
+
80+
namespace margelo::nitro {
81+
82+
using namespace facebook;
83+
@@ -109,6 +113,15 @@ public:
84+
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
85+
std::string message = exception.what();
86+
throw jsi::JSError(runtime, funcName + ": " + message);
87+
+#ifdef ANDROID
88+
+#pragma clang diagnostic push
89+
+#pragma clang diagnostic ignored "-Wexceptions"
90+
+ } catch (const jni::JniException& exception) {
91+
+ std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
92+
+ std::string message = exception.what();
93+
+ throw jsi::JSError(runtime, funcName + ": " + message);
94+
+#pragma clang diagnostic pop
95+
+#endif
96+
} catch (...) {
97+
// Some unknown exception was thrown - add method name information and re-throw as `JSError`.
98+
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
99+
```
100+
101+
see [raw](https://github.com/TheWidlarzGroup/react-native-video/blob/v7/example/patches/react-native-nitro-modules%2B0.27.2.patch)
102+
</details>
103+
104+
54105
## Usage
55106

56107
```tsx title="App.tsx"

example/ios/Podfile.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ PODS:
88
- hermes-engine (0.77.2):
99
- hermes-engine/Pre-built (= 0.77.2)
1010
- hermes-engine/Pre-built (0.77.2)
11-
- NitroModules (0.26.2):
11+
- NitroModules (0.27.2):
1212
- DoubleConversion
1313
- glog
1414
- hermes-engine
@@ -1816,7 +1816,7 @@ SPEC CHECKSUMS:
18161816
fmt: a40bb5bd0294ea969aaaba240a927bd33d878cdd
18171817
glog: eb93e2f488219332457c3c4eafd2738ddc7e80b8
18181818
hermes-engine: 8eb265241fa1d7095d3a40d51fd90f7dce68217c
1819-
NitroModules: 39248e88212416d858a4f4561cf719c6cc8ef900
1819+
NitroModules: 7ed5fd8f6f1e814810b9df26830b78f3355690bf
18201820
RCT-Folly: e78785aa9ba2ed998ea4151e314036f6c49e6d82
18211821
RCTDeprecation: 85b72250b63cfb54f29ca96ceb108cb9ef3c2079
18221822
RCTRequired: 567cb8f5d42b990331bfd93faad1d8999b1c1736

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@react-native-community/slider": "^4.5.6",
1414
"react": "18.3.1",
1515
"react-native": "^0.77.0",
16-
"react-native-nitro-modules": "^0.26.0",
16+
"react-native-nitro-modules": "^0.27.0",
1717
"react-native-video": "*"
1818
},
1919
"devDependencies": {
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
diff --git a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
2+
index efcea05..ffad3f2 100644
3+
--- a/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
4+
+++ b/node_modules/react-native-nitro-modules/cpp/core/HybridFunction.hpp
5+
@@ -23,6 +23,10 @@ struct JSIConverter;
6+
#include <string>
7+
#include <type_traits>
8+
9+
+#ifdef ANDROID
10+
+#include <fbjni/fbjni.h>
11+
+#endif
12+
+
13+
namespace margelo::nitro {
14+
15+
using namespace facebook;
16+
@@ -109,6 +113,15 @@ public:
17+
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
18+
std::string message = exception.what();
19+
throw jsi::JSError(runtime, funcName + ": " + message);
20+
+#ifdef ANDROID
21+
+#pragma clang diagnostic push
22+
+#pragma clang diagnostic ignored "-Wexceptions"
23+
+ } catch (const jni::JniException& exception) {
24+
+ std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());
25+
+ std::string message = exception.what();
26+
+ throw jsi::JSError(runtime, funcName + ": " + message);
27+
+#pragma clang diagnostic pop
28+
+#endif
29+
} catch (...) {
30+
// Some unknown exception was thrown - add method name information and re-throw as `JSError`.
31+
std::string funcName = getHybridFuncFullName<THybrid>(kind, name, hybridInstance.get());

packages/react-native-video/android/src/main/java/com/video/hybrids/videoplayer/HybridVideoPlayer.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -338,10 +338,6 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() {
338338
}
339339
}
340340

341-
override fun clean() {
342-
release()
343-
}
344-
345341
fun movePlayerToVideoView(videoView: VideoView) {
346342
VideoManager.addViewToPlayer(videoView, this)
347343

@@ -351,6 +347,10 @@ class HybridVideoPlayer() : HybridVideoPlayerSpec() {
351347
}
352348
}
353349

350+
override fun dispose() {
351+
release()
352+
}
353+
354354
override val memorySize: Long
355355
get() = allocator?.totalBytesAllocated?.toLong() ?: 0L
356356

packages/react-native-video/ios/hybrids/VideoPlayer/HybridVideoPlayer.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,6 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, NativeVideoPlayerSpec {
183183
return player?.rate != 0
184184
}
185185

186-
func clean() throws {
187-
release()
188-
}
189-
190186
func release() {
191187
playerQueue.async { [weak self] in
192188
guard let self = self else { return }
@@ -494,6 +490,10 @@ class HybridVideoPlayer: HybridVideoPlayerSpec, NativeVideoPlayerSpec {
494490
}
495491

496492
// MARK: - Memory Management
493+
494+
func dispose() {
495+
release()
496+
}
497497

498498
var memorySize: Int {
499499
var size = 0

packages/react-native-video/nitrogen/generated/android/c++/JFunc_void_BandwidthData.hpp

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)