react-native-nitro-modules 0.26.4 → 0.27.1
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/fix-prefab.gradle +51 -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 +2 -1
package/android/build.gradle
CHANGED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
tasks.configureEach { task ->
|
|
2
|
+
// Make sure that we generate our prefab publication file only after having built the native library
|
|
3
|
+
// so that not a header publication file, but a full configuration publication will be generated, which
|
|
4
|
+
// will include the .so file
|
|
5
|
+
|
|
6
|
+
def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
|
|
7
|
+
def matcher = task.name =~ prefabConfigurePattern
|
|
8
|
+
if (matcher.matches()) {
|
|
9
|
+
def variantName = matcher[0][1]
|
|
10
|
+
task.outputs.upToDateWhen { false }
|
|
11
|
+
task.dependsOn("externalNativeBuild${variantName}")
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
afterEvaluate {
|
|
16
|
+
def abis = reactNativeArchitectures()
|
|
17
|
+
rootProject.allprojects.each { proj ->
|
|
18
|
+
if (proj === rootProject) return
|
|
19
|
+
|
|
20
|
+
def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
|
|
21
|
+
config.dependencies.any { dep ->
|
|
22
|
+
dep.group == project.group && dep.name == project.name
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (!dependsOnThisLib && proj != project) return
|
|
26
|
+
|
|
27
|
+
if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
|
|
28
|
+
return
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
|
|
32
|
+
// Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
|
|
33
|
+
// generate a libnameConfig.cmake file that will contain our native library (.so).
|
|
34
|
+
// See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
|
|
35
|
+
variants.all { variant ->
|
|
36
|
+
def variantName = variant.name
|
|
37
|
+
abis.each { abi ->
|
|
38
|
+
def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
|
|
39
|
+
if (!searchDir.exists()) return
|
|
40
|
+
def matches = []
|
|
41
|
+
searchDir.eachDir { randomDir ->
|
|
42
|
+
def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
|
|
43
|
+
if (prefabFile.exists()) matches << prefabFile
|
|
44
|
+
}
|
|
45
|
+
matches.each { prefabConfig ->
|
|
46
|
+
prefabConfig.setLastModified(System.currentTimeMillis())
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -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.1",
|
|
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",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"lib",
|
|
15
15
|
"android/build.gradle",
|
|
16
16
|
"android/gradle.properties",
|
|
17
|
+
"android/fix-prefab.gradle",
|
|
17
18
|
"android/CMakeLists.txt",
|
|
18
19
|
"android/src/",
|
|
19
20
|
"ios/",
|