expo-modules-core 2.3.8 → 2.3.9
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/CHANGELOG.md +8 -1
- package/android/build.gradle +22 -9
- package/android/src/compose/expo/modules/kotlin/views/ModuleDefinitionBuilderComposeExtension.kt +35 -0
- package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +2 -2
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionBuilder.kt +17 -17
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionComponent.kt +75 -68
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionWithPromiseComponent.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/functions/UntypedAsyncFunctionComponent.kt +84 -0
- package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +8 -25
- package/android/src/main/java/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +19 -19
- package/android/src/main/java/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +19 -19
- package/android/src/withoutCompose/expo/modules/kotlin/views/ModuleDefinitionBuilderComposeExtension.kt +10 -0
- package/common/cpp/TestingSyncJSCallInvoker.h +0 -10
- package/ios/Core/Promise.swift +8 -6
- package/ios/Core/Views/SwiftUI/SwiftUIViewDefinition.swift +2 -1
- package/ios/JSI/EXJSIConversions.mm +4 -0
- package/ios/JSI/EXJavaScriptRuntime.mm +2 -2
- package/ios/JSI/EXJavaScriptSharedObjectBinding.h +25 -0
- package/ios/JSI/EXJavaScriptSharedObjectBinding.mm +24 -0
- package/ios/TestUtils/MainThreadInvoker.h +14 -0
- package/ios/TestUtils/MainThreadInvoker.mm +19 -0
- package/ios/TestUtils/TestingJSCallInvoker.h +46 -0
- package/ios/Tests/FunctionSpec.swift +18 -6
- package/package.json +3 -3
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunction.kt +0 -91
- /package/android/src/{main/java → compose}/expo/modules/kotlin/views/AutoSizingComposable.kt +0 -0
- /package/android/src/{main/java → compose}/expo/modules/kotlin/views/ComposeProps.kt +0 -0
- /package/android/src/{main/java → compose}/expo/modules/kotlin/views/ComposeViewProp.kt +0 -0
- /package/android/src/{main/java → compose}/expo/modules/kotlin/views/ExpoComposeView.kt +0 -0
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
package expo.modules.kotlin.functions
|
|
2
|
-
|
|
3
|
-
import android.view.View
|
|
4
|
-
import expo.modules.BuildConfig
|
|
5
|
-
import expo.modules.kotlin.AppContext
|
|
6
|
-
import expo.modules.kotlin.Promise
|
|
7
|
-
import expo.modules.kotlin.exception.FunctionCallException
|
|
8
|
-
import expo.modules.kotlin.exception.exceptionDecorator
|
|
9
|
-
import expo.modules.kotlin.exception.toCodedException
|
|
10
|
-
import expo.modules.kotlin.jni.decorators.JSDecoratorsBridgingObject
|
|
11
|
-
import expo.modules.kotlin.types.AnyType
|
|
12
|
-
import expo.modules.kotlin.weak
|
|
13
|
-
import kotlinx.coroutines.launch
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Base class of async function components that require a promise to be called.
|
|
17
|
-
*/
|
|
18
|
-
abstract class AsyncFunction(
|
|
19
|
-
name: String,
|
|
20
|
-
desiredArgsTypes: Array<AnyType>
|
|
21
|
-
) : BaseAsyncFunctionComponent(name, desiredArgsTypes) {
|
|
22
|
-
internal abstract fun callUserImplementation(args: Array<Any?>, promise: Promise, appContext: AppContext)
|
|
23
|
-
|
|
24
|
-
override fun attachToJSObject(appContext: AppContext, jsObject: JSDecoratorsBridgingObject, moduleName: String) {
|
|
25
|
-
val appContextHolder = appContext.weak()
|
|
26
|
-
jsObject.registerAsyncFunction(
|
|
27
|
-
name,
|
|
28
|
-
takesOwner,
|
|
29
|
-
isEnumerable,
|
|
30
|
-
desiredArgsTypes.map { it.getCppRequiredTypes() }.toTypedArray()
|
|
31
|
-
) { args, promiseImpl ->
|
|
32
|
-
if (BuildConfig.DEBUG) {
|
|
33
|
-
promiseImpl.decorateWithDebugInformation(
|
|
34
|
-
appContextHolder,
|
|
35
|
-
moduleName,
|
|
36
|
-
name
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
val functionBody = {
|
|
41
|
-
try {
|
|
42
|
-
exceptionDecorator({
|
|
43
|
-
FunctionCallException(name, moduleName, it)
|
|
44
|
-
}) {
|
|
45
|
-
callUserImplementation(args, promiseImpl, appContext)
|
|
46
|
-
}
|
|
47
|
-
} catch (e: Throwable) {
|
|
48
|
-
// The promise was resolved, so we should rethrow the error.
|
|
49
|
-
if (promiseImpl.wasSettled) {
|
|
50
|
-
throw e
|
|
51
|
-
}
|
|
52
|
-
promiseImpl.reject(e.toCodedException())
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
dispatchOnQueue(appContext, functionBody)
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
private fun dispatchOnQueue(appContext: AppContext, block: () -> Unit) {
|
|
61
|
-
when (val queue = queue) {
|
|
62
|
-
Queues.DEFAULT -> {
|
|
63
|
-
appContext.modulesQueue.launch {
|
|
64
|
-
block()
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
Queues.MAIN -> {
|
|
69
|
-
if (!BuildConfig.IS_NEW_ARCHITECTURE_ENABLED && desiredArgsTypes.any { it.inheritFrom<View>() }) {
|
|
70
|
-
// On certain occasions, invoking a function on a view could lead to an error
|
|
71
|
-
// because of the asynchronous communication between the JavaScript and native components.
|
|
72
|
-
// In such cases, the native view may not have been mounted yet,
|
|
73
|
-
// but the JavaScript code has already received the future tag of the view.
|
|
74
|
-
// To avoid this issue, we have decided to temporarily utilize
|
|
75
|
-
// the UIManagerModule for dispatching functions on the main thread.
|
|
76
|
-
appContext.dispatchOnMainUsingUIManager(block)
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
appContext.mainQueue.launch {
|
|
81
|
-
block()
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
is CustomQueue ->
|
|
86
|
-
queue.scope.launch {
|
|
87
|
-
block()
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
/package/android/src/{main/java → compose}/expo/modules/kotlin/views/AutoSizingComposable.kt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|