expo-modules-core 3.0.13 → 3.0.14

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 CHANGED
@@ -10,6 +10,16 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 3.0.14 — 2025-09-08
14
+
15
+ ### 🐛 Bug fixes
16
+
17
+ - [Android] Fix type check in the `SharedRef` converter. ([#39446](https://github.com/expo/expo/pull/39446) by [@lukmccall](https://github.com/lukmccall))
18
+
19
+ ### 💡 Others
20
+
21
+ - improve startup performance by not relying on kotlin reflection. ([#39389](https://github.com/expo/expo/pull/39389) by [@ACHP](https://github.com/ACHP))
22
+
13
23
  ## 3.0.13 — 2025-09-04
14
24
 
15
25
  ### 💡 Others
@@ -25,7 +25,7 @@ if (shouldIncludeCompose) {
25
25
  }
26
26
 
27
27
  group = 'host.exp.exponent'
28
- version = '3.0.13'
28
+ version = '3.0.14'
29
29
 
30
30
  def isExpoModulesCoreTests = {
31
31
  Gradle gradle = getGradle()
@@ -75,7 +75,7 @@ android {
75
75
  defaultConfig {
76
76
  consumerProguardFiles 'proguard-rules.pro'
77
77
  versionCode 1
78
- versionName "3.0.13"
78
+ versionName "3.0.14"
79
79
  buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
80
80
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
81
81
 
@@ -8,3 +8,6 @@ val <T : Any> KClass<T>.fastPrimaryConstructor: KFunction<T>?
8
8
  // If class only has one constructor, use it as a primary constructor.
9
9
  // Otherwise, try to find the primary constructor using kotlin reflection.
10
10
  get() = constructors.singleOrNull() ?: primaryConstructor
11
+
12
+ fun KClass<*>.fastIsSupperClassOf(jClass: Class<*>) =
13
+ this.javaObjectType.isAssignableFrom(jClass) || this.java.isAssignableFrom(jClass)
@@ -10,7 +10,8 @@ import expo.modules.kotlin.functions.SyncFunctionComponent
10
10
  import expo.modules.kotlin.objects.ObjectDefinitionBuilder
11
11
  import expo.modules.kotlin.objects.PropertyComponentBuilderWithThis
12
12
  import expo.modules.kotlin.sharedobjects.SharedObject
13
- import expo.modules.kotlin.sharedobjects.SharedRef
13
+ import expo.modules.kotlin.sharedobjects.isSharedObjectClass
14
+ import expo.modules.kotlin.sharedobjects.isSharedRefClass
14
15
  import expo.modules.kotlin.traits.Trait
15
16
  import expo.modules.kotlin.types.AnyType
16
17
  import expo.modules.kotlin.types.TypeConverterProvider
@@ -19,7 +20,6 @@ import expo.modules.kotlin.types.toAnyType
19
20
  import expo.modules.kotlin.types.toArgsArray
20
21
  import expo.modules.kotlin.types.toReturnType
21
22
  import kotlin.reflect.KClass
22
- import kotlin.reflect.full.isSubclassOf
23
23
 
24
24
  class ClassComponentBuilder<SharedObjectType : Any>(
25
25
  private val appContext: AppContext,
@@ -33,8 +33,8 @@ class ClassComponentBuilder<SharedObjectType : Any>(
33
33
 
34
34
  fun buildClass(): ClassDefinitionData {
35
35
  val hasOwnerType = ownerClass != Unit::class
36
- val isSharedObject = hasOwnerType && ownerClass.isSubclassOf(SharedObject::class)
37
- val isSharedRef = hasOwnerType && ownerClass.isSubclassOf(SharedRef::class)
36
+ val isSharedObject = hasOwnerType && ownerClass.isSharedObjectClass()
37
+ val isSharedRef = hasOwnerType && ownerClass.isSharedRefClass()
38
38
 
39
39
  if (eventsDefinition != null && isSharedObject) {
40
40
  listOf("__expo_onStartListeningToEvent" to SharedObject::onStartListeningToEvent, "__expo_onStopListeningToEvent" to SharedObject::onStopListeningToEvent)
@@ -8,6 +8,7 @@ import expo.modules.kotlin.jni.JavaScriptWeakObject
8
8
  import expo.modules.kotlin.logger
9
9
  import expo.modules.kotlin.types.JSTypeConverter
10
10
  import expo.modules.kotlin.weak
11
+ import kotlin.reflect.KClass
11
12
 
12
13
  @DoNotStrip
13
14
  open class SharedObject(runtimeContext: RuntimeContext? = null) {
@@ -83,3 +84,6 @@ open class SharedObject(runtimeContext: RuntimeContext? = null) {
83
84
  return 0
84
85
  }
85
86
  }
87
+
88
+ fun KClass<*>.isSharedObjectClass() =
89
+ SharedObject::class.java.isAssignableFrom(this.java)
@@ -3,6 +3,7 @@ package expo.modules.kotlin.sharedobjects
3
3
  import com.facebook.react.bridge.Dynamic
4
4
  import expo.modules.kotlin.AppContext
5
5
  import expo.modules.kotlin.exception.IncorrectRefTypeException
6
+ import expo.modules.kotlin.fastIsSupperClassOf
6
7
  import expo.modules.kotlin.jni.CppType
7
8
  import expo.modules.kotlin.jni.ExpectedType
8
9
  import expo.modules.kotlin.toStrongReference
@@ -73,7 +74,8 @@ class SharedRefTypeConverter<T : SharedRef<*>>(
73
74
  val ref = sharedRef.ref ?: return sharedRef
74
75
  val sharedRefClass = sharedRefType?.classifier as? KClass<*>
75
76
  ?: return sharedRef
76
- if (ref::class.java.isAssignableFrom(sharedRefClass.javaObjectType) || ref::class.java.isAssignableFrom(sharedRefClass.java)) {
77
+
78
+ if (sharedRefClass.fastIsSupperClassOf(ref.javaClass)) {
77
79
  return sharedRef
78
80
  }
79
81
 
@@ -3,6 +3,7 @@ package expo.modules.kotlin.sharedobjects
3
3
  import expo.modules.core.interfaces.DoNotStrip
4
4
  import expo.modules.kotlin.AppContext
5
5
  import expo.modules.kotlin.RuntimeContext
6
+ import kotlin.reflect.KClass
6
7
 
7
8
  /**
8
9
  * Shared object (ref) that holds a strong reference to any native object. Allows passing references
@@ -29,3 +30,6 @@ inline fun <reified RefType> SharedRef<*>.cast(): SharedRef<RefType>? {
29
30
 
30
31
  return null
31
32
  }
33
+
34
+ fun KClass<*>.isSharedRefClass() =
35
+ SharedRef::class.java.isAssignableFrom(this.java)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-modules-core",
3
- "version": "3.0.13",
3
+ "version": "3.0.14",
4
4
  "description": "The core of Expo Modules architecture",
5
5
  "main": "src/index.ts",
6
6
  "types": "build/index.d.ts",
@@ -65,5 +65,5 @@
65
65
  "@testing-library/react-native": "^13.2.0",
66
66
  "expo-module-scripts": "^5.0.6"
67
67
  },
68
- "gitHead": "8cafaff8076e443e6c80e8013ec809f4f290f24d"
68
+ "gitHead": "d087a2182086089f23bcee65e27434f21db50128"
69
69
  }