expo-modules-core 55.0.0 → 55.0.2
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 +11 -1
- package/android/build.gradle +2 -2
- package/android/cmake/main.cmake +2 -1
- package/android/src/compose/expo/modules/kotlin/views/ComposeViewProp.kt +0 -18
- package/android/src/fabric/FabricComponentsRegistry.cpp +47 -0
- package/android/src/fabric/FabricComponentsRegistry.h +25 -0
- package/android/src/main/cpp/JNIInjector.cpp +1 -3
- package/android/src/main/java/expo/modules/adapters/react/FabricComponentsRegistry.kt +6 -33
- package/android/src/main/java/expo/modules/adapters/react/ModuleRegistryAdapter.java +8 -12
- package/android/src/main/java/expo/modules/kotlin/KotlinInteropModuleRegistry.kt +24 -9
- package/android/src/main/java/expo/modules/kotlin/views/AnyViewProp.kt +0 -4
- package/android/src/main/java/expo/modules/kotlin/views/ConcreteViewProp.kt +1 -19
- package/android/src/main/java/expo/modules/kotlin/views/GroupViewManagerWrapper.kt +6 -7
- package/android/src/main/java/expo/modules/kotlin/views/SimpleViewManagerWrapper.kt +3 -15
- package/android/src/main/java/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +9 -15
- package/android/src/main/java/expo/modules/kotlin/views/ViewManagerWrapperDelegate.kt +9 -69
- package/common/cpp/fabric/ExpoViewComponentDescriptor.cpp +78 -0
- package/common/cpp/fabric/ExpoViewComponentDescriptor.h +6 -74
- package/common/cpp/fabric/ExpoViewProps.cpp +8 -17
- package/common/cpp/fabric/ExpoViewProps.h +3 -7
- package/common/cpp/fabric/ExpoViewShadowNode.cpp +34 -0
- package/common/cpp/fabric/ExpoViewShadowNode.h +10 -45
- package/common/cpp/fabric/ExpoViewState.h +55 -7
- package/ios/Core/Views/SwiftUI/SwiftUIVirtualViewObjC.mm +5 -5
- package/ios/Fabric/ExpoFabricViewObjC.mm +5 -5
- package/ios/JSI/EXJSIConversions.mm +1 -6
- package/package.json +3 -3
- package/android/src/main/cpp/fabric/AndroidExpoViewComponentDescriptor.cpp +0 -105
- package/android/src/main/cpp/fabric/AndroidExpoViewComponentDescriptor.h +0 -46
- package/android/src/main/cpp/fabric/AndroidExpoViewProps.cpp +0 -22
- package/android/src/main/cpp/fabric/AndroidExpoViewProps.h +0 -29
- package/android/src/main/cpp/fabric/AndroidExpoViewState.cpp +0 -36
- package/android/src/main/cpp/fabric/AndroidExpoViewState.h +0 -36
- package/android/src/main/cpp/fabric/FabricComponentsRegistry.cpp +0 -97
- package/android/src/main/cpp/fabric/FabricComponentsRegistry.h +0 -50
- package/android/src/main/cpp/fabric/NativeStatePropsGetter.cpp +0 -32
- package/android/src/main/cpp/fabric/NativeStatePropsGetter.h +0 -25
- package/android/src/main/java/expo/modules/kotlin/jni/fabric/NativeStatePropsGetter.kt +0 -9
- package/common/cpp/fabric/ExpoViewState.cpp +0 -37
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 55.0.2 — 2026-01-22
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- [macos] Remove react-native-macos@0.79.0 workarounds ([#42409](https://github.com/expo/expo/pull/42409) by [@gabrieldonadel](https://github.com/gabrieldonadel))
|
|
18
|
+
|
|
19
|
+
## 55.0.1 — 2026-01-22
|
|
20
|
+
|
|
21
|
+
_This version does not introduce any user-facing changes._
|
|
22
|
+
|
|
13
23
|
## 55.0.0 — 2026-01-21
|
|
14
24
|
|
|
15
25
|
### 🛠 Breaking changes
|
|
@@ -45,7 +55,7 @@
|
|
|
45
55
|
### 🐛 Bug fixes
|
|
46
56
|
|
|
47
57
|
- [Android] Fixed DSL view props using stale state when updating. ([#41622](https://github.com/expo/expo/pull/41622) by [@kimchi-developer](https://github.com/kimchi-developer))
|
|
48
|
-
-
|
|
58
|
+
- [core] Fixed `useReleasingSharedObject` to defer releasing until after render.
|
|
49
59
|
- [android] Fix source sets for events for functional view definitions. ([#41685](https://github.com/expo/expo/pull/41685) by [@aleqsio](https://github.com/aleqsio))
|
|
50
60
|
- [iOS] Fix throwing `InvalidArgsNumberException` when declaring `AsyncFunction` with optional arguments and `Promise`. ([#41054](https://github.com/expo/expo/pull/41054) by [@Wenszel](https://github.com/Wenszel))
|
|
51
61
|
- [iOS] fix queue assertion crash ([#41296](https://github.com/expo/expo/pull/41296) by [@vonovak](https://github.com/vonovak))
|
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.2'
|
|
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.2"
|
|
100
100
|
buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
|
|
101
101
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", "true"
|
|
102
102
|
|
package/android/cmake/main.cmake
CHANGED
|
@@ -15,9 +15,10 @@ file(
|
|
|
15
15
|
"${main_dir}/decorators/*.cpp"
|
|
16
16
|
"${main_dir}/installers/*.cpp"
|
|
17
17
|
"${main_dir}/worklets/*.cpp"
|
|
18
|
-
"${main_dir}/fabric/*.cpp"
|
|
19
18
|
)
|
|
20
19
|
|
|
20
|
+
file(GLOB fabric_andorid_sources "${ANDROID_SRC_DIR}/fabric/*.cpp")
|
|
21
|
+
|
|
21
22
|
add_library(
|
|
22
23
|
expo-modules-core
|
|
23
24
|
SHARED
|
|
@@ -17,19 +17,9 @@ class ComposeViewProp(
|
|
|
17
17
|
anyType: AnyType,
|
|
18
18
|
val property: KProperty1<*, *>
|
|
19
19
|
) : AnyViewProp(name, anyType) {
|
|
20
|
-
private var _isStateProp = false
|
|
21
20
|
|
|
22
21
|
@Suppress("UNCHECKED_CAST")
|
|
23
22
|
override fun set(prop: Dynamic, onView: View, appContext: AppContext?) {
|
|
24
|
-
setPropDirectly(prop, onView, appContext)
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
override fun set(prop: Any?, onView: View, appContext: AppContext?) {
|
|
28
|
-
setPropDirectly(prop, onView, appContext)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@Suppress("UNCHECKED_CAST")
|
|
32
|
-
private fun setPropDirectly(prop: Any?, onView: View, appContext: AppContext?) {
|
|
33
23
|
exceptionDecorator({
|
|
34
24
|
PropSetException(name, onView::class, it)
|
|
35
25
|
}) {
|
|
@@ -60,13 +50,5 @@ class ComposeViewProp(
|
|
|
60
50
|
}
|
|
61
51
|
}
|
|
62
52
|
|
|
63
|
-
fun asStateProp(): ComposeViewProp {
|
|
64
|
-
_isStateProp = true
|
|
65
|
-
return this
|
|
66
|
-
}
|
|
67
|
-
|
|
68
53
|
override val isNullable: Boolean = anyType.kType.isMarkedNullable
|
|
69
|
-
|
|
70
|
-
override val isStateProp: Boolean
|
|
71
|
-
get() = _isStateProp
|
|
72
54
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
#include "FabricComponentsRegistry.h"
|
|
4
|
+
|
|
5
|
+
#include <react/renderer/componentregistry/ComponentDescriptorProvider.h>
|
|
6
|
+
#include <CoreComponentsRegistry.h>
|
|
7
|
+
|
|
8
|
+
#include "ExpoViewComponentDescriptor.h"
|
|
9
|
+
|
|
10
|
+
namespace jni = facebook::jni;
|
|
11
|
+
namespace react = facebook::react;
|
|
12
|
+
|
|
13
|
+
namespace expo {
|
|
14
|
+
|
|
15
|
+
// static
|
|
16
|
+
void FabricComponentsRegistry::registerNatives() {
|
|
17
|
+
registerHybrid({
|
|
18
|
+
makeNativeMethod("initHybrid", FabricComponentsRegistry::initHybrid),
|
|
19
|
+
makeNativeMethod("registerComponentsRegistry", FabricComponentsRegistry::registerComponentsRegistry),
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// static
|
|
24
|
+
jni::local_ref<FabricComponentsRegistry::jhybriddata>
|
|
25
|
+
FabricComponentsRegistry::initHybrid(jni::alias_ref<jhybridobject> jThis) {
|
|
26
|
+
return makeCxxInstance();
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
void FabricComponentsRegistry::registerComponentsRegistry(
|
|
30
|
+
jni::alias_ref<jni::JArrayClass<jni::JString>> componentNames) {
|
|
31
|
+
// Inject the component to the CoreComponentsRegistry because we don't want to touch the MainApplicationReactNativeHost
|
|
32
|
+
auto providerRegistry = react::CoreComponentsRegistry::sharedProviderRegistry();
|
|
33
|
+
|
|
34
|
+
size_t size = componentNames->size();
|
|
35
|
+
for (size_t i = 0; i < size; ++i) {
|
|
36
|
+
auto flavor = std::make_shared<std::string const>(componentNames->getElement(i)->toStdString());
|
|
37
|
+
auto componentName = react::ComponentName{flavor->c_str()};
|
|
38
|
+
providerRegistry->add(react::ComponentDescriptorProvider {
|
|
39
|
+
reinterpret_cast<react::ComponentHandle>(componentName),
|
|
40
|
+
componentName,
|
|
41
|
+
flavor,
|
|
42
|
+
&facebook::react::concreteComponentDescriptorConstructor<expo::ExpoViewComponentDescriptor>
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
} // namespace expo
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
#pragma once
|
|
4
|
+
|
|
5
|
+
#include <fbjni/fbjni.h>
|
|
6
|
+
|
|
7
|
+
namespace expo {
|
|
8
|
+
|
|
9
|
+
class FabricComponentsRegistry : public facebook::jni::HybridClass<FabricComponentsRegistry> {
|
|
10
|
+
public:
|
|
11
|
+
static auto constexpr
|
|
12
|
+
kJavaDescriptor = "Lexpo/modules/adapters/react/FabricComponentsRegistry;";
|
|
13
|
+
|
|
14
|
+
static void registerNatives();
|
|
15
|
+
|
|
16
|
+
FabricComponentsRegistry() {};
|
|
17
|
+
|
|
18
|
+
void registerComponentsRegistry(
|
|
19
|
+
facebook::jni::alias_ref<facebook::jni::JArrayClass<facebook::jni::JString>> componentNames);
|
|
20
|
+
|
|
21
|
+
private:
|
|
22
|
+
static facebook::jni::local_ref<jhybriddata> initHybrid(facebook::jni::alias_ref<jhybridobject> jThis);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
} // namespace expo
|
|
@@ -21,8 +21,7 @@
|
|
|
21
21
|
#include "worklets/WorkletNativeRuntime.h"
|
|
22
22
|
|
|
23
23
|
#if RN_FABRIC_ENABLED
|
|
24
|
-
#include "
|
|
25
|
-
#include "fabric/NativeStatePropsGetter.h"
|
|
24
|
+
#include "FabricComponentsRegistry.h"
|
|
26
25
|
#endif
|
|
27
26
|
|
|
28
27
|
#include <jni.h>
|
|
@@ -63,7 +62,6 @@ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *) {
|
|
|
63
62
|
|
|
64
63
|
#if RN_FABRIC_ENABLED
|
|
65
64
|
expo::FabricComponentsRegistry::registerNatives();
|
|
66
|
-
expo::NativeStatePropsGetter::registerNatives();
|
|
67
65
|
#endif
|
|
68
66
|
});
|
|
69
67
|
}
|
|
@@ -3,51 +3,24 @@
|
|
|
3
3
|
package expo.modules.adapters.react
|
|
4
4
|
|
|
5
5
|
import com.facebook.jni.HybridData
|
|
6
|
+
import com.facebook.react.uimanager.ViewManager
|
|
6
7
|
import com.facebook.soloader.SoLoader
|
|
7
8
|
import expo.modules.core.interfaces.DoNotStrip
|
|
8
|
-
import expo.modules.kotlin.jni.ExpectedType
|
|
9
|
-
import expo.modules.kotlin.views.ViewManagerWrapperDelegate
|
|
10
9
|
|
|
11
10
|
@Suppress("KotlinJniMissingFunction")
|
|
12
11
|
@DoNotStrip
|
|
13
|
-
class FabricComponentsRegistry(
|
|
12
|
+
class FabricComponentsRegistry(viewManagerList: List<ViewManager<*, *>>) {
|
|
13
|
+
private val componentNames: List<String> = viewManagerList.map { it.name }
|
|
14
|
+
|
|
14
15
|
@DoNotStrip
|
|
15
16
|
private val mHybridData = initHybrid()
|
|
16
17
|
|
|
17
18
|
init {
|
|
18
|
-
|
|
19
|
-
viewDelegates[i].viewManagerName
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
val stateProps = viewDelegates.map {
|
|
23
|
-
it.props.filter { (_, prop) -> prop.isStateProp }.values
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
val statePropNames = Array(componentNames.size) { i ->
|
|
27
|
-
Array(stateProps[i].size) { j ->
|
|
28
|
-
stateProps[i].elementAt(j).name
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
val statePropsType = Array(componentNames.size) { i ->
|
|
33
|
-
Array(stateProps[i].size) { j ->
|
|
34
|
-
stateProps[i].elementAt(j).type.getCppRequiredTypes()
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
registerComponentsRegistry(
|
|
39
|
-
componentNames,
|
|
40
|
-
statePropNames,
|
|
41
|
-
statePropsType
|
|
42
|
-
)
|
|
19
|
+
registerComponentsRegistry(componentNames.toTypedArray())
|
|
43
20
|
}
|
|
44
21
|
|
|
45
22
|
private external fun initHybrid(): HybridData
|
|
46
|
-
private external fun registerComponentsRegistry(
|
|
47
|
-
componentNames: Array<String>,
|
|
48
|
-
statePropNames: Array<Array<String>>,
|
|
49
|
-
statePropTypes: Array<Array<ExpectedType>>
|
|
50
|
-
)
|
|
23
|
+
private external fun registerComponentsRegistry(componentNames: Array<String>)
|
|
51
24
|
|
|
52
25
|
@Throws(Throwable::class)
|
|
53
26
|
protected fun finalize() {
|
|
@@ -22,7 +22,7 @@ import expo.modules.kotlin.CoreLoggerKt;
|
|
|
22
22
|
import expo.modules.kotlin.ExpoBridgeModule;
|
|
23
23
|
import expo.modules.kotlin.KotlinInteropModuleRegistry;
|
|
24
24
|
import expo.modules.kotlin.ModulesProvider;
|
|
25
|
-
import expo.modules.kotlin.views.
|
|
25
|
+
import expo.modules.kotlin.views.ViewWrapperDelegateHolder;
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
* An adapter over {@link ModuleRegistry}, compatible with React (implementing {@link ReactPackage}).
|
|
@@ -43,7 +43,7 @@ public class ModuleRegistryAdapter implements ReactPackage {
|
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
// We need to save all view holders to update them when the new kotlin module registry will be created.
|
|
46
|
-
private List<
|
|
46
|
+
private List<ViewWrapperDelegateHolder> mWrapperDelegateHolders = null;
|
|
47
47
|
private FabricComponentsRegistry mFabricComponentsRegistry = null;
|
|
48
48
|
|
|
49
49
|
public ModuleRegistryAdapter(List<Package> packageList) {
|
|
@@ -69,9 +69,9 @@ public class ModuleRegistryAdapter implements ReactPackage {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
List<NativeModule> nativeModules = getNativeModulesFromModuleRegistry(reactContext, moduleRegistry, null);
|
|
72
|
-
if (
|
|
72
|
+
if (mWrapperDelegateHolders != null) {
|
|
73
73
|
KotlinInteropModuleRegistry kotlinInteropModuleRegistry = proxy.getKotlinInteropModuleRegistry();
|
|
74
|
-
kotlinInteropModuleRegistry.
|
|
74
|
+
kotlinInteropModuleRegistry.updateModuleHoldersInViewManagers(mWrapperDelegateHolders);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
return nativeModules;
|
|
@@ -108,17 +108,13 @@ public class ModuleRegistryAdapter implements ReactPackage {
|
|
|
108
108
|
|
|
109
109
|
NativeModulesProxy modulesProxy = Objects.requireNonNull(getOrCreateNativeModulesProxy(reactContext, null));
|
|
110
110
|
KotlinInteropModuleRegistry kotlinInteropModuleRegistry = modulesProxy.getKotlinInteropModuleRegistry();
|
|
111
|
-
List<
|
|
111
|
+
List<ViewManager<?, ?>> kViewManager = kotlinInteropModuleRegistry.exportViewManagers();
|
|
112
112
|
// Saves all holders that needs to be in sync with module registry
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
.stream()
|
|
116
|
-
.map(ViewManagerWrapperDelegate::toRNViewManager)
|
|
117
|
-
.toList();
|
|
118
|
-
viewManagerList.addAll(viewManagers);
|
|
113
|
+
mWrapperDelegateHolders = kotlinInteropModuleRegistry.extractViewManagersDelegateHolders(kViewManager);
|
|
114
|
+
viewManagerList.addAll(kViewManager);
|
|
119
115
|
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
|
|
120
116
|
// Intentionally to only add Sweet API view managers for Fabric support
|
|
121
|
-
mFabricComponentsRegistry = new FabricComponentsRegistry(
|
|
117
|
+
mFabricComponentsRegistry = new FabricComponentsRegistry(kViewManager);
|
|
122
118
|
}
|
|
123
119
|
|
|
124
120
|
return viewManagerList;
|
|
@@ -2,12 +2,17 @@ package expo.modules.kotlin
|
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
4
|
import com.facebook.react.bridge.ReadableArray
|
|
5
|
+
import com.facebook.react.uimanager.ViewManager
|
|
5
6
|
import expo.modules.adapters.react.NativeModulesProxy
|
|
6
7
|
import expo.modules.kotlin.exception.CodedException
|
|
7
8
|
import expo.modules.kotlin.exception.UnexpectedException
|
|
8
9
|
import expo.modules.kotlin.modules.DEFAULT_MODULE_VIEW
|
|
9
10
|
import expo.modules.kotlin.tracing.trace
|
|
11
|
+
import expo.modules.kotlin.views.GroupViewManagerWrapper
|
|
12
|
+
import expo.modules.kotlin.views.SimpleViewManagerWrapper
|
|
13
|
+
import expo.modules.kotlin.views.ViewManagerType
|
|
10
14
|
import expo.modules.kotlin.views.ViewManagerWrapperDelegate
|
|
15
|
+
import expo.modules.kotlin.views.ViewWrapperDelegateHolder
|
|
11
16
|
import java.lang.ref.WeakReference
|
|
12
17
|
|
|
13
18
|
class KotlinInteropModuleRegistry(
|
|
@@ -39,12 +44,16 @@ class KotlinInteropModuleRegistry(
|
|
|
39
44
|
}
|
|
40
45
|
}
|
|
41
46
|
|
|
42
|
-
fun
|
|
43
|
-
trace("KotlinInteropModuleRegistry.
|
|
47
|
+
fun exportViewManagers(): List<ViewManager<*, *>> =
|
|
48
|
+
trace("KotlinInteropModuleRegistry.exportViewManagers") {
|
|
44
49
|
registry
|
|
45
50
|
.flatMap { module ->
|
|
46
51
|
module.definition.viewManagerDefinitions.map { (name, definition) ->
|
|
47
|
-
ViewManagerWrapperDelegate(module, definition, if (name == DEFAULT_MODULE_VIEW) module.name else null)
|
|
52
|
+
val wrapperDelegate = ViewManagerWrapperDelegate(module, definition, if (name == DEFAULT_MODULE_VIEW) module.name else null)
|
|
53
|
+
when (definition.getViewManagerType()) {
|
|
54
|
+
ViewManagerType.SIMPLE -> SimpleViewManagerWrapper(wrapperDelegate)
|
|
55
|
+
ViewManagerType.GROUP -> GroupViewManagerWrapper(wrapperDelegate)
|
|
56
|
+
}
|
|
48
57
|
}
|
|
49
58
|
}
|
|
50
59
|
}
|
|
@@ -65,6 +74,11 @@ class KotlinInteropModuleRegistry(
|
|
|
65
74
|
return@trace result
|
|
66
75
|
}
|
|
67
76
|
|
|
77
|
+
fun extractViewManagersDelegateHolders(viewManagers: List<ViewManager<*, *>>): List<ViewWrapperDelegateHolder> =
|
|
78
|
+
trace("KotlinInteropModuleRegistry.extractViewManagersDelegateHolders") {
|
|
79
|
+
viewManagers.filterIsInstance<ViewWrapperDelegateHolder>()
|
|
80
|
+
}
|
|
81
|
+
|
|
68
82
|
/**
|
|
69
83
|
* Since React Native v0.55, {@link com.facebook.react.ReactPackage#createViewManagers(ReactApplicationContext)}
|
|
70
84
|
* gets called only once per lifetime of {@link com.facebook.react.ReactInstanceManager}.
|
|
@@ -73,12 +87,13 @@ class KotlinInteropModuleRegistry(
|
|
|
73
87
|
* the instance that was bound with the prop method won't be the same as the instance returned by module registry.
|
|
74
88
|
* To fix that we need to update all modules holder in exported view managers.
|
|
75
89
|
*/
|
|
76
|
-
fun
|
|
77
|
-
trace("KotlinInteropModuleRegistry.
|
|
78
|
-
|
|
79
|
-
.
|
|
80
|
-
|
|
81
|
-
|
|
90
|
+
fun updateModuleHoldersInViewManagers(viewWrapperHolders: List<ViewWrapperDelegateHolder>) =
|
|
91
|
+
trace("KotlinInteropModuleRegistry.updateModuleHoldersInViewManagers") {
|
|
92
|
+
viewWrapperHolders
|
|
93
|
+
.map { it.viewWrapperDelegate }
|
|
94
|
+
.forEach { holderWrapper ->
|
|
95
|
+
holderWrapper.moduleHolder = requireNotNull(registry.getModuleHolder(holderWrapper.moduleHolder.name)) {
|
|
96
|
+
"Cannot update the module holder for ${holderWrapper.moduleHolder.name}."
|
|
82
97
|
}
|
|
83
98
|
}
|
|
84
99
|
}
|
|
@@ -11,9 +11,5 @@ abstract class AnyViewProp(
|
|
|
11
11
|
) {
|
|
12
12
|
abstract fun set(prop: Dynamic, onView: View, appContext: AppContext? = null)
|
|
13
13
|
|
|
14
|
-
abstract fun set(prop: Any?, onView: View, appContext: AppContext? = null)
|
|
15
|
-
|
|
16
14
|
abstract val isNullable: Boolean
|
|
17
|
-
|
|
18
|
-
internal abstract val isStateProp: Boolean
|
|
19
15
|
}
|
|
@@ -12,34 +12,16 @@ open class ConcreteViewProp<ViewType : View, PropType>(
|
|
|
12
12
|
propType: AnyType,
|
|
13
13
|
protected val setter: (view: ViewType, prop: PropType) -> Unit
|
|
14
14
|
) : AnyViewProp(name, propType) {
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
@Suppress("UNCHECKED_CAST")
|
|
17
16
|
override fun set(prop: Dynamic, onView: View, appContext: AppContext?) {
|
|
18
|
-
setPropDirectly(prop, onView, appContext)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
override fun set(prop: Any?, onView: View, appContext: AppContext?) {
|
|
22
|
-
setPropDirectly(prop, onView, appContext)
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
private fun setPropDirectly(prop: Any?, onView: View, appContext: AppContext?) {
|
|
26
17
|
exceptionDecorator({
|
|
27
18
|
PropSetException(name, onView::class, it)
|
|
28
19
|
}) {
|
|
29
|
-
@Suppress("UNCHECKED_CAST")
|
|
30
20
|
setter(onView as ViewType, type.convert(prop, appContext) as PropType)
|
|
31
21
|
}
|
|
32
22
|
}
|
|
33
23
|
|
|
34
24
|
override val isNullable: Boolean = propType.kType.isMarkedNullable
|
|
35
|
-
|
|
36
|
-
override val isStateProp: Boolean
|
|
37
|
-
get() = _isStateProp
|
|
38
|
-
|
|
39
|
-
fun asStateProp(): ConcreteViewProp<ViewType, PropType> {
|
|
40
|
-
_isStateProp = true
|
|
41
|
-
return this
|
|
42
|
-
}
|
|
43
25
|
}
|
|
44
26
|
|
|
45
27
|
class ConcreteViewPropWithDefault<ViewType : View, PropType>(
|
|
@@ -12,7 +12,7 @@ import expo.modules.core.utilities.ifNull
|
|
|
12
12
|
class GroupViewManagerWrapper(
|
|
13
13
|
override val viewWrapperDelegate: ViewManagerWrapperDelegate
|
|
14
14
|
) : ViewGroupManager<ViewGroup>(), ViewWrapperDelegateHolder {
|
|
15
|
-
override fun getName(): String = viewWrapperDelegate.
|
|
15
|
+
override fun getName(): String = "ViewManagerAdapter_${viewWrapperDelegate.name}"
|
|
16
16
|
|
|
17
17
|
override fun createViewInstance(reactContext: ThemedReactContext): ViewGroup =
|
|
18
18
|
viewWrapperDelegate.createView(reactContext) as ViewGroup
|
|
@@ -21,7 +21,6 @@ class GroupViewManagerWrapper(
|
|
|
21
21
|
val propsMap = props.getBackingMap()
|
|
22
22
|
// Updates expo related properties.
|
|
23
23
|
val handledProps = viewWrapperDelegate.updateProperties(viewToUpdate, propsMap)
|
|
24
|
-
viewWrapperDelegate.updateStateProps(viewToUpdate)
|
|
25
24
|
// Updates remaining props using RN implementation.
|
|
26
25
|
// To not triggered undefined setters we filtrated already handled properties.
|
|
27
26
|
super.updateProperties(
|
|
@@ -40,9 +39,9 @@ class GroupViewManagerWrapper(
|
|
|
40
39
|
props: ReactStylesDiffMap?,
|
|
41
40
|
stateWrapper: StateWrapper?
|
|
42
41
|
): Any? {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return
|
|
42
|
+
val view = view as? ExpoView ?: return null
|
|
43
|
+
view.stateWrapper = stateWrapper
|
|
44
|
+
return super.updateState(view, props, stateWrapper)
|
|
46
45
|
}
|
|
47
46
|
|
|
48
47
|
override fun getNativeProps(): MutableMap<String, String> {
|
|
@@ -58,8 +57,8 @@ class GroupViewManagerWrapper(
|
|
|
58
57
|
viewWrapperDelegate.onDestroy(view)
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any
|
|
62
|
-
val expoEvent = viewWrapperDelegate.getExportedCustomDirectEventTypeConstants()
|
|
60
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any>? {
|
|
61
|
+
val expoEvent = viewWrapperDelegate.getExportedCustomDirectEventTypeConstants() ?: emptyMap()
|
|
63
62
|
return super.getExportedCustomDirectEventTypeConstants()?.plus(expoEvent) ?: expoEvent
|
|
64
63
|
}
|
|
65
64
|
|
|
@@ -3,14 +3,13 @@ package expo.modules.kotlin.views
|
|
|
3
3
|
import android.view.View
|
|
4
4
|
import com.facebook.react.uimanager.ReactStylesDiffMap
|
|
5
5
|
import com.facebook.react.uimanager.SimpleViewManager
|
|
6
|
-
import com.facebook.react.uimanager.StateWrapper
|
|
7
6
|
import com.facebook.react.uimanager.ThemedReactContext
|
|
8
7
|
import com.facebook.react.uimanager.getBackingMap
|
|
9
8
|
|
|
10
9
|
class SimpleViewManagerWrapper(
|
|
11
10
|
override val viewWrapperDelegate: ViewManagerWrapperDelegate
|
|
12
11
|
) : SimpleViewManager<View>(), ViewWrapperDelegateHolder {
|
|
13
|
-
override fun getName(): String = viewWrapperDelegate.
|
|
12
|
+
override fun getName(): String = "ViewManagerAdapter_${viewWrapperDelegate.name}"
|
|
14
13
|
|
|
15
14
|
override fun createViewInstance(reactContext: ThemedReactContext): View =
|
|
16
15
|
viewWrapperDelegate.createView(reactContext)
|
|
@@ -19,7 +18,6 @@ class SimpleViewManagerWrapper(
|
|
|
19
18
|
val propsMap = props.getBackingMap()
|
|
20
19
|
// Updates expo related properties.
|
|
21
20
|
val handledProps = viewWrapperDelegate.updateProperties(viewToUpdate, propsMap)
|
|
22
|
-
viewWrapperDelegate.updateStateProps(viewToUpdate)
|
|
23
21
|
// Updates remaining props using RN implementation.
|
|
24
22
|
// To not triggered undefined setters we filtrated already handled properties.
|
|
25
23
|
super.updateProperties(
|
|
@@ -28,16 +26,6 @@ class SimpleViewManagerWrapper(
|
|
|
28
26
|
)
|
|
29
27
|
}
|
|
30
28
|
|
|
31
|
-
override fun updateState(
|
|
32
|
-
view: View,
|
|
33
|
-
props: ReactStylesDiffMap?,
|
|
34
|
-
stateWrapper: StateWrapper?
|
|
35
|
-
): Any? {
|
|
36
|
-
(view as? ExpoView)?.stateWrapper = stateWrapper
|
|
37
|
-
viewWrapperDelegate.updateStateProps(view)
|
|
38
|
-
return null
|
|
39
|
-
}
|
|
40
|
-
|
|
41
29
|
override fun onAfterUpdateTransaction(view: View) {
|
|
42
30
|
super.onAfterUpdateTransaction(view)
|
|
43
31
|
viewWrapperDelegate.onViewDidUpdateProps(view)
|
|
@@ -56,8 +44,8 @@ class SimpleViewManagerWrapper(
|
|
|
56
44
|
viewWrapperDelegate.onDestroy(view)
|
|
57
45
|
}
|
|
58
46
|
|
|
59
|
-
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any
|
|
60
|
-
val expoEvent = viewWrapperDelegate.getExportedCustomDirectEventTypeConstants()
|
|
47
|
+
override fun getExportedCustomDirectEventTypeConstants(): Map<String, Any>? {
|
|
48
|
+
val expoEvent = viewWrapperDelegate.getExportedCustomDirectEventTypeConstants() ?: emptyMap()
|
|
61
49
|
return super.getExportedCustomDirectEventTypeConstants()?.plus(expoEvent) ?: expoEvent
|
|
62
50
|
}
|
|
63
51
|
}
|
|
@@ -123,14 +123,12 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
123
123
|
inline fun <reified PropType> Prop(
|
|
124
124
|
name: String,
|
|
125
125
|
noinline body: (view: T, prop: PropType) -> Unit
|
|
126
|
-
)
|
|
127
|
-
|
|
126
|
+
) {
|
|
127
|
+
props[name] = ConcreteViewProp(
|
|
128
128
|
name,
|
|
129
129
|
toAnyType<PropType>(),
|
|
130
130
|
body
|
|
131
|
-
)
|
|
132
|
-
props[name] = this
|
|
133
|
-
}
|
|
131
|
+
)
|
|
134
132
|
}
|
|
135
133
|
|
|
136
134
|
/**
|
|
@@ -140,14 +138,12 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
140
138
|
inline fun <reified ViewType : View, reified PropType> Prop(
|
|
141
139
|
name: String,
|
|
142
140
|
noinline body: (view: ViewType, prop: PropType) -> Unit
|
|
143
|
-
)
|
|
144
|
-
|
|
141
|
+
) {
|
|
142
|
+
props[name] = ConcreteViewProp(
|
|
145
143
|
name,
|
|
146
144
|
toAnyType<PropType>(),
|
|
147
145
|
body
|
|
148
|
-
)
|
|
149
|
-
props[name] = this
|
|
150
|
-
}
|
|
146
|
+
)
|
|
151
147
|
}
|
|
152
148
|
|
|
153
149
|
/**
|
|
@@ -158,15 +154,13 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
158
154
|
name: String,
|
|
159
155
|
defaultValue: PropType,
|
|
160
156
|
noinline body: (view: ViewType, prop: PropType) -> Unit
|
|
161
|
-
)
|
|
162
|
-
|
|
157
|
+
) {
|
|
158
|
+
props[name] = ConcreteViewPropWithDefault(
|
|
163
159
|
name,
|
|
164
160
|
toAnyType<PropType>(),
|
|
165
161
|
body,
|
|
166
162
|
defaultValue
|
|
167
|
-
)
|
|
168
|
-
props[name] = this
|
|
169
|
-
}
|
|
163
|
+
)
|
|
170
164
|
}
|
|
171
165
|
|
|
172
166
|
inline fun <reified ViewType : View, reified PropType, reified CustomValueType> PropGroup(
|