react-native-nitro-modules 0.30.0 → 0.30.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/src/main/java/com/margelo/nitro/NitroModules.kt +50 -42
- package/android/src/main/java/com/margelo/nitro/NitroModulesPackage.kt +26 -22
- package/android/src/main/java/com/margelo/nitro/core/AnyMap.kt +44 -7
- package/android/src/main/java/com/margelo/nitro/core/AnyValue.kt +145 -139
- package/android/src/main/java/com/margelo/nitro/core/ArrayBuffer.kt +162 -154
- package/android/src/main/java/com/margelo/nitro/core/HybridObject.kt +51 -51
- package/android/src/main/java/com/margelo/nitro/core/Promise.kt +9 -1
- package/android/src/main/java/com/margelo/nitro/utils/HardwareBuffer+updateFrom.kt +1 -2
- package/android/src/main/java/com/margelo/nitro/utils/HardwareBufferUtils.kt +33 -26
- package/android/src/main/java/com/margelo/nitro/views/HybridView.kt +20 -19
- package/cpp/utils/NitroDefines.hpp +1 -1
- package/ios/core/AnyMap.swift +12 -17
- package/ios/core/ArrayBuffer.swift +45 -36
- package/ios/core/HybridObject.swift +4 -6
- package/ios/core/Promise.swift +23 -25
- package/ios/core/RuntimeError.swift +6 -8
- package/ios/utils/Date+fromChrono.swift +4 -4
- package/ios/utils/SwiftClosure.swift +12 -16
- package/ios/views/HybridView.swift +30 -32
- package/lib/commonjs/views/getHostComponent.js +1 -2
- package/lib/commonjs/views/getHostComponent.js.map +1 -1
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -3
|
@@ -13,57 +13,65 @@ import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder
|
|
|
13
13
|
@Keep
|
|
14
14
|
@OptIn(FrameworkAPI::class)
|
|
15
15
|
@Suppress("KotlinJniMissingFunction")
|
|
16
|
-
class NitroModules internal constructor(
|
|
17
|
-
|
|
16
|
+
class NitroModules internal constructor(
|
|
17
|
+
val context: ReactApplicationContext,
|
|
18
|
+
) : NitroModulesSpec(context) {
|
|
19
|
+
private val mHybridData: HybridData
|
|
18
20
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
init {
|
|
22
|
+
mHybridData = initHybrid()
|
|
23
|
+
applicationContext = context
|
|
24
|
+
}
|
|
23
25
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
override fun getName(): String {
|
|
27
|
+
return NAME
|
|
28
|
+
}
|
|
27
29
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
31
|
+
override fun install(): String? {
|
|
32
|
+
try {
|
|
33
|
+
// 1. Get jsi::Runtime pointer
|
|
34
|
+
val jsContext =
|
|
35
|
+
context.javaScriptContextHolder
|
|
36
|
+
?: return "ReactApplicationContext.javaScriptContextHolder is null!"
|
|
34
37
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
+
// 2. Get CallInvokerHolder
|
|
39
|
+
val callInvokerHolder =
|
|
40
|
+
context.jsCallInvokerHolder as? CallInvokerHolderImpl
|
|
41
|
+
?: return "ReactApplicationContext.jsCallInvokerHolder is null!"
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
43
|
+
// 3. Install Nitro
|
|
44
|
+
install(jsContext.get(), callInvokerHolder)
|
|
41
45
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
46
|
+
return null
|
|
47
|
+
} catch (e: Throwable) {
|
|
48
|
+
// ?. Something went wrong! Maybe a JNI error?
|
|
49
|
+
return e.message
|
|
47
50
|
}
|
|
51
|
+
}
|
|
48
52
|
|
|
49
|
-
|
|
50
|
-
private external fun install(jsRuntimePointer: Long, callInvokerHolder: CallInvokerHolderImpl)
|
|
53
|
+
private external fun initHybrid(): HybridData
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
const val NAME = "NitroModules"
|
|
55
|
+
private external fun install(
|
|
56
|
+
jsRuntimePointer: Long,
|
|
57
|
+
callInvokerHolder: CallInvokerHolderImpl,
|
|
58
|
+
)
|
|
57
59
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
companion object {
|
|
61
|
+
/**
|
|
62
|
+
* The TurboModule's name.
|
|
63
|
+
*/
|
|
64
|
+
const val NAME = "NitroModules"
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Get the current `ReactApplicationContext`, or `null` if none is available.
|
|
68
|
+
*/
|
|
69
|
+
@JvmStatic
|
|
70
|
+
var applicationContext: ReactApplicationContext? = null
|
|
71
|
+
|
|
72
|
+
init {
|
|
73
|
+
// Make sure Nitro's C++ library is loaded
|
|
74
|
+
JNIOnLoad.initializeNativeNitro()
|
|
68
75
|
}
|
|
69
|
-
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -7,28 +7,32 @@ import com.facebook.react.module.model.ReactModuleInfo
|
|
|
7
7
|
import com.facebook.react.module.model.ReactModuleInfoProvider
|
|
8
8
|
|
|
9
9
|
class NitroModulesPackage : TurboReactPackage() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
override fun getModule(
|
|
11
|
+
name: String,
|
|
12
|
+
reactContext: ReactApplicationContext,
|
|
13
|
+
): NativeModule? {
|
|
14
|
+
return if (name == NitroModules.NAME) {
|
|
15
|
+
NitroModules(reactContext)
|
|
16
|
+
} else {
|
|
17
|
+
null
|
|
16
18
|
}
|
|
19
|
+
}
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
21
|
+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
|
|
22
|
+
return ReactModuleInfoProvider {
|
|
23
|
+
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
|
|
24
|
+
val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
|
|
25
|
+
moduleInfos[NitroModules.NAME] =
|
|
26
|
+
ReactModuleInfo(
|
|
27
|
+
NitroModules.NAME,
|
|
28
|
+
NitroModules.NAME,
|
|
29
|
+
canOverrideExistingModule = false,
|
|
30
|
+
needsEagerInit = false,
|
|
31
|
+
hasConstants = false,
|
|
32
|
+
isCxxModule = false,
|
|
33
|
+
isTurboModule = isTurboModule,
|
|
34
|
+
)
|
|
35
|
+
moduleInfos
|
|
33
36
|
}
|
|
34
|
-
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -30,52 +30,89 @@ class AnyMap {
|
|
|
30
30
|
mHybridData = hybridData
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
|
|
34
33
|
@FastNative
|
|
35
34
|
external fun contains(key: String): Boolean
|
|
35
|
+
|
|
36
36
|
@FastNative
|
|
37
37
|
external fun remove(key: String)
|
|
38
|
+
|
|
38
39
|
@FastNative
|
|
39
40
|
external fun clear()
|
|
41
|
+
|
|
40
42
|
external fun getAllKeys(): Array<String>
|
|
41
43
|
|
|
42
44
|
@FastNative
|
|
43
45
|
external fun isNull(key: String): Boolean
|
|
46
|
+
|
|
44
47
|
@FastNative
|
|
45
48
|
external fun isDouble(key: String): Boolean
|
|
49
|
+
|
|
46
50
|
@FastNative
|
|
47
51
|
external fun isBoolean(key: String): Boolean
|
|
52
|
+
|
|
48
53
|
@FastNative
|
|
49
54
|
external fun isBigInt(key: String): Boolean
|
|
55
|
+
|
|
50
56
|
@FastNative
|
|
51
57
|
external fun isString(key: String): Boolean
|
|
58
|
+
|
|
52
59
|
@FastNative
|
|
53
60
|
external fun isArray(key: String): Boolean
|
|
61
|
+
|
|
54
62
|
@FastNative
|
|
55
63
|
external fun isObject(key: String): Boolean
|
|
56
64
|
|
|
57
65
|
@FastNative
|
|
58
66
|
external fun getDouble(key: String): Double
|
|
67
|
+
|
|
59
68
|
@FastNative
|
|
60
69
|
external fun getBoolean(key: String): Boolean
|
|
70
|
+
|
|
61
71
|
@FastNative
|
|
62
72
|
external fun getBigInt(key: String): Long
|
|
73
|
+
|
|
63
74
|
external fun getString(key: String): String
|
|
75
|
+
|
|
64
76
|
external fun getAnyArray(key: String): AnyArray
|
|
77
|
+
|
|
65
78
|
external fun getAnyObject(key: String): AnyObject
|
|
66
79
|
|
|
67
80
|
@FastNative
|
|
68
81
|
external fun setNull(key: String)
|
|
82
|
+
|
|
69
83
|
@FastNative
|
|
70
|
-
external fun setDouble(
|
|
84
|
+
external fun setDouble(
|
|
85
|
+
key: String,
|
|
86
|
+
value: Double,
|
|
87
|
+
)
|
|
88
|
+
|
|
71
89
|
@FastNative
|
|
72
|
-
external fun setBoolean(
|
|
90
|
+
external fun setBoolean(
|
|
91
|
+
key: String,
|
|
92
|
+
value: Boolean,
|
|
93
|
+
)
|
|
94
|
+
|
|
73
95
|
@FastNative
|
|
74
|
-
external fun setBigInt(
|
|
96
|
+
external fun setBigInt(
|
|
97
|
+
key: String,
|
|
98
|
+
value: Long,
|
|
99
|
+
)
|
|
100
|
+
|
|
75
101
|
@FastNative
|
|
76
|
-
external fun setString(
|
|
77
|
-
|
|
78
|
-
|
|
102
|
+
external fun setString(
|
|
103
|
+
key: String,
|
|
104
|
+
value: String,
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
external fun setAnyArray(
|
|
108
|
+
key: String,
|
|
109
|
+
value: AnyArray,
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
external fun setAnyObject(
|
|
113
|
+
key: String,
|
|
114
|
+
value: AnyObject,
|
|
115
|
+
)
|
|
79
116
|
|
|
80
117
|
private external fun initHybrid(): HybridData
|
|
81
118
|
}
|
|
@@ -22,143 +22,149 @@ typealias AnyObject = Map<String, AnyValue>
|
|
|
22
22
|
@Keep
|
|
23
23
|
@DoNotStrip
|
|
24
24
|
class AnyValue {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
25
|
+
private val mHybridData: HybridData
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Create a new [AnyValue] that holds `null`.
|
|
29
|
+
*/
|
|
30
|
+
constructor() {
|
|
31
|
+
mHybridData = initHybrid()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Create a new [AnyValue] that holds the given [Double]
|
|
36
|
+
*/
|
|
37
|
+
constructor(value: Double) {
|
|
38
|
+
mHybridData = initHybrid(value)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Create a new [AnyValue] that holds the given [Boolean]
|
|
43
|
+
*/
|
|
44
|
+
constructor(value: Boolean) {
|
|
45
|
+
mHybridData = initHybrid(value)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Create a new [AnyValue] that holds the given [Long]
|
|
50
|
+
*/
|
|
51
|
+
constructor(value: Long) {
|
|
52
|
+
mHybridData = initHybrid(value)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Create a new [AnyValue] that holds the given [String]
|
|
57
|
+
*/
|
|
58
|
+
constructor(value: String) {
|
|
59
|
+
mHybridData = initHybrid(value)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Create a new [AnyValue] that holds the given [AnyArray]
|
|
64
|
+
*/
|
|
65
|
+
constructor(value: AnyArray) {
|
|
66
|
+
mHybridData = initHybrid(value)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Create a new [AnyValue] that holds the given [AnyObject]
|
|
71
|
+
*/
|
|
72
|
+
constructor(value: AnyObject) {
|
|
73
|
+
mHybridData = initHybrid(value)
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Gets whether this [AnyValue] instance is holding a `null`.
|
|
78
|
+
*/
|
|
79
|
+
@FastNative
|
|
80
|
+
external fun isNull(): Boolean
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Gets whether this [AnyValue] instance is holding a [Double] value.
|
|
84
|
+
*/
|
|
85
|
+
@FastNative
|
|
86
|
+
external fun isDouble(): Boolean
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Gets whether this [AnyValue] instance is holding a [Boolean] value.
|
|
90
|
+
*/
|
|
91
|
+
@FastNative
|
|
92
|
+
external fun isBoolean(): Boolean
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Gets whether this [AnyValue] instance is holding a [Long] value.
|
|
96
|
+
*/
|
|
97
|
+
@FastNative
|
|
98
|
+
external fun isBigInt(): Boolean
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Gets whether this [AnyValue] instance is holding a [String] value.
|
|
102
|
+
*/
|
|
103
|
+
@FastNative
|
|
104
|
+
external fun isString(): Boolean
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Gets whether this [AnyValue] instance is holding an [AnyArray] value.
|
|
108
|
+
*/
|
|
109
|
+
@FastNative
|
|
110
|
+
external fun isAnyArray(): Boolean
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* Gets whether this [AnyValue] instance is holding an [AnyObject] value.
|
|
114
|
+
*/
|
|
115
|
+
@FastNative
|
|
116
|
+
external fun isAnyObject(): Boolean
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Get the [Double] value this [AnyValue] is holding.
|
|
120
|
+
* @throws Error if this [AnyValue] is not holding a [Double] (see [isDouble]`()`)
|
|
121
|
+
*/
|
|
122
|
+
@FastNative
|
|
123
|
+
external fun asDouble(): Double
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Get the [Boolean] value this [AnyValue] is holding.
|
|
127
|
+
* @throws Error if this [AnyValue] is not holding a [Boolean] (see [isBoolean]`()`)
|
|
128
|
+
*/
|
|
129
|
+
@FastNative
|
|
130
|
+
external fun asBoolean(): Boolean
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Get the [Long] value this [AnyValue] is holding.
|
|
134
|
+
* @throws Error if this [AnyValue] is not holding a [Long] (see [isLong]`()`)
|
|
135
|
+
*/
|
|
136
|
+
@FastNative
|
|
137
|
+
external fun asBigInt(): Long
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Get the [String] value this [AnyValue] is holding.
|
|
141
|
+
* @throws Error if this [AnyValue] is not holding a [String] (see [isString]`()`)
|
|
142
|
+
*/
|
|
143
|
+
external fun asString(): String
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Get the [AnyArray] value this [AnyValue] is holding.
|
|
147
|
+
* @throws Error if this [AnyValue] is not holding an [AnyArray] (see [isAnyArray]`()`)
|
|
148
|
+
*/
|
|
149
|
+
external fun asAnyArray(): AnyArray
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Get the [AnyObject] value this [AnyValue] is holding.
|
|
153
|
+
* @throws Error if this [AnyValue] is not holding an [AnyObject] (see [isAnyObject]`()`)
|
|
154
|
+
*/
|
|
155
|
+
external fun asAnyObject(): AnyObject
|
|
156
|
+
|
|
157
|
+
private external fun initHybrid(): HybridData
|
|
158
|
+
|
|
159
|
+
private external fun initHybrid(value: Double): HybridData
|
|
160
|
+
|
|
161
|
+
private external fun initHybrid(value: Boolean): HybridData
|
|
162
|
+
|
|
163
|
+
private external fun initHybrid(value: Long): HybridData
|
|
164
|
+
|
|
165
|
+
private external fun initHybrid(value: String): HybridData
|
|
166
|
+
|
|
167
|
+
private external fun initHybrid(value: AnyArray): HybridData
|
|
168
|
+
|
|
169
|
+
private external fun initHybrid(value: AnyObject): HybridData
|
|
164
170
|
}
|