react-native-nitro-modules 0.26.4 → 0.27.0
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/build.gradle +1 -0
- package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +15 -0
- package/cpp/core/HybridObject.cpp +2 -0
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/ios/core/AnyMap.swift +1 -1
- package/ios/core/HybridObject.swift +14 -0
- package/ios/core/Promise.swift +1 -1
- package/ios/views/HybridView.swift +7 -0
- package/package.json +1 -1
package/android/build.gradle
CHANGED
|
@@ -31,6 +31,21 @@ abstract class HybridObject {
|
|
|
31
31
|
open val memorySize: Long
|
|
32
32
|
get() = 0L
|
|
33
33
|
|
|
34
|
+
/**
|
|
35
|
+
* Eagerly- (and manually-) dispose all native resources this `HybridObject` holds.
|
|
36
|
+
* This method can only be manually called from JS using `dispose()`.
|
|
37
|
+
*
|
|
38
|
+
* If this method is never manually called, a `HybridObject` is expected to disposes it's
|
|
39
|
+
* resources as usual via the object's destructor (`~HybridObject()`, `deinit` or `finalize()`).
|
|
40
|
+
*
|
|
41
|
+
* By default, this method does nothing. It can be overridden to perform actual disposing/cleanup
|
|
42
|
+
* if required.
|
|
43
|
+
* This method must not throw.
|
|
44
|
+
*/
|
|
45
|
+
@DoNotStrip
|
|
46
|
+
@Keep
|
|
47
|
+
open fun dispose() { }
|
|
48
|
+
|
|
34
49
|
/**
|
|
35
50
|
* Holds the native C++ instance.
|
|
36
51
|
* In `HybridObject`, the C++ instance is a sub-class of `JHybridObject`, such as one of it's specs.
|
|
@@ -28,6 +28,8 @@ jsi::Value HybridObject::disposeRaw(jsi::Runtime& runtime, const jsi::Value& thi
|
|
|
28
28
|
// 2. Remove the NativeState from `this`
|
|
29
29
|
jsi::Object thisObject = thisArg.asObject(runtime);
|
|
30
30
|
thisObject.setNativeState(runtime, nullptr);
|
|
31
|
+
// 3. Clear our object cache
|
|
32
|
+
_objectCache.clear();
|
|
31
33
|
|
|
32
34
|
return jsi::Value::undefined();
|
|
33
35
|
}
|
package/ios/core/AnyMap.swift
CHANGED
|
@@ -45,7 +45,7 @@ public indirect enum AnyValue {
|
|
|
45
45
|
* Represents an `AnyMap`- an untyped map instance.
|
|
46
46
|
* See C++ `AnyMap.hpp` for more information.
|
|
47
47
|
*/
|
|
48
|
-
public final class AnyMap {
|
|
48
|
+
public final class AnyMap: @unchecked Sendable {
|
|
49
49
|
public let cppPart: margelo.nitro.SharedAnyMap
|
|
50
50
|
|
|
51
51
|
public init() {
|
|
@@ -27,9 +27,23 @@ public protocol HybridObject: AnyObject {
|
|
|
27
27
|
* ```
|
|
28
28
|
*/
|
|
29
29
|
var memorySize: Int { get }
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Eagerly- (and manually-) dispose all native resources this `HybridObject` holds.
|
|
33
|
+
* This method can only be manually called from JS using `dispose()`.
|
|
34
|
+
*
|
|
35
|
+
* If this method is never manually called, a `HybridObject` is expected to disposes it's
|
|
36
|
+
* resources as usual via the object's destructor (`~HybridObject()`, `deinit` or `finalize()`).
|
|
37
|
+
*
|
|
38
|
+
* By default, this method does nothing. It can be overridden to perform actual disposing/cleanup
|
|
39
|
+
* if required.
|
|
40
|
+
*/
|
|
41
|
+
func dispose()
|
|
30
42
|
}
|
|
31
43
|
|
|
32
44
|
public extension HybridObject {
|
|
33
45
|
// By default, this returns `0`.
|
|
34
46
|
var memorySize: Int { return 0 }
|
|
47
|
+
// By default, this does nothing.
|
|
48
|
+
func dispose() { }
|
|
35
49
|
}
|
package/ios/core/Promise.swift
CHANGED
|
@@ -17,7 +17,7 @@ import Foundation
|
|
|
17
17
|
* - `Promise<T>.rejected(withError:)` - Creates a new already rejected Promise.
|
|
18
18
|
* - `Promise<T>()` - Creates a new Promise with fully manual control over the `resolve(..)`/`reject(..)` functions.
|
|
19
19
|
*/
|
|
20
|
-
public final class Promise<T
|
|
20
|
+
public final class Promise<T>: @unchecked Sendable {
|
|
21
21
|
private enum State {
|
|
22
22
|
case result(T)
|
|
23
23
|
case error(Error)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-nitro-modules",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.27.0",
|
|
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",
|