expo-modules-core 1.2.6 → 1.2.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/java/expo/modules/kotlin/AppContext.kt +10 -0
- package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +6 -0
- package/android/src/main/java/expo/modules/kotlin/ModuleRegistry.kt +13 -0
- package/android/src/main/java/expo/modules/kotlin/functions/AnyFunction.kt +0 -1
- package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinition.kt +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 1.2.7 — 2023-05-03
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- [Android] Improve the initial loading speed of the native view. ([#22153](https://github.com/expo/expo/pull/22153) by [@lukmccall](https://github.com/lukmccall))
|
|
18
|
+
|
|
13
19
|
## 1.2.6 — 2023-03-20
|
|
14
20
|
|
|
15
21
|
### 🐛 Bug fixes
|
package/android/build.gradle
CHANGED
|
@@ -6,7 +6,7 @@ apply plugin: 'maven-publish'
|
|
|
6
6
|
apply plugin: "de.undercouch.download"
|
|
7
7
|
|
|
8
8
|
group = 'host.exp.exponent'
|
|
9
|
-
version = '1.2.
|
|
9
|
+
version = '1.2.7'
|
|
10
10
|
|
|
11
11
|
buildscript {
|
|
12
12
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
@@ -173,7 +173,7 @@ android {
|
|
|
173
173
|
targetSdkVersion safeExtGet("targetSdkVersion", 33)
|
|
174
174
|
consumerProguardFiles 'proguard-rules.pro'
|
|
175
175
|
versionCode 1
|
|
176
|
-
versionName "1.2.
|
|
176
|
+
versionName "1.2.7"
|
|
177
177
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
|
|
178
178
|
|
|
179
179
|
testInstrumentationRunner "expo.modules.TestRunner"
|
|
@@ -68,6 +68,15 @@ class AppContext(
|
|
|
68
68
|
.looper.let { Handler(it) }
|
|
69
69
|
.asCoroutineDispatcher()
|
|
70
70
|
|
|
71
|
+
/**
|
|
72
|
+
* A scope used to dispatch all background work.
|
|
73
|
+
*/
|
|
74
|
+
val backgroundCoroutineScope = CoroutineScope(
|
|
75
|
+
Dispatchers.IO +
|
|
76
|
+
SupervisorJob() +
|
|
77
|
+
CoroutineName("expo.modules.BackgroundCoroutineScope")
|
|
78
|
+
)
|
|
79
|
+
|
|
71
80
|
/**
|
|
72
81
|
* A queue used to dispatch all async methods that are called via JSI.
|
|
73
82
|
*/
|
|
@@ -265,6 +274,7 @@ class AppContext(
|
|
|
265
274
|
registry.cleanUp()
|
|
266
275
|
modulesQueue.cancel(ContextDestroyedException())
|
|
267
276
|
mainQueue.cancel(ContextDestroyedException())
|
|
277
|
+
backgroundCoroutineScope.cancel(ContextDestroyedException())
|
|
268
278
|
logger.info("✅ AppContext was destroyed")
|
|
269
279
|
}
|
|
270
280
|
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
package expo.modules.kotlin
|
|
2
2
|
|
|
3
|
+
import android.view.View
|
|
3
4
|
import com.facebook.react.bridge.Arguments
|
|
4
5
|
import com.facebook.react.bridge.ReadableArray
|
|
5
6
|
import expo.modules.kotlin.events.BasicEventListener
|
|
@@ -12,6 +13,7 @@ import expo.modules.kotlin.exception.exceptionDecorator
|
|
|
12
13
|
import expo.modules.kotlin.jni.JavaScriptModuleObject
|
|
13
14
|
import expo.modules.kotlin.modules.Module
|
|
14
15
|
import kotlinx.coroutines.launch
|
|
16
|
+
import kotlin.reflect.KClass
|
|
15
17
|
|
|
16
18
|
class ModuleHolder(val module: Module) {
|
|
17
19
|
val definition = module.definition()
|
|
@@ -93,4 +95,8 @@ class ModuleHolder(val module: Module) {
|
|
|
93
95
|
fun cleanUp() {
|
|
94
96
|
module.cleanUp()
|
|
95
97
|
}
|
|
98
|
+
|
|
99
|
+
fun viewClass(): KClass<out View>? {
|
|
100
|
+
return definition.viewManagerDefinition?.viewType?.kotlin
|
|
101
|
+
}
|
|
96
102
|
}
|
|
@@ -6,7 +6,9 @@ import kotlinx.coroutines.CoroutineName
|
|
|
6
6
|
import kotlinx.coroutines.CoroutineScope
|
|
7
7
|
import kotlinx.coroutines.Dispatchers
|
|
8
8
|
import kotlinx.coroutines.SupervisorJob
|
|
9
|
+
import kotlinx.coroutines.launch
|
|
9
10
|
import java.lang.ref.WeakReference
|
|
11
|
+
import kotlin.reflect.full.declaredMemberProperties
|
|
10
12
|
|
|
11
13
|
class ModuleRegistry(
|
|
12
14
|
private val appContext: WeakReference<AppContext>
|
|
@@ -26,6 +28,17 @@ class ModuleRegistry(
|
|
|
26
28
|
}
|
|
27
29
|
holder.post(EventName.MODULE_CREATE)
|
|
28
30
|
holder.registerContracts()
|
|
31
|
+
// The initial invocation of `declaredMemberProperties` appears to be slow,
|
|
32
|
+
// as Kotlin must deserialize metadata internally.
|
|
33
|
+
// This is a known issue that may be resolved by the new K2 compiler in the future.
|
|
34
|
+
// However, until then, we must find a way to address this problem.
|
|
35
|
+
// Therefore, we have decided to dispatch a lambda
|
|
36
|
+
// that invokes `declaredMemberProperties` during module creation.
|
|
37
|
+
holder.viewClass()?.let { viewType ->
|
|
38
|
+
appContext.get()?.backgroundCoroutineScope?.launch {
|
|
39
|
+
viewType.declaredMemberProperties
|
|
40
|
+
}
|
|
41
|
+
}
|
|
29
42
|
registry[holder.name] = holder
|
|
30
43
|
}
|
|
31
44
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package expo.modules.kotlin.functions
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.ReadableArray
|
|
4
|
-
import com.facebook.react.bridge.ReadableType
|
|
5
4
|
import expo.modules.kotlin.AppContext
|
|
6
5
|
import expo.modules.kotlin.exception.ArgumentCastException
|
|
7
6
|
import expo.modules.kotlin.exception.CodedException
|
|
@@ -16,7 +16,7 @@ import expo.modules.kotlin.recycle
|
|
|
16
16
|
|
|
17
17
|
class ViewManagerDefinition(
|
|
18
18
|
private val viewFactory: (Context, AppContext) -> View,
|
|
19
|
-
|
|
19
|
+
internal val viewType: Class<out View>,
|
|
20
20
|
private val props: Map<String, AnyViewProp>,
|
|
21
21
|
val onViewDestroys: ((View) -> Unit)? = null,
|
|
22
22
|
val callbacksDefinition: CallbacksDefinition? = null,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-core",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.7",
|
|
4
4
|
"description": "The core of Expo Modules architecture",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@testing-library/react-hooks": "^7.0.1",
|
|
43
43
|
"expo-module-scripts": "^3.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "f5076c4ff6cf352b5fd8e528533a377167fa4edb"
|
|
46
46
|
}
|