react-native-nitro-modules 0.27.5 → 0.27.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/src/main/cpp/core/JHybridObject.cpp +5 -0
- package/android/src/main/cpp/core/JHybridObject.hpp +5 -1
- package/android/src/main/cpp/utils/JNISharedPtr.hpp +3 -0
- package/cpp/core/HybridObject.hpp +1 -1
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/lib/commonjs/views/getHostComponent.js +2 -1
- package/lib/commonjs/views/getHostComponent.js.map +1 -1
- package/package.json +1 -1
|
@@ -30,4 +30,9 @@ std::shared_ptr<HybridObject> JHybridObject::shared() {
|
|
|
30
30
|
return JNISharedPtr::make_shared_from_jni<JHybridObject>(_javaPart);
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
JHybridObject::~JHybridObject() {
|
|
34
|
+
// Hermes GC can destroy JS objects on a non-JNI Thread.
|
|
35
|
+
jni::ThreadScope::WithClassLoader([&] { _javaPart.reset(); });
|
|
36
|
+
}
|
|
37
|
+
|
|
33
38
|
} // namespace margelo::nitro
|
|
@@ -23,12 +23,16 @@ class JHybridObject : public jni::HybridClass<JHybridObject>, public virtual Hyb
|
|
|
23
23
|
public:
|
|
24
24
|
static auto constexpr kJavaDescriptor = "Lcom/margelo/nitro/core/HybridObject;";
|
|
25
25
|
|
|
26
|
+
public:
|
|
26
27
|
// C++ constructor (called from Java via `initHybrid()`)
|
|
27
28
|
explicit JHybridObject(jni::alias_ref<jhybridobject> jThis) : _javaPart(jni::make_global(jThis)) {}
|
|
28
29
|
// C++ default constructor used by older Nitro versions (deprecated in favor of the jThis one)
|
|
29
30
|
[[deprecated]] JHybridObject() = default;
|
|
30
|
-
~JHybridObject() override = default;
|
|
31
31
|
|
|
32
|
+
public:
|
|
33
|
+
~JHybridObject() override;
|
|
34
|
+
|
|
35
|
+
public:
|
|
32
36
|
// `shared()` has custom logic because we ref-count using `jni::global_ref`!
|
|
33
37
|
std::shared_ptr<HybridObject> shared() override;
|
|
34
38
|
|
|
@@ -49,6 +49,9 @@ public:
|
|
|
49
49
|
public:
|
|
50
50
|
/**
|
|
51
51
|
* Creates a new `std::shared_ptr<T>` from the given `jni::global_ref<T::javaobject>`.
|
|
52
|
+
* Note: This does not perform any caching and will just re-create the shared_ptr control-block
|
|
53
|
+
* each time. It is not safe to call this multiple times if you use enable_shared_from_this.
|
|
54
|
+
* Instead, use HybridObject::shared().
|
|
52
55
|
*/
|
|
53
56
|
template <typename T, typename std::enable_if<is_base_template_of<T, jni::HybridClass>::value, int>::type = 0>
|
|
54
57
|
static std::shared_ptr<T> make_shared_from_jni(const jni::global_ref<typename T::javaobject>& ref) {
|
|
@@ -65,7 +65,7 @@ public:
|
|
|
65
65
|
* The HybridObject must be managed inside a `shared_ptr` already, otherwise this will fail.
|
|
66
66
|
*/
|
|
67
67
|
template <typename Derived>
|
|
68
|
-
std::shared_ptr<Derived>
|
|
68
|
+
std::shared_ptr<Derived> shared_cast() {
|
|
69
69
|
return std::dynamic_pointer_cast<Derived>(shared());
|
|
70
70
|
}
|
|
71
71
|
/**
|
|
@@ -6,7 +6,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.getHostComponent = getHostComponent;
|
|
7
7
|
var _reactNative = require("react-native");
|
|
8
8
|
var NativeComponentRegistry = _interopRequireWildcard(require("react-native/Libraries/NativeComponent/NativeComponentRegistry"));
|
|
9
|
-
function
|
|
9
|
+
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
|
|
10
|
+
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
|
|
10
11
|
// @ts-expect-error this unfortunately isn't typed or default-exported.
|
|
11
12
|
|
|
12
13
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","NativeComponentRegistry","_interopRequireWildcard","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","NativeComponentRegistry","_interopRequireWildcard","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","getHostComponent","name","getViewConfig","Error","Platform","OS"],"sourceRoot":"../../../src","sources":["views/getHostComponent.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,uBAAA,GAAAC,uBAAA,CAAAF,OAAA;AAAyG,SAAAG,yBAAAC,CAAA,6BAAAC,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAF,wBAAA,YAAAA,CAAAC,CAAA,WAAAA,CAAA,GAAAG,CAAA,GAAAD,CAAA,KAAAF,CAAA;AAAA,SAAAF,wBAAAE,CAAA,EAAAE,CAAA,SAAAA,CAAA,IAAAF,CAAA,IAAAA,CAAA,CAAAI,UAAA,SAAAJ,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAK,OAAA,EAAAL,CAAA,QAAAG,CAAA,GAAAJ,wBAAA,CAAAG,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAG,GAAA,CAAAN,CAAA,UAAAG,CAAA,CAAAI,GAAA,CAAAP,CAAA,OAAAQ,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAAAC,MAAA,CAAAC,cAAA,IAAAD,MAAA,CAAAE,wBAAA,WAAAC,CAAA,IAAAd,CAAA,oBAAAc,CAAA,OAAAC,cAAA,CAAAC,IAAA,CAAAhB,CAAA,EAAAc,CAAA,SAAAG,CAAA,GAAAP,CAAA,GAAAC,MAAA,CAAAE,wBAAA,CAAAb,CAAA,EAAAc,CAAA,UAAAG,CAAA,KAAAA,CAAA,CAAAV,GAAA,IAAAU,CAAA,CAAAC,GAAA,IAAAP,MAAA,CAAAC,cAAA,CAAAJ,CAAA,EAAAM,CAAA,EAAAG,CAAA,IAAAT,CAAA,CAAAM,CAAA,IAAAd,CAAA,CAAAc,CAAA,YAAAN,CAAA,CAAAH,OAAA,GAAAL,CAAA,EAAAG,CAAA,IAAAA,CAAA,CAAAe,GAAA,CAAAlB,CAAA,EAAAQ,CAAA,GAAAA,CAAA;AADzG;;AAgBA;AACA;AACA;;AAsBA;AACA;AACA;;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA;AACA;AACA;AACA;AACA;AACO,SAASW,gBAAgBA,CAI9BC,IAAY,EACZC,aAAsC,EACL;EACjC,IAAIxB,uBAAuB,IAAI,IAAI,EAAE;IACnC,MAAM,IAAIyB,KAAK,CACb,+CAA+CC,qBAAQ,CAACC,EAAE,GAC5D,CAAC;EACH;EACA,OAAO3B,uBAAuB,CAACU,GAAG,CAACa,IAAI,EAAEC,aAAa,CAAC;AACzD","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.27.
|
|
3
|
+
"version": "0.27.6",
|
|
4
4
|
"description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.",
|
|
5
5
|
"main": "lib/commonjs/index",
|
|
6
6
|
"module": "lib/module/index",
|