expo-modules-core 55.0.6 → 55.0.7
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 +6 -0
- package/android/build.gradle +2 -2
- package/android/src/main/cpp/MethodMetadata.cpp +1 -1
- package/android/src/main/cpp/MethodMetadata.h +5 -0
- package/android/src/main/cpp/decorators/JSDecoratorsBridgingObject.cpp +12 -2
- package/android/src/main/cpp/decorators/JSDecoratorsBridgingObject.h +1 -0
- package/android/src/main/cpp/decorators/JSFunctionsDecorator.cpp +4 -0
- package/android/src/main/cpp/decorators/JSFunctionsDecorator.h +3 -0
- package/android/src/main/cpp/types/CppType.h +2 -1
- package/android/src/main/cpp/types/JNIToJSIConverter.cpp +61 -0
- package/android/src/main/cpp/types/JNIToJSIConverter.h +8 -0
- package/android/src/main/cpp/types/ReturnType.h +33 -0
- package/android/src/main/java/expo/modules/kotlin/functions/SyncFunctionComponent.kt +1 -0
- package/android/src/main/java/expo/modules/kotlin/jni/ReturnType.kt +30 -0
- package/android/src/main/java/expo/modules/kotlin/jni/decorators/JSDecoratorsBridgingObject.kt +1 -0
- package/android/src/main/java/expo/modules/kotlin/types/ExperimentalJSTypeConverter.kt +237 -0
- package/android/src/main/java/expo/modules/kotlin/types/ReturnType.kt +3 -158
- package/package.json +2 -2
- package/types.d.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 55.0.7 — 2026-02-03
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix global type declaration chain to point to `expo -> expo-modules-core/types -> ./build/global` rather than `types="node"` ([#42751](https://github.com/expo/expo/pull/42751) by [@kitten](https://github.com/kitten))
|
|
18
|
+
|
|
13
19
|
## 55.0.6 — 2026-02-03
|
|
14
20
|
|
|
15
21
|
### 🛠 Breaking changes
|
package/android/build.gradle
CHANGED
|
@@ -29,7 +29,7 @@ if (shouldIncludeCompose) {
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
group = 'host.exp.exponent'
|
|
32
|
-
version = '55.0.
|
|
32
|
+
version = '55.0.7'
|
|
33
33
|
|
|
34
34
|
def isExpoModulesCoreTests = {
|
|
35
35
|
Gradle gradle = getGradle()
|
|
@@ -96,7 +96,7 @@ android {
|
|
|
96
96
|
defaultConfig {
|
|
97
97
|
consumerProguardFiles 'proguard-rules.pro'
|
|
98
98
|
versionCode 1
|
|
99
|
-
versionName "55.0.
|
|
99
|
+
versionName "55.0.7"
|
|
100
100
|
buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
|
|
101
101
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
102
102
|
|
|
@@ -194,7 +194,7 @@ jsi::Value MethodMetadata::callSync(
|
|
|
194
194
|
jni::JniLocalScope scope(env, (int) count);
|
|
195
195
|
|
|
196
196
|
auto result = this->callJNISync(env, rt, thisValue, args, count);
|
|
197
|
-
return convert(env, rt, result);
|
|
197
|
+
return convert(env, rt, this->info.returnType, result);
|
|
198
198
|
}
|
|
199
199
|
|
|
200
200
|
jsi::Function MethodMetadata::toAsyncFunction(
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
#include "types/CppType.h"
|
|
6
6
|
#include "types/ExpectedType.h"
|
|
7
7
|
#include "types/AnyType.h"
|
|
8
|
+
#include "types/ReturnType.h"
|
|
8
9
|
|
|
9
10
|
#include <jsi/jsi.h>
|
|
10
11
|
#include <fbjni/fbjni.h>
|
|
@@ -48,6 +49,10 @@ public:
|
|
|
48
49
|
* Representation of expected argument types.
|
|
49
50
|
*/
|
|
50
51
|
std::vector<std::unique_ptr<AnyType>> argTypes;
|
|
52
|
+
/**
|
|
53
|
+
* Representation of expected return type.
|
|
54
|
+
*/
|
|
55
|
+
ReturnType returnType = ReturnType::UNKNOWN;
|
|
51
56
|
};
|
|
52
57
|
|
|
53
58
|
Info info;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
#include "JSDecoratorsBridgingObject.h"
|
|
4
4
|
|
|
5
5
|
#include "JSClassesDecorator.h"
|
|
6
|
+
#include "../types/ReturnType.h"
|
|
6
7
|
|
|
7
8
|
namespace expo {
|
|
8
9
|
|
|
@@ -36,13 +37,21 @@ void JSDecoratorsBridgingObject::registerSyncFunction(
|
|
|
36
37
|
jboolean takesOwner,
|
|
37
38
|
jboolean enumerable,
|
|
38
39
|
jni::alias_ref<jni::JArrayClass<ExpectedType>> expectedArgTypes,
|
|
40
|
+
jint cppReturnType,
|
|
39
41
|
jni::alias_ref<JNIFunctionBody::javaobject> body
|
|
40
42
|
) {
|
|
41
43
|
if (!functionDecorator) {
|
|
42
44
|
functionDecorator = std::make_unique<JSFunctionsDecorator>();
|
|
43
45
|
}
|
|
44
46
|
|
|
45
|
-
functionDecorator->registerSyncFunction(
|
|
47
|
+
functionDecorator->registerSyncFunction(
|
|
48
|
+
name,
|
|
49
|
+
takesOwner,
|
|
50
|
+
enumerable,
|
|
51
|
+
expectedArgTypes,
|
|
52
|
+
(ReturnType)cppReturnType,
|
|
53
|
+
body
|
|
54
|
+
);
|
|
46
55
|
}
|
|
47
56
|
|
|
48
57
|
void JSDecoratorsBridgingObject::registerAsyncFunction(
|
|
@@ -94,7 +103,8 @@ void JSDecoratorsBridgingObject::registerConstant(
|
|
|
94
103
|
constantsDecorator->registerConstant(name, getter);
|
|
95
104
|
}
|
|
96
105
|
|
|
97
|
-
void JSDecoratorsBridgingObject::registerConstants(
|
|
106
|
+
void JSDecoratorsBridgingObject::registerConstants(
|
|
107
|
+
jni::alias_ref<react::NativeMap::javaobject> constants) {
|
|
98
108
|
if (!constantsDecorator) {
|
|
99
109
|
constantsDecorator = std::make_unique<JSConstantsDecorator>();
|
|
100
110
|
}
|
|
@@ -30,6 +30,7 @@ void JSFunctionsDecorator::registerFunction(
|
|
|
30
30
|
bool enumerable,
|
|
31
31
|
bool isAsync,
|
|
32
32
|
std::vector<std::unique_ptr<AnyType>> &&argTypes,
|
|
33
|
+
ReturnType returnType,
|
|
33
34
|
jni::global_ref<jobject> body
|
|
34
35
|
) {
|
|
35
36
|
MethodMetadata::Info info{
|
|
@@ -51,6 +52,7 @@ void JSFunctionsDecorator::registerSyncFunction(
|
|
|
51
52
|
jboolean takesOwner,
|
|
52
53
|
jboolean enumerable,
|
|
53
54
|
jni::alias_ref<jni::JArrayClass<ExpectedType>> expectedArgTypes,
|
|
55
|
+
ReturnType returnType,
|
|
54
56
|
jni::alias_ref<JNIFunctionBody::javaobject> body
|
|
55
57
|
) {
|
|
56
58
|
registerFunction(
|
|
@@ -61,6 +63,7 @@ void JSFunctionsDecorator::registerSyncFunction(
|
|
|
61
63
|
enumerable,
|
|
62
64
|
/*isAsync=*/false,
|
|
63
65
|
mapConverters(expectedArgTypes),
|
|
66
|
+
returnType,
|
|
64
67
|
jni::make_global(body)
|
|
65
68
|
);
|
|
66
69
|
}
|
|
@@ -80,6 +83,7 @@ void JSFunctionsDecorator::registerAsyncFunction(
|
|
|
80
83
|
enumerable,
|
|
81
84
|
/*isAsync=*/true,
|
|
82
85
|
mapConverters(expectedArgTypes),
|
|
86
|
+
ReturnType::UNKNOWN,
|
|
83
87
|
jni::make_global(body)
|
|
84
88
|
);
|
|
85
89
|
}
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include "../MethodMetadata.h"
|
|
13
13
|
#include "../JNIFunctionBody.h"
|
|
14
14
|
#include "../types/ExpectedType.h"
|
|
15
|
+
#include "../types/ReturnType.h"
|
|
15
16
|
|
|
16
17
|
namespace jni = facebook::jni;
|
|
17
18
|
namespace jsi = facebook::jsi;
|
|
@@ -26,6 +27,7 @@ public:
|
|
|
26
27
|
jboolean takesOwner,
|
|
27
28
|
jboolean enumerable,
|
|
28
29
|
jni::alias_ref<jni::JArrayClass<ExpectedType>> expectedArgTypes,
|
|
30
|
+
ReturnType returnType,
|
|
29
31
|
jni::alias_ref<JNIFunctionBody::javaobject> body
|
|
30
32
|
);
|
|
31
33
|
|
|
@@ -56,6 +58,7 @@ private:
|
|
|
56
58
|
bool enumerable,
|
|
57
59
|
bool isAsync,
|
|
58
60
|
std::vector<std::unique_ptr<AnyType>> &&argTypes,
|
|
61
|
+
ReturnType returnType,
|
|
59
62
|
jni::global_ref<jobject> body
|
|
60
63
|
);
|
|
61
64
|
};
|
|
@@ -7,7 +7,7 @@ namespace expo {
|
|
|
7
7
|
* A cpp version of the `expo.modules.kotlin.jni.CppType` enum.
|
|
8
8
|
* Used to determine which representation of the js value should be sent to the Kotlin.
|
|
9
9
|
*/
|
|
10
|
-
enum CppType {
|
|
10
|
+
enum class CppType {
|
|
11
11
|
NONE = 0,
|
|
12
12
|
DOUBLE = 1 << 0,
|
|
13
13
|
INT = 1 << 1,
|
|
@@ -35,4 +35,5 @@ enum CppType {
|
|
|
35
35
|
NATIVE_ARRAY_BUFFER = 1 << 23,
|
|
36
36
|
SERIALIZABLE = 1 << 24,
|
|
37
37
|
};
|
|
38
|
+
|
|
38
39
|
} // namespace expo
|
|
@@ -90,6 +90,67 @@ jsi::Value convert(
|
|
|
90
90
|
return jsi::Value::undefined();
|
|
91
91
|
}
|
|
92
92
|
|
|
93
|
+
jsi::Value convert(
|
|
94
|
+
JNIEnv *env,
|
|
95
|
+
jsi::Runtime &rt,
|
|
96
|
+
ReturnType returnType,
|
|
97
|
+
const jni::local_ref<jobject> &value
|
|
98
|
+
) {
|
|
99
|
+
#define CAST_AND_RETURN(type) \
|
|
100
|
+
return convertToJS(env, rt, *((jni::local_ref<type>*)((void*)&value)));
|
|
101
|
+
#define COMMA ,
|
|
102
|
+
|
|
103
|
+
switch (returnType) {
|
|
104
|
+
case ReturnType::UNKNOWN:
|
|
105
|
+
return convert(env, rt, value);
|
|
106
|
+
case ReturnType::DOUBLE:
|
|
107
|
+
CAST_AND_RETURN(jni::JDouble)
|
|
108
|
+
case ReturnType::INT:
|
|
109
|
+
CAST_AND_RETURN(jni::JInteger)
|
|
110
|
+
case ReturnType::LONG:
|
|
111
|
+
CAST_AND_RETURN(jni::JLong)
|
|
112
|
+
case ReturnType::STRING:
|
|
113
|
+
CAST_AND_RETURN(jni::JString)
|
|
114
|
+
case ReturnType::BOOLEAN:
|
|
115
|
+
CAST_AND_RETURN(jni::JBoolean)
|
|
116
|
+
case ReturnType::FLOAT:
|
|
117
|
+
CAST_AND_RETURN(jni::JFloat)
|
|
118
|
+
case ReturnType::WRITEABLE_ARRAY:
|
|
119
|
+
CAST_AND_RETURN(react::WritableNativeArray::javaobject)
|
|
120
|
+
case ReturnType::WRITEABLE_MAP:
|
|
121
|
+
CAST_AND_RETURN(react::WritableNativeMap::javaobject)
|
|
122
|
+
case ReturnType::JS_MODULE:
|
|
123
|
+
CAST_AND_RETURN(JavaScriptModuleObject::javaobject)
|
|
124
|
+
case ReturnType::SHARED_OBJECT:
|
|
125
|
+
CAST_AND_RETURN(JSharedObject::javaobject)
|
|
126
|
+
case ReturnType::JS_TYPED_ARRAY:
|
|
127
|
+
CAST_AND_RETURN(JavaScriptTypedArray::javaobject)
|
|
128
|
+
case ReturnType::JS_ARRAY_BUFFER:
|
|
129
|
+
CAST_AND_RETURN(JavaScriptArrayBuffer::javaobject)
|
|
130
|
+
case ReturnType::NATIVE_ARRAY_BUFFER:
|
|
131
|
+
CAST_AND_RETURN(NativeArrayBuffer::javaobject)
|
|
132
|
+
case ReturnType::MAP:
|
|
133
|
+
CAST_AND_RETURN(jni::JMap<jstring COMMA jobject>)
|
|
134
|
+
case ReturnType::COLLECTION:
|
|
135
|
+
CAST_AND_RETURN(jni::JCollection<jobject>)
|
|
136
|
+
case ReturnType::DOUBLE_ARRAY:
|
|
137
|
+
CAST_AND_RETURN(jni::JArrayDouble)
|
|
138
|
+
case ReturnType::INT_ARRAY:
|
|
139
|
+
CAST_AND_RETURN(jni::JArrayInt)
|
|
140
|
+
case ReturnType::LONG_ARRAY:
|
|
141
|
+
CAST_AND_RETURN(jni::JArrayLong)
|
|
142
|
+
case ReturnType::FLOAT_ARRAY:
|
|
143
|
+
CAST_AND_RETURN(jni::JArrayFloat)
|
|
144
|
+
case ReturnType::BOOLEAN_ARRAY:
|
|
145
|
+
CAST_AND_RETURN(jni::JArrayBoolean )
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
#undef COMMA
|
|
149
|
+
#undef CAST_AND_RETURN
|
|
150
|
+
|
|
151
|
+
assert("Unhandled ReturnType in JNIToJSIConverter::convert" && false);
|
|
152
|
+
}
|
|
153
|
+
|
|
93
154
|
std::optional<jsi::Value> decorateValueForDynamicExtension(jsi::Runtime &rt, const jsi::Value &value) {
|
|
94
155
|
if (value.isString()) {
|
|
95
156
|
std::string string = value.getString(rt).utf8(rt);
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
#include "../concepts/jni_deref.h"
|
|
13
13
|
#include "../concepts/jni.h"
|
|
14
14
|
#include "../concepts/jsi.h"
|
|
15
|
+
#include "ReturnType.h"
|
|
15
16
|
|
|
16
17
|
#include <fbjni/fbjni.h>
|
|
17
18
|
#include <jsi/jsi.h>
|
|
@@ -36,6 +37,13 @@ jsi::Value convert(
|
|
|
36
37
|
const jni::local_ref<jobject> &value
|
|
37
38
|
);
|
|
38
39
|
|
|
40
|
+
jsi::Value convert(
|
|
41
|
+
JNIEnv *env,
|
|
42
|
+
jsi::Runtime &rt,
|
|
43
|
+
ReturnType returnType,
|
|
44
|
+
const jni::local_ref<jobject> &value
|
|
45
|
+
);
|
|
46
|
+
|
|
39
47
|
std::optional<jsi::Value> convertStringToFollyDynamicIfNeeded(
|
|
40
48
|
jsi::Runtime &rt,
|
|
41
49
|
const std::string &string
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright © 2026-present 650 Industries, Inc. (aka Expo)
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
namespace expo {
|
|
6
|
+
/**
|
|
7
|
+
* A cpp version of the `expo.modules.kotlin.jni.ReturnType` enum.
|
|
8
|
+
*/
|
|
9
|
+
enum class ReturnType {
|
|
10
|
+
UNKNOWN = 0,
|
|
11
|
+
DOUBLE = 1 << 0,
|
|
12
|
+
INT = 1 << 1,
|
|
13
|
+
LONG = 1 << 2,
|
|
14
|
+
STRING = 1 << 3,
|
|
15
|
+
BOOLEAN = 1 << 4,
|
|
16
|
+
FLOAT = 1 << 5,
|
|
17
|
+
WRITEABLE_ARRAY = 1 << 6,
|
|
18
|
+
WRITEABLE_MAP = 1 << 7,
|
|
19
|
+
JS_MODULE = 1 << 8,
|
|
20
|
+
SHARED_OBJECT = 1 << 9,
|
|
21
|
+
JS_TYPED_ARRAY = 1 << 10,
|
|
22
|
+
JS_ARRAY_BUFFER = 1 << 11,
|
|
23
|
+
NATIVE_ARRAY_BUFFER = 1 << 12,
|
|
24
|
+
MAP = 1 << 13,
|
|
25
|
+
COLLECTION = 1 << 14,
|
|
26
|
+
DOUBLE_ARRAY = 1 << 15,
|
|
27
|
+
INT_ARRAY = 1 << 16,
|
|
28
|
+
LONG_ARRAY = 1 << 17,
|
|
29
|
+
FLOAT_ARRAY = 1 << 18,
|
|
30
|
+
BOOLEAN_ARRAY = 1 << 19,
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
} // namespace expo
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
package expo.modules.kotlin.jni
|
|
2
|
+
|
|
3
|
+
private var nextValue = 0
|
|
4
|
+
|
|
5
|
+
private fun nextValue(): Int = (1 shl nextValue).also { nextValue++ }
|
|
6
|
+
|
|
7
|
+
// Keep this in sync with C++ enum in `ReturnType.h`.
|
|
8
|
+
enum class ReturnType(val value: Int = nextValue()) {
|
|
9
|
+
UNKNOWN(0),
|
|
10
|
+
DOUBLE,
|
|
11
|
+
INT,
|
|
12
|
+
LONG,
|
|
13
|
+
STRING,
|
|
14
|
+
BOOLEAN,
|
|
15
|
+
FLOAT,
|
|
16
|
+
WRITEABLE_ARRAY,
|
|
17
|
+
WRITEABLE_MAP,
|
|
18
|
+
JS_MODULE,
|
|
19
|
+
SHARED_OBJECT,
|
|
20
|
+
JS_TYPED_ARRAY,
|
|
21
|
+
JS_ARRAY_BUFFER,
|
|
22
|
+
NATIVE_ARRAY_BUFFER,
|
|
23
|
+
MAP,
|
|
24
|
+
COLLECTION,
|
|
25
|
+
DOUBLE_ARRAY,
|
|
26
|
+
INT_ARRAY,
|
|
27
|
+
LONG_ARRAY,
|
|
28
|
+
FLOAT_ARRAY,
|
|
29
|
+
BOOLEAN_ARRAY
|
|
30
|
+
}
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
package expo.modules.kotlin.types
|
|
2
|
+
|
|
3
|
+
import android.net.Uri
|
|
4
|
+
import android.os.Bundle
|
|
5
|
+
import expo.modules.kotlin.jni.ReturnType
|
|
6
|
+
import expo.modules.kotlin.records.Record
|
|
7
|
+
import expo.modules.kotlin.records.formatters.FormattedRecord
|
|
8
|
+
import expo.modules.kotlin.typedarray.RawTypedArrayHolder
|
|
9
|
+
import expo.modules.kotlin.types.folly.FollyDynamicExtensionConverter
|
|
10
|
+
import java.io.File
|
|
11
|
+
import java.net.URI
|
|
12
|
+
import java.net.URL
|
|
13
|
+
import kotlin.time.Duration
|
|
14
|
+
import kotlin.time.DurationUnit
|
|
15
|
+
|
|
16
|
+
interface ExperimentalJSTypeConverter<T> {
|
|
17
|
+
fun convertToJS(value: Any?): Any?
|
|
18
|
+
val returnType: ReturnType
|
|
19
|
+
|
|
20
|
+
class PassThroughConverter : ExperimentalJSTypeConverter<Any> {
|
|
21
|
+
override fun convertToJS(value: Any?): Any? {
|
|
22
|
+
return value
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
override val returnType: ReturnType
|
|
26
|
+
get() = ReturnType.UNKNOWN
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
class BundleConverter : ExperimentalJSTypeConverter<Bundle> {
|
|
30
|
+
override fun convertToJS(value: Any?): Any? {
|
|
31
|
+
enforceType<Bundle?>(value)
|
|
32
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override val returnType: ReturnType
|
|
36
|
+
get() = ReturnType.WRITEABLE_MAP
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
class ArrayConverter : ExperimentalJSTypeConverter<Array<*>> {
|
|
40
|
+
override fun convertToJS(value: Any?): Any? {
|
|
41
|
+
enforceType<Array<*>?>(value)
|
|
42
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
override val returnType: ReturnType
|
|
46
|
+
get() = ReturnType.WRITEABLE_ARRAY
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
class IntArrayConverter : ExperimentalJSTypeConverter<IntArray> {
|
|
50
|
+
override fun convertToJS(value: Any?): Any? {
|
|
51
|
+
enforceType<IntArray?>(value)
|
|
52
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
override val returnType: ReturnType
|
|
56
|
+
get() = ReturnType.INT_ARRAY
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
class FloatArrayConverter : ExperimentalJSTypeConverter<FloatArray> {
|
|
60
|
+
override fun convertToJS(value: Any?): Any? {
|
|
61
|
+
enforceType<FloatArray?>(value)
|
|
62
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
override val returnType: ReturnType
|
|
66
|
+
get() = ReturnType.FLOAT_ARRAY
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
class DoubleArrayConverter : ExperimentalJSTypeConverter<DoubleArray> {
|
|
70
|
+
override fun convertToJS(value: Any?): Any? {
|
|
71
|
+
enforceType<DoubleArray?>(value)
|
|
72
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
override val returnType: ReturnType
|
|
76
|
+
get() = ReturnType.DOUBLE_ARRAY
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
class BooleanArrayConverter : ExperimentalJSTypeConverter<BooleanArray> {
|
|
80
|
+
override fun convertToJS(value: Any?): Any? {
|
|
81
|
+
enforceType<BooleanArray?>(value)
|
|
82
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
override val returnType: ReturnType
|
|
86
|
+
get() = ReturnType.BOOLEAN_ARRAY
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
class ByteArrayConverter : ExperimentalJSTypeConverter<ByteArray> {
|
|
90
|
+
override fun convertToJS(value: Any?): Any? {
|
|
91
|
+
enforceType<ByteArray?>(value)
|
|
92
|
+
return value?.let { FollyDynamicExtensionConverter.put(it) }
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
override val returnType: ReturnType
|
|
96
|
+
get() = ReturnType.STRING
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
class MapConverter : ExperimentalJSTypeConverter<Map<*, *>> {
|
|
100
|
+
override fun convertToJS(value: Any?): Any? {
|
|
101
|
+
enforceType<Map<*, *>?>(value)
|
|
102
|
+
return value?.toJSValueExperimental()
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
override val returnType: ReturnType
|
|
106
|
+
get() = ReturnType.MAP
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
class EnumConverter : ExperimentalJSTypeConverter<Enum<*>> {
|
|
110
|
+
override fun convertToJS(value: Any?): Any? {
|
|
111
|
+
enforceType<Enum<*>?>(value)
|
|
112
|
+
return value?.toJSValue()
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
override val returnType: ReturnType
|
|
116
|
+
get() = ReturnType.UNKNOWN // TODO(@lukmccall): Define proper ReturnType for Enums
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
class RecordConverter : ExperimentalJSTypeConverter<Record> {
|
|
120
|
+
override fun convertToJS(value: Any?): Any? {
|
|
121
|
+
enforceType<Record?>(value)
|
|
122
|
+
return value?.toJSValueExperimental()
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
override val returnType: ReturnType
|
|
126
|
+
get() = ReturnType.MAP
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
class URIConverter : ExperimentalJSTypeConverter<URI> {
|
|
130
|
+
override fun convertToJS(value: Any?): Any? {
|
|
131
|
+
enforceType<URI?>(value)
|
|
132
|
+
return value?.toJSValue()
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
override val returnType: ReturnType
|
|
136
|
+
get() = ReturnType.STRING
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
class URLConverter : ExperimentalJSTypeConverter<URL> {
|
|
140
|
+
override fun convertToJS(value: Any?): Any? {
|
|
141
|
+
enforceType<URL?>(value)
|
|
142
|
+
return value?.toJSValue()
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
override val returnType: ReturnType
|
|
146
|
+
get() = ReturnType.STRING
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
class AndroidUriConverter : ExperimentalJSTypeConverter<Uri> {
|
|
150
|
+
override fun convertToJS(value: Any?): Any? {
|
|
151
|
+
enforceType<Uri?>(value)
|
|
152
|
+
return value?.toJSValue()
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
override val returnType: ReturnType
|
|
156
|
+
get() = ReturnType.STRING
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
class FileConverter : ExperimentalJSTypeConverter<File> {
|
|
160
|
+
override fun convertToJS(value: Any?): Any? {
|
|
161
|
+
enforceType<File?>(value)
|
|
162
|
+
return value?.toJSValue()
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
override val returnType: ReturnType
|
|
166
|
+
get() = ReturnType.STRING
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
class PairConverter : ExperimentalJSTypeConverter<Pair<*, *>> {
|
|
170
|
+
override fun convertToJS(value: Any?): Any? {
|
|
171
|
+
enforceType<Pair<*, *>?>(value)
|
|
172
|
+
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
override val returnType: ReturnType
|
|
176
|
+
get() = ReturnType.WRITEABLE_ARRAY
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
class LongConverter : ExperimentalJSTypeConverter<Long> {
|
|
180
|
+
override fun convertToJS(value: Any?): Any? {
|
|
181
|
+
enforceType<Long?>(value)
|
|
182
|
+
return value?.toDouble()
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
override val returnType: ReturnType
|
|
186
|
+
get() = ReturnType.LONG
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
class DurationConverter : ExperimentalJSTypeConverter<Duration> {
|
|
190
|
+
override fun convertToJS(value: Any?): Any? {
|
|
191
|
+
enforceType<Duration?>(value)
|
|
192
|
+
return value?.toDouble(DurationUnit.SECONDS)
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
override val returnType: ReturnType
|
|
196
|
+
get() = ReturnType.DOUBLE
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
class RawTypedArrayHolderConverter : ExperimentalJSTypeConverter<RawTypedArrayHolder> {
|
|
200
|
+
override fun convertToJS(value: Any?): Any? {
|
|
201
|
+
enforceType<RawTypedArrayHolder?>(value)
|
|
202
|
+
return value?.rawArray
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
override val returnType: ReturnType
|
|
206
|
+
get() = ReturnType.JS_TYPED_ARRAY
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
class CollectionConverter : ExperimentalJSTypeConverter<Collection<*>> {
|
|
210
|
+
override fun convertToJS(value: Any?): Any? {
|
|
211
|
+
enforceType<Collection<*>?>(value)
|
|
212
|
+
return value?.toJSValueExperimental()
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
override val returnType: ReturnType
|
|
216
|
+
get() = ReturnType.COLLECTION
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
class AnyConverter : ExperimentalJSTypeConverter<Any> {
|
|
220
|
+
override fun convertToJS(value: Any?): Any? {
|
|
221
|
+
return JSTypeConverter.convertToJSValue(value, useExperimentalConverter = true)
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
override val returnType: ReturnType
|
|
225
|
+
get() = ReturnType.UNKNOWN
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
class FormattedRecordConverter : ExperimentalJSTypeConverter<FormattedRecord<*>> {
|
|
229
|
+
override fun convertToJS(value: Any?): Any? {
|
|
230
|
+
enforceType<FormattedRecord<*>?>(value)
|
|
231
|
+
return value?.toJSValueExperimental()
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
override val returnType: ReturnType
|
|
235
|
+
get() = ReturnType.MAP
|
|
236
|
+
}
|
|
237
|
+
}
|
|
@@ -2,10 +2,8 @@ package expo.modules.kotlin.types
|
|
|
2
2
|
|
|
3
3
|
import android.os.Bundle
|
|
4
4
|
import expo.modules.kotlin.records.formatters.FormattedRecord
|
|
5
|
-
import expo.modules.kotlin.types.folly.FollyDynamicExtensionConverter
|
|
6
5
|
import kotlin.reflect.KClass
|
|
7
6
|
import kotlin.time.Duration
|
|
8
|
-
import kotlin.time.DurationUnit
|
|
9
7
|
|
|
10
8
|
object ReturnTypeProvider {
|
|
11
9
|
val types = mutableMapOf<KClass<*>, ReturnType>()
|
|
@@ -21,162 +19,6 @@ inline fun <reified T> toReturnType(): ReturnType {
|
|
|
21
19
|
return ReturnTypeProvider.get<T>()
|
|
22
20
|
}
|
|
23
21
|
|
|
24
|
-
interface ExperimentalJSTypeConverter<T> {
|
|
25
|
-
fun convertToJS(value: Any?): Any?
|
|
26
|
-
|
|
27
|
-
class PassThroughConverter : ExperimentalJSTypeConverter<Any> {
|
|
28
|
-
override fun convertToJS(value: Any?): Any? {
|
|
29
|
-
return value
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
class BundleConverter : ExperimentalJSTypeConverter<Bundle> {
|
|
34
|
-
override fun convertToJS(value: Any?): Any? {
|
|
35
|
-
enforceType<Bundle?>(value)
|
|
36
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
class ArrayConverter : ExperimentalJSTypeConverter<Array<*>> {
|
|
41
|
-
override fun convertToJS(value: Any?): Any? {
|
|
42
|
-
enforceType<Array<*>?>(value)
|
|
43
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
class IntArrayConverter : ExperimentalJSTypeConverter<IntArray> {
|
|
48
|
-
override fun convertToJS(value: Any?): Any? {
|
|
49
|
-
enforceType<IntArray?>(value)
|
|
50
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
class FloatArrayConverter : ExperimentalJSTypeConverter<FloatArray> {
|
|
55
|
-
override fun convertToJS(value: Any?): Any? {
|
|
56
|
-
enforceType<FloatArray?>(value)
|
|
57
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
class DoubleArrayConverter : ExperimentalJSTypeConverter<DoubleArray> {
|
|
62
|
-
override fun convertToJS(value: Any?): Any? {
|
|
63
|
-
enforceType<DoubleArray?>(value)
|
|
64
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
class BooleanArrayConverter : ExperimentalJSTypeConverter<BooleanArray> {
|
|
69
|
-
override fun convertToJS(value: Any?): Any? {
|
|
70
|
-
enforceType<BooleanArray?>(value)
|
|
71
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
class ByteArrayConverter : ExperimentalJSTypeConverter<ByteArray> {
|
|
76
|
-
override fun convertToJS(value: Any?): Any? {
|
|
77
|
-
enforceType<ByteArray?>(value)
|
|
78
|
-
return value?.let { FollyDynamicExtensionConverter.put(it) }
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
class MapConverter : ExperimentalJSTypeConverter<Map<*, *>> {
|
|
83
|
-
override fun convertToJS(value: Any?): Any? {
|
|
84
|
-
enforceType<Map<*, *>?>(value)
|
|
85
|
-
return value?.toJSValueExperimental()
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
class EnumConverter : ExperimentalJSTypeConverter<Enum<*>> {
|
|
90
|
-
override fun convertToJS(value: Any?): Any? {
|
|
91
|
-
enforceType<Enum<*>?>(value)
|
|
92
|
-
return value?.toJSValue()
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
class RecordConverter : ExperimentalJSTypeConverter<expo.modules.kotlin.records.Record> {
|
|
97
|
-
override fun convertToJS(value: Any?): Any? {
|
|
98
|
-
enforceType<expo.modules.kotlin.records.Record?>(value)
|
|
99
|
-
return value?.toJSValueExperimental()
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
class URIConverter : ExperimentalJSTypeConverter<java.net.URI> {
|
|
104
|
-
override fun convertToJS(value: Any?): Any? {
|
|
105
|
-
enforceType<java.net.URI?>(value)
|
|
106
|
-
return value?.toJSValue()
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
class URLConverter : ExperimentalJSTypeConverter<java.net.URL> {
|
|
111
|
-
override fun convertToJS(value: Any?): Any? {
|
|
112
|
-
enforceType<java.net.URL?>(value)
|
|
113
|
-
return value?.toJSValue()
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
class AndroidUriConverter : ExperimentalJSTypeConverter<android.net.Uri> {
|
|
118
|
-
override fun convertToJS(value: Any?): Any? {
|
|
119
|
-
enforceType<android.net.Uri?>(value)
|
|
120
|
-
return value?.toJSValue()
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
class FileConverter : ExperimentalJSTypeConverter<java.io.File> {
|
|
125
|
-
override fun convertToJS(value: Any?): Any? {
|
|
126
|
-
enforceType<java.io.File?>(value)
|
|
127
|
-
return value?.toJSValue()
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
class PairConverter : ExperimentalJSTypeConverter<Pair<*, *>> {
|
|
132
|
-
override fun convertToJS(value: Any?): Any? {
|
|
133
|
-
enforceType<Pair<*, *>?>(value)
|
|
134
|
-
return value?.toJSValue(JSTypeConverter.DefaultContainerProvider)
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
class LongConverter : ExperimentalJSTypeConverter<Long> {
|
|
139
|
-
override fun convertToJS(value: Any?): Any? {
|
|
140
|
-
enforceType<Long?>(value)
|
|
141
|
-
return value?.toDouble()
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
class DurationConverter : ExperimentalJSTypeConverter<Duration> {
|
|
146
|
-
override fun convertToJS(value: Any?): Any? {
|
|
147
|
-
enforceType<Duration?>(value)
|
|
148
|
-
return value?.toDouble(DurationUnit.SECONDS)
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
class RawTypedArrayHolderConverter : ExperimentalJSTypeConverter<expo.modules.kotlin.typedarray.RawTypedArrayHolder> {
|
|
153
|
-
override fun convertToJS(value: Any?): Any? {
|
|
154
|
-
enforceType<expo.modules.kotlin.typedarray.RawTypedArrayHolder?>(value)
|
|
155
|
-
return value?.rawArray
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
class CollectionConverter : ExperimentalJSTypeConverter<Collection<*>> {
|
|
160
|
-
override fun convertToJS(value: Any?): Any? {
|
|
161
|
-
enforceType<Collection<*>?>(value)
|
|
162
|
-
return value?.toJSValueExperimental()
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
class AnyConverter : ExperimentalJSTypeConverter<Any> {
|
|
167
|
-
override fun convertToJS(value: Any?): Any? {
|
|
168
|
-
return JSTypeConverter.convertToJSValue(value, useExperimentalConverter = true)
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
class FormattedRecordConverter : ExperimentalJSTypeConverter<FormattedRecord<*>> {
|
|
173
|
-
override fun convertToJS(value: Any?): Any? {
|
|
174
|
-
enforceType<FormattedRecord<*>?>(value)
|
|
175
|
-
return value?.toJSValueExperimental()
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
|
|
180
22
|
class ReturnType(
|
|
181
23
|
private val klass: KClass<*>
|
|
182
24
|
) {
|
|
@@ -216,6 +58,9 @@ class ReturnType(
|
|
|
216
58
|
return converter.convertToJS(value)
|
|
217
59
|
}
|
|
218
60
|
|
|
61
|
+
val cppType: expo.modules.kotlin.jni.ReturnType
|
|
62
|
+
get() = converter.returnType
|
|
63
|
+
|
|
219
64
|
internal inline fun <reified T> inheritFrom(): Boolean {
|
|
220
65
|
val jClass = klass.java
|
|
221
66
|
return T::class.java.isAssignableFrom(jClass)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-core",
|
|
3
|
-
"version": "55.0.
|
|
3
|
+
"version": "55.0.7",
|
|
4
4
|
"description": "The core of Expo Modules architecture",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -66,5 +66,5 @@
|
|
|
66
66
|
"@testing-library/react-native": "^13.2.0",
|
|
67
67
|
"expo-module-scripts": "^55.0.2"
|
|
68
68
|
},
|
|
69
|
-
"gitHead": "
|
|
69
|
+
"gitHead": "feb52bad4c6c47d4c010248e74265eb3d9873371"
|
|
70
70
|
}
|
package/types.d.ts
CHANGED