expo-modules-core 2.3.2 → 2.3.4
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 +10 -0
- package/android/build.gradle +2 -2
- package/build/registerWebModule.d.ts +2 -1
- package/build/registerWebModule.d.ts.map +1 -1
- package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/AutolinkingIntegration.kt +3 -0
- package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/ProjectConfiguration.kt +2 -2
- package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/android/MavenPublicationExtension.kt +28 -6
- package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/gradle/ExpoModuleExtension.kt +1 -1
- package/expo-module-gradle-plugin/src/withAutolinkingPlugin/kotlin/expo/modules/plugin/AutolinkingIntegrationImpl.kt +32 -8
- package/expo-module-gradle-plugin/src/withoutAutolinkingPlugin/kotlin/expo/modules/plugin/AutolinkingIntegrationImpl.kt +5 -0
- package/package.json +2 -2
- package/src/registerWebModule.ts +6 -3
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,16 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 2.3.4 — 2025-04-11
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Change registerWebModule to work with minified classes. ([#35946](https://github.com/expo/expo/pull/35946) by [@aleqsio](https://github.com/aleqsio))
|
|
18
|
+
|
|
19
|
+
## 2.3.3 — 2025-04-11
|
|
20
|
+
|
|
21
|
+
_This version does not introduce any user-facing changes._
|
|
22
|
+
|
|
13
23
|
## 2.3.2 — 2025-04-09
|
|
14
24
|
|
|
15
25
|
### 💡 Others
|
package/android/build.gradle
CHANGED
|
@@ -23,7 +23,7 @@ if (KOTLIN_MAJOR_VERSION >= 2) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
group = 'host.exp.exponent'
|
|
26
|
-
version = '2.3.
|
|
26
|
+
version = '2.3.4'
|
|
27
27
|
|
|
28
28
|
// List of features that are required by linked modules
|
|
29
29
|
def coreFeatures = project.findProperty("coreFeatures") ?: []
|
|
@@ -76,7 +76,7 @@ android {
|
|
|
76
76
|
defaultConfig {
|
|
77
77
|
consumerProguardFiles 'proguard-rules.pro'
|
|
78
78
|
versionCode 1
|
|
79
|
-
versionName "2.3.
|
|
79
|
+
versionName "2.3.4"
|
|
80
80
|
buildConfigField "String", "EXPO_MODULES_CORE_VERSION", "\"${versionName}\""
|
|
81
81
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled.toString()
|
|
82
82
|
|
|
@@ -2,7 +2,8 @@ import type { NativeModule } from './ts-declarations/NativeModule';
|
|
|
2
2
|
/**
|
|
3
3
|
* Registers a web module.
|
|
4
4
|
* @param moduleImplementation A class that extends `NativeModule`. The class is registered under `globalThis.expo.modules[className]`.
|
|
5
|
+
* @param moduleName – a name to register the module under `globalThis.expo.modules[className]`.
|
|
5
6
|
* @returns A singleton instance of the class passed into arguments.
|
|
6
7
|
*/
|
|
7
|
-
export declare function registerWebModule<EventsMap extends Record<never, never>, ModuleType extends typeof NativeModule<EventsMap>>(moduleImplementation: ModuleType): ModuleType;
|
|
8
|
+
export declare function registerWebModule<EventsMap extends Record<never, never>, ModuleType extends typeof NativeModule<EventsMap>>(moduleImplementation: ModuleType, moduleName: string): ModuleType;
|
|
8
9
|
//# sourceMappingURL=registerWebModule.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registerWebModule.d.ts","sourceRoot":"","sources":["../src/registerWebModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE
|
|
1
|
+
{"version":3,"file":"registerWebModule.d.ts","sourceRoot":"","sources":["../src/registerWebModule.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAEnE;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAC/B,SAAS,SAAS,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,EACtC,UAAU,SAAS,OAAO,YAAY,CAAC,SAAS,CAAC,EACjD,oBAAoB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAiBlE"}
|
package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/ProjectConfiguration.kt
CHANGED
|
@@ -84,7 +84,7 @@ internal fun Project.applyPublishing(expoModulesExtension: ExpoModuleExtension)
|
|
|
84
84
|
.publications
|
|
85
85
|
.createReleasePublication(publicationInfo)
|
|
86
86
|
|
|
87
|
-
createExpoPublishToMavenLocalTask(publicationInfo)
|
|
87
|
+
createExpoPublishToMavenLocalTask(publicationInfo, expoModulesExtension)
|
|
88
88
|
|
|
89
89
|
val npmLocalRepositoryRelativePath = "local-maven-repo"
|
|
90
90
|
val npmLocalRepository = URI("file://${project.projectDir.parentFile}/${npmLocalRepositoryRelativePath}")
|
|
@@ -93,7 +93,7 @@ internal fun Project.applyPublishing(expoModulesExtension: ExpoModuleExtension)
|
|
|
93
93
|
mavenRepo.url = npmLocalRepository
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
createExpoPublishTask(publicationInfo, npmLocalRepositoryRelativePath)
|
|
96
|
+
createExpoPublishTask(publicationInfo, expoModulesExtension, npmLocalRepositoryRelativePath)
|
|
97
97
|
}
|
|
98
98
|
}
|
|
99
99
|
|
|
@@ -3,7 +3,10 @@
|
|
|
3
3
|
package expo.modules.plugin.android
|
|
4
4
|
|
|
5
5
|
import expo.modules.plugin.androidLibraryExtension
|
|
6
|
+
import expo.modules.plugin.gradle.ExpoModuleExtension
|
|
6
7
|
import expo.modules.plugin.publishingExtension
|
|
8
|
+
import groovy.lang.Binding
|
|
9
|
+
import groovy.lang.GroovyShell
|
|
7
10
|
import kotlinx.serialization.ExperimentalSerializationApi
|
|
8
11
|
import kotlinx.serialization.json.Json
|
|
9
12
|
import kotlinx.serialization.json.JsonArray
|
|
@@ -19,7 +22,6 @@ import org.gradle.api.component.SoftwareComponent
|
|
|
19
22
|
import org.gradle.api.publish.PublicationContainer
|
|
20
23
|
import org.gradle.api.publish.maven.MavenPublication
|
|
21
24
|
import org.gradle.api.tasks.TaskProvider
|
|
22
|
-
import java.net.URI
|
|
23
25
|
import java.nio.file.Path
|
|
24
26
|
import kotlin.io.path.exists
|
|
25
27
|
import kotlin.io.path.toPath
|
|
@@ -85,10 +87,10 @@ internal fun PublicationContainer.createReleasePublication(publicationInfo: Publ
|
|
|
85
87
|
}
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
internal fun Project.createExpoPublishTask(publicationInfo: PublicationInfo, pathToRepository: String): TaskProvider<Task> {
|
|
90
|
+
internal fun Project.createExpoPublishTask(publicationInfo: PublicationInfo, expoModulesExtension: ExpoModuleExtension, pathToRepository: String): TaskProvider<Task> {
|
|
89
91
|
val taskProvider = tasks.register("expoPublish") { task ->
|
|
90
92
|
task.doLast {
|
|
91
|
-
expoPublishBody(publicationInfo, pathToRepository = pathToRepository)
|
|
93
|
+
expoPublishBody(publicationInfo, expoModulesExtension, pathToRepository = pathToRepository)
|
|
92
94
|
}
|
|
93
95
|
}
|
|
94
96
|
taskProvider.configure { task ->
|
|
@@ -130,10 +132,10 @@ internal fun Project.createEmptyExpoPublishToMavenLocalTask(): TaskProvider<Task
|
|
|
130
132
|
return taskProvider
|
|
131
133
|
}
|
|
132
134
|
|
|
133
|
-
internal fun Project.createExpoPublishToMavenLocalTask(publicationInfo: PublicationInfo): TaskProvider<Task> {
|
|
135
|
+
internal fun Project.createExpoPublishToMavenLocalTask(publicationInfo: PublicationInfo, expoModulesExtension: ExpoModuleExtension): TaskProvider<Task> {
|
|
134
136
|
val taskProvider = tasks.register("expoPublishToMavenLocal") { task ->
|
|
135
137
|
task.doLast {
|
|
136
|
-
expoPublishBody(publicationInfo)
|
|
138
|
+
expoPublishBody(publicationInfo, expoModulesExtension)
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
taskProvider.configure { task ->
|
|
@@ -147,7 +149,9 @@ internal fun Project.createExpoPublishToMavenLocalTask(publicationInfo: Publicat
|
|
|
147
149
|
return taskProvider
|
|
148
150
|
}
|
|
149
151
|
|
|
150
|
-
private fun Project.expoPublishBody(publicationInfo: PublicationInfo, pathToRepository: String? = null) {
|
|
152
|
+
private fun Project.expoPublishBody(publicationInfo: PublicationInfo, expoModulesExtension: ExpoModuleExtension, pathToRepository: String? = null) {
|
|
153
|
+
validateProjectConfiguration(expoModulesExtension)
|
|
154
|
+
|
|
151
155
|
if (pathToRepository == null) {
|
|
152
156
|
val mavenLocal = publishingExtension().repositories.mavenLocal()
|
|
153
157
|
val mavenLocalPath = mavenLocal.url.toPath()
|
|
@@ -182,6 +186,24 @@ private fun Project.expoPublishBody(publicationInfo: PublicationInfo, pathToRepo
|
|
|
182
186
|
}.result.get()
|
|
183
187
|
}
|
|
184
188
|
|
|
189
|
+
private fun Project.validateProjectConfiguration(expoModulesExtension: ExpoModuleExtension) {
|
|
190
|
+
val shouldUsePublicationScript = expoModulesExtension.autolinking.getShouldUsePublicationScriptPath(this)
|
|
191
|
+
// If the path to the script is not defined, we assume that we can publish the module.
|
|
192
|
+
if (shouldUsePublicationScript == null) {
|
|
193
|
+
return
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
val binding = Binding()
|
|
197
|
+
binding.setVariable("providers", project.providers)
|
|
198
|
+
val shell = GroovyShell(javaClass.classLoader, binding)
|
|
199
|
+
|
|
200
|
+
val shouldUsePublication = shell.run(shouldUsePublicationScript, emptyArray<String>()) as? Boolean == true
|
|
201
|
+
|
|
202
|
+
if (!shouldUsePublication) {
|
|
203
|
+
throw IllegalStateException("The publication script returned false. Please check the script or your project configuration. You're trying to precompile a non-default configuration.")
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
185
207
|
private fun modifyModuleConfig(projectName: String, currentConfig: JsonObject, publicationInfo: PublicationInfo, pathToRepository: String?): JsonObject {
|
|
186
208
|
val publicationObject = JsonObject(mapOf(
|
|
187
209
|
"groupId" to publicationInfo.groupId.toJsonElement(),
|
package/expo-module-gradle-plugin/src/main/kotlin/expo/modules/plugin/gradle/ExpoModuleExtension.kt
CHANGED
|
@@ -17,7 +17,7 @@ open class ExpoModuleExtension(val project: Project) {
|
|
|
17
17
|
project.gradle.extensions.getByType(ExpoGradleHelperExtension::class.java)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
|
|
20
|
+
internal val autolinking: AutolinkingIntegration by lazy {
|
|
21
21
|
AutolinkingIntegrationImpl()
|
|
22
22
|
}
|
|
23
23
|
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
package expo.modules.plugin
|
|
2
2
|
|
|
3
3
|
import expo.modules.plugin.configuration.ExpoAutolinkingConfig
|
|
4
|
+
import expo.modules.plugin.configuration.GradleProject
|
|
4
5
|
import org.gradle.api.Project
|
|
6
|
+
import java.io.File
|
|
5
7
|
|
|
6
8
|
class AutolinkingIntegrationImpl : AutolinkingIntegration {
|
|
7
9
|
override fun getExpoDependency(project: Project, name: String): Any {
|
|
8
|
-
val config =
|
|
9
|
-
val dependency = config.allProjects.find { it.name == name }
|
|
10
|
+
val config = getProjectConfig(project, name)
|
|
10
11
|
|
|
11
|
-
if (
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (dependency.usePublication) {
|
|
16
|
-
val publication = requireNotNull(dependency.publication)
|
|
12
|
+
if (config.usePublication) {
|
|
13
|
+
val publication = requireNotNull(config.publication)
|
|
17
14
|
return "${publication.groupId}:${publication.artifactId}:${publication.version}"
|
|
18
15
|
}
|
|
19
16
|
|
|
@@ -21,6 +18,33 @@ class AutolinkingIntegrationImpl : AutolinkingIntegration {
|
|
|
21
18
|
?: throw IllegalStateException("Couldn't find project with name $name.")
|
|
22
19
|
}
|
|
23
20
|
|
|
21
|
+
override fun getShouldUsePublicationScriptPath(project: Project): File? {
|
|
22
|
+
val config = getProjectConfig(project)
|
|
23
|
+
val scriptPath = config.shouldUsePublicationScriptPath
|
|
24
|
+
?: return null
|
|
25
|
+
val scriptFile = File(scriptPath)
|
|
26
|
+
|
|
27
|
+
if (!scriptFile.exists()) {
|
|
28
|
+
project.logger.warn("[ExpoAutolinkingPlugin] The script file does not exist: $scriptFile")
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return scriptFile
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
private fun getProjectConfig(project: Project, projectName: String): GradleProject {
|
|
36
|
+
val config = getConfig(project)
|
|
37
|
+
val dependency = config.allProjects.find { it.name == projectName }
|
|
38
|
+
|
|
39
|
+
if (dependency == null) {
|
|
40
|
+
throw IllegalStateException("Couldn't find project with name $projectName in `expo-autolinking-settings` configuration.")
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return dependency
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
private fun getProjectConfig(project: Project) = getProjectConfig(project, project.name)
|
|
47
|
+
|
|
24
48
|
private fun getConfig(project: Project): ExpoAutolinkingConfig {
|
|
25
49
|
val gradleExtension = project.gradle.extensions.findByType(ExpoGradleExtension::class.java)
|
|
26
50
|
?: throw IllegalStateException("`ExpoGradleExtension` not found. Please, make sure that `useExpoModules` was called in `settings.gradle`.")
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
package expo.modules.plugin
|
|
2
2
|
|
|
3
3
|
import org.gradle.api.Project
|
|
4
|
+
import java.io.File
|
|
4
5
|
|
|
5
6
|
class AutolinkingIntegrationImpl : AutolinkingIntegration {
|
|
6
7
|
override fun getExpoDependency(project: Project, name: String): Any {
|
|
7
8
|
return project.rootProject.findProject(":$name")
|
|
8
9
|
?: throw IllegalStateException("Couldn't find project with name $name.")
|
|
9
10
|
}
|
|
11
|
+
|
|
12
|
+
override fun getShouldUsePublicationScriptPath(project: Project): File? {
|
|
13
|
+
return null
|
|
14
|
+
}
|
|
10
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-core",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.4",
|
|
4
4
|
"description": "The core of Expo Modules architecture",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"@testing-library/react-native": "^13.1.0",
|
|
45
45
|
"expo-module-scripts": "^4.1.1"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "dd2c7150fd75c56505aa6d3f805c14e255649c5d"
|
|
48
48
|
}
|
package/src/registerWebModule.ts
CHANGED
|
@@ -4,18 +4,21 @@ import type { NativeModule } from './ts-declarations/NativeModule';
|
|
|
4
4
|
/**
|
|
5
5
|
* Registers a web module.
|
|
6
6
|
* @param moduleImplementation A class that extends `NativeModule`. The class is registered under `globalThis.expo.modules[className]`.
|
|
7
|
+
* @param moduleName – a name to register the module under `globalThis.expo.modules[className]`.
|
|
7
8
|
* @returns A singleton instance of the class passed into arguments.
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
export function registerWebModule<
|
|
11
12
|
EventsMap extends Record<never, never>,
|
|
12
13
|
ModuleType extends typeof NativeModule<EventsMap>,
|
|
13
|
-
>(moduleImplementation: ModuleType): ModuleType {
|
|
14
|
+
>(moduleImplementation: ModuleType, moduleName: string): ModuleType {
|
|
14
15
|
ensureNativeModulesAreInstalled();
|
|
15
16
|
|
|
16
|
-
|
|
17
|
+
moduleName = moduleName ?? moduleImplementation.name;
|
|
17
18
|
if (!moduleName) {
|
|
18
|
-
throw new Error(
|
|
19
|
+
throw new Error(
|
|
20
|
+
'Web module implementation is missing a name - it is either not a class or has been minified. Pass the name as a second argument to the `registerWebModule` function.'
|
|
21
|
+
);
|
|
19
22
|
}
|
|
20
23
|
if (!globalThis?.expo?.modules) {
|
|
21
24
|
globalThis.expo.modules = {};
|